/* ===== CSS Variables ===== */
:root {
    --primary: #0ea5e9;
    --primary-dark: #0284c7;
    --secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #1f2937;
    --border: #e5e7eb;
    --input: #ffffff;
    --radius: 14px;
    --shadow: 0 10px 24px rgba(0,0,0,.08);
}

[data-theme="dark"] {
    --primary: #0ea5e9;
    --primary-dark: #0284c7;
    --secondary: #94a3b8;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg: #0f172a;
    --card: #1e293b;
    --text: #f1f5f9;
    --border: #334155;
    --input: #1e293b;
}

/* ===== Base Styles ===== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.55;
    background-color: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* Global font consistency */
* {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.container-fluid {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ===== Accessibility ===== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ===== Header ===== */
.app-header {
    position: sticky;
    top: 0;
    z-index: 110;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.97) 0%, rgba(255, 255, 255, 0.9) 100%);
    border-bottom: 1px solid rgba(148, 163, 184, 0.25);
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
    backdrop-filter: blur(18px);
    width: 100%;
    --app-header-height: clamp(68px, 8vw, 96px);
}

[data-theme="dark"] .app-header {
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.94) 0%, rgba(15, 23, 42, 0.88) 100%);
    border-bottom-color: rgba(51, 65, 85, 0.6);
    box-shadow: 0 12px 30px rgba(3, 7, 18, 0.75);
}

.app-header__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 18px 0;
    min-height: var(--app-header-height);
}

.app-header__brand {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.app-header__menu {
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(226, 232, 240, 0.35);
    color: var(--text);
    transition: all 0.2s ease;
}

.app-header__menu:hover,
.app-header__menu:focus-visible {
    border-color: var(--primary);
    background: rgba(14, 165, 233, 0.12);
    color: var(--primary);
    outline: none;
}

.app-header__menu-icon {
    position: relative;
    display: inline-block;
    width: 18px;
    height: 2px;
    background: currentColor;
    border-radius: 999px;
    transition: transform 0.25s ease, background 0.25s ease;
}

.app-header__menu-icon::before,
.app-header__menu-icon::after {
    content: "";
    position: absolute;
    left: 0;
    width: 18px;
    height: 2px;
    background: currentColor;
    border-radius: 999px;
    transition: transform 0.25s ease, opacity 0.25s ease;
}

.app-header__menu-icon::before {
    top: -6px;
}

.app-header__menu-icon::after {
    top: 6px;
}

.mobile-menu-toggle.active .app-header__menu-icon {
    background: transparent;
}

.mobile-menu-toggle.active .app-header__menu-icon::before {
    transform: translateY(6px) rotate(45deg);
}

.mobile-menu-toggle.active .app-header__menu-icon::after {
    transform: translateY(-6px) rotate(-45deg);
}

.app-header__logo {
    display: flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
    color: var(--text);
    min-width: 0;
}

.app-header__logo-image {
    height: 44px;
    width: auto;
    max-width: 180px;
    object-fit: contain;
}

.app-header__logo-mark {
    font-size: 30px;
    line-height: 1;
}

.app-header__identity {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.app-header__title {
    font-size: 20px;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.02em;
}

.app-header__subtitle {
    font-size: 12px;
    color: var(--secondary);
    letter-spacing: 0.02em;
    max-width: 240px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-header__search {
    flex: 1;
    max-width: 420px;
    min-width: 220px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-header__search input {
    flex: 1;
    border: 1px solid rgba(148, 163, 184, 0.45);
    border-radius: 14px;
    padding: 10px 16px;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    transition: all 0.2s ease;
    box-shadow: inset 0 1px 0 rgba(148, 163, 184, 0.18);
}

.app-header__search input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.18);
    outline: none;
}

.app-header__search-advanced {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(226, 232, 240, 0.35);
    color: var(--secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.app-header__search-advanced:hover,
.app-header__search-advanced:focus-visible {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(14, 165, 233, 0.12);
    outline: none;
}

.app-header__actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.app-header__primary-action {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 10px 18px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 10px 24px rgba(14, 165, 233, 0.22);
}

.app-header__primary-action svg {
    width: 18px;
    height: 18px;
}

.app-header__primary-action--compact {
    gap: 4px;
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 10px;
    box-shadow: 0 6px 14px rgba(14, 165, 233, 0.16);
    letter-spacing: 0.01em;
}

.app-header__primary-action--compact span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.app-header__icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.45);
    background: rgba(226, 232, 240, 0.25);
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s ease;
}

.app-header__icon-btn--primary {
    border-color: rgba(14, 165, 233, 0.45);
    background: rgba(14, 165, 233, 0.16);
    color: var(--primary);
    box-shadow: 0 6px 14px rgba(14, 165, 233, 0.18);
}

.app-header__icon-btn:hover,
.app-header__icon-btn:focus-visible {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(14, 165, 233, 0.12);
    outline: none;
}

.app-header__icon-btn--primary:hover,
.app-header__icon-btn--primary:focus-visible {
    border-color: var(--primary);
    background: rgba(14, 165, 233, 0.22);
    color: var(--primary-dark);
}

.app-header__icon-btn--danger {
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.45);
    background: rgba(239, 68, 68, 0.08);
}

.app-header__icon-btn svg {
    width: 16px;
    height: 16px;
}

.app-header__icon-btn--danger:hover,
.app-header__icon-btn--danger:focus-visible {
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.16);
    color: var(--danger);
}

.app-header__icon-btn--sm {
    width: 32px;
    height: 32px;
    border-radius: 9px;
}

.app-header__profile {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    background: rgba(226, 232, 240, 0.4);
    text-decoration: none;
    color: var(--text);
    transition: all 0.2s ease;
    min-width: 0;
}

.app-header__profile:hover,
.app-header__profile:focus-visible {
    border-color: var(--primary);
    background: rgba(14, 165, 233, 0.12);
    color: var(--primary);
    outline: none;
}

.app-header__avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    background: rgba(148, 163, 184, 0.35);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
}

.app-header__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.app-header__avatar--initials {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-weight: 600;
    font-size: 13px;
    letter-spacing: 0.02em;
    background: rgba(37, 99, 235, 0.12);
    color: var(--primary-dark);
}

.app-header__profile-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.app-header__profile-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-header svg {
    display: block;
}

.app-header svg path,
.app-header svg circle,
.app-header svg line,
.app-header svg polyline,
.app-header svg rect {
    stroke: currentColor;
    stroke-width: 1.8;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.main-nav {
    background: transparent;
    border-top: 1px solid rgba(148, 163, 184, 0.15);
    padding: 0;
    margin-bottom: 32px;
}

.app-header__nav .container-fluid {
    padding: 0 20px;
}

.app-header__nav-items {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 0;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.35) transparent;
}

.app-header__nav-items::-webkit-scrollbar {
    height: 6px;
}

.app-header__nav-items::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.4);
    border-radius: 999px;
}

.nav-container {
    display: flex;
    gap: 10px;
    align-items: center;
}

.nav-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: rgba(226, 232, 240, 0.3);
    color: var(--secondary);
    font-weight: 600;
    font-size: 13px;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.nav-item__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.nav-item__icon svg {
    width: 16px;
    height: 16px;
}

.nav-item__label {
    display: inline-flex;
    align-items: center;
    font-weight: 600;
    font-size: 13px;
}

.nav-item--text {
    padding-left: 16px;
    padding-right: 16px;
}

.nav-item svg {
    width: 18px;
    height: 18px;
}

.nav-item:hover {
    background: rgba(14, 165, 233, 0.12);
    color: var(--primary);
    border-color: rgba(14, 165, 233, 0.45);
}

.nav-item.active {
    color: #fff;
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 10px 24px rgba(14, 165, 233, 0.28);
}

.nav-item.active svg path,
.nav-item.active svg circle,
.nav-item.active svg line,
.nav-item.active svg polyline,
.nav-item.active svg rect {
    stroke: currentColor;
}

.mobile-nav-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.mobile-nav-backdrop.active {
    display: block;
    opacity: 1;
}

@media (max-width: 1280px) {
    .app-header__subtitle {
        max-width: 180px;
    }
}

@media (max-width: 1024px) {
    .app-header__top {
        flex-wrap: wrap;
        row-gap: 16px;
    }

    .app-header__menu {
        display: inline-flex;
    }

    .app-header__search {
        order: 3;
        flex: 1 1 100%;
        max-width: none;
    }

    .app-header__actions {
        flex: 1 1 auto;
    }

    .main-nav {
        display: none;
        position: fixed;
        top: calc(var(--app-header-height) + 16px);
        left: 16px;
        right: 16px;
        background: var(--card);
        border-radius: 18px;
        border: 1px solid rgba(148, 163, 184, 0.35);
        box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
        padding: 18px 20px 24px;
        max-height: calc(100vh - var(--app-header-height) - 48px);
        overflow-y: auto;
        transform: translateY(16px);
        opacity: 0;
        transition: transform 0.25s ease, opacity 0.25s ease;
        z-index: 1001;
    }

    .main-nav.active {
        display: block;
        opacity: 1;
        transform: translateY(0);
    }

    .app-header__nav .container-fluid {
        padding: 0;
    }

    .app-header__nav-items {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        overflow: visible;
    }

    .nav-item {
        width: 100%;
        justify-content: flex-start;
        padding: 14px 18px;
        font-size: 15px;
        border: 1px solid rgba(148, 163, 184, 0.3);
    }

    .nav-item:hover {
        transform: translateX(4px);
    }
}

@media (max-width: 640px) {
    .app-header__subtitle {
        display: none;
    }

    .app-header__actions {
        gap: 8px;
    }

    .app-header__profile {
        padding: 8px 12px;
    }
}

/* ===== Stats Grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

@media (max-width: 768px) {
    .stats-grid,
    .dashboard-grid,
    .kpi-grid,
    .action-buttons {
        grid-template-columns: 1fr !important;
    }
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: .3s;
    box-shadow: var(--shadow);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(0,0,0,.12);
}

.stat-icon {
    font-size: 32px;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(14,165,233,.1);
    border-radius: 12px;
}

.stat-info h3 {
    font-size: 24px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 4px;
}

.stat-info p {
    color: var(--secondary);
    font-size: 14px;
    margin: 0;
}

/* ===== Dashboard Grid ===== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 16px;
}

@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

.dashboard-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.dashboard-card h2 {
    color: var(--primary);
    margin-bottom: 20px;
    font-size: 18px;
    font-weight: 700;
}

/* ===== KPI Grid ===== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.kpi-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    text-align: center;
}

.kpi-label {
    display: block;
    font-size: 12px;
    color: var(--secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-value {
    display: block;
    font-size: 18px;
    font-weight: 800;
    color: var(--primary);
}

.kpi-value.debt {
    color: var(--danger);
}

/* ===== Activity List ===== */
.activity-list {
    max-height: 300px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-details {
    flex: 1;
}

.activity-details strong {
    display: block;
    margin-bottom: 4px;
}

.activity-details span {
    color: var(--secondary);
    font-size: 12px;
}

.activity-profit {
    font-weight: 700;
    font-size: 14px;
}

.activity-profit.positive {
    color: var(--success);
}

.activity-profit.negative {
    color: var(--danger);
}

/* ===== Action Buttons ===== */
.action-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    text-decoration: none;
    color: var(--text);
    transition: all 0.2s ease;
    text-align: center;
}

.action-btn:hover {
    background: var(--primary);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.action-icon {
    font-size: 24px;
    margin-bottom: 8px;
}

.action-btn span:last-child {
    font-size: 12px;
    font-weight: 600;
}

/* ===== Buttons ===== */
.btn {
    display: inline-block;
    padding: 12px 20px;
    border: 1px solid var(--border);
    border-radius: 10px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

/* Compact header buttons */
.header-actions .btn {
    padding: 7px 12px;
    font-size: 12px;
    border-radius: 6px;
}

.header-actions .btn svg {
    width: 14px;
    height: 14px;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(14,165,233,.3);
}

.btn-outline {
    background: transparent;
    color: var(--text);
}

.btn-outline:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.btn-success {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}

.btn-warning {
    background: var(--warning);
    border-color: var(--warning);
    color: #000;
}

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

/* ===== Form Styles ===== */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--text);
    font-size: 14px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--input);
    color: var(--text);
    font-size: 14px;
    transition: all 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(14,165,233,.1);
}

/* Select dropdown styling for dark mode */
select.form-control {
    background-color: var(--input);
    color: var(--text);
    cursor: pointer;
}

select.form-control:focus {
    background-color: var(--input);
}

[data-theme="dark"] select.form-control option {
    background: #1e293b;
    color: #f1f5f9;
}

/* ===== Table Styles ===== */
.table,
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    background: var(--card);
    color: var(--text);
}

.table th,
.table td,
.data-table th,
.data-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.table th,
.data-table th {
    background: var(--bg);
    font-weight: 700;
    color: var(--secondary);
}

.data-table tbody tr:hover {
    background: var(--bg);
}

[data-theme="dark"] .data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.table-responsive {
    overflow-x: auto;
    margin: 16px 0;
}

/* ===== Utility Classes ===== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }

.p-0 { padding: 0; }
.p-1 { padding: 8px; }
.p-2 { padding: 16px; }
.p-3 { padding: 24px; }

/* ===== Footer ===== */
.footer {
    margin-top: 60px;
    padding: 30px 0;
    border-top: 1px solid var(--border);
    background: var(--card);
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--secondary);
    font-size: 14px;
}

/* ===== Alert Dismissible ===== */
.alert-dismissible {
    position: relative;
    padding-right: 40px;
}

.alert-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    color: inherit;
    font-size: 20px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.alert-close:hover {
    opacity: 1;
}

/* ===== Print Styles ===== */
@media print {
    .header, .main-nav, .theme-toggle {
        display: none !important;
    }
    
    .dashboard-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* ===== Loading States ===== */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.spinner {
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--primary);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
    display: inline-block;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== Alert Messages ===== */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    border-left: 4px solid;
}

.alert-success {
    background: rgba(16,185,129,.1);
    border-left-color: var(--success);
    color: var(--success);
}

.alert-error {
    background: rgba(239,68,68,.1);
    border-left-color: var(--danger);
    color: var(--danger);
}

.alert-warning {
    background: rgba(245,158,11,.1);
    border-left-color: var(--warning);
    color: var(--warning);
}

.alert-info {
    background: rgba(14,165,233,.1);
    border-left-color: var(--primary);
    color: var(--primary);
}

/* Additional styles for the complete system */

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.page-header h1 {
    color: var(--primary);
    margin: 0;
    font-size: 28px;
}

.page-header p {
    color: var(--secondary);
    margin: 5px 0 0 0;
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-active {
    background: rgba(16,185,129,.1);
    color: var(--success);
    border: 1px solid rgba(16,185,129,.3);
}

.status-inactive {
    background: rgba(100,116,139,.1);
    color: var(--secondary);
    border: 1px solid rgba(100,116,139,.3);
}

.status-maintenance {
    background: rgba(245,158,11,.1);
    color: var(--warning);
    border: 1px solid rgba(245,158,11,.3);
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* Configuration Tabs - Simple & Clean */
.config-tabs {
    margin-top: 20px;
}

.config-tabs .tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--border);
    padding: 0;
    margin-bottom: 30px;
    overflow-x: auto;
    background: transparent;
    position: relative;
}

[data-theme="dark"] .config-tabs .tabs {
    border-bottom-color: var(--border);
}

.config-tabs .tabs .tab,
.config-tabs .tabs button.tab {
    all: unset;
    box-sizing: border-box;
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    
    display: flex !important;
    align-items: center;
    gap: 8px;
    border: none !important;
    border-bottom: 3px solid transparent !important;
    background: transparent !important;
    color: var(--secondary) !important;
    padding: 12px 20px !important;
    border-radius: 0 !important;
    cursor: pointer;
    font-weight: 600 !important;
    font-size: 14px !important;
    transition: all 0.2s ease !important;
    white-space: nowrap;
    position: relative;
    margin: 0 !important;
    outline: none !important;
    text-decoration: none !important;
    font-family: inherit !important;
}

[data-theme="dark"] .config-tabs .tabs .tab {
    color: var(--secondary);
}

/* Simple hover effect */
.config-tabs .tabs .tab:not(.active):hover {
    color: var(--primary) !important;
    background: rgba(14, 165, 233, 0.05) !important;
}

[data-theme="dark"] .config-tabs .tabs .tab:not(.active):hover {
    background: rgba(14, 165, 233, 0.1) !important;
    color: var(--primary) !important;
}

.config-tabs .tabs .tab.active {
    background: transparent !important;
    color: var(--primary) !important;
    border-bottom-color: var(--primary) !important;
    font-weight: 700 !important;
}

.config-tabs .tabs .tab span {
    font-size: 16px;
    display: inline-block;
    vertical-align: middle;
}

.config-tabs .tab-pane {
    animation: fadeIn 0.3s ease;
    display: none !important;
}

.config-tabs .tab-pane.active {
    display: block !important;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.config-form {
    margin-top: 0;
}

/* Table Improvements */
.table td, .table th {
    vertical-align: middle;
}

.table .btn-sm {
    padding: 4px 8px;
    font-size: 12px;
}

/* Financial Display */
.financial-display {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
}

.financial-display.negative {
    color: var(--danger);
}

/* Responsive Tables */
@media (max-width: 768px) {
    .table-responsive {
        font-size: 12px;
    }
    
    .table td, .table th {
        padding: 6px;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .config-tabs .tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        padding: 8px;
        gap: 6px;
    }
    
    .config-tabs .tabs .tab {
        padding: 12px 18px;
        font-size: 13px;
        flex-shrink: 0;
        gap: 6px;
    }
    
    .config-tabs .tabs .tab span {
        font-size: 18px;
    }
    
    .config-tabs .tabs .tab.active {
        transform: translateY(-1px);
    }
}

/* Print Styles */
@media print {
    .header, .main-nav, .btn, .form-actions, .theme-toggle {
        display: none !important;
    }
    
    .main-content {
        margin: 0;
        padding: 0;
    }
    
    .dashboard-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #000;
        margin-bottom: 20px;
    }
}

/* Loading States */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid var(--border);
    border-top: 5px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Animation for loading */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Utility Classes */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }

.p-0 { padding: 0; }
.p-1 { padding: 8px; }
.p-2 { padding: 16px; }
.p-3 { padding: 24px; }

.hidden { display: none; }

/* Form validation styles */
.form-control.error {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.field-error {
    color: var(--danger);
    font-size: 12px;
    margin-top: 4px;
    display: block;
}

.form-error {
    margin-bottom: 16px;
}

.form-success {
    margin-bottom: 16px;
}

/* Auto-save indicator */
.auto-save-indicator {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: var(--success);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1000;
}

.auto-save-indicator.visible {
    opacity: 1;
}

/* File upload preview */
.file-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 8px;
}

.file-name {
    font-weight: 500;
}

.file-size {
    color: var(--secondary);
    font-size: 12px;
}

.remove-file {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 16px;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Print styles for forms */
@media print {
    .btn, .form-actions, .auto-save-indicator {
        display: none !important;
    }
    
    .form-control {
        border: 1px solid #000 !important;
        background: white !important;
        color: black !important;
    }
}

/* Form Tabs */
.form-tabs {
    display: flex;
    gap: 8px;
    border-bottom: 2px solid var(--border);
    margin-bottom: 24px;
    padding-bottom: 0;
    overflow-x: auto;
}

.form-tab {
    padding: 12px 20px;
    background: var(--bg);
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.form-tab:hover {
    background: var(--card);
    color: var(--primary);
}

.form-tab.active {
    background: var(--card);
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Compact Form Grid */
.form-grid-compact {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
}

/* Form rows with justify alignment */
.form-grid-justify {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    width: 100%;
    margin: 0;
}

.form-row .form-group {
    flex: 1 1 0%;
    min-width: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
}

/* Ensure form-row fills full width and justifies */
.form-grid-justify .form-row {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.form-row .form-group {
    flex: 1 1 0%;
    min-width: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
}

.form-group.full-width {
    grid-column: 1 / -1;
    width: 100%;
    flex: 1 1 100% !important;
}

/* Compact form labels */
.form-grid-compact .form-label {
    font-size: 13px;
    margin-bottom: 6px;
}

.form-grid-compact .form-control {
    padding: 10px 12px;
    font-size: 14px;
}

/* Card Header */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.card-header h2 {
    margin: 0;
}

/* AI Assistant */
.ai-assistant-shell {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9800;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
}

.ai-assistant-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    border: none;
    background: linear-gradient(135deg, #2563EB, #38BDF8);
    color: #fff;
    border-radius: 999px;
    padding: 10px 18px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 12px 30px rgba(37, 99, 235, 0.35);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ai-assistant-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 36px rgba(37, 99, 235, 0.38);
}

.ai-assistant-panel {
    width: min(420px, calc(100vw - 32px));
    max-height: min(70vh, 620px);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 22px 60px rgba(15, 23, 42, 0.25);
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.ai-assistant-shell.is-open .ai-assistant-panel {
    display: flex;
}

/* Full-page mode */
.ai-assistant-shell.is-fullpage {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 99999 !important;
    background: var(--bg);
    align-items: stretch;
    padding: 0;
    margin: 0;
}

.ai-assistant-shell.is-fullpage .ai-assistant-toggle {
    display: none;
}

.ai-assistant-shell.is-fullpage .ai-assistant-panel {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 100vh !important;
    height: 100vh !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    display: flex !important;
    margin: 0 !important;
    position: relative !important;
}

.ai-assistant-mode-toggle {
    border: none;
    background: transparent;
    color: var(--secondary);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: background 0.2s ease, color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    position: relative;
    z-index: 10;
    flex-shrink: 0;
}

.ai-assistant-mode-toggle:hover {
    background: var(--bg-alt);
    color: var(--primary);
}

.ai-assistant-mode-icon {
    width: 16px;
    height: 16px;
    display: block;
    transition: transform 0.2s ease;
}

.ai-assistant-shell.is-fullpage .ai-assistant-mode-icon {
    transform: rotate(45deg);
}

.ai-assistant-mode-toggle svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    pointer-events: none;
}

.ai-assistant-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.ai-assistant-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
}

.ai-assistant-subtitle {
    margin: 4px 0 0 0;
    font-size: 13px;
    color: var(--secondary);
}

.ai-assistant-close {
    border: none;
    background: transparent;
    color: var(--secondary);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 4px;
}

.ai-assistant-context {
    padding: 14px 20px;
    border-bottom: 1px dashed var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: var(--secondary);
}

.ai-assistant-status {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-assistant-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.15);
    transition: background 0.2s ease;
}

.ai-assistant-status-dot.is-busy {
    background: #f97316;
    box-shadow: 0 0 0 6px rgba(249, 115, 22, 0.18);
}

.ai-assistant-context-clear {
    border: none;
    background: var(--bg-alt);
    color: var(--secondary);
    border-radius: 999px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 12px;
}

.ai-assistant-quick {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-alt);
}

.ai-assistant-quick-btn {
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 12px;
    background: var(--card);
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.ai-assistant-quick-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.ai-assistant-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--bg);
}

.ai-assistant-message {
    display: flex;
    gap: 12px;
    font-size: 14px;
    line-height: 1.5;
}

.ai-assistant-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

.ai-assistant-bubble {
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--card);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.1);
    max-width: 100%;
    color: var(--text);
}

.ai-assistant-message--user .ai-assistant-bubble {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.12), rgba(37, 99, 235, 0.05));
    border: 1px solid rgba(37, 99, 235, 0.2);
}

.ai-assistant-bubble code {
    background: rgba(15, 23, 42, 0.08);
    padding: 2px 6px;
    border-radius: 6px;
    font-family: 'JetBrains Mono', monospace;
}

.ai-assistant-form {
    border-top: 1px solid var(--border);
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-assistant-form textarea {
    width: 100%;
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 12px;
    resize: vertical;
    min-height: 70px;
    background: var(--card);
    color: var(--text);
}

.ai-assistant-form textarea:focus {
    border-color: var(--primary);
    outline: 2px solid rgba(37, 99, 235, 0.2);
}

.ai-assistant-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

@media (max-width: 768px) {
    .ai-assistant-shell {
        right: 16px;
        bottom: 16px;
    }

    .ai-assistant-panel {
        width: calc(100vw - 32px);
        max-height: calc(100vh - 150px);
    }
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* Button Sizes */
.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
    font-weight: 700;
}

/* Sticky Actions */
.form-actions {
    position: sticky;
    bottom: 0;
    background: var(--card);
    padding: 20px;
    border-top: 2px solid var(--border);
    margin-top: 30px;
    z-index: 10;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.05);
}

/* Form Text Helper */
.form-text {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--secondary);
}

/* Responsive Form Grid */
@media (max-width: 768px) {
    .form-grid-compact {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        flex-direction: column;
    }
    
    .form-row .form-group {
        flex: 1 1 auto;
        width: 100%;
        min-width: 100%;
    }
    
    .form-tabs {
        flex-direction: column;
    }
    
    .form-tab {
        border-bottom: 1px solid var(--border);
        border-left: 3px solid transparent;
    }
    
    .form-tab.active {
        border-left-color: var(--primary);
        border-bottom-color: var(--border);
    }
}