/* ============================================================
   SIJI-BILL — Main Stylesheet
   ISP Billing Management System
   ============================================================ */

/* ---------- CSS Variables ---------- */
:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-glow: rgba(59,130,246,0.18);
    --secondary: #6366f1;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;

    --bg-base: #0f1117;
    --bg-surface: #161b27;
    --bg-card: #1c2233;
    --bg-hover: #232b3e;
    --bg-active: #1e2d4a;

    --border: #2a3350;
    --border-light: #334060;

    --text-primary: #e8ecf4;
    --text-secondary: #8892aa;
    --text-muted: #4f5b73;

    --sidebar-w: 260px;
    --sidebar-collapsed: 72px;
    --topbar-h: 60px;

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --shadow: 0 4px 24px rgba(0,0,0,0.35);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.2);

    --font-sans: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --transition: 0.2s ease;
}

[data-theme="light"] {
    --bg-base: #f0f3fa;
    --bg-surface: #ffffff;
    --bg-card: #ffffff;
    --bg-hover: #f5f7ff;
    --bg-active: #eef2ff;
    --border: #e2e8f0;
    --border-light: #cbd5e1;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --shadow: 0 4px 24px rgba(0,0,0,0.08);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.05);
}

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

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-base);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ---------- 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(--border-light); }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    transition: width var(--transition), transform var(--transition);
    overflow: hidden;
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: var(--topbar-h);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    overflow: hidden;
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 16px;
    flex-shrink: 0;
    box-shadow: 0 0 12px var(--primary-glow);
}

.brand-text { overflow: hidden; }
.brand-name {
    display: block;
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.5px;
    white-space: nowrap;
}
.brand-sub {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
    letter-spacing: 0.3px;
}

.sidebar-toggle, .topbar-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: background var(--transition), color var(--transition);
}
.sidebar-toggle:hover, .topbar-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    overflow: hidden;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    color: #fff;
    flex-shrink: 0;
}

.user-avatar-sm {
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    color: #fff;
    flex-shrink: 0;
}

.user-info { overflow: hidden; }
.user-name {
    display: block;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}
.user-role {
    font-size: 10px;
    color: var(--primary);
    font-weight: 500;
    text-transform: capitalize;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
}

.nav-section { margin-bottom: 6px; }

.nav-label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    padding: 8px 20px 4px;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar.collapsed .nav-label { opacity: 0; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 16px;
    margin: 1px 8px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: all var(--transition);
    cursor: pointer;
    border: none;
    background: none;
    width: calc(100% - 16px);
    position: relative;
    white-space: nowrap;
}

.nav-item i {
    width: 18px;
    text-align: center;
    font-size: 14px;
    flex-shrink: 0;
    transition: color var(--transition);
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

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

.nav-item.active i { color: var(--primary); }

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

.nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding: 10px 8px;
    flex-shrink: 0;
}

.logout-btn {
    color: var(--danger) !important;
    opacity: 0.8;
}
.logout-btn:hover { background: rgba(239,68,68,0.1) !important; opacity: 1; }

/* ============================================================
   MAIN WRAPPER
   ============================================================ */
.main-wrapper {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left var(--transition);
}

.sidebar.collapsed ~ .main-wrapper,
body.sidebar-collapsed .main-wrapper {
    margin-left: var(--sidebar-collapsed);
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
    height: var(--topbar-h);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 90;
    gap: 16px;
}

.topbar-left, .topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.breadcrumb-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.breadcrumb-item { color: var(--text-muted); }
.breadcrumb-item.active { color: var(--text-primary); font-weight: 500; }
.breadcrumb-sep { font-size: 9px; color: var(--text-muted); }

.topbar-clock {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
}

.topbar-btn {
    width: 34px;
    height: 34px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    position: relative;
}
.topbar-btn:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-light); }

.notif-dot {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 7px;
    height: 7px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid var(--bg-surface);
}

.topbar-notif { position: relative; }

.notif-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 320px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: none;
    z-index: 200;
}

.notif-dropdown.open { display: block; }

.notif-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 13px;
}

.notif-clear { font-size: 11px; color: var(--primary); text-decoration: none; font-weight: 400; }

.notif-empty {
    padding: 32px;
    text-align: center;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 13px;
}
.notif-empty i { font-size: 24px; }

.topbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* ============================================================
   PAGE CONTENT
   ============================================================ */
.page-content {
    flex: 1;
    padding: 24px;
}

.page-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 24px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
}

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
    gap: 16px;
    flex-wrap: wrap;
}

.page-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.page-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ============================================================
   STAT CARDS
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: border-color var(--transition), transform var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    border-color: var(--border-light);
    transform: translateY(-2px);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--card-accent, var(--primary));
}

.stat-card.primary   { --card-accent: var(--primary); }
.stat-card.success   { --card-accent: var(--success); }
.stat-card.warning   { --card-accent: var(--warning); }
.stat-card.danger    { --card-accent: var(--danger); }
.stat-card.info      { --card-accent: var(--info); }
.stat-card.secondary { --card-accent: var(--secondary); }

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.stat-card.primary   .stat-icon { background: rgba(59,130,246,.15);  color: var(--primary);   }
.stat-card.success   .stat-icon { background: rgba(16,185,129,.15);  color: var(--success);   }
.stat-card.warning   .stat-icon { background: rgba(245,158,11,.15);  color: var(--warning);   }
.stat-card.danger    .stat-icon { background: rgba(239,68,68,.15);   color: var(--danger);    }
.stat-card.info      .stat-icon { background: rgba(6,182,212,.15);   color: var(--info);      }
.stat-card.secondary .stat-icon { background: rgba(99,102,241,.15);  color: var(--secondary); }

.stat-body { flex: 1; min-width: 0; }

.stat-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    font-variant-numeric: tabular-nums;
}

.stat-change {
    font-size: 11px;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
    flex-wrap: wrap;
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title i { color: var(--primary); font-size: 13px; }

.card-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.card-body { padding: 20px; }

.card-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-surface);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font-sans);
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary   { background: var(--primary);   color: #fff; }
.btn-primary:hover  { background: var(--primary-dark); }
.btn-success   { background: var(--success);   color: #fff; }
.btn-success:hover  { background: #059669; }
.btn-warning   { background: var(--warning);   color: #fff; }
.btn-warning:hover  { background: #d97706; }
.btn-danger    { background: var(--danger);    color: #fff; }
.btn-danger:hover   { background: #dc2626; }
.btn-info      { background: var(--info);      color: #fff; }
.btn-secondary { background: var(--secondary); color: #fff; }

.btn-outline-primary {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
}
.btn-outline-primary:hover { background: var(--primary-glow); }

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

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 11px 22px; font-size: 15px; }
.btn-icon { padding: 8px; width: 34px; height: 34px; justify-content: center; }
.btn-icon.btn-sm { width: 28px; height: 28px; padding: 4px; }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
}

table.dataTable { border-collapse: collapse !important; width: 100% !important; }

.table, table.dataTable {
    font-size: 13.5px;
    color: var(--text-primary);
}

.table th, table.dataTable thead th {
    background: var(--bg-surface) !important;
    color: var(--text-muted) !important;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    padding: 12px 16px !important;
    border-bottom: 1px solid var(--border) !important;
    border-top: none !important;
    white-space: nowrap;
}

.table td, table.dataTable tbody td {
    padding: 12px 16px !important;
    border-bottom: 1px solid var(--border) !important;
    vertical-align: middle;
    background: transparent !important;
}

.table tbody tr:hover td,
table.dataTable tbody tr:hover td {
    background: var(--bg-hover) !important;
}

/* DataTables overrides */
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    font-size: 13px;
    outline: none;
}

.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_length label,
.dataTables_wrapper .dataTables_filter label {
    color: var(--text-muted);
    font-size: 13px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    background: var(--bg-card) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-sm) !important;
    color: var(--text-secondary) !important;
    font-size: 12px !important;
    padding: 4px 10px !important;
    margin: 2px !important;
    transition: all var(--transition);
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover,
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #fff !important;
}

/* ============================================================
   BADGES & STATUS
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: capitalize;
}

.badge-primary   { background: rgba(59,130,246,.15);  color: var(--primary);   }
.badge-success   { background: rgba(16,185,129,.15);  color: var(--success);   }
.badge-warning   { background: rgba(245,158,11,.15);  color: var(--warning);   }
.badge-danger    { background: rgba(239,68,68,.15);   color: var(--danger);    }
.badge-info      { background: rgba(6,182,212,.15);   color: var(--info);      }
.badge-secondary { background: rgba(99,102,241,.15);  color: var(--secondary); }
.badge-ghost     { background: var(--bg-hover);       color: var(--text-muted);}

/* Status specific */
.status-active   { background: rgba(16,185,129,.15);  color: var(--success); }
.status-inactive { background: rgba(239,68,68,.15);   color: var(--danger);  }
.status-pending  { background: rgba(245,158,11,.15);  color: var(--warning); }
.status-paid     { background: rgba(16,185,129,.15);  color: var(--success); }
.status-unpaid   { background: rgba(239,68,68,.15);   color: var(--danger);  }
.status-overdue  { background: rgba(239,68,68,.2);    color: var(--danger);  }
.status-partial  { background: rgba(245,158,11,.15);  color: var(--warning); }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 18px; }

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.form-label.required::after {
    content: ' *';
    color: var(--danger);
}

.form-control, .form-select {
    width: 100%;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13.5px;
    font-family: var(--font-sans);
    padding: 9px 12px;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
    appearance: none;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-control::placeholder { color: var(--text-muted); }

textarea.form-control { resize: vertical; min-height: 80px; }

.form-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-error {
    font-size: 11px;
    color: var(--danger);
    margin-top: 4px;
}

.input-group {
    display: flex;
    gap: 0;
}
.input-group .form-control { border-radius: var(--radius-sm) 0 0 var(--radius-sm); flex: 1; }
.input-group .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

.input-icon { position: relative; }
.input-icon .form-control { padding-left: 36px; }
.input-icon i {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 13px;
}

/* ---------- Checkbox & Radio ---------- */
.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.form-check input[type=checkbox],
.form-check input[type=radio] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}

.form-check label { font-size: 13px; cursor: pointer; color: var(--text-secondary); }

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    margin-bottom: 16px;
    border-left: 3px solid;
}

.alert-success { background: rgba(16,185,129,.1); border-color: var(--success); color: #34d399; }
.alert-danger  { background: rgba(239,68,68,.1);  border-color: var(--danger);  color: #f87171; }
.alert-warning { background: rgba(245,158,11,.1); border-color: var(--warning); color: #fbbf24; }
.alert-info    { background: rgba(6,182,212,.1);  border-color: var(--info);    color: #22d3ee; }

.alert-close {
    margin-left: auto;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    opacity: 0.7;
    font-size: 12px;
}

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(20px);
    transition: transform var(--transition);
    box-shadow: var(--shadow);
}

.modal-overlay.open .modal { transform: translateY(0); }

.modal-lg { max-width: 800px; }
.modal-xl { max-width: 1100px; }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
}

.modal-title { font-size: 16px; font-weight: 600; }

.modal-close {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    background: var(--bg-hover);
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all var(--transition);
}
.modal-close:hover { background: var(--bg-active); color: var(--text-primary); }

.modal-body { padding: 22px; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 22px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

/* ============================================================
   GRID / LAYOUT
   ============================================================ */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ============================================================
   CHART CONTAINERS
   ============================================================ */
.chart-container {
    position: relative;
    height: 280px;
}

/* ============================================================
   TAB NAVIGATION
   ============================================================ */
.tabs {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
    overflow-x: auto;
}

.tab-btn {
    padding: 10px 18px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition);
    font-family: var(--font-sans);
}

.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

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

/* ============================================================
   MISC COMPONENTS
   ============================================================ */
.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}

.text-primary-color { color: var(--primary) !important; }
.text-success  { color: var(--success)   !important; }
.text-warning  { color: var(--warning)   !important; }
.text-danger   { color: var(--danger)    !important; }
.text-info     { color: var(--info)      !important; }
.text-muted    { color: var(--text-muted)!important; }

.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fs-12  { font-size: 12px; }
.fs-13  { font-size: 13px; }
.mono   { font-family: var(--font-mono); }

.d-none { display: none !important; }
.d-flex { display: flex !important; }
.d-grid { display: grid !important; }

.align-center { align-items: center; }
.gap-8  { gap: 8px;  }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }

.mt-0  { margin-top: 0;   }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px;}
.mt-24 { margin-top: 24px;}
.mb-0  { margin-bottom: 0;    }
.mb-8  { margin-bottom: 8px;  }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

.justify-between { justify-content: space-between; }
.justify-end     { justify-content: flex-end; }

/* ---------- Empty state ---------- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state i { font-size: 40px; margin-bottom: 12px; opacity: 0.4; display: block; }
.empty-state h4 { font-size: 16px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state p  { font-size: 13px; }

/* ---------- Loading spinner ---------- */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Tooltip ---------- */
[data-tooltip] {
    position: relative;
    cursor: help;
}
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: #e2e8f0;
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
    z-index: 999;
}
[data-tooltip]:hover::after { opacity: 1; }

/* ============================================================
   AUTH PAGES
   ============================================================ */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-base);
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.auth-wrapper::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(59,130,246,.08) 0%, transparent 70%);
    top: -100px;
    right: -100px;
    border-radius: 50%;
}

.auth-wrapper::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(99,102,241,.06) 0%, transparent 70%);
    bottom: -50px;
    left: -50px;
    border-radius: 50%;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    position: relative;
    z-index: 1;
    box-shadow: var(--shadow);
}

.auth-logo {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo-icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #fff;
    margin: 0 auto 12px;
    box-shadow: 0 0 24px var(--primary-glow);
}

.auth-logo h1 { font-size: 22px; font-weight: 700; letter-spacing: 0.5px; }
.auth-logo p  { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ============================================================
   SPECIFIC PAGES
   ============================================================ */

/* MikroTik Connection Status */
.mikrotik-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 500;
}
.mikrotik-status .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}
.dot.connected { background: var(--success); }
.dot.disconnected { background: var(--danger); animation: none; }
@keyframes pulse { 0%,100%{opacity:1;} 50%{opacity:0.4;} }

/* Map container */
#customerMap, #networkMap {
    width: 100%;
    height: 400px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}

/* Connection type badge */
.conn-pppoe   { background: rgba(99,102,241,.15); color: var(--secondary); }
.conn-static  { background: rgba(6,182,212,.15);  color: var(--info);      }
.conn-hotspot { background: rgba(245,158,11,.15); color: var(--warning);   }

/* Amount display */
.amount {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 13px;
}

/* Invoice print preview */
@media print {
    .sidebar, .topbar, .page-footer, .page-actions { display: none !important; }
    .main-wrapper { margin-left: 0 !important; }
    .page-content { padding: 0 !important; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.mobile-open { transform: translateX(0); }
    .main-wrapper { margin-left: 0 !important; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
    .stats-grid { grid-template-columns: 1fr; }
    .page-content { padding: 16px; }
    .topbar { padding: 0 16px; }
    .auth-card { padding: 28px 24px; }
    .topbar-clock { display: none; }
}

/* ============================================================
   MOBILE OVERLAY
   ============================================================ */
.mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
    backdrop-filter: blur(2px);
}

.mobile-overlay.active { display: block; }

/* Modal open state */
.modal-overlay.open {
    display: flex !important;
}

/* Modal Fix */
.modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0,0,0,0.5) !important;
    z-index: 9999 !important;
    display: none;
    align-items: center !important;
    justify-content: center !important;
}
.modal-overlay[style*="flex"] {
    display: flex !important;
}
.modal-box {
    background: var(--bg-card) !important;
    border-radius: 12px !important;
    padding: 0 !important;
    min-width: 400px !important;
    max-width: 560px !important;
    width: 90% !important;
    max-height: 90vh !important;
    overflow-y: auto !important;
    z-index: 10000 !important;
}

/* Modal scroll fix */
.modal-overlay.open {
    display: flex !important;
    overflow-y: auto !important;
}
.modal, .modal-box {
    max-height: 85vh !important;
    overflow-y: auto !important;
    margin: auto !important;
}
