:root {
  color-scheme: light;
  --fg: #181b2c;
  --muted: #727892;
  --bg: #f5f6fb;
  --card: #ffffff;
  --line: #e8eaf3;
  --accent: #5b4fd8;
  --accent-dark: #4a3fc2;
  --accent-soft: #efedff;
  --danger: #b42318;
  --success: #087443;
  --shadow: 0 6px 24px rgba(40, 36, 92, .06);
  --radius: 16px;
  --side: 248px;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #6250d6;
  --series-other: #a3a7b8;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; color: var(--fg); background: radial-gradient(circle at 85% -10%, #e9e5ff 0, transparent 38%), var(--bg); background-attachment: fixed; font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, textarea, select { font: inherit; }
button { min-height: 36px; padding: .48rem .85rem; border: 1px solid #dcdfee; border-radius: 10px; background: #fff; color: #26344d; font-weight: 600; cursor: pointer; transition: background .15s ease, border-color .15s ease, box-shadow .15s ease, transform .15s ease; }
button:hover { border-color: #b7b2ef; background: #f8f7ff; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid rgba(91, 79, 216, .22); outline-offset: 1px; }
button:active { transform: translateY(1px); }
button[type=submit], #new { color: #fff; background: var(--accent); border-color: var(--accent); }
button[type=submit]:hover, #new:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
button.danger { color: var(--danger); margin-left: .3rem; }
button:disabled { opacity: .45; cursor: default; transform: none; }
input, textarea, select { width: 100%; min-height: 38px; padding: .55rem .7rem; border: 1px solid #dfe2ee; border-radius: 10px; background: #fff; color: var(--fg); }
input::placeholder, textarea::placeholder { color: #98a3b5; }
textarea { resize: vertical; }
label { display: block; margin: .65rem 0; color: #59677e; font-size: .88rem; font-weight: 600; }
.error { color: var(--danger); min-height: 1.2em; }
.auth { display: grid; place-items: center; min-height: 100vh; padding: 1.25rem; background: radial-gradient(circle at 12% 12%, #e1eaff 0, transparent 32%), var(--bg); }
.card { background: var(--card); padding: 2rem; border: 1px solid #e6ebf3; border-radius: 16px; width: 100%; max-width: 410px; box-shadow: 0 18px 50px rgba(24, 39, 75, .12); }
.card h1 { margin: 0 0 1.2rem; font-size: 1.55rem; letter-spacing: -.035em; }
.card form button { width: 100%; margin-top: .75rem; }
.tabs { display: flex; gap: .4rem; padding: .25rem; border-radius: 10px; background: #f0f4fa; }
.tabs button { flex: 1; border-color: transparent; background: transparent; }
.tabs .active { background: #fff; border-color: #dbe4f2; color: var(--accent); box-shadow: 0 1px 4px #1b315010; }
.top { position: sticky; top: 0; z-index: 20; display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; min-height: 66px; padding: .75rem 1.5rem; background: rgba(255,255,255,.85); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); }
.top > strong { display: inline-flex; align-items: center; min-height: 38px; color: var(--accent-dark); font-size: 1.05rem; font-weight: 800; letter-spacing: -.025em; }
.top #who { margin-left: auto; color: var(--muted); font-size: .9rem; }
.top button { min-height: 34px; padding: .4rem .7rem; font-size: .85rem; }
.page { width: 100%; max-width: 1680px; margin: 0 auto; padding: 1.6rem clamp(1rem, 2.2vw, 2rem) 2rem; }
/* App shell: light sidebar, slim header */
#side { position: fixed; z-index: 30; top: 0; bottom: 0; left: 0; display: flex; flex-direction: column; width: var(--side); padding: 1.1rem .85rem; background: #fff; border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: .6rem; padding: .2rem .5rem 1.1rem; font-size: 1.12rem; font-weight: 800; letter-spacing: -.03em; color: #1d1a4a; }
.brand-name { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.brand-name > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand small { color: var(--muted); font-size: .74rem; font-weight: 600; letter-spacing: 0; }
.logo { flex: 0 0 36px; }
.logo { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; color: #fff; font-size: .88rem; background: linear-gradient(135deg, #7b6cf6, #4a3fc2); box-shadow: 0 6px 16px rgba(91, 79, 216, .35); }
#nav { flex: 1; overflow-y: auto; margin: 0 -.3rem; padding: 0 .3rem; }
.nav-group { margin-bottom: .15rem; }
#nav button { display: flex; align-items: center; gap: .7rem; width: 100%; min-height: 40px; padding: .5rem .7rem; border: 0; border-radius: 10px; color: #4b5068; background: transparent; text-align: left; white-space: nowrap; font-weight: 600; }
#nav button:hover { background: #f4f3ff; color: var(--accent-dark); }
#nav button.open { color: #1d1a4a; }
#nav button.current { color: var(--accent-dark); background: var(--accent-soft); font-weight: 700; }
#nav .ico { width: 19px; height: 19px; flex: 0 0 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#nav .chev { margin-left: auto; width: 14px; height: 14px; flex-basis: 14px; transition: transform .15s ease; }
#nav button.open .chev { transform: rotate(90deg); }
#nav .nav-sub { position: relative; margin: .1rem 0 .4rem 1.55rem; padding-left: .55rem; border-left: 1px solid var(--line); }
#nav .nav-sub button { min-height: 34px; padding: .4rem .65rem; font-size: .87rem; font-weight: 550; color: #5d6279; }
#nav .nav-sub button.active { color: var(--accent-dark); background: var(--accent-soft); font-weight: 700; }
.side-foot { margin-top: .8rem; padding: .6rem .5rem 0; border-top: 1px solid var(--line); font-size: .74rem; color: var(--muted); }
.side-foot strong { color: #4b5068; font-weight: 650; }
.app .top { margin-left: var(--side); padding-inline: clamp(1rem, 2.2vw, 2rem); }
.app .page { width: auto; margin: 0 0 0 var(--side); }
.crumb { color: var(--muted); font-size: .9rem; }
.crumb strong { color: var(--fg); }
.user { display: flex; align-items: center; gap: .6rem; margin-left: auto; }
.avatar { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; color: #fff; font-weight: 750; background: linear-gradient(135deg, #f59e8b, #e8618c); }
.who { display: flex; flex-direction: column; line-height: 1.2; margin-right: .4rem; }
.who small { color: var(--muted); font-size: .78rem; }
.icon-btn { display: none; min-width: 38px; padding: .3rem; font-size: 1.1rem; }
#scrim { position: fixed; inset: 0; z-index: 25; background: rgba(16, 20, 45, .35); }
#scrim[hidden] { display: none; }
.bar { display: flex; flex-wrap: wrap; gap: .65rem; align-items: center; margin-bottom: 1.1rem; }
.bar h2 { margin: 0 auto 0 0; color: #1d1a4a; font-size: clamp(1.35rem, 2vw, 1.8rem); font-weight: 750; letter-spacing: -.04em; }
.bar input { width: auto; flex: 0 1 220px; min-width: 150px; }
.bar #search { background: #fff; }
.bar .filters { align-items: center; }
#custom { margin: 0 0 1rem; padding: 1.1rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
#custom[hidden] { display: none; }
.table-wrap { overflow: auto; width: 100%; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--card); margin: 0; }
th, td { text-align: left; padding: .8rem .9rem; border-bottom: 1px solid #edf0f5; vertical-align: middle; }
th { position: sticky; top: 0; background: #f7f7fc; color: #6a6f88; font-size: .77rem; font-weight: 750; text-transform: uppercase; letter-spacing: .045em; white-space: nowrap; }
tbody tr { transition: background .12s ease; }
tbody tr:hover { background: #faf9ff; }
tbody tr:last-child td { border-bottom: 0; }
td { color: #354258; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions button { margin-left: .3rem; padding: .32rem .6rem; min-height: 30px; font-size: .82rem; }
.filters { display: flex; flex-wrap: wrap; gap: .45rem; }
.filters select { width: auto; min-width: 125px; }
.pager { display: flex; gap: .8rem; align-items: center; justify-content: flex-end; margin: 1rem 0; color: var(--muted); font-size: .88rem; }
.pager button { min-height: 32px; padding: .35rem .7rem; }
#empty { padding: 2rem; text-align: center; color: var(--muted); background: #fff; border: 1px dashed #cfd8e6; border-radius: 12px; }
dialog { border: 1px solid #e1e7f0; border-radius: 16px; width: min(500px, 94vw); max-height: 90vh; padding: 1.4rem; color: var(--fg); box-shadow: 0 24px 80px rgba(16, 30, 60, .25); }
dialog::backdrop { background: rgba(16, 27, 49, .48); backdrop-filter: blur(3px); }
dialog h3 { margin: 0 0 1rem; font-size: 1.25rem; letter-spacing: -.025em; }
dialog form { max-height: calc(90vh - 3rem); overflow-y: auto; }
.actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.2rem; padding-top: .9rem; border-top: 1px solid var(--line); }
label.check { display: flex; align-items: center; gap: .5rem; color: var(--fg); }
label.check input { width: auto; min-height: auto; }
dialog.wide { width: min(980px, 96vw); }
.lines { margin: .8rem 0; }
.line-row { display: grid; grid-template-columns: 3fr 1fr 1fr 1.8fr auto; gap: .5rem; align-items: end; margin: .5rem 0; }
.line-row button { margin-bottom: .6rem; }
.totals { text-align: right; font-weight: 750; }
.disc { display: flex; gap: .4rem; }
.disc select { flex: 1 1 55%; width: auto; }
.disc input { flex: 1 1 45%; width: auto; min-width: 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .55rem 1.2rem; background: #f7f9fc; padding: 1rem; border: 1px solid var(--line); border-radius: 10px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 550; }
.pre { white-space: pre-line; }
.muted { color: var(--muted); }
.ok { color: var(--success); font-weight: 700; }
.total-row td { font-weight: 750; border-top: 2px solid #aebbd0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: .85rem; margin: .6rem 0 1.25rem; }
.tile { min-width: 0; border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.1rem; background: var(--card); box-shadow: var(--shadow); }
.tile strong { display: block; margin-top: .25rem; color: #18243a; font-size: 1.55rem; line-height: 1.25; letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.tile .muted, .tile small { color: var(--muted); font-size: .82rem; }
#custom .filters { margin-bottom: .7rem; }
#custom .filters label { display: inline-block; margin-right: .8rem; }
/* Dashboard */
#custom.bare { padding: 0; border: 0; background: none; box-shadow: none; }
.dash { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, .95fr); gap: 1.1rem; }
.panel { min-width: 0; padding: 1.15rem 1.25rem; border: 1px solid var(--line); border-radius: 20px; background: var(--card); box-shadow: var(--shadow); }
.card-head { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .8rem; }
.card-head h3 { margin: 0 auto 0 0; font-size: 1.02rem; letter-spacing: -.02em; color: #1d1a4a; }
.hero { grid-column: span 2; background: linear-gradient(120deg, #f6f3ff 0%, #ffffff 55%, #eef4ff 100%); }
.hero-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.hero-head p { margin: 0; }
.hero-head h2 { margin: .1rem 0 .25rem; font-size: clamp(1.5rem, 2.4vw, 2rem); letter-spacing: -.045em; color: #1d1a4a; }
.hero-actions { display: flex; gap: .5rem; align-items: flex-start; }
button.primary { color: #fff; background: var(--accent); border-color: var(--accent); }
button.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
button.link { min-height: 0; padding: .2rem .3rem; border: 0; background: none; color: var(--accent); font-size: .85rem; }
button.link:hover { background: none; text-decoration: underline; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .8rem; }
.stat { min-width: 0; padding: .9rem 1rem; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.9); }
.stat .muted { font-size: .82rem; }
.stat strong { display: block; margin: .15rem 0; font-size: 1.35rem; letter-spacing: -.035em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat small { font-size: .76rem; }
.stat-ico { display: inline-grid; place-items: center; width: 34px; height: 34px; margin-bottom: .55rem; border-radius: 50%; }
.stat-ico .ico, .spot-top .ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.t-green { color: #087443; background: #e3f6ec; }
.t-violet { color: #5b4fd8; background: #ece9ff; }
.t-blue { color: #2a78d6; background: #e5effc; }
.t-rose { color: #c4314b; background: #fde8ec; }
.up { color: var(--success); font-weight: 650; }
.down { color: var(--danger); font-weight: 650; }
.spot { display: flex; flex-direction: column; gap: .3rem; padding: 1.35rem; border-radius: 20px; color: #fff; background: radial-gradient(circle at 100% 0%, rgba(140, 120, 255, .55) 0, transparent 45%), linear-gradient(150deg, #1f1b4d 0%, #131230 100%); box-shadow: 0 16px 40px rgba(25, 20, 70, .28); }
.spot-top { display: flex; align-items: center; gap: .5rem; margin-bottom: auto; padding-bottom: 1.2rem; font-weight: 700; color: #d9d4ff; }
.spot small { color: #b9b4e6; }
.spot > strong { font-size: clamp(1.7rem, 2.6vw, 2.2rem); letter-spacing: -.045em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.spot-row { display: flex; gap: 1.2rem; margin: .4rem 0 .9rem; font-size: .8rem; color: #b9b4e6; }
.spot-row b { display: block; color: #fff; font-size: .95rem; font-variant-numeric: tabular-nums; }
button.light { color: #1d1a4a; background: #fff; border-color: #fff; }
button.light:hover { background: #eeeaff; }
.seg-ctl { display: inline-flex; padding: 3px; border-radius: 10px; background: #f2f1f8; }
.seg-ctl button { min-height: 28px; padding: .2rem .65rem; border: 0; background: none; color: var(--muted); font-size: .8rem; }
.seg-ctl button[aria-pressed=true] { background: #fff; color: var(--accent-dark); box-shadow: 0 1px 4px rgba(30, 25, 80, .1); }
.panel { display: flex; flex-direction: column; }
.viz { position: relative; flex: 1; min-height: 230px; }
.viz svg { position: absolute; inset: 0; display: block; overflow: visible; }
.p-pl .viz { min-height: 200px; }
.viz-slot { flex: 1; display: flex; flex-direction: column; }
.viz .grid { stroke: #eceef5; stroke-width: 1; }
.viz .baseline { stroke: #d5d8e4; stroke-width: 1; }
.tick { fill: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.area-top { stop-color: var(--series-7); stop-opacity: .26; }
.area-bottom { stop-color: var(--series-7); stop-opacity: 0; }
.viz .line { fill: none; stroke: var(--series-7); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.cross { stroke: #b9b4e6; stroke-width: 1; stroke-dasharray: 3 3; }
.viz .dot { fill: var(--series-7); stroke: #fff; stroke-width: 2; }
.hit { fill: transparent; cursor: crosshair; }
.bar-group.on .bar { opacity: .8; }
.s1 { fill: var(--series-1); stroke: var(--series-1); }
.s2 { fill: var(--series-2); stroke: var(--series-2); }
.s3 { fill: var(--series-3); stroke: var(--series-3); }
.s4 { fill: var(--series-4); stroke: var(--series-4); }
.s5 { fill: var(--series-5); stroke: var(--series-5); }
.s6 { fill: var(--series-6); stroke: var(--series-6); }
.s7 { fill: var(--series-7); stroke: var(--series-7); }
.so { fill: var(--series-other); stroke: var(--series-other); }
.bar { stroke: none; }
i.key { display: inline-block; flex: 0 0 auto; width: 10px; height: 10px; border-radius: 3px; }
i.key.s1 { background: var(--series-1); } i.key.s2 { background: var(--series-2); } i.key.s3 { background: var(--series-3); }
i.key.s4 { background: var(--series-4); } i.key.s5 { background: var(--series-5); } i.key.s6 { background: var(--series-6); }
i.key.s7 { background: var(--series-7); } i.key.so { background: var(--series-other); }
.viz-tip { position: absolute; z-index: 5; min-width: 140px; padding: .5rem .65rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; box-shadow: 0 10px 30px rgba(30, 25, 80, .16); font-size: .8rem; pointer-events: none; }
.viz-tip[hidden] { display: none; }
.viz-tip strong { display: block; margin-bottom: .2rem; }
.tip-row { display: flex; align-items: center; gap: .4rem; }
.tip-row b { margin-left: auto; padding-left: .8rem; font-variant-numeric: tabular-nums; }
.donut-wrap { display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; gap: .9rem; }
.donut { width: 100%; max-width: 180px; height: auto; }
.donut-wrap .legend { width: 100%; }
.donut-track { fill: none; stroke: #f0f0f6; stroke-width: 22; }
.seg { fill: none; stroke-width: 22; }
.donut-total { fill: var(--fg); font-size: 20px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.legend { margin: 0; padding: 0; list-style: none; font-size: .84rem; }
.legend li { display: flex; align-items: center; gap: .5rem; padding: .3rem 0; border-bottom: 1px solid #f3f3f8; }
.legend li:last-child { border-bottom: 0; }
.legend .lg-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend b { font-variant-numeric: tabular-nums; font-weight: 650; }
.mini-legend { display: flex; gap: .8rem; font-size: .8rem; color: var(--muted); }
.mini-legend span { display: inline-flex; align-items: center; gap: .35rem; }
.p-recent { grid-column: span 2; }
.pos-row { padding: .65rem 0; border-bottom: 1px solid #f0f1f6; }
.pos-row:last-of-type { border-bottom: 0; }
.pos-line { display: flex; justify-content: space-between; gap: .5rem; margin-bottom: .35rem; font-weight: 600; }
.pos-line b { font-variant-numeric: tabular-nums; }
.meter { display: block; width: 100%; height: 6px; margin-bottom: .3rem; }
.meter-track { fill: #eeeff5; }
.meter-fill { stroke: none; }
.sub-note { margin: .6rem 0 0; font-size: .8rem; }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-bottom: .6rem; }
.table-wrap.flat { border: 0; box-shadow: none; border-radius: 0; }
.table-wrap.flat th { background: none; }
.table-wrap.flat td { white-space: nowrap; }
.pill { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 700; }
.pill-green { color: #087443; background: #e3f6ec; }
.pill-amber { color: #8a5a00; background: #fff3d6; }
.pill-violet { color: #4a3fc2; background: #ece9ff; }
.pill-gray { color: #5d6279; background: #eef0f5; }
.empty-note { margin: 1.5rem 0; text-align: center; }
@media (max-width: 1280px) {
  .dash { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .hero, .p-recent, .p-sales { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .dash { grid-template-columns: minmax(0, 1fr); gap: .8rem; }
  .hero, .p-recent, .p-sales { grid-column: auto; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1000px) {
  #side { transform: translateX(-100%); transition: transform .2s ease; box-shadow: 0 20px 60px rgba(16, 20, 45, .25); }
  body.menu-open #side { transform: none; }
  .icon-btn { display: inline-grid; place-items: center; }
  .app .top, .app .page { margin-left: 0; }
  .page { padding: 1.2rem .9rem 1.6rem; }
  .top { padding-inline: 1rem; }
  th, td { padding: .65rem .7rem; }
}
@media (max-width: 640px) {
  .top { gap: .45rem; padding: .6rem .7rem; }
  .who, .crumb { display: none; }
  .user button { padding: .35rem .55rem; font-size: .8rem; }
  .page { padding: 1rem .7rem 1.5rem; }
  .bar { align-items: stretch; }
  .bar h2 { flex: 1 1 100%; margin-bottom: .25rem; }
  .bar input, .bar .filters, .bar .filters select { flex: 1 1 100%; width: 100%; }
  .bar #new { flex: 0 0 auto; }
  .filters select { min-width: 0; }
  .pager { justify-content: center; flex-wrap: wrap; }
  .line-row { grid-template-columns: 1fr 1fr; }
  .line-row > :first-child, .line-row > :nth-child(4) { grid-column: 1 / -1; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
  .tile { padding: .8rem; }
  .tile strong { font-size: 1.25rem; }
}
@media (max-width: 380px) { .tiles { grid-template-columns: 1fr; } }
@media print {
  body { background: #fff; }
  .top, #side, .bar, .pager, .table-wrap:not(dialog .table-wrap), .actions, #page-msg { display: none !important; }
  .page { width: 100%; margin: 0; padding: 0; }
  dialog[open] { position: static; width: 100%; box-shadow: none; }
}
