:root {
  color-scheme: dark;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  background: #121613;
  color: #f3f5ef;
  --bg: #121613;
  --sidebar: #171c18;
  --surface: #1a201b;
  --surface-strong: #222a22;
  --line: #313b32;
  --text: #f3f5ef;
  --muted: #b1bdb0;
  --faint: #97a993;
  --accent: #d7f67e;
  --accent-text: #17200d;
  --green-tint: #293621;
  --radius: 16px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 300px; min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .48; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
h1, h2, h3, p { margin: 0; }
small { display: block; }
svg { display: block; width: 1.18em; height: 1.18em; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
[data-icon] { flex: none; display: inline-flex; align-items: center; justify-content: center; }
.shell { min-height: 100vh; display: grid; grid-template-columns: 218px minmax(0, 1fr); }

.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 28px 17px 20px;
  background: var(--sidebar);
  border-right: 1px solid #2a342b;
}
.brand {
  border: 0;
  padding: 2px 7px;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  align-self: flex-start;
  text-align: left;
  font-weight: 750;
  font-size: 1.12rem;
  line-height: 1.15;
  color: var(--text);
  background: transparent;
}
.brand small { color: var(--muted); font-size: .79rem; font-weight: 500; margin-top: 4px; }
.brand-icon {
  background: var(--accent);
  color: var(--accent-text);
  width: 38px;
  height: 38px;
  border-radius: 11px;
  font-size: 1.28rem;
}
.nav { margin-top: 51px; display: grid; gap: 4px; }
.nav button {
  min-height: 46px;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0 10px;
  text-align: left;
  color: var(--muted);
  background: transparent;
  white-space: nowrap;
  font-size: .91rem;
  font-weight: 560;
}
.nav button:hover { background: var(--surface-strong); color: var(--text); }
.nav button[aria-current="page"] { background: #293521; border-color: #3e4c33; color: var(--accent); }
.nav button svg { width: 18px; height: 18px; }
.sidebar-note {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding: 12px 9px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .81rem;
  line-height: 1.35;
}
.sidebar-note small { margin-top: 2px; font-size: .75rem; color: var(--faint); }

.main { min-width: 0; width: min(100%, 1340px); margin: 0 auto; padding: 36px clamp(23px, 3.7vw, 58px) 43px; }
.page-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 25px; }
h1 { font-size: clamp(2rem, 3.1vw, 2.75rem); font-weight: 760; letter-spacing: -.055em; line-height: 1.05; }
.page-header p { margin-top: 9px; font-size: .99rem; color: var(--muted); line-height: 1.45; }
.header-actions, .button-row, .filters { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
.demo-badge {
  border: 1px solid #4c523a;
  background: #262b1e;
  color: #d6dfb8;
  padding: 7px 10px;
  border-radius: 7px;
  font-weight: 620;
  font-size: .79rem;
  white-space: nowrap;
}
.button {
  min-height: 42px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
  font-size: .91rem;
  text-decoration: none;
  white-space: nowrap;
}
.button:hover { background: #e1fb9a; }
.button.secondary { background: #232b23; border-color: #414c3e; color: #e6ebdf; }
.button.secondary:hover { background: #2d3829; }
.button.quiet { min-height: 34px; color: var(--accent); background: transparent; padding-inline: 8px; }
.button.quiet:hover { background: var(--green-tint); }
.button-icon { min-height: 34px; width: 34px; padding: 6px; }

.status-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(190px, 32%);
  align-items: center;
  gap: 27px;
  min-height: 174px;
  padding: 22px 25px;
  border-radius: var(--radius);
  border: 1px solid #425039;
  background: radial-gradient(ellipse at 80% 10%, #32412a 0, transparent 69%), #202a1e;
}
.status-panel[data-running="false"] { background: var(--surface); border-color: var(--line); }
.status-row { display: flex; align-items: center; gap: 8px; font-size: .87rem; font-weight: 650; color: #c6e4ab; }
.status-row .dot { width: 7px; height: 7px; background: #bce77f; border-radius: 50%; box-shadow: 0 0 0 4px #aedd6d21; }
.status-panel[data-running="false"] .status-row { color: var(--muted); }
.status-panel[data-running="false"] .dot { background: var(--faint); box-shadow: none; }
.status-panel h2 { font-size: clamp(1.35rem, 2.5vw, 2rem); line-height: 1.16; margin: 9px 0 13px; letter-spacing: -.034em; }
.status-panel .button { min-height: 37px; }
.chart { align-self: center; min-width: 0; }
.chart-label { color: #d6e4cc; font-size: .84rem; font-weight: 600; margin-bottom: 9px; }
.chart-bars {
  height: 70px;
  background: repeating-linear-gradient(to top, #90a18424 0, #90a18424 1px, transparent 1px, transparent 23px);
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: clamp(5px, 1vw, 13px);
  align-items: end;
  padding: 0 3px 1px;
}
.chart-bars span { min-height: 4px; background: #8ca565; border-radius: 4px 4px 0 0; opacity: .79; }
.chart-bars span:last-child { background: var(--accent); opacity: 1; }
.chart-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin-top: 6px; text-align: center; color: #b2c2a9; font-size: .75rem; }

.metrics { margin-top: 16px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.metric { position: relative; padding: 15px 17px 14px; min-width: 0; text-align: left; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); color: inherit; }
.metric:hover { border-color: #627355; }
.metric strong { display: block; font-size: 1.7rem; line-height: 1; letter-spacing: -.045em; margin-bottom: 7px; }
.metric p { color: var(--muted); line-height: 1.3; font-size: .89rem; }
.metric > [data-icon] { position: absolute; right: 13px; top: 13px; color: #a5be91; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(255px, .49fr); gap: 13px; margin-top: 17px; align-items: start; }
.side-panels { display: grid; gap: 13px; }
.panel { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 16px 18px; }
.panel-header h2 { font-size: 1.04rem; font-weight: 735; letter-spacing: -.015em; }
.panel-header .button { min-height: 33px; }
.panel-body { padding: 0 18px 17px; }
.panel-body p { color: var(--muted); font-size: .93rem; line-height: 1.5; }
.panel-body p + .button-row { margin-top: 16px; }
.pills { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.pill { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; overflow-wrap: anywhere; background: #283224; color: #d6e8ca; border: 1px solid #374636; border-radius: 7px; padding: 5px 8px; font-size: .85rem; font-weight: 590; }
.pill.pop { background: #2d3923; color: #d9efb8; }
.pill button { color: #d9e7d2; border: 0; background: transparent; padding: 5px; margin: -3px -4px -3px 2px; border-radius: 5px; }
.pill button:hover { color: var(--accent); background: #384830; }
.segmented { display: flex; gap: 3px; padding: 3px; background: #151b16; border: 1px solid #303a30; border-radius: 9px; }
.segmented button { flex: 1; padding: 7px 8px; background: transparent; border: 0; border-radius: 6px; color: var(--muted); white-space: nowrap; font-size: .86rem; font-weight: 640; min-height: 34px; }
.segmented button[aria-pressed="true"] { color: var(--accent); background: #2b3925; }
.segmented button:hover { color: var(--accent); }

.match-list, .source-list { list-style: none; padding: 0; margin: 0; }
.match-list li, .source-list li { border-top: 1px solid var(--line); }
.match-row { display: grid; grid-template-columns: 33px minmax(75px, 1fr) minmax(85px, .72fr) auto 28px; align-items: center; gap: 10px; padding: 11px 16px; width: 100%; background: transparent; border: 0; color: inherit; text-align: left; }
.match-row:hover { background: #242e23; }
.match-row > [data-icon] { color: var(--faint); }
.match-row time { color: var(--muted); font-size: .81rem; white-space: nowrap; }
.match-word { justify-self: start; }
.source-icon { display: inline-grid; place-items: center; height: 33px; width: 33px; border-radius: 9px; color: #dceab5; background: #39442c; font-size: .87rem; font-weight: 770; }
.source-icon.blue { background: #283a42; color: #c6e6fb; }
.source-icon.amber { background: #493a2b; color: #ffdb9e; }
.source-icon.violet { background: #382e45; color: #e7d6ff; }
.row-title { font-size: .91rem; font-weight: 670; overflow-wrap: anywhere; }
.row-meta { margin-top: 4px; color: var(--muted); font-size: .78rem; font-weight: 450; }

.section-panel .panel-header { padding-block: 18px; }
.section-panel + .panel { margin-top: 16px; }
.source-list li { display: flex; align-items: center; gap: 12px; padding: 13px 18px; min-height: 62px; }
.source-list li > div { flex: 1; }
.source-list .row-title { font-size: .99rem; }
.toggle { min-width: 45px; height: 28px; padding: 4px; display: inline-flex; align-items: center; border: 1px solid #536150; border-radius: 18px; background: #333d33; }
.toggle::before { content: ""; width: 18px; height: 18px; background: #c7d2c5; border-radius: 50%; transition: transform .13s ease; }
.toggle[aria-checked="true"] { background: var(--accent); border-color: var(--accent); }
.toggle[aria-checked="true"]::before { background: #222e16; transform: translateX(16px); }
.filters { padding: 0 18px 16px; }
.field { display: grid; gap: 7px; color: var(--text); font-weight: 630; font-size: .9rem; }
input, textarea, select { min-width: 0; background: #161c17; color: var(--text); border: 1px solid #53604f; border-radius: 8px; padding: 10px 12px; }
textarea { width: 100%; min-height: 125px; resize: vertical; font-weight: 400; line-height: 1.45; }
select { min-height: 40px; }
.search { flex: 1; min-width: min(100%, 220px); }
.empty { padding: 18px; color: var(--muted); line-height: 1.5; }
.word-actions { padding-top: 15px; }
.section-panel .pills { gap: 10px; }

dialog { background: var(--surface); color: var(--text); border: 1px solid #4c5c46; border-radius: 16px; width: min(calc(100% - 28px), 510px); max-height: min(87dvh, 690px); padding: 0; box-shadow: 0 20px 54px #0008; }
dialog::backdrop { background: #080b09bb; }
.dialog-inner { padding: 20px 22px; }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.dialog-header h2 { font-size: 1.28rem; letter-spacing: -.02em; }
.dialog-inner p { color: var(--muted); line-height: 1.5; margin-bottom: 13px; }
.dialog-inner form { display: grid; gap: 14px; }
.dialog-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dialog-inner .button-row { justify-content: flex-end; margin-top: 14px; }
.dialog-inner form .button-row { margin-top: 0; }
.dialog-error { color: #ffbaab; min-height: 1em; font-size: .88rem; }
.notice { position: fixed; z-index: 3; right: 22px; bottom: 22px; max-width: calc(100vw - 44px); color: var(--text); background: #293827; border: 1px solid #5c7251; border-radius: 10px; box-shadow: 0 6px 22px #0007; padding: 11px 14px; font-size: .91rem; }

@media (max-width: 1060px) {
  .shell { grid-template-columns: 190px minmax(0, 1fr); }
  .main { padding-inline: 23px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .side-panels { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 710px) {
  .shell { display: block; }
  .sidebar { position: static; height: auto; display: block; padding: max(10px, env(safe-area-inset-top)) 12px 6px; border-right: 0; background: transparent; }
  .brand { gap: 8px; font-size: 1rem; }
  .brand small { display: inline; margin: 0 0 0 5px; }
  .brand-icon { height: 32px; width: 32px; font-size: 1.1rem; }
  .sidebar-note { display: none; }
  .nav { position: fixed; z-index: 2; inset: auto 0 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; margin: 0; padding: 5px 5px calc(5px + env(safe-area-inset-bottom)); background: #192119; border-top: 1px solid #394737; }
  .nav button { justify-content: center; flex-direction: column; gap: 4px; padding: 4px 0; min-height: 48px; font-size: .74rem; }
  .nav button svg { width: 17px; height: 17px; }
  .main { padding: 14px 14px calc(73px + env(safe-area-inset-bottom)); }
  .page-header { align-items: flex-start; margin-bottom: 16px; }
  .page-header p { font-size: .9rem; }
  .header-actions { justify-content: flex-end; gap: 6px; }
  .header-actions .button { min-height: 34px; padding: 5px 7px; font-size: .82rem; }
  .demo-badge { padding: 5px 7px; font-size: .73rem; }
  .status-panel { grid-template-columns: minmax(0, 1fr) minmax(100px, .62fr); padding: 15px 13px; min-height: 155px; gap: 12px; }
  .status-row { font-size: .78rem; }
  .status-panel h2 { margin-block: 7px 11px; }
  .chart-label { font-size: .75rem; }
  .chart-bars { gap: 4px; height: 49px; }
  .chart-days { font-size: .65rem; gap: 2px; }
  .metrics { gap: 6px; margin-top: 9px; }
  .metric { padding: 12px 8px; border-radius: 10px; }
  .metric p { font-size: .76rem; }
  .metric strong { font-size: 1.35rem; }
  .metric > [data-icon] { top: 9px; right: 8px; font-size: .85rem; }
  .dashboard-grid { margin-top: 10px; }
  .side-panels { grid-template-columns: 1fr; }
  .panel-header { padding-inline: 12px; }
  .panel-body { padding-inline: 12px; }
  .match-row { grid-template-columns: 29px minmax(80px, 1fr) minmax(65px, .68fr) auto; gap: 6px; padding-inline: 10px; }
  .match-row > [data-icon] { display: none; }
  .source-icon { width: 29px; height: 29px; }
  .match-row .row-title, .match-row .pill { font-size: .8rem; }
  .match-row time { font-size: .74rem; }
  .notice { bottom: calc(63px + env(safe-area-inset-bottom)); }
}
@media (max-width: 375px) {
  .main { padding-inline: 10px; }
  .nav button { font-size: .67rem; }
  .header-actions { flex-direction: column; align-items: flex-end; }
  .dialog-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
