:root {
  --bg-0: #07120d;
  --bg-1: #0a1a12;
  --bg-2: #0e2318;
  --surface: rgba(255, 255, 255, 0.035);
  --surface-2: rgba(255, 255, 255, 0.06);
  --border: rgba(212, 175, 55, 0.14);
  --border-soft: rgba(255, 255, 255, 0.08);
  --text: #e9f1ec;
  --text-dim: #93a99c;
  --text-faint: #5f7a6c;
  --gold: #d4af37;
  --gold-soft: #e7c75a;
  --emerald: #1f9d63;
  --emerald-deep: #1f7a4d;
  --teal: #2bb89a;
  --danger: #e06b5a;
  --warn: #e0b15a;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --font: "Inter", "Helvetica Neue", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --serif: "Cormorant Garamond", "Georgia", "Songti SC", serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 12% -8%, rgba(31, 157, 99, 0.16), transparent 60%),
    radial-gradient(900px 600px at 100% 0%, rgba(212, 175, 55, 0.10), transparent 55%),
    linear-gradient(160deg, var(--bg-1), var(--bg-0) 70%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ---------------- Login ---------------- */
.login-screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(1000px 600px at 20% 10%, rgba(31, 157, 99, 0.18), transparent 60%),
    radial-gradient(800px 600px at 90% 90%, rgba(212, 175, 55, 0.12), transparent 55%),
    linear-gradient(150deg, #0a1a12, #060f0a);
  z-index: 50;
}
.login-card {
  width: 380px; max-width: 92vw; padding: 38px 34px 28px;
  background: linear-gradient(180deg, rgba(255,255,255,0.055), rgba(255,255,255,0.02));
  border: 1px solid var(--border); border-radius: 18px;
  backdrop-filter: blur(18px); box-shadow: var(--shadow);
}
.login-brand { display: flex; align-items: center; gap: 13px; margin-bottom: 22px; }
.brand-mark { width: 42px; height: 42px; filter: drop-shadow(0 4px 10px rgba(0,0,0,.4)); }
.login-title { font-family: var(--serif); font-size: 23px; letter-spacing: 2px; color: #fff; font-weight: 600; }
.login-sub { font-size: 11px; letter-spacing: 3px; color: var(--gold); text-transform: uppercase; }
.login-desc { color: var(--text-dim); font-size: 12.5px; line-height: 1.6; margin-bottom: 22px; }
.login-card label { display: block; font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--text-faint); margin: 14px 0 6px; }
.login-card input {
  width: 100%; padding: 11px 13px; background: rgba(0,0,0,.28); color: var(--text);
  border: 1px solid var(--border-soft); border-radius: 9px; font-size: 14px; outline: none;
  transition: border-color .18s, box-shadow .18s;
}
.login-card input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(212,175,55,.14); }
.login-error { color: var(--danger); font-size: 12px; min-height: 16px; margin-top: 10px; }
.login-foot { margin-top: 22px; text-align: center; font-size: 10.5px; letter-spacing: 1.5px; color: var(--text-faint); text-transform: uppercase; }

/* ---------------- App shell ---------------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex: 0 0 248px; position: sticky; top: 0; height: 100vh;
  background: linear-gradient(180deg, rgba(10,26,18,.92), rgba(6,15,10,.92));
  border-right: 1px solid var(--border); backdrop-filter: blur(10px);
  display: flex; flex-direction: column; padding: 22px 16px;
}
.side-brand { display: flex; align-items: center; gap: 11px; padding: 4px 6px 22px; }
.side-brand-name { font-family: var(--serif); font-size: 17px; letter-spacing: 2px; color: #fff; font-weight: 600; line-height: 1.1; }
.side-brand-sub { font-size: 10.5px; letter-spacing: 3px; color: var(--gold); text-transform: uppercase; margin-top: 2px; }
.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 13px; border-radius: 10px;
  color: var(--text-dim); font-size: 13.5px; letter-spacing: .3px; text-decoration: none;
  transition: background .16s, color .16s; border: 1px solid transparent; cursor: pointer;
}
.nav-item svg { width: 18px; height: 18px; opacity: .85; }
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(212,175,55,.16), rgba(212,175,55,.02));
  color: #fff; border-color: var(--border); box-shadow: inset 2px 0 0 var(--gold);
}
.nav-item.active svg { opacity: 1; }
.side-foot { padding: 14px 8px 0; border-top: 1px solid var(--border-soft); }
.side-foot-label { font-size: 9.5px; letter-spacing: 2px; color: var(--text-faint); }
.side-foot-val { font-size: 12px; color: var(--gold-soft); margin-top: 3px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 20px 32px; border-bottom: 1px solid var(--border-soft);
  background: rgba(7,18,13,.55); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 10;
}
.topbar-title h1 { font-family: var(--serif); font-size: 26px; font-weight: 600; letter-spacing: .5px; color: #fff; }
.topbar-sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; letter-spacing: .3px; }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.global-search { position: relative; display: flex; align-items: center; }
.gs-icon { position: absolute; left: 12px; width: 16px; height: 16px; color: var(--text-faint); }
.global-search input {
  width: 230px; padding: 9px 12px 9px 34px; background: rgba(0,0,0,.28); color: var(--text);
  border: 1px solid var(--border-soft); border-radius: 10px; font-size: 13px; outline: none; transition: .16s;
}
.global-search input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(212,175,55,.12); }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 5px 8px 5px 5px; border: 1px solid var(--border-soft); border-radius: 30px; background: var(--surface); }
.user-avatar { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, var(--emerald), var(--gold)); color: #06140d; font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: 13px; }
.user-name { font-size: 13px; color: var(--text); }
.icon-btn { background: transparent; border: none; color: var(--text-faint); font-size: 16px; padding: 4px 7px; border-radius: 8px; transition: .15s; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.view { padding: 26px 32px 60px; flex: 1; }

/* ---------------- KPI cards ---------------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.kpi {
  position: relative; padding: 18px 18px 16px; border-radius: var(--radius); overflow: hidden;
  background: linear-gradient(160deg, var(--surface-2), var(--surface)); border: 1px solid var(--border-soft);
}
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: linear-gradient(var(--gold), var(--emerald)); opacity: .8; }
.kpi-label { font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-dim); }
.kpi-value { font-family: var(--serif); font-size: 30px; color: #fff; margin-top: 8px; font-weight: 600; letter-spacing: .5px; }
.kpi-value .unit { font-size: 14px; color: var(--gold-soft); margin-left: 4px; font-family: var(--font); }
.kpi-sub { font-size: 11.5px; color: var(--text-faint); margin-top: 4px; }

/* ---------------- Panels / cards ---------------- */
.panel { background: linear-gradient(180deg, var(--surface-2), var(--surface)); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 20px; margin-bottom: 22px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.panel-title { font-size: 15px; font-weight: 600; letter-spacing: .3px; color: #fff; display: flex; align-items: center; gap: 9px; }
.panel-title .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 10px var(--gold); }
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 22px; }

/* ---------------- Tables ---------------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data thead th {
  text-align: left; padding: 11px 14px; font-size: 10.5px; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--text-faint); border-bottom: 1px solid var(--border); background: rgba(0,0,0,.18); white-space: nowrap;
}
table.data tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border-soft); color: var(--text); vertical-align: middle; }
table.data tbody tr { transition: background .14s; cursor: pointer; }
table.data tbody tr:hover { background: rgba(212,175,55,.05); }
table.data tbody tr:last-child td { border-bottom: none; }
.cell-strong { color: #fff; font-weight: 600; }
.cell-sub { color: var(--text-dim); font-size: 11.5px; }

/* ---------------- Badges ---------------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 30px; font-size: 11px; letter-spacing: .4px; border: 1px solid transparent; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-green { color: var(--emerald); background: rgba(31,157,99,.12); border-color: rgba(31,157,99,.3); }
.b-gold { color: var(--gold-soft); background: rgba(212,175,55,.12); border-color: rgba(212,175,55,.3); }
.b-teal { color: var(--teal); background: rgba(43,184,154,.12); border-color: rgba(43,184,154,.3); }
.b-warn { color: var(--warn); background: rgba(224,177,90,.12); border-color: rgba(224,177,90,.3); }
.b-danger { color: var(--danger); background: rgba(224,107,90,.12); border-color: rgba(224,107,90,.3); }
.b-dim { color: var(--text-dim); background: rgba(255,255,255,.05); border-color: var(--border-soft); }
.b-blue { color: #6fb3e0; background: rgba(111,179,224,.12); border-color: rgba(111,179,224,.3); }

/* ---------------- Buttons ---------------- */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 15px; border-radius: 9px; font-size: 13px; font-weight: 500; border: 1px solid var(--border-soft); background: var(--surface-2); color: var(--text); transition: .15s; letter-spacing: .3px; }
.btn:hover { background: var(--surface); border-color: var(--border); }
.btn-gold { background: linear-gradient(135deg, var(--gold), #b8922b); color: #1a1304; border: none; font-weight: 600; box-shadow: 0 6px 18px rgba(212,175,55,.25); }
.btn-gold:hover { filter: brightness(1.06); }
.btn-block { width: 100%; justify-content: center; padding: 12px; margin-top: 18px; font-size: 14px; }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn-danger { color: var(--danger); border-color: rgba(224,107,90,.35); background: rgba(224,107,90,.08); }
.btn-danger:hover { background: rgba(224,107,90,.16); }
.btn-ghost { background: transparent; }
.btn svg { width: 15px; height: 15px; }

/* ---------------- Toolbar ---------------- */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.search-inline { position: relative; display: flex; align-items: center; }
.search-inline svg { position: absolute; left: 11px; width: 15px; height: 15px; color: var(--text-faint); }
.search-inline input { padding: 9px 12px 9px 32px; background: rgba(0,0,0,.25); border: 1px solid var(--border-soft); border-radius: 9px; color: var(--text); font-size: 13px; width: 220px; outline: none; transition: .15s; }
.search-inline input:focus { border-color: var(--gold); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
select.filter, .form-control select, .form-control input, .form-control textarea {
  padding: 9px 11px; background: rgba(0,0,0,.25); border: 1px solid var(--border-soft); border-radius: 9px; color: var(--text); font-size: 13px; outline: none; transition: .15s;
}
select.filter:focus, .form-control select:focus, .form-control input:focus, .form-control textarea:focus { border-color: var(--gold); }
.form-control textarea { resize: vertical; min-height: 70px; }

/* ---------------- Modal ---------------- */
.overlay { position: fixed; inset: 0; background: rgba(3,9,6,.62); backdrop-filter: blur(4px); z-index: 40; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
.modal { width: 620px; max-width: 94vw; background: linear-gradient(180deg, #10241a, #0a1812); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); animation: pop .18s ease; }
@keyframes pop { from { transform: translateY(12px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--border-soft); }
.modal-head h3 { font-family: var(--serif); font-size: 20px; color: #fff; font-weight: 600; }
.modal-close { background: transparent; border: none; color: var(--text-dim); font-size: 22px; line-height: 1; }
.modal-body { padding: 22px 24px; max-height: 64vh; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--border-soft); }

/* ---------------- Form ---------------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-control { display: flex; flex-direction: column; gap: 6px; }
.form-control.full { grid-column: 1 / -1; }
.form-control label { font-size: 11px; letter-spacing: .8px; text-transform: uppercase; color: var(--text-dim); }
.form-control label .req { color: var(--gold); margin-left: 3px; }
.form-control .hint { font-size: 11px; color: var(--text-faint); }
.checkbox-row { display: flex; align-items: center; gap: 9px; }
.checkbox-row input { width: 17px; height: 17px; accent-color: var(--emerald); }

/* ---------------- Drawer ---------------- */
.drawer-overlay { position: fixed; inset: 0; background: rgba(3,9,6,.5); z-index: 45; }
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: 460px; max-width: 94vw; background: linear-gradient(180deg, #10241a, #0a1812); border-left: 1px solid var(--border); box-shadow: -20px 0 60px rgba(0,0,0,.5); z-index: 46; display: flex; flex-direction: column; animation: slide .2s ease; }
@keyframes slide { from { transform: translateX(100%); } to { transform: none; } }
.drawer-head { padding: 22px 24px; border-bottom: 1px solid var(--border-soft); display: flex; justify-content: space-between; align-items: flex-start; }
.drawer-head .d-code { font-size: 11px; letter-spacing: 1.5px; color: var(--gold); text-transform: uppercase; }
.drawer-head h3 { font-family: var(--serif); font-size: 21px; color: #fff; margin-top: 5px; font-weight: 600; }
.drawer-body { padding: 20px 24px; overflow-y: auto; flex: 1; }
.drawer-foot { padding: 16px 24px; border-top: 1px solid var(--border-soft); display: flex; gap: 10px; justify-content: flex-end; }
.detail-row { display: flex; justify-content: space-between; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--border-soft); }
.detail-row:last-child { border-bottom: none; }
.detail-key { color: var(--text-dim); font-size: 12.5px; flex: 0 0 42%; }
.detail-val { color: var(--text); font-size: 13px; text-align: right; word-break: break-word; }
.detail-section { font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--gold); margin: 20px 0 6px; }

/* ---------------- Charts ---------------- */
.chart-bar { display: flex; flex-direction: column; gap: 11px; }
.bar-item { display: grid; grid-template-columns: 110px 1fr 70px; align-items: center; gap: 12px; font-size: 12.5px; }
.bar-track { height: 9px; background: rgba(255,255,255,.06); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--emerald), var(--gold)); border-radius: 6px; }
.bar-val { text-align: right; color: var(--text-dim); }
.donut-wrap { display: flex; align-items: center; gap: 22px; }
.donut-legend { display: flex; flex-direction: column; gap: 9px; font-size: 12.5px; }
.legend-item { display: flex; align-items: center; gap: 8px; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; }
.legend-val { color: var(--text-dim); margin-left: auto; }

/* ---------------- Misc ---------------- */
.empty { text-align: center; color: var(--text-faint); padding: 40px; font-size: 13px; }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; }
.muted { color: var(--text-dim); }
.pos { color: var(--emerald); } .neg { color: var(--danger); }
.direction-up { color: var(--emerald); } .direction-down { color: var(--danger); } .direction-flat { color: var(--text-dim); }
.toast-root { position: fixed; bottom: 24px; right: 24px; z-index: 60; display: flex; flex-direction: column; gap: 10px; }
.toast { padding: 12px 18px; border-radius: 10px; background: linear-gradient(180deg, #133021, #0c1f15); border: 1px solid var(--border); color: var(--text); font-size: 13px; box-shadow: var(--shadow); animation: pop .18s ease; }
.toast.success { border-color: rgba(31,157,99,.4); } .toast.error { border-color: rgba(224,107,90,.4); }
.loading { text-align: center; color: var(--text-faint); padding: 50px; font-size: 13px; }
.stat-inline { display: flex; gap: 26px; flex-wrap: wrap; }
.stat-inline .si { }
.stat-inline .si-v { font-family: var(--serif); font-size: 22px; color: #fff; }
.stat-inline .si-k { font-size: 11px; color: var(--text-dim); letter-spacing: 1px; text-transform: uppercase; }

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .sidebar { display: none; }
  .kpi-grid { grid-template-columns: 1fr; }
  .view, .topbar { padding-left: 16px; padding-right: 16px; }
}
