:root,
html[data-theme="dark"] {
    --bg-0: #05070f;
    --bg-1: #0a1020;
    --bg-2: #111827;
    --panel: rgba(12, 20, 38, 0.72);
    --panel-strong: rgba(10, 16, 32, 0.92);
    --line: rgba(56, 189, 248, 0.28);
    --line-hot: rgba(244, 114, 182, 0.45);
    --text: #e2e8f0;
    --muted: #94a3b8;
    --cyan: #22d3ee;
    --magenta: #f472b6;
    --lime: #a3e635;
    --amber: #fbbf24;
    --danger: #fb7185;
    --success: #34d399;
    --debit: #fda4af;
    --credit: #67e8f9;
    --input-bg: rgba(2, 6, 14, 0.7);
    --sidebar-bg: linear-gradient(180deg, rgba(8, 14, 28, 0.95), rgba(8, 12, 24, 0.88));
    --topbar-bg: rgba(5, 8, 16, 0.55);
    --stat-bg: linear-gradient(160deg, rgba(15, 23, 42, 0.9), rgba(8, 12, 24, 0.85));
    --dropzone-bg: rgba(2, 8, 18, 0.55);
    --table-border: rgba(148, 163, 184, 0.12);
    --shadow: 0 0 0 1px rgba(34, 211, 238, 0.12), 0 20px 50px rgba(0, 0, 0, 0.45);
    --glow-cyan: 0 0 18px rgba(34, 211, 238, 0.35);
    --glow-magenta: 0 0 18px rgba(244, 114, 182, 0.3);
    --body-bg: radial-gradient(1200px 700px at 10% -10%, rgba(34, 211, 238, 0.14), transparent 55%),
               radial-gradient(900px 600px at 100% 0%, rgba(244, 114, 182, 0.12), transparent 50%),
               linear-gradient(160deg, var(--bg-0), var(--bg-1) 45%, #070b16);
    --grid-line: rgba(34, 211, 238, 0.045);
    --scanline: rgba(34, 211, 238, 0.03);
    --flash-success-bg: rgba(52, 211, 153, 0.12);
    --flash-success-border: rgba(52, 211, 153, 0.4);
    --flash-success-text: #a7f3d0;
    --flash-error-bg: rgba(251, 113, 133, 0.12);
    --flash-error-border: rgba(251, 113, 133, 0.4);
    --flash-error-text: #fecdd3;
    --radius: 18px;
    --sidebar: 280px;
    --font-display: "Orbitron", sans-serif;
    --font-body: "Rajdhani", sans-serif;
    --chart-text: #cbd5e1;
    --chart-grid: rgba(148, 163, 184, 0.12);
}

html[data-theme="light"] {
    --bg-0: #f4f8ff;
    --bg-1: #eef4ff;
    --bg-2: #ffffff;
    --panel: rgba(255, 255, 255, 0.92);
    --panel-strong: #ffffff;
    --line: rgba(14, 165, 233, 0.28);
    --line-hot: rgba(219, 39, 119, 0.28);
    --text: #0f172a;
    --muted: #475569;
    --cyan: #0284c7;
    --magenta: #db2777;
    --lime: #65a30d;
    --amber: #d97706;
    --danger: #e11d48;
    --success: #059669;
    --debit: #be123c;
    --credit: #0369a1;
    --input-bg: #ffffff;
    --sidebar-bg: linear-gradient(180deg, #ffffff, #f8fbff);
    --topbar-bg: rgba(255, 255, 255, 0.9);
    --stat-bg: linear-gradient(160deg, #ffffff, #f8fbff);
    --dropzone-bg: #f8fbff;
    --table-border: rgba(15, 23, 42, 0.1);
    --shadow: 0 0 0 1px rgba(14, 165, 233, 0.12), 0 18px 40px rgba(15, 23, 42, 0.08);
    --glow-cyan: 0 0 16px rgba(14, 165, 233, 0.18);
    --glow-magenta: 0 0 16px rgba(219, 39, 119, 0.14);
    --body-bg: radial-gradient(1200px 700px at 10% -10%, rgba(14, 165, 233, 0.12), transparent 55%),
               radial-gradient(900px 600px at 100% 0%, rgba(219, 39, 119, 0.08), transparent 50%),
               linear-gradient(160deg, #f7faff, #eef5ff 45%, #f8fafc);
    --grid-line: rgba(14, 165, 233, 0.07);
    --scanline: rgba(14, 165, 233, 0.02);
    --flash-success-bg: rgba(5, 150, 105, 0.1);
    --flash-success-border: rgba(5, 150, 105, 0.35);
    --flash-success-text: #065f46;
    --flash-error-bg: rgba(225, 29, 72, 0.08);
    --flash-error-border: rgba(225, 29, 72, 0.3);
    --flash-error-text: #9f1239;
    --chart-text: #334155;
    --chart-grid: rgba(100, 116, 139, 0.2);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
    font-family: var(--font-body);
    color: var(--text);
    background: var(--body-bg);
    overflow-x: hidden;
    transition: background 0.25s ease, color 0.25s ease;
}

a { color: var(--cyan); text-decoration: none; }
button, input, select { font: inherit; }

.grid-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(var(--grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(circle at center, black, transparent 85%);
    z-index: 0;
}

.scanline {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(to bottom, transparent 50%, var(--scanline) 51%);
    background-size: 100% 4px;
    z-index: 1;
    animation: scan 8s linear infinite;
}

@keyframes scan {
    from { transform: translateY(0); }
    to { transform: translateY(4px); }
}

.app-shell {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: var(--sidebar) 1fr;
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 1.25rem;
    border-right: 1px solid var(--line);
    background: var(--sidebar-bg);
    box-shadow: inset -1px 0 0 rgba(244, 114, 182, 0.08), var(--glow-cyan);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.brand {
    display: flex;
    gap: 0.9rem;
    align-items: center;
    padding: 0.5rem;
}

.brand-mark {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    font-family: var(--font-display);
    font-weight: 800;
    color: #041018;
    background: linear-gradient(135deg, var(--cyan), #67e8f9 40%, var(--magenta));
    box-shadow: var(--glow-cyan), var(--glow-magenta);
}

.brand-mark.xl {
    width: 72px;
    height: 72px;
    font-size: 1.4rem;
    margin: 0 auto 1rem;
}

.brand-title {
    font-family: var(--font-display);
    font-size: 0.95rem;
    letter-spacing: 0.04em;
}

.brand-sub {
    color: var(--muted);
    font-size: 0.9rem;
}

.side-nav {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    flex: 1;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-radius: 12px;
    color: var(--muted);
    border: 1px solid transparent;
    transition: 0.2s ease;
}

.nav-link:hover,
.nav-link.active {
    color: var(--text);
    background: rgba(34, 211, 238, 0.08);
    border-color: rgba(34, 211, 238, 0.35);
    box-shadow: 0 0 20px rgba(34, 211, 238, 0.12);
}

.nav-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--cyan);
    box-shadow: 0 0 10px var(--cyan);
}

.nav-dot.debit { background: var(--magenta); box-shadow: 0 0 10px var(--magenta); }
.nav-dot.credit { background: var(--cyan); }

.sidebar-foot {
    display: grid;
    gap: 0.75rem;
}

.admin-chip {
    padding: 0.7rem 0.9rem;
    border-radius: 999px;
    border: 1px solid rgba(163, 230, 53, 0.35);
    color: var(--lime);
    text-align: center;
    box-shadow: 0 0 16px rgba(163, 230, 53, 0.15);
}

.main-area {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(34, 211, 238, 0.15);
    background: var(--topbar-bg);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 5;
}

.topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--text);
    padding: 0.65rem 0.95rem;
    cursor: pointer;
    font-weight: 700;
    letter-spacing: 0.03em;
    box-shadow: var(--shadow);
}

.theme-toggle:hover {
    border-color: var(--cyan);
    box-shadow: var(--glow-cyan);
}

.theme-icon {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--amber), var(--cyan));
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35);
}

html[data-theme="light"] .theme-icon {
    background: linear-gradient(135deg, #0f172a, #0284c7);
}

.login-theme-toggle {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 10;
}

.page-title {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(1.1rem, 2vw, 1.45rem);
    letter-spacing: 0.04em;
}

.page-sub {
    margin: 0.2rem 0 0;
    color: var(--muted);
}

.menu-toggle {
    display: none;
    background: transparent;
    border: 1px solid var(--line);
    color: var(--text);
    border-radius: 10px;
    width: 42px;
    height: 42px;
    cursor: pointer;
}

.content {
    padding: 1.25rem 1.5rem 2rem;
    display: grid;
    gap: 1.25rem;
}

.glass-panel {
    background: var(--panel);
    border-radius: var(--radius);
    border: 1px solid var(--table-border);
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}

.neon-border {
    position: relative;
    overflow: hidden;
}

.neon-border::before {
    content: "";
    position: absolute;
    inset: 0;
    padding: 1px;
    border-radius: inherit;
    background: linear-gradient(120deg, rgba(34, 211, 238, 0.7), transparent 35%, transparent 65%, rgba(244, 114, 182, 0.65));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    border-radius: 12px;
    padding: 0.75rem 1.1rem;
    border: 1px solid transparent;
    cursor: pointer;
    font-weight: 700;
    letter-spacing: 0.03em;
    transition: 0.2s ease;
}

.btn-primary {
    color: #041018;
    background: linear-gradient(135deg, var(--cyan), #67e8f9);
    box-shadow: var(--glow-cyan);
}

.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }

.btn-ghost {
    color: var(--text);
    background: rgba(148, 163, 184, 0.08);
    border-color: rgba(148, 163, 184, 0.25);
}

.btn-ghost:hover {
    border-color: var(--cyan);
    box-shadow: var(--glow-cyan);
}

.btn-block { width: 100%; }

.filter-bar { padding: 1rem 1.15rem; }
.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.85rem;
    align-items: end;
}

.field {
    display: grid;
    gap: 0.4rem;
}

.field span {
    color: var(--muted);
    font-size: 0.92rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.field input,
.field select {
    width: 100%;
    border-radius: 12px;
    border: 1px solid rgba(34, 211, 238, 0.25);
    background: var(--input-bg);
    color: var(--text);
    padding: 0.75rem 0.9rem;
    outline: none;
}

html[data-theme="light"] .field input,
html[data-theme="light"] .field select {
    border-color: rgba(14, 165, 233, 0.35);
}

.field input:focus,
.field select:focus {
    border-color: var(--cyan);
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.15), var(--glow-cyan);
}

.field.grow { grid-column: span 1; }
.filter-actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
}

.stat-grid.compact { grid-template-columns: repeat(1, minmax(0, 320px)); }

.stat-card {
    padding: 1.15rem 1.2rem;
    border-radius: var(--radius);
    background: var(--stat-bg);
    border: 1px solid var(--table-border);
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
    animation: rise 0.55s ease both;
}

.stat-card::after {
    content: "";
    position: absolute;
    inset: auto -20% -40% auto;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    filter: blur(20px);
    opacity: 0.45;
}

.stat-card.neon-cyan { border-color: rgba(34, 211, 238, 0.45); box-shadow: var(--glow-cyan); }
.stat-card.neon-cyan::after { background: var(--cyan); }
.stat-card.neon-magenta { border-color: rgba(244, 114, 182, 0.45); box-shadow: var(--glow-magenta); }
.stat-card.neon-magenta::after { background: var(--magenta); }
.stat-card.neon-lime { border-color: rgba(163, 230, 53, 0.4); }
.stat-card.neon-lime::after { background: var(--lime); }
.stat-card.neon-amber { border-color: rgba(251, 191, 36, 0.4); }
.stat-card.neon-amber::after { background: var(--amber); }

.stat-label {
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 0.85rem;
}

.stat-value {
    margin-top: 0.45rem;
    font-family: var(--font-display);
    font-size: clamp(1rem, 2vw, 1.25rem);
    letter-spacing: 0.02em;
}

.stat-value.compact { font-size: 1.15rem; }
.stat-meta { margin-top: 0.45rem; color: var(--muted); }

.chart-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.chart-panel { padding: 1.1rem 1.15rem 1.25rem; }
.chart-panel.wide { grid-column: 1 / -1; }

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 0.85rem;
}

.panel-head h2,
.panel-head h3 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1rem;
    letter-spacing: 0.04em;
}

.panel-head p {
    margin: 0.35rem 0 0;
    color: var(--muted);
}

.chart-box {
    height: 300px;
    position: relative;
}

.chart-box-sm { height: 260px; }

.table-panel { padding: 1.1rem 1.15rem 1.25rem; }
.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

th, td {
    text-align: left;
    padding: 0.85rem 0.7rem;
    border-bottom: 1px solid var(--table-border);
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

tbody tr:nth-child(even) {
    background: transparent;
}

html[data-theme="light"] tbody tr:nth-child(even) {
    background: rgba(14, 165, 233, 0.04);
}

html[data-theme="light"] tbody tr:hover {
    background: rgba(14, 165, 233, 0.08);
}

.amount { font-weight: 700; font-variant-numeric: tabular-nums; }
.debit-text { color: var(--debit); }
.credit-text { color: var(--credit); }
.empty { color: var(--muted); text-align: center !important; }
.muted { color: var(--muted); font-size: 0.9rem; }
.file-cell { font-weight: 600; }

.flash {
    border-radius: 14px;
    padding: 0.9rem 1rem;
    border: 1px solid transparent;
}

.flash-success {
    background: var(--flash-success-bg);
    border-color: var(--flash-success-border);
    color: var(--flash-success-text);
    box-shadow: 0 0 18px rgba(52, 211, 153, 0.15);
}

.flash-error {
    background: var(--flash-error-bg);
    border-color: var(--flash-error-border);
    color: var(--flash-error-text);
}

.flash ul { margin: 0; padding-left: 1.1rem; }

.status-pill {
    display: inline-flex;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    text-transform: uppercase;
    font-size: 0.78rem;
    letter-spacing: 0.06em;
}

.status-completed {
    color: var(--flash-success-text);
    border: 1px solid var(--flash-success-border);
    background: var(--flash-success-bg);
}

.status-failed {
    color: var(--flash-error-text);
    border: 1px solid var(--flash-error-border);
    background: var(--flash-error-bg);
}

.status-processing {
    color: #92400e;
    border: 1px solid rgba(251, 191, 36, 0.4);
    background: rgba(251, 191, 36, 0.1);
}

html[data-theme="dark"] .status-processing {
    color: #fde68a;
}

.pagination-wrap {
    margin-top: 1rem;
    display: flex;
    justify-content: flex-end;
}

.pagination-wrap nav,
.pagination-wrap ul {
    display: flex;
    gap: 0.4rem;
    list-style: none;
    padding: 0;
    margin: 0;
}

.pagination-wrap a,
.pagination-wrap span {
    display: inline-flex;
    padding: 0.45rem 0.75rem;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    color: var(--text);
}

.upload-layout {
    display: grid;
    grid-template-columns: 1.3fr 0.9fr;
    gap: 1rem;
}

.upload-card, .tip-card { padding: 1.25rem; }
.upload-form { display: grid; gap: 1rem; }

.dropzone {
    display: block;
    cursor: pointer;
    border-radius: 16px;
    border: 1px dashed rgba(34, 211, 238, 0.5);
    background: var(--dropzone-bg);
    min-height: 220px;
    position: relative;
    overflow: hidden;
}

.dropzone input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.dropzone-inner {
    height: 100%;
    min-height: 220px;
    display: grid;
    place-content: center;
    text-align: center;
    gap: 0.45rem;
    padding: 1.5rem;
}

.drop-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 0.4rem;
    border-radius: 16px;
    display: grid;
    place-items: center;
    font-family: var(--font-display);
    background: linear-gradient(135deg, rgba(34, 211, 238, 0.2), rgba(244, 114, 182, 0.2));
    border: 1px solid rgba(34, 211, 238, 0.4);
    box-shadow: var(--glow-cyan);
}

.file-name {
    margin-top: 0.5rem;
    color: var(--cyan);
    font-weight: 700;
}

.tip-list {
    margin: 1rem 0 0;
    padding-left: 1.1rem;
    color: var(--muted);
    display: grid;
    gap: 0.65rem;
}

.login-body { display: grid; place-items: center; min-height: 100vh; padding: 1.5rem; }
.login-wrap { position: relative; z-index: 2; width: min(440px, 100%); }
.login-card { padding: 2rem 1.5rem; }
.login-brand { text-align: center; margin-bottom: 1.5rem; }
.login-brand h1 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.35rem;
    letter-spacing: 0.05em;
}
.login-brand p { margin: 0.45rem 0 0; color: var(--muted); }
.login-form { display: grid; gap: 0.95rem; }
.check-row {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    color: var(--muted);
}

html[data-theme="light"] .nav-link:hover,
html[data-theme="light"] .nav-link.active {
    background: rgba(14, 165, 233, 0.1);
    border-color: rgba(14, 165, 233, 0.35);
    box-shadow: 0 0 16px rgba(14, 165, 233, 0.08);
}

html[data-theme="light"] .admin-chip {
    color: #3f6212;
    border-color: rgba(101, 163, 13, 0.35);
    background: rgba(163, 230, 53, 0.12);
    box-shadow: none;
}

html[data-theme="light"] .sidebar {
    box-shadow: inset -1px 0 0 rgba(219, 39, 119, 0.06), 0 0 0 1px rgba(14, 165, 233, 0.08);
}

html[data-theme="light"] .stat-card::after {
    opacity: 0.18;
}

html[data-theme="light"] .btn-primary {
    color: #fff;
    background: linear-gradient(135deg, #0284c7, #0ea5e9);
}

html[data-theme="light"] .btn-ghost {
    background: rgba(15, 23, 42, 0.03);
    border-color: rgba(15, 23, 42, 0.12);
}

html[data-theme="light"] .neon-border::before {
    background: linear-gradient(120deg, rgba(14, 165, 233, 0.7), transparent 35%, transparent 65%, rgba(219, 39, 119, 0.55));
}

html[data-theme="light"] .scanline {
    opacity: 0.35;
}

.table-tools {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.check-col {
    width: 52px;
    text-align: center !important;
}

.num-col {
    width: 56px;
    text-align: center !important;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    color: var(--muted);
}

.txn-check {
    width: 18px;
    height: 18px;
    accent-color: var(--magenta);
    cursor: pointer;
}

.group-dock {
    position: sticky;
    bottom: 1rem;
    z-index: 8;
    padding: 1rem 1.15rem;
}

.group-dock-grid {
    display: grid;
    grid-template-columns: 1.1fr 1.2fr 1.2fr auto;
    gap: 0.85rem;
    align-items: end;
}

.group-dock-stats {
    display: flex;
    gap: 1rem;
    margin-top: 0.35rem;
    flex-wrap: wrap;
    font-size: 1.05rem;
}

.row-actions {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

tfoot td {
    border-top: 1px solid var(--line);
    padding-top: 1rem;
}

.group-row td {
    background: rgba(14, 165, 233, 0.06);
}

html[data-theme="dark"] .group-row td {
    background: rgba(34, 211, 238, 0.08);
}

.salary-row-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.salary-child-row td {
    background: rgba(148, 163, 184, 0.06);
}

@media (max-width: 1100px) {
    .stat-grid,
    .chart-grid,
    .filter-grid,
    .upload-layout,
    .group-dock-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 860px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: min(86vw, 300px);
        transform: translateX(-105%);
        transition: transform 0.25s ease;
        z-index: 30;
    }
    .sidebar.open { transform: translateX(0); }
    .menu-toggle { display: inline-grid; place-items: center; }
    .content { padding: 1rem; }
    .topbar { padding: 1rem; }
}
