:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --bg-color: #0f172a;
    --sidebar-bg: #1e293b;
    --card-bg: rgba(30, 41, 59, 0.7);
    --text-main: #f8fafc;
    --text-dim: #94a3b8;
    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;
    --border-color: rgba(255, 255, 255, 0.1);
    --glass-blur: blur(12px);
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    overflow: hidden;
}

h1, h2, h3, .logo {
    font-family: 'Outfit', sans-serif;
}

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    padding: 0 0 24px 0;
    border-right: 1px solid var(--border-color);
}

.logo {
    width: 100%;
    margin-bottom: 32px;
}

#logo-link {
    display: block;
    width: 100%;
    text-decoration: none;
}

.main-logo {
    width: 100%;
    height: auto;
    display: block;
    transition: opacity 0.3s ease;
}

.main-logo:hover {
    opacity: 0.9;
}

.nav-menu {
    flex-grow: 1;
    padding: 0 6px;
}

.nav-item {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    color: var(--text-dim);
    text-decoration: none;
    border-radius: 12px;
    margin-bottom: 8px;
    transition: all 0.3s ease;
    font-weight: 500;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.nav-item.active {
    background-color: var(--primary-color);
    color: white;
}

.sidebar-footer {
    padding: 24px;
    border-top: 1px solid var(--border-color);
}

/* Main Content */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.top-header {
    padding: 24px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgba(15, 23, 42, 0.8);
    backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--border-color);
}

#object-ctx-actions {
    display: flex;
    gap: 8px;
}

#view-title {
    font-size: 28px;
    font-weight: 700;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 16px;
}

#file-status {
    font-size: 14px;
    color: var(--text-dim);
}

.avatar {
    width: 40px;
    height: 40px;
    background-color: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

/* Content Area */
.content-area {
    padding: 40px;
    overflow-y: auto;
    overflow-x: hidden;
    min-width: 0;
    flex-grow: 1;
}

.view {
    animation: fadeIn 0.4s ease-out;
}

.hidden {
    display: none !important;
}

.other-input {
    margin-top: 10px;
    border-color: var(--primary-color) !important;
    background: rgba(99, 102, 241, 0.05) !important;
}

.confirm-modal-content {
    max-width: 550px !important;
    text-align: center;
}

.confirm-modal-content h2 {
    margin-bottom: 20px;
}

.confirm-modal-content p {
    margin-bottom: 32px;
    color: var(--text-dim);
    line-height: 1.6;
}

#confirm-modal-actions {
    display: flex;
    flex-direction: row;
    justify-content: center;
    gap: 16px;
    margin-top: 32px;
}

#confirm-modal-actions button {
    flex: 1;
    white-space: nowrap;
    padding: 14px 10px;
    font-size: 14px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; } /* Must be none, otherwise it breaks position: sticky in Chrome! */
}

.dashboard-filters {
    display: flex;
    gap: 20px;
    margin-bottom: 32px;
    padding: 24px;
    background: rgba(30, 41, 59, 0.85);
    border-radius: 20px;
    border: 1px solid var(--border-color);
    backdrop-filter: var(--glass-blur);
    box-shadow: var(--shadow-lg);
    position: sticky;
    top: -40px;
    z-index: 1000;
}

.dashboard-filters .filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.dashboard-filters label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.dashboard-filters select {
    background: #1e293b; /* Solid opaque background */
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 16px;
    color: #ffffff !important;
    font-size: 14px;
    outline: none;
    cursor: pointer;
    transition: all 0.3s ease;
    appearance: none; /* Reset native appearance for consistency */
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center;
    background-size: 16px !important;
}

.dashboard-filters select option {
    background: #1e293b;
    color: #ffffff;
    padding: 12px;
}

.dashboard-filters select:hover {
    background-color: #334155;
    border-color: var(--primary-color);
}

.multi-select {
    position: relative;
}

.multi-select-header {
    background: #1e293b;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 16px;
    color: #ffffff;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
}

.multi-select-header:hover {
    background-color: #334155;
    border-color: var(--primary-color);
}

.multi-select-header .selected-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.multi-select-options {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #1e293b;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 8px;
    z-index: 9999; /* Max priority to be on top of everything */
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
    max-height: 350px;
    overflow-y: auto;
}

.option-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    color: #ffffff;
}

.option-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.option-item.all-option {
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 8px;
    padding-bottom: 12px;
    border-radius: 0;
}

.option-item input[type="checkbox"] {
    appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
}

.option-item input[type="checkbox"]:checked {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.option-item input[type="checkbox"]:checked::after {
    content: '\2713';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 12px;
    font-weight: bold;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.stat-card {
    background: var(--card-bg);
    backdrop-filter: var(--glass-blur);
    padding: 24px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-icon.income { background: rgba(16, 185, 129, 0.1); color: var(--accent-success); }
.stat-icon.expense { background: rgba(239, 68, 68, 0.1); color: var(--accent-danger); }
.stat-icon.profit { background: rgba(99, 102, 241, 0.1); color: var(--primary-color); }

.nav-group-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0 12px;
    margin-bottom: 8px;
    margin-top: 24px;
    opacity: 0.6;
}

.nav-group:first-child .nav-group-title {
    margin-top: 0;
}

.stat-info h3 {
    font-size: 14px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.stat-info .value {
    font-size: 24px;
    font-weight: 700;
}

/* Charts */
.charts-container {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

.chart-card {
    background: var(--card-bg);
    backdrop-filter: var(--glass-blur);
    padding: 24px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
}

.chart-card h3 {
    margin-bottom: 24px;
    font-size: 18px;
    font-weight: 600;
}

.chart-totals {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.total-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.total-item .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.total-item .dot.direct { background: #6366f1; }
.total-item .dot.indirect { background: #10b981; }

.total-item .label {
    color: var(--text-dim);
    flex-grow: 1;
}

.total-item .val {
    font-weight: 700;
    color: var(--text-main);
}

/* Tables */
.table-container {
    background: var(--card-bg);
    border-radius: 20px;
    border: 1px solid var(--border-color);
    overflow-x: auto;
    overflow-y: visible;
    box-shadow: var(--shadow-lg);
    /* Critical: constrain width so table doesn't blow out the flex layout */
    width: 100%;
    min-width: 0;
}

table {
    /* max-content: expands to fit columns' min-widths.
       min-width: 100%: never narrower than the card.
       Together these let .table-container scroll horizontally without
       the table forcing the entire page layout to widen. */
    width: max-content;
    min-width: 100%;
    border-collapse: separate; /* Required for robust sticky headers */
    border-spacing: 0;
    text-align: left;
}

thead {
    position: sticky;
    top: 0;
    z-index: 11;
}

th {
    background: #151e32;
    position: sticky !important;
    top: -1px !important;
    z-index: 100 !important;
    border-top: 1px solid var(--border-color);
    box-shadow: 0 1px 0 var(--border-color);
    background-clip: padding-box;
    padding: 16px 24px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    /* Optional: add a tiny shadow below the sticky header */
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

td {
    padding: 16px 24px;
    font-size: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
    vertical-align: middle;
}

/* Actions Column Alignment */
.actions-cell {
    text-align: right !important;
}

.actions-wrapper {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    width: 100%;
}

/* Summary Table Specific Alignment */
#summary-table th:nth-child(n+2),
#summary-table td:nth-child(n+2) {
    text-align: center;
}

#summary-table th:first-child,
#summary-table td:first-child {
    text-align: left;
}

tr:hover td {
    background: rgba(99, 102, 241, 0.1);
    color: white;
}

/* Column Width Optimization */
table th:first-child,
table td:first-child {
    text-align: left;
}



.col-numeric {
    text-align: left !important;
}

.col-numeric .table-filter {
    text-align: left !important;
    text-align-last: left !important;
}



tr {
    transition: all 0.2s ease;
}

.mode-add #delete-entry-btn,
.mode-add #delete-btn-container {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    position: absolute !important;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    font-size: 14px;
}

.btn-primary { background: var(--primary-color); color: white; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-2px); }

.btn-secondary { background: rgba(255, 255, 255, 0.05); color: var(--text-main); border: 1px solid var(--border-color); }
.btn-secondary:hover { background: rgba(255, 255, 255, 0.1); }

#edit-current-object,
#archive-current-object,
#restore-current-object {
    display: inline-flex;
    align-items: center !important;
    justify-content: center !important;
    width: 36px !important;
    height: 36px !important;
    padding: 0 !important;
    border-radius: 8px !important;
    transition: all 0.2s ease !important;
    cursor: pointer !important;
    box-sizing: border-box !important;
}

#edit-current-object {
    color: #818cf8 !important;
    background: rgba(129, 140, 248, 0.12) !important;
    border: 1px solid rgba(129, 140, 248, 0.35) !important;
}
#edit-current-object:hover {
    color: white !important;
    background: #818cf8 !important;
    border-color: #818cf8 !important;
    transform: translateY(-1px) !important;
}

#archive-current-object {
    color: #ff5252 !important;
    background: rgba(239, 68, 68, 0.1) !important;
    border: 1px solid rgba(239, 68, 68, 0.35) !important;
}
#archive-current-object:hover {
    color: white !important;
    background: rgba(239, 68, 68, 0.25) !important;
    border-color: rgba(239, 68, 68, 0.65) !important;
    transform: translateY(-1px) !important;
}

#restore-current-object {
    color: #22c55e !important;
    background: rgba(34, 197, 94, 0.1) !important;
    border: 1px solid rgba(34, 197, 94, 0.35) !important;
}
#restore-current-object:hover {
    color: white !important;
    background: rgba(34, 197, 94, 0.25) !important;
    border-color: rgba(34, 197, 94, 0.65) !important;
    transform: translateY(-1px) !important;
}

.btn-success { background: var(--accent-success); color: white; }
.btn-success:hover { background: #059669; }

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--sidebar-bg);
    margin: 30px auto;
    padding: 32px;
    border-radius: 24px;
    width: 500px;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    border: 1px solid var(--border-color);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    position: relative;
}

/* Custom scrollbar for modal */
.modal-content::-webkit-scrollbar {
    width: 6px;
}
.modal-content::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    position: sticky;
    top: -32px;
    background: var(--sidebar-bg);
    padding-top: 32px;
    padding-bottom: 16px;
    margin-top: -32px;
    z-index: 10;
}

.close-btn {
    font-size: 24px;
    cursor: pointer;
    color: var(--text-dim);
}

.form-grid {
    display: grid;
    gap: 20px;
    margin-bottom: 24px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 14px;
    color: var(--text-dim);
}

.form-group input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    padding: 12px;
    border-radius: 10px;
    color: white;
    outline: none;
}

.form-group select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    padding: 12px;
    border-radius: 10px;
    color: white;
    outline: none;
    width: 100%;
    cursor: pointer;
    appearance: none; /* Remove default arrow to style it */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
}

.form-group select:focus {
    border-color: var(--primary-color);
}

.form-group select option {
    background-color: var(--sidebar-bg);
    color: white;
    padding: 12px;
}

.toolbar {
    margin-bottom: 24px;
    display: flex;
    justify-content: flex-end;
}

/* Integrated Table Filters */
th {
    vertical-align: middle;
}

th:has(.table-filter) {
    padding: 10px 12px !important;
}

.header-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    width: 100%;
    box-sizing: border-box;
}

.header-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: rgba(255, 255, 255, 0.45);
    margin-bottom: 2px;
    padding-left: 2px;
    pointer-events: none;
    white-space: nowrap;
}

.table-filter {
    width: 100% !important;
    height: 28px !important;
    background: rgba(255, 255, 255, 0.04) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 6px !important;
    color: #e2e8f0 !important;
    padding: 2px 20px 2px 8px !important; /* Top: 2px, Right: 20px, Bottom: 2px, Left: 8px */
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='rgba(255, 255, 255, 0.6)'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2.5' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 6px center !important;
    background-size: 10px !important;
    text-align: left !important;
    text-align-last: left !important;
    transition: all 0.2s ease;
    margin: 0 !important;
    box-sizing: border-box;
}

.table-filter:hover {
    background-color: rgba(255, 255, 255, 0.08) !important;
    border-color: rgba(255, 255, 255, 0.15) !important;
}

.table-filter:focus {
    border-color: var(--primary-color, #3b82f6) !important;
    background-color: rgba(255, 255, 255, 0.1) !important;
}

.table-filter option {
    background-color: var(--sidebar-bg);
    color: white;
    font-weight: normal;
}

/* Notifications */
.notification-toast {
    position: fixed;
    bottom: 40px;
    right: 120px;
    background: var(--accent-success);
    color: white;
    padding: 16px 32px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.4);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 99999 !important;
    font-weight: 600;
    pointer-events: none;
}

.notification-toast.show {
    transform: translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* Objects Grid */
.objects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 24px;
}

.object-card {
    background: var(--card-bg);
    backdrop-filter: var(--glass-blur);
    padding: 24px 32px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 24px;
    transition: all 0.3s ease;
    cursor: pointer;
    min-height: 120px;
}

.object-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
    box-shadow: var(--shadow-lg);
}

.object-icon {
    width: 72px;
    height: 72px;
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    flex-shrink: 0;
}

.object-name {
    font-weight: 700;
    font-size: 18px;
    color: var(--text-main);
    text-align: left;
    flex-grow: 1;
    word-break: break-word;
    line-height: 1.4;
}

.favorite-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 20px;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    color: var(--text-dim);
    transition: all 0.2s ease;
    border-radius: 50%;
}

.favorite-btn:hover {
    transform: scale(1.2);
    background: rgba(255, 255, 255, 0.05);
}

.favorite-btn:active {
    transform: scale(0.9);
}

.favorite-btn.active {
    color: #f59e0b;
    filter: drop-shadow(0 0 4px rgba(245, 158, 11, 0.4));
}

.favorites-separator {
    grid-column: 1 / -1;
    margin-top: 15px;
    margin-bottom: 5px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.object-card-actions {
    display: flex;
    gap: 8px;
    opacity: 0.3;
    transition: opacity 0.3s ease;
}

.object-card:hover .object-card-actions {
    opacity: 1;
}

.card-action-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: rgba(255,255,255,0.05);
    color: var(--text-muted);
    transition: all 0.2s ease;
}

.card-action-btn:hover {
    background: var(--primary-color);
    color: white;
}

.card-action-btn.archive:hover {
    background: #ef4444;
}

/* Object Details View */
.object-details-header {
    margin-bottom: 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.object-header-actions {
    display: flex;
    gap: 12px;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 14px;
}

.object-details-header h2 {
    font-size: 28px;
    background: linear-gradient(135deg, #fff 0%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.object-actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 32px;
    padding: 20px;
}

.action-card {
    background: var(--card-bg);
    backdrop-filter: var(--glass-blur);
    padding: 24px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
}

.action-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.action-card:hover .action-icon {
    transform: scale(1.05);
}

.action-card .action-icon {
    font-size: 32px;
    width: 60px;
    height: 60px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-bottom: 0 !important;
    margin-right: 0 !important;
    transition: all 0.3s ease;
}

.action-card[data-action="direct"] .action-icon {
    color: #ff5252;
    background: rgba(255, 82, 82, 0.1);
}
.action-card[data-action="realization"] .action-icon {
    color: #00e676;
    background: rgba(0, 230, 118, 0.1);
}
.action-card[data-action="distributed"] .action-icon {
    color: #a855f7;
    background: rgba(168, 85, 247, 0.1);
}

.action-label {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.3;
    text-align: left;
}
/* Directory Specific Styles */
.directory-container {
    max-width: 1200px;
    margin: 0 auto;
    background: var(--card-bg);
    border-radius: 20px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

/* Unified Directory & Archive List Styles */
.directory-table, .archive-table {
    width: 100% !important;
    max-width: 1200px !important; /* Возвращаем идеальную ширину */
    margin: 0 auto !important; /* Центрируем */
    border-collapse: separate !important;
    border-spacing: 0 8px !important;
    display: table !important; /* Возвращаем нормальное поведение таблицы */
}

.directory-table tbody, .archive-table tbody {
    display: table-row-group !important;
}

.directory-table tr, .archive-table tr {
    background: var(--card-bg) !important;
    transition: all 0.3s ease;
    display: table-row !important;
}

.directory-table tr:hover, .archive-table tr:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.directory-table td, .archive-table td {
    padding: 12px 18px !important;
    border: none !important;
    color: var(--text-main) !important;
    font-size: 16px !important;
    font-weight: 500 !important;
    vertical-align: middle !important; /* Жесткое выравнивание по центру */
    line-height: 1 !important; /* Убираем скрытые отступы текста */
}

/* In case of a single-column table empty row (first-child and last-child are same) */
.directory-table td:only-child, .archive-table td:only-child {
    border-radius: 15px !important;
    border: 1px solid var(--border-color) !important;
}

.directory-table td:first-child:not(:only-child), .archive-table td:first-child:not(:only-child) {
    border-radius: 15px 0 0 15px;
    border: 1px solid var(--border-color) !important;
    border-right: none !important;
}

.directory-table td:last-child:not(:only-child), .archive-table td:last-child:not(:only-child) {
    border-radius: 0 15px 15px 0;
    border: 1px solid var(--border-color) !important;
    border-left: none !important;
    text-align: right !important;
}

/* Table Headers styling for Directory and Archive */
.directory-table th, .archive-table th {
    background: rgba(30, 41, 59, 0.95) !important;
    border-top: 1px solid var(--border-color) !important;
    border-bottom: 1px solid var(--border-color) !important;
    border-left: none !important;
    border-right: none !important;
    padding: 14px 12px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    color: var(--text-dim) !important;
    box-shadow: none !important;
    vertical-align: middle !important;
}

.directory-table th:first-child:not(:only-child), .archive-table th:first-child:not(:only-child) {
    border-radius: 15px 0 0 15px !important;
    border-left: 1px solid var(--border-color) !important;
}

.directory-table th:last-child:not(:only-child), .archive-table th:last-child:not(:only-child) {
    border-radius: 0 15px 15px 0 !important;
    border-right: 1px solid var(--border-color) !important;
}

.directory-table th:only-child, .archive-table th:only-child {
    border-radius: 15px !important;
    border: 1px solid var(--border-color) !important;
}

.actions-wrapper {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    vertical-align: middle !important;
    width: 100%;
}

/* Unified Action Icons (for Tables and Object Cards) */
button.action-icon {
    cursor: pointer;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(255, 255, 255, 0.05);
    margin: 0 !important;
    margin-left: 6px !important;
    border: none;
    outline: none;
    vertical-align: middle !important;
    font-size: 16px;
}

button.action-icon:hover {
    transform: scale(1.1);
    color: white !important;
}

/* Icon Variants */
.icon-edit { color: #818cf8; background: rgba(129, 140, 248, 0.1); }
.icon-edit:hover { background: #818cf8; }

.trash-btn,
.icon-delete {
    color: #ff5252 !important;
    background: rgba(239, 68, 68, 0.1) !important;
    border: 1px solid rgba(239, 68, 68, 0.35) !important;
    border-radius: 8px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    transition: all 0.2s ease !important;
    cursor: pointer !important;
    box-sizing: border-box !important;
}

.trash-btn:hover,
.icon-delete:hover {
    background: rgba(239, 68, 68, 0.25) !important;
    border-color: rgba(239, 68, 68, 0.65) !important;
    color: #ffffff !important;
    transform: translateY(-1px) !important;
}

.icon-archive { color: #fbbf24; background: rgba(251, 191, 36, 0.1); }
.icon-archive:hover { background: #f59e0b; }

.icon-restore { color: #34d399; background: rgba(52, 211, 153, 0.1); }
.icon-restore:hover { background: #10b981; }

.object-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(255,255,255,0.05);
    justify-content: flex-end;
}

/* Object Sections Architecture */
.object-sections-container {
    display: flex;
    flex-direction: column;
    gap: 32px;
    margin-top: 24px;
}

.object-section {
    background: var(--card-bg);
    border-radius: 24px;
    padding: 28px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.section-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.section-header i {
    font-size: 22px;
    color: var(--primary-color);
}

.section-header h3 {
    font-size: 20px;
    font-weight: 700;
    margin: 0;
    color: var(--text-main);
}

.placeholder-content {
    padding: 40px;
    text-align: center;
    background: rgba(255, 255, 255, 0.02);
    border: 2px dashed rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    color: var(--text-dim);
}

.placeholder-content p {
    font-size: 15px;
    max-width: 400px;
    margin: 0 auto;
    line-height: 1.6;
}

/* Small Cards variant for Economy section */
.small-cards.object-actions-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    padding: 0;
}

.small-cards .action-card {
    padding: 16px 20px;
    gap: 16px;
    border-radius: 16px;
}

.small-cards .action-card .action-icon {
    font-size: 24px;
    width: 48px;
    height: 48px;
    border-radius: 10px;
    margin-bottom: 0 !important;
}

.small-cards .action-label {
    font-size: 15px;
}

/* AI Floating Widget */
#ai-widget-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    pointer-events: none;
}

#ai-widget-window, #ai-widget-button {
    pointer-events: all;
}

#ai-widget-button {
    width: 68px;
    height: 68px;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: none;
    outline: none;
}

#ai-widget-button:hover {
    transform: scale(1.1) rotate(5deg);
}

#ai-widget-button img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.5));
}

#ai-widget-window {
    width: 380px;
    height: 550px;
    background: var(--sidebar-bg);
    border-radius: 24px;
    border: 1px solid var(--border-color);
    backdrop-filter: var(--glass-blur);
    box-shadow: 0 20px 50px rgba(0,0,0,0.6);
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.8);
    transform-origin: bottom right;
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#ai-widget-window.active {
    transform: scale(1);
    opacity: 1;
    pointer-events: all;
}

.ai-widget-header {
    padding: 16px 20px;
    background: rgba(15, 23, 42, 0.8);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-widget-header h3 {
    margin: 0;
    font-size: 15px;
    color: white;
    display: flex;
    align-items: center;
    gap: 10px;
}

#ai-widget-chat {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Custom scrollbar for chat */
#ai-widget-chat::-webkit-scrollbar {
    width: 4px;
}
#ai-widget-chat::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.ai-widget-footer {
    padding: 12px;
    background: rgba(15, 23, 42, 0.9);
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 8px;
}

#ai-widget-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 10px 14px;
    color: white;
    resize: none;
    height: 40px;
    font-family: inherit;
    font-size: 13px;
    outline: none;
    transition: border-color 0.3s;
}

#ai-widget-input:focus {
    border-color: var(--primary-color);
}

.ai-msg {
    padding: 10px 14px;
    border-radius: 16px;
    max-width: 85%;
    font-size: 13.5px;
    line-height: 1.5;
    word-break: break-word;
}

.ai-msg.system {
    align-self: flex-start;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    color: var(--text-main);
    border-bottom-left-radius: 4px;
}

.ai-msg.user {
    align-self: flex-end;
    background: var(--primary-color);
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-msg strong {
    color: var(--accent-success);
}

#confirm-modal {
    z-index: 20000 !important;
}

/* Custom Directories Hover Actions Overlay */
.stat-card:hover .card-actions-overlay,
.action-card:hover .card-actions-overlay {
    opacity: 1 !important;
}
.card-edit-btn:hover {
    background: var(--primary-color) !important;
    color: white !important;
    transform: scale(1.1);
}
.card-delete-btn:hover {
    background: var(--accent-danger) !important;
    color: white !important;
    transform: scale(1.1);
}
.directories-grid-wrapper {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

/* Premium styled dark mode select options */
select option {
    background-color: #1e293b !important;
    color: #f8fafc !important;
}

.editable-cell, .readonly-cell, .salary-amount-input { white-space: nowrap; }

.drillable-row:hover {
    background-color: rgba(255, 255, 255, 0.05) !important;
}
 /* Hide number input spinners globally */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] {
    -moz-appearance: textfield; /* Firefox */
}


/* Switch Toggle */
.switch input:checked + .slider { background-color: var(--primary-color) !important; }
.switch input:focus + .slider { box-shadow: 0 0 1px var(--primary-color); }
.switch input:checked + .slider span { transform: translateX(20px); }

.kanban-cards::-webkit-scrollbar { width: 6px; }
.kanban-cards::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; }


/* Global Select Styling */
select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center !important;
    background-size: 16px;
    padding-right: 30px !important;
    box-sizing: border-box !important;
}
select option {
    background: var(--sidebar-bg, #0f172a);
    color: white;
}


#supply-table-body td {
    word-break: break-word;
    overflow-wrap: anywhere;
    white-space: normal;
}



#supply-table-container thead th {
    position: sticky;
    top: 0;
    z-index: 100;
    background: #151e32;
    border-bottom: 1px solid var(--border-color);
}


.supply-inner-scroll {
    display: block;
    width: 100%;
    height: calc(100vh - 260px) !important;
    overflow-y: auto !important;
    overflow-x: auto !important;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-bg);
}

.supply-inner-scroll table {
    border-collapse: separate !important;
    border-spacing: 0 !important;
    margin: 0 !important;
    /* Supply table uses table-layout: fixed with % columns — keep width: 100% */
    width: 100% !important;
    min-width: unset !important;
}

.supply-inner-scroll th {
    position: sticky !important;
    top: -1px !important;
    z-index: 100 !important;
    background-color: #151e32 !important;
    background-clip: padding-box !important;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3) !important;
    border-bottom: 1px solid var(--border-color) !important;
}

.no-spin::-webkit-inner-spin-button, .no-spin::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

@keyframes pulse-notification {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
    70% { transform: scale(1.05); box-shadow: 0 0 0 5px rgba(239, 68, 68, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.pulsing-chat > span {
    animation: pulse-notification 2s infinite ease-in-out;
}

/* Supply Order Modal Layout Adjustments for Responsiveness */
.supply-modal-wrapper {
    position: absolute;
    left: 0;
    top: 25%;
    transform: translateY(-25%);
    width: 100%;
    display: flex;
    gap: 20px;
    align-items: stretch;
    justify-content: center;
    max-height: calc(100vh - 60px);
    padding: 0 20px;
    box-sizing: border-box;
    transition: all 0.3s ease;
}

.supply-modal-spacer {
    width: 380px;
    flex-shrink: 0;
    pointer-events: none;
    transition: all 0.3s ease;
}

.supply-modal-details {
    width: 800px;
    max-width: 100%;
    min-width: 500px;
    margin: 0 !important;
    flex-shrink: 1;
    max-height: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
}

.supply-modal-chat-container {
    width: 380px;
    min-width: 300px;
    margin: 0;
    flex-shrink: 1;
    position: relative;
    transition: all 0.3s ease;
}

.supply-modal-chat {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    margin: 0 !important;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

/* For screens narrower than 1640px: hide dummy spacer to center the details & chat as a group */
@media (max-width: 1640px) {
    .supply-modal-spacer {
        display: none !important;
    }
}

/* For small screens (tablets, mobile, narrow viewports): stack vertically instead of side-by-side */
@media (max-width: 900px) {
    .supply-modal-wrapper {
        position: fixed;
        top: 0;
        left: 0;
        transform: none;
        height: 100%;
        max-height: 100%;
        overflow-y: auto;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
        padding: 20px;
    }
    
    .supply-modal-details {
        width: 100%;
        min-width: 0;
        max-height: none;
        flex-shrink: 0;
    }
    
    .supply-modal-chat-container {
        width: 100%;
        min-width: 0;
        height: 450px;
        flex-shrink: 0;
        margin-top: 10px;
    }
    
    .supply-modal-chat {
        position: relative;
        height: 100%;
        max-height: none;
    }
}


/* Month Grouped View Styles */
.table-container.month-grouped-view {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

.table-container.month-grouped-view table {
    border-collapse: separate;
    border-spacing: 0;
}

.table-container.month-grouped-view thead th {
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.table-container.month-grouped-view thead th:first-child {
    border-top-left-radius: 20px;
    border-bottom-left-radius: 20px;
    border-left: 1px solid var(--border-color);
}

.table-container.month-grouped-view thead th:last-child {
    border-top-right-radius: 20px;
    border-bottom-right-radius: 20px;
    border-right: 1px solid var(--border-color);
}

/* Add a visual gap after headers */
.table-container.month-grouped-view .header-spacer td {
    height: 16px;
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
}

.table-container.month-grouped-view tr.data-row td {
    background: var(--card-bg);
    border-top: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}

.table-container.month-grouped-view tr.data-row.month-end td {
    border-bottom: 1px solid var(--border-color);
}

.table-container.month-grouped-view tr.data-row.month-start td {
    border-top: 1px solid var(--border-color);
}

.table-container.month-grouped-view tr.data-row.month-start td:first-child {
    border-top-left-radius: 20px;
}
.table-container.month-grouped-view tr.data-row.month-start td:last-child {
    border-top-right-radius: 20px;
}

.table-container.month-grouped-view tr.data-row.month-end td:first-child {
    border-bottom-left-radius: 20px;
}
.table-container.month-grouped-view tr.data-row.month-end td:last-child {
    border-bottom-right-radius: 20px;
}

.table-container.month-grouped-view tr.data-row td:first-child {
    border-left: 1px solid var(--border-color);
}
.table-container.month-grouped-view tr.data-row td:last-child {
    border-right: 1px solid var(--border-color);
}

.table-container.month-grouped-view tr.visual-month-separator td {
    height: 24px;
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
}

/* Styled RBAC badge-style select dropdowns */
.rbac-select-badge {
    background-color: rgba(255, 255, 255, 0.05);
    color: #94a3b8;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
    text-align: center;
    min-width: 130px;
}

.rbac-select-badge:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* Color coding based on select state classes */
.rbac-select-badge.status-none {
    background-color: rgba(239, 68, 68, 0.1) !important;
    border-color: rgba(239, 68, 68, 0.3) !important;
    color: #ef4444 !important;
}

.rbac-select-badge.status-view {
    background-color: rgba(245, 158, 11, 0.1) !important;
    border-color: rgba(245, 158, 11, 0.3) !important;
    color: #f59e0b !important;
}

.rbac-select-badge.status-full {
    background-color: rgba(16, 185, 129, 0.1) !important;
    border-color: rgba(16, 185, 129, 0.3) !important;
    color: #10b981 !important;
}

.rbac-node ul {
    border-left: 1px dashed rgba(255, 255, 255, 0.08);
    margin-left: 7px;
    padding-left: 20px !important;
    transition: opacity 0.2s ease;
}

.rbac-node-children.dimmed,
.rbac-node ul.dimmed {
    opacity: 0.35;
}


.status-partial { background-color: rgba(33, 150, 243, 0.15) !important; color: #4dabf7 !important; border-color: rgba(33, 150, 243, 0.3) !important; }

/* RBAC tree row hover highlight */
.rbac-item {
    transition: background-color 0.15s ease;
    border-radius: 6px;
}
.rbac-item:hover {
    background-color: rgba(255, 255, 255, 0.08) !important;
}

/* Hierarchy Width Overrides ONLY */
/* Level 0 (Root - e.g. Объекты) */
.rbac-tree-list > li.rbac-node > .rbac-item > select.rbac-select-badge {
    min-width: 240px !important;
}

/* Level 1 (e.g. Экономика объекта) */
.rbac-tree-list > li.rbac-node > ul > li.rbac-node > .rbac-item > select.rbac-select-badge {
    min-width: 200px !important;
}

/* Level 2 (e.g. Прямые затраты) */
.rbac-tree-list > li.rbac-node > ul > li.rbac-node > ul > li.rbac-node > .rbac-item > select.rbac-select-badge {
    min-width: 160px !important;
}

/* Level 3 and deeper (e.g. Вывоз мусора) */
.rbac-tree-list > li.rbac-node > ul > li.rbac-node > ul > li.rbac-node > ul select.rbac-select-badge,
.rbac-tree-list > li.rbac-node > ul > li.rbac-node > ul > li:not(.rbac-node) select.rbac-select-badge {
    min-width: 120px !important;
}


/* Custom styled checkboxes for the RBAC tree to ensure unified blue look across all browsers and systems */
.rbac-tree-list input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    border-radius: 4px;
    background-color: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    margin: 0;
    vertical-align: middle;
}

.rbac-tree-list input[type="checkbox"]:hover {
    border-color: #3b82f6;
    background-color: rgba(59, 130, 246, 0.1);
}

.rbac-tree-list input[type="checkbox"]:checked {
    background-color: #3b82f6;
    border-color: #3b82f6;
}

.rbac-tree-list input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 4.5px;
    top: 1.5px;
    width: 4px;
    height: 8px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.rbac-tree-list input[type="checkbox"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Disabled RBAC select badges style (unchecked items) */
.rbac-tree-list select.rbac-select-badge:disabled {
    background-color: rgba(239, 68, 68, 0.07) !important;
    border-color: rgba(239, 68, 68, 0.15) !important;
    color: transparent !important;
    background-image: none !important;
    cursor: not-allowed;
}

/* Worker details name hover styles */
.worker-details-name:hover span {
    color: var(--primary-color) !important;
    border-bottom-color: var(--primary-color) !important;
}

/* Settlements details styling */
.settlements-details-row {
    background: rgba(0, 0, 0, 0.15) !important;
}

.settlements-details-row td {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
}

/* Disable general hover background for details row and its nested cells */
tr.settlements-details-row:hover td {
    background: rgba(0, 0, 0, 0.15) !important;
}

.settlements-details-row table tr:hover td {
    background: rgba(255, 255, 255, 0.05) !important;
    color: white !important;
}

/* Penalty Comment Popup styling */
.penalty-comment-popup {
    position: fixed;
    z-index: 10000;
    width: 300px;
    background: #1e293b;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    backdrop-filter: var(--glass-blur);
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.penalty-comment-popup.hidden {
    display: none !important;
    opacity: 0;
    transform: scale(0.95);
}
.penalty-comment-popup .popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 8px;
}
.penalty-comment-popup .popup-close {
    cursor: pointer;
    font-size: 20px;
    color: var(--text-dim);
    transition: color 0.2s;
    line-height: 1;
}
.penalty-comment-popup .popup-close:hover {
    color: var(--accent-danger);
}
.penalty-comment-popup textarea {
    width: 100%;
    height: 80px;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    color: white;
    font-size: 13px;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: border-color 0.2s;
}
.penalty-comment-popup textarea:focus {
    border-color: var(--primary-color);
}
.penalty-comment-popup .popup-footer {
    display: flex;
    justify-content: flex-end;
}
.penalty-comment-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
    z-index: 10;
    padding: 4px;
    border-radius: 4px;
}
.penalty-comment-btn.has-comment {
    color: var(--primary-color);
    opacity: 0.95;
}
.penalty-comment-btn.no-comment {
    color: var(--text-dim);
    opacity: 0.4;
}
.penalty-comment-btn:hover {
    opacity: 1;
    transform: translateY(-50%) scale(1.2);
    background: rgba(255,255,255,0.05);
}

.settlement-factory-multiselect.popover-open {
    z-index: 9999 !important;
}

/* Factory Visual Groups & Drag and Drop */
.factory-group-header {
    border-bottom: 2px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 8px;
    margin-top: 32px;
    margin-bottom: 16px;
    transition: all 0.3s ease;
}

.factory-group-header span {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: 0.5px;
}

.edit-group-btn {
    opacity: 0.5;
    transition: all 0.2s ease;
}

.factory-group-header:hover .edit-group-btn {
    opacity: 1;
}

.edit-group-btn:hover {
    color: #60a5fa !important;
    transform: scale(1.1);
}

.factory-group-zone {
    border: 2px dashed rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.05);
    min-height: 90px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.factory-group-zone:empty {
    display: flex;
    align-items: center;
    justify-content: center;
}

.draggable-object-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease !important;
}

.draggable-object-card:active {
    cursor: grabbing !important;
    transform: scale(0.98);
    opacity: 0.7;
}

.draggable-object-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}
