:root {
  --bg: #0d1016;
  --bg2: #12161f;
  --panel: #171c26;
  --panel2: #1d2431;
  --line: #2a3242;
  --text: #e8ebf2;
  --muted: #8b95a9;
  --useful: #34d399;
  --intent: #60a5fa;
  --waste: #f87171;
  --neutral: #94a3b8;
  --accent: #a78bfa;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { background: var(--bg); }
body {
  background-color: var(--bg);
  background: radial-gradient(1200px 600px at 70% -10%, #1b2336 0%, var(--bg) 55%);
  color: var(--text);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .85em; overflow-wrap: anywhere; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; }

.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(13, 16, 22, .82);
  backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; letter-spacing: .2px; display: inline-flex; align-items: center; gap: 9px; }
.brand.big { font-size: 24px; margin-bottom: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: linear-gradient(135deg, var(--useful), var(--intent)); box-shadow: 0 0 14px rgba(52, 211, 153, .55); }
.topbar nav { display: flex; gap: 6px; flex: 1; }
.topbar nav a { padding: 7px 11px; border-radius: 9px; color: var(--muted); font-weight: 600; font-size: 14px; }
.topbar nav a:hover { color: var(--text); background: var(--panel); text-decoration: none; }
.topbar nav a.active { color: var(--text); background: var(--panel2); }
.logout { margin-left: auto; }
.linkish { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; }
.linkish:hover { color: var(--text); }

main { width: min(1500px, 100%); margin: 0 auto; padding: 26px 28px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin: 8px 0 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 28px; letter-spacing: -.4px; }
.page-head p { margin: 4px 0 0; }
.muted { color: var(--muted); }
.weeknav { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 13px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); cursor: pointer; font: inherit; font-weight: 600; font-size: 13px;
}
.btn:hover { border-color: #3a465c; background: var(--panel2); text-decoration: none; }
.btn.small { padding: 5px 9px; font-size: 12px; border-radius: 8px; }
.btn.primary, button.primary { background: linear-gradient(135deg, #2dd4bf, #3b82f6); border: 0; color: #061018; }
button.primary { padding: 10px 16px; border-radius: 10px; font: inherit; font-weight: 700; cursor: pointer; }
.btn.danger, button.danger { border-color: rgba(248, 113, 113, .45); color: #fecaca; background: rgba(248, 113, 113, .1); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: linear-gradient(180deg, var(--panel2), var(--panel)); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi-label { display: block; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .8px; }
.kpi strong { display: block; font-size: 24px; margin: 4px 0 3px; letter-spacing: -.4px; }
.kpi-hint { color: var(--muted); font-size: 12px; }
.kpi-waste strong { color: var(--waste); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card.highlight { border-color: rgba(96, 165, 250, .55); background: linear-gradient(180deg, rgba(96, 165, 250, .12), var(--panel)); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; font-size: 16px; letter-spacing: -.1px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

.stackbar { display: flex; height: 8px; border-radius: 99px; overflow: hidden; background: var(--bg2); border: 1px solid var(--line); }
.stackbar.big { height: 16px; margin: 8px 0 10px; }
.seg { display: block; height: 100%; }
.seg.v-useful { background: var(--useful); }
.seg.v-intent { background: var(--intent); }
.seg.v-waste { background: var(--waste); }
.seg.v-neutral { background: var(--neutral); opacity: .6; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; color: var(--muted); font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend b { color: var(--text); }
.swatch { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.swatch.v-useful { background: var(--useful); }
.swatch.v-intent { background: var(--intent); }
.swatch.v-waste { background: var(--waste); }
.swatch.v-neutral { background: var(--neutral); }

.timeline { display: grid; grid-template-columns: 2.4rem repeat(7, minmax(92px, 1fr)); gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.tl-labels { position: relative; height: 720px; margin-top: 46px; color: var(--muted); font-size: 11px; }
.tl-labels span { position: absolute; right: 4px; transform: translateY(-50%); }
.tl-day { min-width: 92px; display: flex; flex-direction: column; gap: 6px; }
.tl-head { display: flex; justify-content: space-between; align-items: baseline; padding: 8px 9px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg2); font-weight: 700; font-size: 13px; }
.tl-head small { color: var(--muted); font-weight: 500; }
.tl-head.today { border-color: rgba(96, 165, 250, .7); box-shadow: 0 0 0 1px rgba(96, 165, 250, .25) inset; }
.tl-col {
  position: relative; height: 720px; border: 1px solid var(--line); border-radius: 10px;
  background:
    repeating-linear-gradient(to bottom, rgba(255,255,255,.05) 0 1px, transparent 1px 25%),
    var(--bg2);
  overflow: hidden;
}
.blk {
  position: absolute; left: 3px; right: auto; min-height: 5px; border-radius: 7px;
  padding: 4px 5px; overflow: hidden; color: #061018; font-size: 11px; line-height: 1.2;
  font-weight: 700; border: 1px solid rgba(0,0,0,.18); box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
.blk.tiny { padding: 0; border-radius: 3px; min-height: 2px; border-width: 0; }
.blk:hover { filter: brightness(1.08); text-decoration: none; z-index: 3; }
.blk.v-useful { background: linear-gradient(180deg, #5eead4, var(--useful)); }
.blk.v-intent { background: linear-gradient(180deg, #93c5fd, var(--intent)); }
.blk.v-waste { background: linear-gradient(180deg, #fca5a5, var(--waste)); color: #2a0808; }
.blk.v-neutral { background: linear-gradient(180deg, #cbd5e1, var(--neutral)); color: #111827; }
.blk-time { display: block; opacity: .75; font-size: 10px; }
.blk-title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge { display: inline-block; padding: 2px 7px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .2px; }
.badge.v-useful, .badge.useful { background: rgba(52, 211, 153, .16); color: #6ee7b7; }
.badge.v-intent, .badge.intent { background: rgba(96, 165, 250, .16); color: #93c5fd; }
.badge.v-waste, .badge.waste { background: rgba(248, 113, 113, .16); color: #fca5a5; }
.badge.v-neutral, .badge.neutral { background: rgba(148, 163, 184, .16); color: #cbd5e1; }

.sessionlist, .planlist, .devices, .feedlist { list-style: none; margin: 0; padding: 0; }
.sessionlist li, .planlist li, .devices li { padding: 9px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.sessionlist li:last-child, .planlist li:last-child, .devices li:last-child { border-bottom: 0; }
.sessionlist small, .planlist small, .devices small { color: var(--muted); }
.planlist span { color: var(--muted); font-variant-numeric: tabular-nums; }
.feedlist li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.feedlist li:last-child { border-bottom: 0; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.actions form { display: inline; }

.form label { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; color: var(--muted); font-size: 12px; font-weight: 600; }
.form input, .form select, .form textarea {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 9px; color: var(--text);
  padding: 9px 11px; font: inherit; font-size: 14px; width: 100%;
}
.form input:focus, .form select:focus, .form textarea:focus { outline: 2px solid rgba(96, 165, 250, .4); border-color: rgba(96, 165, 250, .7); }
.form.inline { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.form.inline label { margin-bottom: 0; min-width: 160px; }
.form.inline button { margin-bottom: 1px; }

.meta { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }
.token { background: var(--bg2); border: 1px solid var(--line); border-radius: 9px; padding: 12px; font-size: 16px; user-select: all; }

.flash { padding: 11px 14px; border-radius: 10px; margin-bottom: 14px; border: 1px solid var(--line); }
.flash.ok { background: rgba(52, 211, 153, .1); border-color: rgba(52, 211, 153, .4); color: #a7f3d0; }
.flash.err { background: rgba(248, 113, 113, .1); border-color: rgba(248, 113, 113, .45); color: #fecaca; }

.login-body { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login-card { width: min(420px, 100%); padding: 28px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; margin: 14px 0; color: var(--muted); font-size: 12px; font-weight: 600; }
.login-card input { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; color: var(--text); padding: 11px 12px; font: inherit; }
.login-card button { width: 100%; margin-top: 8px; }

.foot { border-top: 1px solid var(--line); padding: 18px 28px; color: var(--muted); font-size: 12px; display: flex; justify-content: center; }
.foot a { color: var(--muted); }

@media (max-width: 1000px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  .topbar { padding: 12px 16px; gap: 12px; flex-wrap: wrap; }
  .topbar nav { order: 3; width: 100%; overflow-x: auto; }
  main { padding: 18px 14px 44px; }
  .page-head h1 { font-size: 22px; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .timeline { grid-template-columns: 2rem repeat(7, 86px); }
  .tl-col, .tl-labels { height: 520px; }
  .tl-labels { margin-top: 46px; }
  .card { padding: 14px; }
  .table { display: block; overflow-x: auto; white-space: nowrap; }
}
