:root {
    color-scheme: dark;
    --bg: #090b12;
    --panel: #111521;
    --panel-2: #171c2b;
    --border: #252b3d;
    --text: #f4f6fb;
    --muted: #929bad;
    --purple: #8c6cff;
    --purple-soft: rgba(140, 108, 255, .14);
    --green: #47d7a1;
    --yellow: #f4c95d;
    --red: #f07283;
    --radius: 16px;
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; color: var(--text); background: radial-gradient(circle at 75% -20%, #201b3b 0, var(--bg) 36%); }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 260px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 24px 18px; border-right: 1px solid var(--border); background: rgba(10, 12, 19, .88); display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 25px; }
.brand-mark { width: 42px; height: 42px; border-radius: 13px; background: linear-gradient(135deg, #a58cff, #6745df); display: grid; place-items: center; color: white; font-size: 13px; font-weight: 800; box-shadow: 0 10px 28px rgba(106, 72, 222, .28); }
.brand strong, .brand small, .sidebar-footer strong, .sidebar-footer small { display: block; }
.brand strong { font-size: 14px; }
.brand small, .sidebar-footer small { color: var(--muted); font-size: 11px; margin-top: 3px; }
.nav-list { display: grid; gap: 5px; }
.nav-list p { margin: 22px 12px 7px; color: #656d80; font-size: 10px; letter-spacing: .16em; text-transform: uppercase; font-weight: 700; }
.nav-list a { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 13px; border-radius: 11px; color: #b3bac9; font-size: 14px; transition: .15s ease; }
.nav-list a:hover { color: white; background: var(--panel-2); }
.nav-icon { width: 24px; text-align: center; color: var(--purple); font-weight: 700; }
.sidebar-footer { margin-top: auto; padding: 16px 8px 0; border-top: 1px solid var(--border); display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; }
.user-avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: #d9d0ff; background: var(--purple-soft); font-weight: 800; }
.sidebar-footer strong { font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.logout-button { border: 0; background: transparent; color: var(--muted); font-size: 20px; cursor: pointer; padding: 7px; }
.logout-button:hover { color: white; }

.content { min-width: 0; width: 100%; max-width: 1540px; padding: 38px 42px 60px; }
.page-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 28px; }
.page-header h1 { margin: 4px 0 6px; font-size: clamp(28px, 4vw, 38px); letter-spacing: -.03em; }
.page-header p { margin: 0; }
.eyebrow { color: var(--purple); font-size: 11px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; }
.muted { color: var(--muted); line-height: 1.55; }
.live-badge { padding: 9px 13px; border: 1px solid rgba(71, 215, 161, .22); border-radius: 999px; color: #9ae9cd; background: rgba(71, 215, 161, .07); font-size: 12px; white-space: nowrap; }
.live-dot { display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 14px rgba(71, 215, 161, .8); }

.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.metric-card { min-height: 150px; padding: 22px; border: 1px solid var(--border); border-radius: var(--radius); background: linear-gradient(145deg, rgba(24, 29, 44, .9), rgba(15, 18, 28, .95)); display: flex; flex-direction: column; }
.metric-card strong { margin: 18px 0 8px; font-size: clamp(25px, 3vw, 34px); letter-spacing: -.03em; }
.metric-card small { color: var(--muted); margin-top: auto; }
.metric-label { color: #bec4d1; font-size: 13px; }
.accent-card { border-color: rgba(140, 108, 255, .45); background: linear-gradient(145deg, rgba(65, 48, 116, .38), rgba(20, 19, 36, .9)); }
.online-card strong { color: var(--green); }
.quick-grid { margin-top: 20px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.quick-link { padding: 18px 20px; border: 1px solid var(--border); border-radius: 13px; background: rgba(17, 21, 33, .72); }
.quick-link:hover { border-color: #424b65; background: var(--panel-2); }
.quick-link span, .quick-link small { display: block; }
.quick-link span { font-weight: 700; margin-bottom: 6px; }
.quick-link small { color: var(--muted); line-height: 1.4; }

.filter-panel { margin-bottom: 20px; padding: 16px; display: grid; grid-template-columns: repeat(4, minmax(130px, 1fr)) minmax(190px, 1.5fr) auto; align-items: end; gap: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: rgba(17, 21, 33, .78); }
.compact-filters { grid-template-columns: repeat(2, minmax(160px, 220px)) auto; justify-content: start; }
.filter-field { min-width: 0; }
.filter-field label, .form-stack > label { display: block; margin: 0 0 7px; color: #aab2c2; font-size: 12px; font-weight: 650; }
input, select { width: 100%; height: 42px; padding: 0 11px; border: 1px solid #30374c; border-radius: 9px; outline: 0; color: var(--text); background: #0e121d; }
input:focus, select:focus { border-color: var(--purple); box-shadow: 0 0 0 3px var(--purple-soft); }
.filter-actions { display: flex; gap: 8px; }
.button { min-height: 42px; padding: 0 15px; border: 1px solid transparent; border-radius: 9px; display: inline-flex; justify-content: center; align-items: center; font-weight: 700; font-size: 13px; cursor: pointer; white-space: nowrap; }
.button-primary { color: white; background: linear-gradient(135deg, #8e70f6, #7150dc); box-shadow: 0 8px 22px rgba(113, 80, 220, .18); }
.button-primary:hover { filter: brightness(1.09); }
.button-secondary { color: #c2c8d5; border-color: #30374c; background: #151a28; }
.button-secondary:hover { color: white; border-color: #49536e; }

.table-card { overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: rgba(17, 21, 33, .82); }
.table-heading { min-height: 64px; padding: 0 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.table-heading h2 { margin: 0; font-size: 16px; }
.table-heading span { color: var(--muted); font-size: 12px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 13px 17px; text-align: left; color: #788197; background: rgba(10, 13, 21, .5); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
td { padding: 16px 17px; border-top: 1px solid rgba(37, 43, 61, .72); color: #c7ccd7; vertical-align: top; }
tbody tr:hover { background: rgba(140, 108, 255, .035); }
td small, .primary-cell { display: block; }
td small { margin-top: 5px; color: var(--muted); line-height: 1.35; }
.primary-cell { color: var(--text); font-weight: 650; white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.money { color: var(--text); font-weight: 750; white-space: nowrap; }
.status { display: inline-flex; padding: 5px 9px; border-radius: 999px; font-size: 11px; font-weight: 750; }
.status-success { color: #86e7c4; background: rgba(71, 215, 161, .11); }
.status-danger { color: #f4a0aa; background: rgba(240, 114, 131, .11); }
.status-pending { color: #f6d988; background: rgba(244, 201, 93, .11); }
details summary { color: #bbaaff; cursor: pointer; white-space: nowrap; }
.order-lines { min-width: 250px; padding-top: 10px; display: grid; gap: 10px; }
.order-lines div { padding-bottom: 9px; border-bottom: 1px solid var(--border); }
.order-lines span { color: var(--text); }
.empty-state { padding: 50px 20px; text-align: center; color: var(--muted); }
.pagination { min-height: 60px; display: flex; justify-content: center; align-items: center; gap: 20px; color: var(--muted); font-size: 13px; }
.pagination a { color: #c7baff; }

.online-summary { margin-bottom: 20px; padding: 20px 22px; border: 1px solid rgba(71, 215, 161, .2); border-radius: var(--radius); background: linear-gradient(110deg, rgba(38, 114, 91, .16), rgba(17, 21, 33, .8)); display: flex; align-items: center; justify-content: space-between; }
.online-summary > div { display: flex; align-items: baseline; gap: 8px; }
.online-summary strong { color: var(--green); font-size: 34px; }
.online-summary small { color: var(--muted); }
.version-badge { padding: 5px 8px; border-radius: 7px; background: #1b2030; color: #c2c9d8; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.login-body { display: grid; place-items: center; background: radial-gradient(circle at 50% 20%, #28204b 0, var(--bg) 45%); }
.login-shell { width: 100%; min-height: 100vh; padding: 24px; display: grid; place-items: center; }
.login-card { width: min(100%, 410px); padding: 36px; border: 1px solid var(--border); border-radius: 22px; background: rgba(17, 21, 33, .94); box-shadow: 0 30px 90px rgba(0, 0, 0, .35); }
.login-card .brand-mark { margin-bottom: 24px; }
.login-card h1 { margin: 7px 0 7px; font-size: 29px; letter-spacing: -.03em; }
.form-stack { margin-top: 26px; display: grid; }
.form-stack input { margin-bottom: 15px; }
.form-stack .button { margin-top: 10px; width: 100%; }
.checkbox-row { display: flex !important; align-items: center; gap: 9px; cursor: pointer; }
.checkbox-row input { width: 16px; height: 16px; margin: 0; accent-color: var(--purple); }
.validation { color: #f39aa7; font-size: 12px; line-height: 1.4; }
.validation ul { margin: 0 0 13px; padding-left: 18px; }
.error-card { max-width: 620px; margin: 14vh auto 0; padding: 34px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }
.error-card h1 { margin: 8px 0; }
.error-card .button { margin-top: 14px; }

@media (max-width: 1100px) {
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filter-panel { grid-template-columns: repeat(3, minmax(140px, 1fr)); }
    .filter-actions { grid-column: span 2; }
}

@media (max-width: 760px) {
    .app-shell { display: block; }
    .sidebar { position: static; width: 100%; height: auto; padding: 14px 16px; border-right: 0; border-bottom: 1px solid var(--border); }
    .brand { padding: 0; }
    .brand small { display: none; }
    .nav-list { margin-top: 14px; display: flex; overflow-x: auto; }
    .nav-list p { display: none; }
    .nav-list a { flex: 0 0 auto; }
    .sidebar-footer { position: absolute; top: 18px; right: 16px; padding: 0; border: 0; grid-template-columns: auto; }
    .sidebar-footer .user-avatar, .sidebar-footer div { display: none; }
    .content { padding: 28px 16px 45px; }
    .page-header { align-items: flex-start; flex-direction: column; }
    .metric-grid, .quick-grid { grid-template-columns: 1fr; }
    .metric-card { min-height: 132px; }
    .filter-panel, .compact-filters { grid-template-columns: 1fr; }
    .filter-actions { grid-column: auto; }
    .online-summary { align-items: flex-start; flex-direction: column; gap: 8px; }
    .login-card { padding: 27px 23px; }
}
