/* ============================================================
   WiFi Closing System — Premium Dark Theme
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ----------  CSS Variables  ---------- */
:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #1c2333;
    --bg-card: #1e2433;
    --bg-card-hover: #252d3f;

    --border: #30363d;
    --border-light: #3d4450;

    --accent: #f5a623;
    --accent-hover: #e8961a;
    --accent-soft: rgba(245, 166, 35, 0.12);

    --green: #3fb950;
    --green-soft: rgba(63, 185, 80, 0.15);
    --red: #f85149;
    --red-soft: rgba(248, 81, 73, 0.15);
    --blue: #58a6ff;
    --blue-soft: rgba(88, 166, 255, 0.12);
    --purple: #bc8cff;
    --purple-soft: rgba(188, 140, 255, 0.12);

    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;

    --sidebar-w: 260px;
    --topbar-h: 64px;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);

    --transition: 0.2s ease;
}

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

html {
    font-size: 15px;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    cursor: pointer;
    font-family: inherit;
}

input,
select,
textarea {
    font-family: inherit;
}

/* ----------  Scrollbar  ---------- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 9px;
}

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

.sidebar-logo {
    padding: 24px 20px 20px;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo .logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent), #e8961a);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 12px;
    box-shadow: 0 4px 12px rgba(245, 166, 35, 0.3);
}

.sidebar-logo h1 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.sidebar-logo p {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.sidebar-nav {
    padding: 16px 12px;
    flex: 1;
    overflow-y: auto;
}

.nav-section-label {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 4px 8px 8px;
    margin-top: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 500;
    transition: all var(--transition);
    margin-bottom: 2px;
}

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

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

.nav-item .nav-icon {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.nav-item .nav-badge {
    margin-left: auto;
    background: var(--accent);
    color: #000;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 20px;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* ============================================================
   MAIN LAYOUT
   ============================================================ */
.main-wrapper {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-width: 0;
    /* prevent flex overflow */
    width: calc(100% - var(--sidebar-w));
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
}

.topbar {
    height: var(--topbar-h);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 28px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-title {
    font-size: 1rem;
    font-weight: 600;
}

.topbar-subtitle {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

.main-content {
    padding: 24px;
    flex: 1;
    min-width: 0;
    /* prevent flex overflow */
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
}

/* ============================================================
   CARDS / PANELS
   ============================================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 22px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

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

.card-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 4px;
}

.card-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
}

.card-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: all var(--transition);
}

.kpi-card:hover {
    border-color: var(--border-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.kpi-icon {
    font-size: 1.4rem;
}

.kpi-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.kpi-val {
    font-size: 1.5rem;
    font-weight: 700;
}

.kpi-val.green {
    color: var(--green);
}

.kpi-val.red {
    color: var(--red);
}

.kpi-val.accent {
    color: var(--accent);
}

.kpi-val.blue {
    color: var(--blue);
}

.kpi-val.purple {
    color: var(--purple);
}

/* ============================================================
   PANELS (Section containers)
   ============================================================ */
.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: visible;
    /* allow table-wrap scrollbar to show */
    margin-bottom: 20px;
}

.panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.panel-header h2 {
    font-size: 0.95rem;
    font-weight: 600;
}

.panel-header p {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.panel-header .panel-actions {
    margin-left: auto;
    display: flex;
    gap: 8px;
}

.panel-body {
    padding: 20px;
}

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

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

thead th {
    background: var(--bg-tertiary);
    padding: 10px 14px;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}

tbody tr:last-child {
    border-bottom: none;
}

tbody tr:hover {
    background: var(--bg-card-hover);
}

tbody td {
    padding: 11px 14px;
    color: var(--text-primary);
    white-space: nowrap;
}

.tfoot-row td {
    background: var(--bg-tertiary);
    font-weight: 700;
    border-top: 2px solid var(--border-light);
    color: var(--accent);
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
}

.badge-green {
    background: var(--green-soft);
    color: var(--green);
}

.badge-red {
    background: var(--red-soft);
    color: var(--red);
}

.badge-blue {
    background: var(--blue-soft);
    color: var(--blue);
}

.badge-accent {
    background: var(--accent-soft);
    color: var(--accent);
}

.badge-purple {
    background: var(--purple-soft);
    color: var(--purple);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    border: none;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: #000;
    box-shadow: 0 2px 8px rgba(245, 166, 35, 0.3);
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 14px rgba(245, 166, 35, 0.4);
    transform: translateY(-1px);
}

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

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-light);
}

.btn-danger {
    background: var(--red-soft);
    color: var(--red);
    border: 1px solid rgba(248, 81, 73, 0.3);
}

.btn-danger:hover {
    background: rgba(248, 81, 73, 0.25);
}

.btn-success {
    background: var(--green-soft);
    color: var(--green);
    border: 1px solid rgba(63, 185, 80, 0.3);
}

.btn-success:hover {
    background: rgba(63, 185, 80, 0.25);
}

.btn-sm {
    padding: 5px 12px;
    font-size: 0.78rem;
}

.btn-icon {
    padding: 7px;
}

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

.form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-label span {
    color: var(--red);
}

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

.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(245, 166, 35, 0.12);
}

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

select.form-control option {
    background: var(--bg-secondary);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
}

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

/* ============================================================
   CALC PREVIEW
   ============================================================ */
.calc-preview {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin: 18px 0;
}

.calc-item {
    text-align: center;
}

.calc-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.calc-val {
    font-size: 1.4rem;
    font-weight: 700;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    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-light);
    border-radius: 14px;
    padding: 28px;
    width: 100%;
    max-width: 520px;
    box-shadow: var(--shadow);
    transform: translateY(12px);
    transition: transform var(--transition);
}

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

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
}

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

.modal-close {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all var(--transition);
}

.modal-close:hover {
    background: var(--red-soft);
    color: var(--red);
    border-color: transparent;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 22px;
}

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 20px;
}

.filter-bar label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
}

.filter-bar .form-control {
    width: auto;
    min-width: 100px;
}

/* ============================================================
   STATUS / ALERTS
   ============================================================ */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}

.alert-success {
    background: var(--green-soft);
    color: var(--green);
    border: 1px solid rgba(63, 185, 80, 0.3);
}

.alert-error {
    background: var(--red-soft);
    color: var(--red);
    border: 1px solid rgba(248, 81, 73, 0.3);
}

.alert-info {
    background: var(--blue-soft);
    color: var(--blue);
    border: 1px solid rgba(88, 166, 255, 0.3);
}

/* ============================================================
   LUCIDE ICONS
   ============================================================ */

/* KPI card icon */
.kpi-icon svg,
.kpi-icon i[data-lucide] {
    width: 22px;
    height: 22px;
    display: block;
}

/* Sidebar nav icon */
.nav-icon svg,
.nav-icon i[data-lucide] {
    width: 18px;
    height: 18px;
    display: inline-block;
    vertical-align: middle;
    stroke-width: 2;
}

/* Logo icon */
.logo-icon svg,
.logo-icon i[data-lucide],
.logo-icon .icon-logo {
    width: 22px;
    height: 22px;
    display: block;
    color: #fff;
    stroke-width: 2;
}

/* Buttons: size inline icons */
.btn svg,
.btn i[data-lucide] {
    flex-shrink: 0;
    display: inline-block;
    vertical-align: middle;
}

/* Empty state icon */
.empty-icon svg,
.empty-icon i[data-lucide] {
    width: 32px;
    height: 32px;
    display: block;
    margin: 0 auto 10px;
    opacity: 0.5;
}

/* ============================================================
   CHART AREA
   ============================================================ */
.chart-container {
    position: relative;
    height: 280px;
    width: 100%;
}

/* ============================================================
   MOBILE HAMBURGER
   ============================================================ */
.hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.3rem;
    padding: 4px;
    cursor: pointer;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 52px 20px;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.empty-state p {
    font-size: 0.88rem;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* Large desktop — tight medium zone (sidebar + content) */
@media (max-width: 1200px) {
    .main-content {
        padding: 20px;
    }

    .kpi-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 12px;
    }

    .kpi-val {
        font-size: 1.2rem;
    }

    tbody td,
    thead th {
        padding: 9px 10px;
    }
}

/* Tablet / small screens — sidebar collapses */
@media (max-width: 900px) {
    :root {
        --sidebar-w: 0px;
    }

    .sidebar {
        transform: translateX(-260px);
        width: 260px;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: block;
    }

    .hamburger {
        display: flex;
    }

    .main-wrapper {
        margin-left: 0;
        width: 100%;
    }

    .main-content {
        padding: 16px;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .calc-preview {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .filter-bar {
        gap: 8px;
    }

    .panel-header {
        flex-wrap: wrap;
    }
}

/* Mobile */
@media (max-width: 500px) {
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .kpi-val {
        font-size: 1.1rem;
    }

    .main-content {
        padding: 12px;
    }

    .topbar {
        padding: 0 14px;
    }

    .filter-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    .modal {
        margin: 12px;
        padding: 20px;
    }

    .calc-preview {
        grid-template-columns: 1fr;
    }

    .panel-header {
        gap: 8px;
    }

    .panel-body {
        padding: 14px;
    }
}