/* ===================================================================
   KingStone Dashboard — Design System & Styles
   ================================================================ */

/* ─── CSS Custom Properties ──────────────────────────────────────── */
:root {
    /* Primary Palette */
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --primary-glow: rgba(79, 70, 229, 0.15);

    /* Accent */
    --accent: #06b6d4;
    --accent-hover: #0891b2;

    /* Semantic */
    --success: #16a34a;
    --success-bg: #f0fdf4;
    --warning: #ea580c;
    --warning-bg: #fff7ed;
    --danger: #dc2626;
    --danger-bg: #fef2f2;

    /* Neutral */
    --bg: #f0f2f5;
    --bg-alt: #e8eaed;
    --surface: #ffffff;
    --surface-hover: #f8f9fa;
    --border: #e2e5e9;
    --border-light: #f0f1f3;

    /* Text */
    --text: #1a1d26;
    --text-secondary: #5f6778;
    --text-muted: #9ca3b4;
    --text-inverse: #ffffff;

    /* Layout */
    --sidebar-width: 260px;
    --bottom-nav-height: 72px;
    --top-bar-height: 60px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.1), 0 4px 8px rgba(0,0,0,0.05);
    --shadow-xl: 0 20px 50px rgba(0,0,0,0.12);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition: 250ms ease;
    --transition-slow: 400ms ease;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    --gradient-accent: linear-gradient(135deg, #06b6d4 0%, #0284c7 100%);
    --gradient-success: linear-gradient(135deg, #16a34a 0%, #059669 100%);
    --gradient-warm: linear-gradient(135deg, #f59e0b 0%, #ea580c 100%);
}

/* ─── Dark Mode ──────────────────────────────────────────────────── */
[data-theme="dark"] {
    --primary: #818cf8;
    --primary-hover: #a5b4fc;
    --primary-light: rgba(129, 140, 248, 0.1);
    --primary-glow: rgba(129, 140, 248, 0.12);

    --accent: #22d3ee;
    --accent-hover: #67e8f9;

    --success: #4ade80;
    --success-bg: rgba(74, 222, 128, 0.1);
    --warning: #fb923c;
    --warning-bg: rgba(251, 146, 60, 0.1);
    --danger: #f87171;
    --danger-bg: rgba(248, 113, 113, 0.1);

    --bg: #0c0e14;
    --bg-alt: #12141c;
    --surface: #1a1d28;
    --surface-hover: #22252f;
    --border: #2a2d3a;
    --border-light: #1f222d;

    --text: #e8eaf0;
    --text-secondary: #9ca3b8;
    --text-muted: #5f6778;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.4);
    --shadow-xl: 0 20px 50px rgba(0,0,0,0.5);
}

/* ─── CSS Reset ──────────────────────────────────────────────────── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
    background: var(--bg);
    color: var(--text);
    direction: rtl;
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; color: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
img { max-width: 100%; display: block; }

/* ─── App Layout ─────────────────────────────────────────────────── */
#app {
    display: flex;
    min-height: 100vh;
}

/* ─── Sidebar (Desktop) ─────────────────────────────────────────── */
#sidebar {
    display: none;
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--surface);
    border-left: 1px solid var(--border);
    padding: 1.5rem 0;
    flex-direction: column;
    z-index: 100;
    box-shadow: var(--shadow-md);
    transition: background var(--transition), border-color var(--transition);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1.5rem 1.5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.5rem;
}

.sidebar-logo .logo-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: white;
    flex-shrink: 0;
}

.sidebar-logo h1 {
    font-size: 1.25rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-nav {
    flex: 1;
    padding: 0.5rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sidebar-nav .nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    position: relative;
}

.sidebar-nav .nav-item:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.sidebar-nav .nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.sidebar-nav .nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    border-radius: 0 4px 4px 0;
    background: var(--primary);
}

.sidebar-nav .nav-item svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.sidebar-footer .theme-toggle-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    border-radius: var(--radius-md);
    background: var(--bg);
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    width: 100%;
}

.sidebar-footer .theme-toggle-btn:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.sidebar-footer .last-refresh-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

/* ─── Top Bar (Mobile) ───────────────────────────────────────────── */
#top-bar {
    position: sticky;
    top: 0;
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    height: var(--top-bar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: background var(--transition), border-color var(--transition);
}

.top-bar-title {
    font-size: 1.15rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.top-bar-actions button {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.top-bar-actions button:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.top-bar-actions button svg {
    width: 20px;
    height: 20px;
}

/* ─── Main Content ───────────────────────────────────────────────── */
#main-content {
    flex: 1;
    min-width: 0;
    padding-bottom: calc(var(--bottom-nav-height) + 1rem);
    transition: padding var(--transition);
}

/* ─── Connection Status ──────────────────────────────────────────── */
#connection-status {
    background: var(--danger);
    color: white;
    text-align: center;
    padding: 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    animation: slideDown 0.3s ease;
}

#connection-status.hidden { display: none; }

#connection-status svg { width: 16px; height: 16px; }

.refresh-time-mobile {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 0.75rem;
}

/* ─── Pages ──────────────────────────────────────────────────────── */
.page {
    display: none;
    padding: 1rem;
    animation: fadeIn 0.35s ease;
}

.page.active {
    display: block;
}

.page-header {
    margin-bottom: 1.25rem;
}

.page-header h2 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text);
}

.page-header p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}

/* ─── KPI Cards ──────────────────────────────────────────────────── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition);
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 80px;
    height: 80px;
    border-radius: 0 0 0 100%;
    opacity: 0.08;
}

.kpi-card:nth-child(1)::before { background: var(--primary); }
.kpi-card:nth-child(2)::before { background: var(--success); }
.kpi-card:nth-child(3)::before { background: var(--accent); }
.kpi-card:nth-child(4)::before { background: var(--warning); }

.kpi-card .kpi-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
}

.kpi-card:nth-child(1) .kpi-icon { background: var(--primary-light); color: var(--primary); }
.kpi-card:nth-child(2) .kpi-icon { background: var(--success-bg); color: var(--success); }
.kpi-card:nth-child(3) .kpi-icon { background: rgba(6,182,212,0.1); color: var(--accent); }
.kpi-card:nth-child(4) .kpi-icon { background: var(--warning-bg); color: var(--warning); }

.kpi-card .kpi-value {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1.2;
    margin-bottom: 0.25rem;
}

.kpi-card .kpi-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ─── Cards ──────────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: background var(--transition), box-shadow var(--transition);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 700;
}

/* ─── Filter Section ─────────────────────────────────────────────── */
.filter-group {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
    transition: background var(--transition);
}

.filter-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.filter-item {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.filter-item label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* ─── Buttons ────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    transition: all var(--transition-fast);
    white-space: nowrap;
    min-height: 40px;
}

.btn svg { width: 16px; height: 16px; }

.btn-primary {
    background: var(--primary);
    color: var(--text-inverse);
}
.btn-primary:hover { background: var(--primary-hover); box-shadow: var(--shadow-md); }

.btn-secondary {
    background: var(--bg);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-icon:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.btn-icon svg { width: 18px; height: 18px; }

/* ─── Inputs ─────────────────────────────────────────────────────── */
input[type="text"],
input[type="search"],
input[type="date"],
select {
    width: 100%;
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 0.85rem;
    transition: all var(--transition-fast);
    min-height: 40px;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

input::placeholder { color: var(--text-muted); }

/* ─── Searchable Dropdown ────────────────────────────────────────── */
.searchable-dropdown {
    position: relative;
    width: 100%;
}

.sd-selected {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
    min-height: 40px;
    transition: all var(--transition-fast);
    user-select: none;
}

.sd-selected:hover { border-color: var(--primary); }

.sd-selected.sd-open {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.sd-selected-text {
    font-size: 0.85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.sd-arrow {
    color: var(--text-muted);
    transition: transform var(--transition-fast);
    display: flex;
    align-items: center;
}

.sd-open .sd-arrow { transform: rotate(180deg); }

.sd-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    left: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    max-height: 260px;
    display: flex;
    flex-direction: column;
    animation: dropdownOpen 0.2s ease;
}

.sd-search {
    margin: 0.5rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    background: var(--bg);
}

.sd-options {
    flex: 1;
    overflow-y: auto;
    padding: 0.25rem;
}

.sd-option {
    padding: 0.55rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.sd-option:hover { background: var(--primary-light); }

.sd-option-active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.sd-empty {
    padding: 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ─── Actions Bar ────────────────────────────────────────────────── */
.actions-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.actions-bar .search-input-wrap {
    flex: 1;
    min-width: 180px;
    position: relative;
}

.actions-bar .search-input-wrap svg {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none;
}

.actions-bar .search-input-wrap input {
    padding-right: 2.25rem;
}

/* ─── Tables ─────────────────────────────────────────────────────── */
.table-responsive {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transition: background var(--transition);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.data-table thead {
    position: sticky;
    top: 0;
    z-index: 5;
}

.data-table th {
    background: var(--bg-alt);
    padding: 0.75rem 1rem;
    text-align: right;
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: background var(--transition-fast);
}

.data-table th:hover { background: var(--border); }

.data-table th .sort-icon {
    display: inline-block;
    margin-right: 0.25rem;
    opacity: 0.3;
    font-size: 0.7rem;
}

.data-table th.sort-active .sort-icon { opacity: 1; color: var(--primary); }

.data-table td {
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--border-light);
    transition: background var(--transition-fast);
}

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

.data-table tbody tr:last-child td { border-bottom: none; }

/* ─── Quantity Colors ────────────────────────────────────────────── */
.quantity-zero {
    color: var(--danger) !important;
    font-weight: 800;
}

.quantity-low {
    color: var(--warning) !important;
    font-weight: 700;
}

.quantity-ok {
    color: var(--success) !important;
    font-weight: 600;
}

/* ─── Transaction Colors ─────────────────────────────────────────── */
.debit-cell {
    color: var(--success) !important;
    font-weight: 600;
}

.credit-cell {
    color: var(--danger) !important;
    font-weight: 600;
}

/* ─── Balance Cards ──────────────────────────────────────────────── */
.balance-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.balance-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1rem;
    background: var(--surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    transition: all var(--transition-fast);
}

.balance-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.balance-card .balance-name {
    font-size: 0.9rem;
    font-weight: 500;
}

.balance-card .balance-value {
    font-size: 0.95rem;
    font-weight: 700;
    font-feature-settings: 'tnum';
}

.balance-positive .balance-value {
    color: var(--success);
}

/* ─── Finance Tabs ───────────────────────────────────────────────── */
.finance-tabs {
    display: flex;
    gap: 0.25rem;
    background: var(--bg-alt);
    border-radius: var(--radius-md);
    padding: 0.25rem;
    margin-bottom: 1rem;
    overflow-x: auto;
}

.finance-tab {
    flex: 1;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: center;
    transition: all var(--transition-fast);
    white-space: nowrap;
    min-width: max-content;
}

.finance-tab:hover { color: var(--primary); }

.finance-tab.active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.tab-panel {
    display: none;
    animation: fadeIn 0.3s ease;
}

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

/* ─── Mobile Data Cards ──────────────────────────────────────────── */
.mobile-cards {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.mobile-card {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 0.85rem 1rem;
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
}

.mobile-card:hover {
    border-color: var(--primary);
}

.mobile-card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.2rem 0;
}

.mobile-card-row:not(:last-child) {
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 0.2rem;
    padding-bottom: 0.35rem;
}

.mobile-card-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.mobile-card-value {
    font-size: 0.85rem;
    font-weight: 600;
}

/* ─── Sales KPI ──────────────────────────────────────────────────── */
.sales-kpi-card {
    background: var(--gradient-primary);
    border-radius: var(--radius-xl);
    padding: 2rem 1.5rem;
    text-align: center;
    color: white;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.sales-kpi-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.06) 0%, transparent 70%);
    animation: shimmer 8s ease infinite;
}

.sales-kpi-card .kpi-label {
    font-size: 0.9rem;
    opacity: 0.85;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.sales-kpi-card .kpi-value {
    font-size: 2.2rem;
    font-weight: 800;
    line-height: 1.2;
    text-shadow: 0 2px 10px rgba(0,0,0,0.15);
}

.sales-kpi-card .kpi-currency {
    font-size: 1rem;
    opacity: 0.7;
    margin-top: 0.25rem;
    font-weight: 500;
}

/* ─── Loading Skeleton ───────────────────────────────────────────── */
.skeleton-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.skeleton-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.skeleton-line {
    height: 0.85rem;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--border-light) 25%, var(--bg-alt) 50%, var(--border-light) 75%);
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s ease-in-out infinite;
    margin-bottom: 0.5rem;
}

.skeleton-line-short { width: 40%; }
.skeleton-line-medium { width: 70%; }
.skeleton-line-long { width: 100%; }

.skeleton-table {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
}

.skeleton-row {
    display: flex;
    gap: 1rem;
}

.skeleton-row .skeleton-line { flex: 1; }

/* ─── Empty State ────────────────────────────────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
    text-align: center;
}

.empty-state-icon { margin-bottom: 1rem; color: var(--text-muted); }

.empty-state-text {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ─── Toast Notifications ────────────────────────────────────────── */
#toast-container {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 90%;
    max-width: 400px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    font-size: 0.85rem;
    font-weight: 500;
    pointer-events: auto;
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s ease;
}

.toast-show { opacity: 1; transform: translateY(0); }
.toast-hide { opacity: 0; transform: translateY(-20px); }

.toast-icon { flex-shrink: 0; display: flex; }

.toast-message { flex: 1; }

.toast-close {
    font-size: 1.2rem;
    opacity: 0.5;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}
.toast-close:hover { opacity: 1; }

.toast-success { border-color: var(--success); }
.toast-success .toast-icon { color: var(--success); }

.toast-error { border-color: var(--danger); }
.toast-error .toast-icon { color: var(--danger); }

.toast-warning { border-color: var(--warning); }
.toast-warning .toast-icon { color: var(--warning); }

.toast-info { border-color: var(--primary); }
.toast-info .toast-icon { color: var(--primary); }

/* ─── Bottom Navigation (Mobile) ─────────────────────────────────── */
#bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 0 0.5rem;
    z-index: 100;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.06);
    transition: background var(--transition), border-color var(--transition);
}

#bottom-nav .nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: all var(--transition-fast);
    position: relative;
    min-width: 56px;
}

#bottom-nav .nav-item svg {
    width: 22px;
    height: 22px;
    transition: transform var(--transition-fast);
}

#bottom-nav .nav-item.active {
    color: var(--primary);
    font-weight: 700;
}

#bottom-nav .nav-item.active svg {
    transform: scale(1.1);
}

#bottom-nav .nav-item.active::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 3px;
    border-radius: 0 0 4px 4px;
    background: var(--primary);
}

/* ─── Animations ─────────────────────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}

@keyframes dropdownOpen {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes skeletonShimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes shimmer {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    50% { transform: translate(5%, 5%) rotate(2deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Loading spinner */
.loading-spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    gap: 0.75rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* ─── Scrollbar ──────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Print Styles ───────────────────────────────────────────────── */
@media print {
    #sidebar, #bottom-nav, #top-bar, #toast-container, #connection-status,
    .filter-group, .actions-bar, .finance-tabs, .btn { display: none !important; }
    .page { display: block !important; padding: 0 !important; }
    .page:not(.active) { display: none !important; }
    body { background: white !important; }
    .data-table { box-shadow: none; }
    .data-table th { background: #f5f5f5 !important; }
}

/* ─── Responsive: Tablets ────────────────────────────────────────── */
@media (min-width: 600px) {
    .kpi-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .filter-row {
        grid-template-columns: repeat(4, 1fr);
    }

    .page {
        padding: 1.25rem;
    }

    .kpi-card .kpi-value {
        font-size: 1.5rem;
    }

    .sales-kpi-card .kpi-value {
        font-size: 2.8rem;
    }

    .skeleton-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ─── Responsive: Desktop ────────────────────────────────────────── */
@media (min-width: 1024px) {
    #sidebar {
        display: flex;
    }

    #bottom-nav {
        display: none;
    }

    #top-bar {
        display: none;
    }

    #main-content {
        margin-right: var(--sidebar-width);
        padding-bottom: 2rem;
    }

    .page {
        padding: 1.75rem 2rem;
        max-width: 1200px;
    }

    .refresh-time-mobile {
        display: none;
    }
}

/* ─── Responsive: Large Desktop ──────────────────────────────────── */
@media (min-width: 1440px) {
    .page {
        padding: 2rem 2.5rem;
    }

    .kpi-card .kpi-value {
        font-size: 1.75rem;
    }
}
