body { font-family: Georgia, serif; margin: 0; color: #1a1a1a; background: #fafafa; }
header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.5rem; border-bottom: 1px solid #ddd; }
nav a { margin-left: 1rem; color: #111; }
main { max-width: 44rem; padding: 2rem 1.5rem; }
.brand { font-weight: 700; margin: 0; }
.plans { padding-left: 1.2rem; }
.note { color: #555; font-size: 0.95rem; }
section { margin-bottom: 1.5rem; }
pre { background: #fff; border: 1px solid #ddd; padding: 1rem; overflow: auto; }
input, textarea, button { font: inherit; }
input, textarea { width: 100%; max-width: 40rem; box-sizing: border-box; }
button { margin-top: 0.5rem; }
table { width: 100%; border-collapse: collapse; background: #fff; margin: 0.6rem 0 1rem; }
th, td { border: 1px solid #ddd; padding: 0.35rem 0.45rem; vertical-align: top; text-align: left; font-size: 0.92rem; }
th { background: #f0f0f0; }
.filters button { margin-right: 0.4rem; }
.desk main { max-width: 72rem; }
.wrap { overflow-x: auto; max-width: 100%; }
@media (max-width: 640px) {
  header { flex-direction: column; align-items: flex-start; }
  nav { display: flex; flex-wrap: wrap; }
  nav a { margin: 0.4rem 0.8rem 0 0; }
  main { padding: 1.25rem 1rem; }
}

body.desk {
  --bg: #0e1424;
  --bg-elev: #171f33;
  --bg-soft: #12192b;
  --line: rgba(165, 180, 220, 0.16);
  --text: #eef2ff;
  --muted: #a7b3d1;
  --indigo: #6d5efc;
  --indigo-2: #8b7cff;
  --violet: #b06cff;
  --emerald: #1fbf8f;
  --sky: #4cc4ff;
  --amber: #f0b429;
  --red: #ff5d73;
  --shadow: 0 16px 40px rgba(4, 8, 20, 0.35);
  --radius: 16px;
  margin: 0;
  background:
    radial-gradient(900px 420px at 100% -10%, rgba(109, 94, 252, 0.22), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Avenir Next", sans-serif;
}
body.desk[data-theme="light"] {
  --bg: #f4f6fb;
  --bg-elev: #ffffff;
  --bg-soft: #eef1f8;
  --line: rgba(28, 36, 68, 0.12);
  --text: #172033;
  --muted: #5c6b8a;
  --shadow: 0 12px 30px rgba(40, 52, 90, 0.08);
  background:
    radial-gradient(900px 420px at 100% -10%, rgba(109, 94, 252, 0.16), transparent 55%),
    var(--bg);
}
body.desk input, body.desk textarea, body.desk select { font: inherit; color: var(--text); background: var(--bg-soft); border: 1px solid var(--line); border-radius: 12px; padding: 0.55rem 0.7rem; width: auto; margin: 0; }
body.desk button { font: inherit; margin: 0; }
body.desk .filters button { margin: 0; }
.menu-toggle { display: none; }
.deal { background: var(--bg-elev); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 0.55rem 0.65rem; cursor: pointer; }
.deal:hover { border-color: var(--indigo-2); }
.btn.is-loading::after { content: ""; width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: sbf-spin 0.7s linear infinite; }
@keyframes sbf-spin { to { transform: rotate(360deg); } }
.toast.success { border-color: var(--emerald); }
.toast.warning { border-color: var(--amber); }
.toast.danger { border-color: var(--red); }
.legend { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.45rem; }
.shell { display: flex; min-height: 100vh; }
.shell aside { width: 248px; flex: 0 0 248px; background: color-mix(in srgb, var(--bg-elev) 88%, #1a1440); color: var(--text); padding: 0.9rem 0.75rem; border-right: 1px solid var(--line); transition: width 0.2s ease, flex-basis 0.2s ease; }
body.desk.nav-collapsed .shell aside { width: 76px; flex-basis: 76px; }
body.desk.nav-collapsed .brand-copy, body.desk.nav-collapsed .nav-label { display: none; }
.brand-row { display: flex; align-items: center; gap: 0.55rem; margin-bottom: 0.8rem; }
.mark { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: linear-gradient(135deg, var(--indigo), var(--violet)); color: white; font-weight: 700; flex: 0 0 auto; }
.shell .brand { margin: 0; color: var(--text); font-size: 0.95rem; }
.aside-note { color: var(--muted); font-size: 0.75rem; margin: 0.1rem 0 0; }
#nav { display: flex; flex-direction: column; gap: 0.2rem; }
.nav-item { display: flex; align-items: center; gap: 0.55rem; width: 100%; text-align: left; background: transparent; color: var(--muted); border: 0; border-radius: 12px; padding: 0.55rem 0.65rem; }
.nav-item:hover { background: color-mix(in srgb, var(--indigo) 16%, transparent); color: var(--text); }
.nav-item.active { background: linear-gradient(135deg, var(--indigo), var(--violet)); color: white; box-shadow: var(--shadow); }
.nav-item:focus-visible, .btn:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--sky); outline-offset: 2px; }
.workspace { flex: 1; min-width: 0; }
.top { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; padding: 1rem 1.25rem; background: color-mix(in srgb, var(--bg-elev) 80%, transparent); border-bottom: 1px solid var(--line); backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 2; }
.top h1 { margin: 0; font-size: 1.45rem; letter-spacing: -0.02em; }
.toolbar, .session, .seg { display: flex; gap: 0.45rem; align-items: center; flex-wrap: wrap; }
.status, .card-note { color: var(--muted); font-size: 0.86rem; overflow-wrap: anywhere; }
#app { padding: 1.1rem 1.25rem 2.4rem; min-width: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr)); gap: 0.8rem; }
.card, .chart-card { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.85rem 0.95rem; box-shadow: var(--shadow); }
.card.wide { margin-bottom: 0.75rem; }
.kpi { position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--sky); }
.tone-success::before { background: var(--emerald); }
.tone-warning::before { background: var(--amber); }
.tone-danger::before { background: var(--red); }
.tone-violet::before { background: var(--violet); }
.tone-info::before { background: var(--sky); }
.card-label { margin: 0; color: var(--muted); font-size: 0.78rem; }
.card-value { margin: 0.35rem 0 0.2rem; font-size: 1.45rem; font-weight: 700; letter-spacing: -0.03em; }
h2 { font-size: 1rem; margin: 1.1rem 0 0.55rem; }
.filters { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; margin: 0.4rem 0 0.8rem; }
.check { font-size: 0.86rem; color: var(--muted); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; border-radius: 12px; border: 1px solid transparent; padding: 0.55rem 0.85rem; cursor: pointer; transition: transform 0.15s ease, filter 0.15s ease, background 0.15s ease; }
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn.is-loading { pointer-events: none; }
.btn.is-loading span.lbl { opacity: 0.65; }
.btn-primary { background: linear-gradient(135deg, var(--indigo), var(--violet)); color: white; }
.btn-secondary { background: var(--bg-soft); color: var(--text); border-color: var(--line); }
.btn-success { background: var(--emerald); color: #06281f; }
.btn-warning { background: var(--amber); color: #2b2104; }
.btn-danger { background: var(--red); color: white; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-icon { width: 38px; height: 38px; padding: 0; }
.filters .btn.active, .seg .btn.active { background: linear-gradient(135deg, var(--indigo), var(--violet)); color: white; border-color: transparent; }
.ico { width: 16px; height: 16px; display: inline-flex; }
.ico svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.board { display: flex; gap: 0.7rem; overflow-x: auto; padding-bottom: 0.7rem; }
.column { min-width: 210px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 14px; padding: 0.6rem; }
.column h3 { font-size: 0.78rem; margin: 0 0 0.45rem; color: var(--muted); overflow-wrap: break-word; line-height: 1.35; }
.deal { display: block; width: 100%; text-align: left; margin: 0.35rem 0; }
.click { cursor: pointer; }
body.desk table { width: 100%; border-collapse: collapse; background: var(--bg-elev); margin: 0.6rem 0 1rem; border-radius: 14px; overflow: hidden; }
body.desk th, body.desk td { border: 0; border-bottom: 1px solid var(--line); padding: 0.55rem 0.65rem; text-align: left; font-size: 0.86rem; color: var(--text); max-width: 22rem; overflow-wrap: break-word; white-space: normal; vertical-align: top; }
body.desk th { background: var(--bg-soft); color: var(--muted); font-weight: 600; }
.bar-row { display: flex; align-items: center; gap: 0.45rem; margin: 0.35rem 0; }
.bar-label { width: 11rem; font-size: 0.75rem; color: var(--muted); }
.bar { display: inline-block; height: 0.7rem; border-radius: 99px; background: linear-gradient(90deg, var(--indigo), var(--sky)); min-width: 2px; }
.chart-svg { width: 100%; height: 180px; display: block; }
.chart-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 0.8rem; }
.drawer { position: fixed; top: 0; right: 0; width: min(560px, 100%); height: 100%; background: var(--bg-elev); color: var(--text); border-left: 1px solid var(--line); overflow: auto; z-index: 6; padding: 1rem; box-shadow: var(--shadow); box-sizing: border-box; }
.drawer-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.7rem 0; }
.drawer-bar { display: flex; justify-content: space-between; gap: 0.5rem; align-items: center; }
.line { display: grid; grid-template-columns: minmax(7.5rem, 12rem) minmax(0, 1fr); gap: 0.55rem; align-items: start; margin: 0.35rem 0; overflow-wrap: break-word; }
.k { color: var(--muted); overflow-wrap: break-word; }
.diag-page { min-width: 0; max-width: 920px; }
.diag-head, .diag-actions, .diag-tabs { min-width: 0; }
.diag-head { display: flex; flex-wrap: wrap; gap: 0.7rem; align-items: flex-start; justify-content: space-between; margin-bottom: 0.4rem; }
.diag-title { min-width: 0; flex: 1 1 16rem; }
.diag-title h2 { margin: 0.15rem 0; overflow-wrap: break-word; }
.diag-actions { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; margin: 0.5rem 0 0.8rem; }
.diag-actions input { flex: 1 1 14rem; min-width: 0; max-width: 100%; }
.diag-tabs { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0 0 0.8rem; }
.diag-tab { flex: 0 0 auto; white-space: nowrap; }
.diag-panel { min-width: 0; }
.field { min-width: 0; margin: 0 0 0.95rem; }
.field .k { display: block; margin: 0 0 0.25rem; font-size: 0.78rem; }
.prose { margin: 0; white-space: pre-wrap; overflow-wrap: break-word; word-break: normal; line-height: 1.5; }
.diag-list { margin: 0; padding-left: 1.15rem; }
.diag-list li { margin: 0.35rem 0; overflow-wrap: break-word; }
.diag-list li + li { margin-top: 0.55rem; }
.plain { padding-left: 1.1rem; }
.rec { border-top: 1px solid var(--line); margin-top: 0.7rem; padding-top: 0.45rem; }
.draft { white-space: pre-wrap; background: var(--bg-soft); padding: 0.7rem; border-radius: 12px; max-height: 24rem; overflow: auto; width: 100%; box-sizing: border-box; }
.stack input { display: block; width: 100%; margin: 0.35rem 0; box-sizing: border-box; }
#app img, #app video { max-width: 100%; height: auto; }
.error { color: var(--red); }
.pill { display: inline-flex; align-items: center; gap: 0.25rem; border-radius: 99px; padding: 0.15rem 0.5rem; font-size: 0.75rem; background: var(--bg-soft); white-space: normal; overflow-wrap: break-word; max-width: 100%; }
.pill.success { background: color-mix(in srgb, var(--emerald) 22%, transparent); color: var(--emerald); }
.pill.warning { background: color-mix(in srgb, var(--amber) 24%, transparent); color: var(--amber); }
.pill.danger { background: color-mix(in srgb, var(--red) 22%, transparent); color: var(--red); }
.pill.info { background: color-mix(in srgb, var(--sky) 22%, transparent); color: var(--sky); }
.pill.violet { background: color-mix(in srgb, var(--violet) 22%, transparent); color: var(--violet); }
.empty { border: 1px dashed var(--line); border-radius: 16px; padding: 1.2rem; text-align: center; color: var(--muted); }
.modal { position: fixed; inset: 0; background: rgba(8, 10, 20, 0.55); display: grid; place-items: center; z-index: 8; }
.modal[hidden], .drawer[hidden], .toast[hidden] { display: none; }
.modal-card { width: min(420px, calc(100% - 2rem)); background: var(--bg-elev); border-radius: 16px; padding: 1rem; box-shadow: var(--shadow); }
.toast { position: fixed; bottom: 1rem; right: 1rem; background: var(--bg-elev); border: 1px solid var(--line); border-radius: 14px; padding: 0.7rem 0.9rem; box-shadow: var(--shadow); z-index: 9; max-width: 320px; }
.steps { display: flex; gap: 0.45rem; overflow-x: auto; }
.step { min-width: 120px; background: var(--bg-soft); border-radius: 12px; padding: 0.55rem; border: 1px solid var(--line); }
.step b { display: block; font-size: 1.1rem; }
@media (prefers-reduced-motion: reduce) {
  .btn, .shell aside { transition: none; }
  .btn.is-loading::after { animation: none; }
}
@media (max-width: 900px) {
  .chart-grid { grid-template-columns: 1fr; }
  .shell { display: block; }
  .shell aside { width: auto; flex: none; border-right: 0; border-bottom: 1px solid var(--line); }
  body.desk.nav-collapsed .shell aside { width: auto; flex-basis: auto; }
  body.desk.nav-collapsed .brand-copy, body.desk.nav-collapsed .nav-label { display: inline; }
  #nav { flex-direction: row; flex-wrap: nowrap; overflow-x: auto; }
  .nav-item { width: auto; flex: 0 0 auto; white-space: nowrap; }
  .deal { white-space: normal; }
  .top { display: block; }
  .toolbar { margin-top: 0.7rem; }
  .menu-toggle { display: inline-flex; }
  body.desk.nav-closed #nav { display: none; }
  .diag-page { max-width: none; }
  .diag-tabs { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 0.35rem; }
  .diag-actions .btn { flex: 1 1 auto; }
  .drawer { width: 100%; }
}
