:root {
  --bg: #eef1f9;
  --card: #ffffff;
  --card-2: #f6f8fd;
  --text: #151a33;
  --text-2: #6b7392;
  --text-3: #9aa1bd;
  --line: #e7eaf5;
  --accent: #5b6cff;
  --accent-2: #9b6bff;
  --teal: #14c8a8;
  --coral: #ff7a6b;
  --amber: #ffb648;
  --pos: #12b886;
  --neg: #ff5468;
  --pos-bg: #e3f8f1;
  --neg-bg: #ffe9ec;
  --shadow: 0 1px 2px rgba(25, 35, 85, .04), 0 14px 34px -14px rgba(40, 52, 120, .16);
  --shadow-lg: 0 30px 60px -24px rgba(40, 52, 140, .35);
  --radius: 24px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}
:root[data-resolved="dark"] {
  --bg: #0b0e22;
  --card: #141838;
  --card-2: #1a1f45;
  --text: #eef0ff;
  --text-2: #98a0c8;
  --text-3: #6a7299;
  --line: #242a55;
  --pos: #2fd9a3;
  --neg: #ff6b7d;
  --pos-bg: rgba(47, 217, 163, .12);
  --neg-bg: rgba(255, 107, 125, .13);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 18px 40px -16px rgba(0, 0, 0, .6);
  --shadow-lg: 0 30px 60px -24px rgba(0, 0, 0, .8);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(900px 500px at 8% -10%, rgba(91, 108, 255, .13), transparent 60%),
    radial-gradient(800px 500px at 100% 0%, rgba(155, 107, 255, .1), transparent 60%);
  background-attachment: fixed;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
svg.i { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.num { font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.muted { color: var(--text-2); }
.pos { color: var(--pos); } .neg { color: var(--neg); }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 252px minmax(0, 1fr); gap: 22px; padding: 22px; max-width: 1760px; margin: 0 auto; }
.side {
  position: sticky; top: 22px; height: calc(100vh - 44px);
  background: var(--card); border-radius: 30px; box-shadow: var(--shadow);
  padding: 22px 16px; display: flex; flex-direction: column; gap: 6px; overflow: hidden;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 10px 20px; }
.logo {
  width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 22px -8px rgba(91, 108, 255, .7);
}
.brand b { font-size: 17px; letter-spacing: -.02em; display: block; line-height: 1.1; }
.brand span { font-size: 11.5px; color: var(--text-2); }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--text-3); padding: 12px 12px 6px; font-weight: 600; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 14px;
  color: var(--text-2); text-decoration: none; font-weight: 550; transition: all .25s var(--ease); position: relative;
}
.nav a:hover { background: var(--card-2); color: var(--text); transform: translateX(2px); }
.nav a.active {
  color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 12px 24px -10px rgba(91, 108, 255, .75);
}
.side-foot { margin-top: auto; }
.side-card {
  border-radius: 20px; padding: 16px; color: #fff; position: relative; overflow: hidden;
  background: linear-gradient(150deg, #1f2556, #3a3fa3 60%, #6b57e8);
}
.side-card::after { content: ""; position: absolute; width: 140px; height: 140px; right: -40px; top: -50px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 255, 255, .28), transparent 70%); }
.side-card small { opacity: .75; font-size: 11.5px; }
.side-card b { display: block; font-size: 20px; margin: 2px 0 8px; letter-spacing: -.02em; }
.side-card .bar { height: 6px; border-radius: 6px; background: rgba(255, 255, 255, .22); overflow: hidden; }
.side-card .bar i { display: block; height: 100%; background: #fff; border-radius: 6px; transition: width 1.2s var(--ease); }

.main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.topbar h1 { font-size: 26px; letter-spacing: -.03em; line-height: 1.1; }
.topbar .sub { color: var(--text-2); font-size: 13px; margin-top: 3px; }
.spacer { flex: 1; }
.search {
  display: flex; align-items: center; gap: 8px; background: var(--card); border-radius: 16px; padding: 0 14px; height: 44px;
  width: 210px; flex: 0 1 210px; box-shadow: var(--shadow); color: var(--text-2);
}
.topbar > div:first-child { min-width: 0; }
.search input { border: 0; outline: 0; background: none; flex: 1; min-width: 0; }
.iconbtn { width: 44px; height: 44px; border-radius: 15px; background: var(--card); box-shadow: var(--shadow); display: grid; place-items: center; color: var(--text-2); transition: all .25s var(--ease); position: relative; }
.iconbtn:hover { color: var(--accent); transform: translateY(-2px); }
.avatar { width: 44px; height: 44px; border-radius: 15px; display: grid; place-items: center; color: #fff; font-weight: 700; background: linear-gradient(135deg, var(--teal), var(--accent)); box-shadow: var(--shadow); }
.monthnav { display: flex; align-items: center; gap: 2px; background: var(--card); border-radius: 16px; padding: 4px; box-shadow: var(--shadow); height: 44px; }
.monthnav button { width: 34px; height: 34px; border-radius: 12px; display: grid; place-items: center; color: var(--text-2); }
.monthnav button:hover { background: var(--card-2); color: var(--accent); }
.monthnav span { min-width: 126px; text-align: center; font-weight: 650; font-size: 13.5px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 18px; border-radius: 15px; font-weight: 650;
  background: var(--card); color: var(--text); box-shadow: var(--shadow); transition: all .25s var(--ease);
}
.btn:hover { transform: translateY(-2px); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; box-shadow: 0 14px 26px -10px rgba(91, 108, 255, .8); }
.btn.sm { height: 34px; padding: 0 13px; font-size: 12.5px; border-radius: 12px; box-shadow: none; background: var(--card-2); }
.btn.sm.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.btn.danger { color: var(--neg); }
.btn.ghost { background: transparent; box-shadow: none; }

/* ---------- grid & cards ---------- */
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 20px; }
.c3 { grid-column: span 3; } .c4 { grid-column: span 4; } .c5 { grid-column: span 5; } .c6 { grid-column: span 6; }
.c7 { grid-column: span 7; } .c8 { grid-column: span 8; } .c12 { grid-column: span 12; }
.card {
  background: var(--card); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); min-width: 0;
  animation: rise .7s var(--ease) both; animation-delay: calc(var(--i, 0) * 70ms);
}
.card.flat { box-shadow: none; background: var(--card-2); }
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(.985); } to { opacity: 1; transform: none; } }
.card-h { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-h h3 { font-size: 16px; letter-spacing: -.02em; }
.card-h .sub { color: var(--text-2); font-size: 12.5px; }
.card-h .spacer { flex: 1; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--text-2); flex-wrap: wrap; }
.legend i, .tip3d .dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; }
.chart3d { position: relative; height: 380px; margin: 0 -8px; border-radius: 18px; overflow: hidden; }
.chart3d.sm { height: 270px; } .chart3d.lg { height: 420px; } .chart3d.xl { height: 480px; }
.chart-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hint { font-size: 11.5px; color: var(--text-3); display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.donut-center { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; text-align: center; }
.donut-center b { font-size: 24px; letter-spacing: -.03em; display: block; }
.donut-center span { font-size: 12px; color: var(--text-2); }

.tip3d {
  position: fixed; left: 0; top: 0; z-index: 200; pointer-events: none; opacity: 0; transition: opacity .15s;
  background: rgba(18, 22, 52, .94); color: #fff; padding: 10px 13px; border-radius: 13px; font-size: 12.5px;
  box-shadow: 0 16px 36px -10px rgba(0, 0, 0, .5); backdrop-filter: blur(8px); min-width: 130px;
}
.tip3d b { display: block; margin-bottom: 5px; font-size: 13px; }
.tip3d .tr { display: flex; align-items: center; gap: 4px; margin-top: 3px; white-space: nowrap; }
.tip3d .tr span { margin-left: auto; padding-left: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- KPI ---------- */
.kpi { display: flex; flex-direction: column; gap: 4px; position: relative; overflow: hidden; }
.kpi .top { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-weight: 600; font-size: 13px; }
.kpi .ico { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; }
.kpi .val { font-size: 29px; font-weight: 750; letter-spacing: -.035em; margin-top: 8px; }
.kpi .meta { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); }
.kpi svg.spark { position: absolute; right: 0; bottom: 0; width: 55%; height: 62px; opacity: .95; }
.chip { display: inline-flex; align-items: center; gap: 3px; padding: 3px 9px; border-radius: 99px; font-size: 12px; font-weight: 650; }
.chip.up { color: var(--pos); background: var(--pos-bg); } .chip.down { color: var(--neg); background: var(--neg-bg); }
.chip.neutral { background: var(--card-2); color: var(--text-2); }
.chip svg.i { width: 13px; height: 13px; }
.hero { background: linear-gradient(140deg, #3b3fd9 0%, #6a4bf0 55%, #9b6bff 100%); color: #fff; }
.hero::before { content: ""; position: absolute; width: 260px; height: 260px; right: -70px; top: -90px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 255, 255, .28), transparent 68%); }
.hero::after { content: ""; position: absolute; width: 200px; height: 200px; left: -60px; bottom: -110px; border-radius: 50%; background: radial-gradient(circle, rgba(20, 200, 168, .5), transparent 70%); }
.hero .top, .hero .meta { color: rgba(255, 255, 255, .8); }
.hero .ico { background: rgba(255, 255, 255, .18); color: #fff; }
.hero .chip { background: rgba(255, 255, 255, .2); color: #fff; }
.hero .split { display: flex; gap: 22px; margin-top: 14px; position: relative; z-index: 1; }
.hero .split div { font-size: 12px; color: rgba(255, 255, 255, .72); } .hero .split b { display: block; color: #fff; font-size: 15px; margin-top: 2px; }
.hero > * { position: relative; z-index: 1; }

/* ---------- lists / progress ---------- */
.row { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.row + .row { border-top: 1px solid var(--line); }
.badge { width: 38px; height: 38px; border-radius: 13px; display: grid; place-items: center; font-size: 18px; flex: none; }
.row .grow { flex: 1; min-width: 0; }
.row .grow b { display: block; font-weight: 620; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .grow small { color: var(--text-2); font-size: 12px; }
.progress { height: 8px; border-radius: 8px; background: var(--card-2); overflow: hidden; }
.progress i { display: block; height: 100%; border-radius: 8px; width: 0; transition: width 1.1s var(--ease); }
.status { font-size: 11.5px; font-weight: 650; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.status.ok { color: var(--pos); background: var(--pos-bg); } .status.warn { color: #b7791f; background: rgba(255, 182, 72, .2); }
.status.bad { color: var(--neg); background: var(--neg-bg); } .status.info { color: var(--accent); background: rgba(91, 108, 255, .12); }

table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); font-weight: 650; padding: 8px 10px; }
.tbl td { padding: 11px 10px; border-top: 1px solid var(--line); vertical-align: middle; }
.tbl tr:hover td { background: var(--card-2); }
.tbl td:first-child, .tbl th:first-child { padding-left: 4px; } .tbl td:last-child, .tbl th:last-child { padding-right: 4px; }
.tbl .r { text-align: right; }
.tblwrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
.cell-cat { display: flex; align-items: center; gap: 10px; }
.cell-cat .badge { width: 32px; height: 32px; font-size: 15px; border-radius: 11px; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--card-2); color: var(--text-2); }

/* ---------- ring ---------- */
.ring { position: relative; display: grid; place-items: center; }
.ring svg { transform: rotate(-90deg); }
.ring .rc { position: absolute; text-align: center; line-height: 1.1; }
.ring .rc b { font-size: 22px; letter-spacing: -.03em; } .ring .rc span { display: block; font-size: 11px; color: var(--text-2); }
.ring circle.fg { transition: stroke-dashoffset 1.4s var(--ease); }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label { font-size: 12.5px; font-weight: 600; color: var(--text-2); display: flex; justify-content: space-between; }
.field > label output { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.input, .select {
  height: 42px; border-radius: 13px; border: 1.5px solid var(--line); background: var(--card-2); padding: 0 13px; outline: 0; width: 100%;
  transition: border-color .2s, box-shadow .2s; -webkit-appearance: none; appearance: none;
}
.select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%239aa1bd' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 13px center; padding-right: 34px; }
.input:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(91, 108, 255, .14); }
.input.sm { height: 34px; border-radius: 10px; padding: 0 10px; }
.input-wrap { position: relative; } .input-wrap span { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; font-weight: 600; }
.input-wrap .input { padding-left: 28px; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 6px; background: linear-gradient(90deg, var(--accent) var(--p, 50%), var(--line) var(--p, 50%)); outline: 0; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; background: #fff; border: 4px solid var(--accent); box-shadow: 0 4px 10px rgba(40, 50, 120, .3); cursor: grab; transition: transform .15s; }
input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.15); }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 4px solid var(--accent); cursor: grab; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.seg { display: inline-flex; background: var(--card-2); border-radius: 14px; padding: 4px; gap: 2px; flex-wrap: wrap; }
.seg button { padding: 8px 14px; border-radius: 11px; font-weight: 600; color: var(--text-2); font-size: 13px; transition: all .2s; }
.seg button.on { background: var(--card); color: var(--accent); box-shadow: var(--shadow); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar .input, .toolbar .select { width: auto; min-width: 150px; }

.stat { background: var(--card-2); border-radius: 18px; padding: 14px 16px; }
.stat small { display: block; color: var(--text-2); font-size: 12px; font-weight: 600; }
.stat b { display: block; font-size: 22px; letter-spacing: -.03em; margin-top: 3px; }
.stat.accent { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; } .stat.accent small { color: rgba(255, 255, 255, .8); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }

/* ---------- modal & toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(12, 15, 40, .5); backdrop-filter: blur(6px); display: grid; place-items: center; z-index: 100; padding: 16px; animation: fade .2s both; }
.modal { background: var(--card); border-radius: 26px; padding: 26px; width: min(480px, 100%); max-height: 92vh; overflow: auto; box-shadow: var(--shadow-lg); animation: pop .35s var(--ease) both; }
.modal h3 { font-size: 20px; letter-spacing: -.02em; margin-bottom: 18px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
@keyframes fade { from { opacity: 0; } } @keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.96); } }
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); background: #151a33; color: #fff; padding: 12px 20px; border-radius: 14px; z-index: 300; box-shadow: var(--shadow-lg); animation: pop .3s var(--ease) both; font-weight: 600; }

.goal-card { display: flex; flex-direction: column; gap: 14px; }
.goal-top { display: flex; align-items: center; gap: 16px; }
.empty { text-align: center; color: var(--text-2); padding: 34px 10px; }
.insight { display: flex; gap: 12px; padding: 12px; border-radius: 16px; background: var(--card-2); margin-bottom: 10px; font-size: 13px; }
.insight .badge { width: 34px; height: 34px; font-size: 16px; }
.tabs { margin-bottom: 18px; }
.two { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 20px; align-items: start; }
.split-bar { display: flex; height: 14px; border-radius: 10px; overflow: hidden; gap: 3px; }
.split-bar i { display: block; height: 100%; border-radius: 6px; transition: flex .9s var(--ease); }
.spark-cell svg { width: 90px; height: 28px; display: block; }
.kv { display: flex; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13px; }
.kv:first-child { border-top: 0; } .kv b { font-variant-numeric: tabular-nums; }
.disclaimer { font-size: 11.5px; color: var(--text-3); margin-top: 14px; line-height: 1.5; }
.foot { text-align: center; color: var(--text-3); font-size: 12px; padding: 26px 0 8px; }

/* ---------- responsive ---------- */
@media (max-width: 1280px) { .c3 { grid-column: span 6; } .c4 { grid-column: span 6; } .c8, .c7, .c5 { grid-column: span 12; } .c6 { grid-column: span 12; } }
@media (max-width: 1100px) { .two { grid-template-columns: 1fr; } .app { grid-template-columns: 78px minmax(0, 1fr); } .nav a span, .brand div, .nav-label, .side-card { display: none; } .nav a { justify-content: center; padding: 13px; } .brand { justify-content: center; padding: 4px 0 16px; } }
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; padding: 14px 14px 92px; gap: 14px; }
  .side { position: fixed; top: auto; bottom: 10px; left: 10px; right: 10px; height: 68px; z-index: 50; flex-direction: row; padding: 8px; border-radius: 24px; overflow-x: auto; box-shadow: var(--shadow-lg); }
  .brand, .side-foot, .nav-label { display: none; } .nav { display: flex; gap: 4px; flex: none; } .nav a { padding: 12px 15px; } .nav a:hover { transform: none; }
  .c3, .c4, .c6, .c8, .c5, .c7 { grid-column: span 12; }
  .search { width: 100%; order: 9; } .topbar h1 { font-size: 22px; } .form-row { grid-template-columns: 1fr; }
  .chart3d { height: 300px; } .chart3d.lg, .chart3d.xl { height: 360px; } .card { padding: 18px; }
  .kpi svg.spark { width: 38%; height: 48px; opacity: .7; }
}
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
