:root {
  --bg: #f7f8fb;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-solid: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: rgba(15, 23, 42, 0.08);
  --primary: #2563eb;
  --primary-2: #0ea5e9;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --shadow: 0 24px 70px rgba(15, 23, 42, 0.12);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --sidebar: #0f172a;
  --sidebar-soft: rgba(255,255,255,.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-theme="dark"] {
  --bg: #020617;
  --panel: rgba(15, 23, 42, 0.72);
  --panel-solid: #0f172a;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --line: rgba(226, 232, 240, 0.1);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
  --sidebar: #020617;
  --sidebar-soft: rgba(255,255,255,.08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(37,99,235,.18), transparent 36vw),
    radial-gradient(circle at 82% 12%, rgba(16,185,129,.14), transparent 28vw),
    var(--bg);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: hidden;
  position: relative;
}
.login-bg {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(15, 23, 42, .96), rgba(15, 23, 42, .72)),
    radial-gradient(circle at 16% 28%, rgba(59,130,246,.55), transparent 24%),
    radial-gradient(circle at 90% 10%, rgba(16,185,129,.44), transparent 20%);
}
.login-card {
  position: relative;
  width: min(460px, 100%);
  padding: 36px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 36px;
  background: rgba(255,255,255,.10);
  backdrop-filter: blur(22px);
  box-shadow: 0 40px 120px rgba(0,0,0,.30);
  color: white;
}
.login-card .muted { color: rgba(255,255,255,.72); }
.login-card h1 { font-size: clamp(34px, 7vw, 52px); line-height: .94; margin: 10px 0 14px; letter-spacing: -.05em; }
.brand-mark {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 22px;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  color: #fff;
  font-weight: 900;
  box-shadow: 0 18px 44px rgba(37,99,235,.35);
}
.brand-mark.small { width: 42px; height: 42px; border-radius: 15px; font-size: 14px; }
.eyebrow {
  margin: 0 0 8px;
  color: var(--primary-2);
  font-size: 12px;
  letter-spacing: .12em;
  text-transform: uppercase;
  font-weight: 800;
}
.muted { color: var(--muted); }

.form-stack { display: grid; gap: 14px; margin-top: 24px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0,1fr)); }
label { display: grid; gap: 7px; font-size: 13px; font-weight: 700; color: inherit; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 13px 14px;
  background: rgba(255,255,255,.84);
  color: #0f172a;
  outline: none;
  transition: border .2s ease, box-shadow .2s ease, transform .2s ease;
}
[data-theme="dark"] input, [data-theme="dark"] select, [data-theme="dark"] textarea {
  background: rgba(15,23,42,.9);
  color: var(--text);
}
input:focus, select:focus, textarea:focus { border-color: rgba(37,99,235,.52); box-shadow: 0 0 0 4px rgba(37,99,235,.12); }
textarea { min-height: 90px; resize: vertical; }

.btn, .ghost-btn {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease, opacity .18s ease;
}
.btn:hover, .ghost-btn:hover { transform: translateY(-1px); }
.btn.primary { color: white; background: linear-gradient(135deg, #2563eb, #0ea5e9); box-shadow: 0 16px 34px rgba(37,99,235,.24); }
.btn.secondary { color: var(--text); background: var(--panel-solid); border: 1px solid var(--line); box-shadow: 0 8px 22px rgba(15,23,42,.08); }
.btn.success { color: white; background: linear-gradient(135deg, #059669, #10b981); }
.btn.danger { color: white; background: linear-gradient(135deg, #dc2626, #ef4444); }
.btn.full { width: 100%; }
.ghost-btn { color: rgba(255,255,255,.78); background: transparent; width: 100%; justify-content: flex-start; }
.ghost-btn:hover { background: var(--sidebar-soft); }
.ghost-btn.danger { color: #fecaca; }
.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-solid);
  color: var(--text);
}

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 280px 1fr; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  background:
    linear-gradient(180deg, rgba(15,23,42,.98), rgba(15,23,42,.92)),
    radial-gradient(circle at top, rgba(37,99,235,.28), transparent 52%);
  color: white;
  display: flex;
  flex-direction: column;
  gap: 18px;
  border-right: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px 14px; }
.sidebar-brand strong { display: block; letter-spacing: -.03em; }
.sidebar-brand span { display: block; color: rgba(255,255,255,.58); font-size: 12px; margin-top: 2px; }
.nav-list { display: grid; gap: 7px; }
.nav-item {
  border: 0;
  width: 100%;
  padding: 12px 13px;
  border-radius: 16px;
  background: transparent;
  color: rgba(255,255,255,.7);
  display: flex;
  align-items: center;
  gap: 11px;
  font-weight: 800;
  text-align: left;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: white; transform: translateX(2px); }
.nav-item.active { background: rgba(255,255,255,.12); color: white; box-shadow: inset 3px 0 0 #38bdf8; }
.nav-icon { width: 26px; height: 26px; border-radius: 10px; display:grid; place-items:center; background: rgba(255,255,255,.1); font-size: 14px; }
.sidebar-footer { margin-top: auto; display: grid; gap: 5px; }

.content-area { padding: 24px 28px 110px; min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}
.topbar h1 { margin: 0; font-size: clamp(30px, 4vw, 46px); letter-spacing: -.055em; line-height: .95; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.live-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 13px; border-radius: 999px;
  background: var(--panel-solid); border: 1px solid var(--line); color: var(--muted); font-size: 13px; font-weight: 800;
}
.live-pill i { width: 8px; height: 8px; border-radius: 50%; background: #10b981; box-shadow: 0 0 0 6px rgba(16,185,129,.14); }
.live-pill.offline i { background: #ef4444; box-shadow: 0 0 0 6px rgba(239,68,68,.14); }
.page-content { display: grid; gap: 18px; animation: fadeIn .28s ease both; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid.auto { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.card, .stat-card, .chart-card, .table-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.card { padding: 20px; }
.stat-card { padding: 19px; position: relative; overflow: hidden; min-height: 148px; }
.stat-card:after { content:""; position:absolute; right:-30px; top:-42px; width: 126px; height:126px; border-radius:50%; background: var(--accent, rgba(37,99,235,.13)); opacity:.7; }
.stat-card span { color: var(--muted); font-size: 13px; font-weight: 800; }
.stat-card strong { display:block; margin-top: 11px; font-size: clamp(26px, 4vw, 36px); letter-spacing: -.04em; }
.stat-card small { display:block; margin-top: 10px; color: var(--muted); }
.chart-card { padding: 18px; min-height: 340px; }
.chart-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.chart-header h3, .card h3 { margin: 0; font-size: 18px; letter-spacing: -.025em; }
.chart-header p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.chart-canvas { width: 100%; height: 260px; display: block; }
.chart-canvas.small { height: 210px; }

.progress { height: 11px; border-radius: 999px; background: rgba(148,163,184,.22); overflow: hidden; }
.progress > i { display:block; height:100%; width: var(--value); background: linear-gradient(90deg, var(--color, #2563eb), #38bdf8); border-radius: inherit; transition: width .5s ease; }
.kpi-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; }
.kpi-row span { color: var(--muted); font-size: 13px; }
.kpi-row strong { font-size: 15px; }

.list { display: grid; gap: 10px; }
.list-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.52);
  border-radius: 18px;
}
[data-theme="dark"] .list-item { background: rgba(15,23,42,.55); }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--color, #2563eb); box-shadow: 0 0 0 5px color-mix(in srgb, var(--color, #2563eb) 14%, transparent); }
.list-title { font-weight: 900; letter-spacing: -.02em; }
.list-subtitle { color: var(--muted); font-size: 12px; margin-top: 3px; }
.amount.positive { color: var(--success); font-weight: 900; }
.amount.negative { color: var(--danger); font-weight: 900; }
.amount.neutral { color: var(--text); font-weight: 900; }

.table-card { overflow: hidden; }
.table-head { padding: 18px 18px 0; display:flex; align-items:center; justify-content:space-between; gap:12px; }
.table-wrap { overflow-x: auto; padding: 8px; }
table { width: 100%; border-collapse: separate; border-spacing: 0 8px; min-width: 740px; }
th { text-align: left; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; padding: 0 12px; }
td { background: rgba(255,255,255,.55); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 13px 12px; font-size: 14px; }
[data-theme="dark"] td { background: rgba(15,23,42,.56); }
td:first-child { border-left: 1px solid var(--line); border-radius: 14px 0 0 14px; }
td:last-child { border-right: 1px solid var(--line); border-radius: 0 14px 14px 0; }
.badge { display: inline-flex; align-items:center; padding: 6px 9px; border-radius: 999px; font-size: 12px; font-weight: 900; background: rgba(37,99,235,.1); color: #2563eb; }
.badge.green { background: rgba(16,185,129,.12); color: #059669; }
.badge.red { background: rgba(239,68,68,.12); color: #dc2626; }
.badge.yellow { background: rgba(245,158,11,.12); color: #b45309; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filters input, .filters select { width: auto; min-width: 170px; }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 40; background: rgba(2,6,23,.58); backdrop-filter: blur(12px);
  display: grid; place-items: center; padding: 18px;
}
.modal {
  width: min(780px, 100%);
  max-height: min(88vh, 900px);
  overflow: auto;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 30px;
  padding: 24px;
  box-shadow: 0 34px 100px rgba(0,0,0,.28);
  position: relative;
}
.modal.wide { width: min(980px, 100%); }
.modal-close {
  position: absolute; right: 16px; top: 16px;
  width: 38px; height: 38px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font-size: 24px; line-height: 1;
}
.modal h2 { margin: 0 44px 6px 0; letter-spacing: -.04em; font-size: 28px; }
.modal p { color: var(--muted); }
.segmented { display: grid; grid-template-columns: repeat(4,1fr); gap: 9px; margin: 18px 0; }
.segmented button { border:1px solid var(--line); background: var(--bg); color: var(--muted); padding: 12px; border-radius: 15px; font-weight: 900; }
.segmented button.active { background: var(--primary); color:white; border-color: var(--primary); }

.toast {
  position: fixed; z-index: 80; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(30px);
  padding: 12px 16px; background: #0f172a; color: white; border-radius: 999px; box-shadow: 0 18px 45px rgba(0,0,0,.22);
  opacity: 0; pointer-events: none; transition: .24s ease; font-weight: 800; font-size: 14px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.empty {
  padding: 24px; text-align: center; border: 1px dashed var(--line); border-radius: 20px; color: var(--muted);
}
.mobile-nav { display: none; }

.animate-in { animation: fadeInScale .42s cubic-bezier(.2,.8,.2,1) both; }
.animate-up { animation: slideUp .24s cubic-bezier(.2,.8,.2,1) both; }
@keyframes fadeIn { from { opacity:0; transform: translateY(8px); } to { opacity:1; transform: none; } }
@keyframes fadeInScale { from { opacity:0; transform: translateY(18px) scale(.98); } to { opacity:1; transform: none; } }
@keyframes slideUp { from { opacity:0; transform: translateY(30px) scale(.98); } to { opacity:1; transform: none; } }

@media (max-width: 1120px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .content-area { padding: 18px 16px 96px; }
  .mobile-nav {
    display: grid;
    position: fixed;
    z-index: 30;
    left: 12px; right: 12px; bottom: 12px;
    grid-template-columns: repeat(5, 1fr);
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: rgba(255,255,255,.82);
    backdrop-filter: blur(18px);
    box-shadow: var(--shadow);
  }
  [data-theme="dark"] .mobile-nav { background: rgba(15,23,42,.82); }
  .mobile-nav .nav-item { justify-content:center; padding: 10px 6px; color: var(--muted); border-radius: 17px; flex-direction: column; gap: 4px; font-size: 11px; }
  .mobile-nav .nav-item.active { background: rgba(37,99,235,.12); color: var(--primary); box-shadow: none; }
  .mobile-nav .nav-icon { background: transparent; width:auto; height:auto; font-size: 17px; }
}
@media (max-width: 860px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .topbar-actions { width: 100%; justify-content: space-between; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .form-grid, .form-grid.three { grid-template-columns: 1fr; }
  .segmented { grid-template-columns: repeat(2, 1fr); }
  .chart-card { min-height: 300px; }
  .chart-canvas { height: 230px; }
  .filters input, .filters select, .filters .btn { width: 100%; }
}
@media (max-width: 520px) {
  .login-card { padding: 26px; border-radius: 30px; }
  .content-area { padding-inline: 12px; }
  .card, .stat-card, .chart-card { border-radius: 22px; }
  .topbar-actions { gap: 8px; }
  .live-pill { display:none; }
  .btn { padding: 11px 14px; }
}
