/* ============================================================
   TÜTSÜ Control — Design System
   Tokens → Base → Components → Screens → Responsive
   ============================================================ */

:root {
  /* Color tokens */
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f2f4f7;
  --surface-3: #e9edf3;
  --border: #e3e7ee;
  --border-strong: #d3d9e3;
  --text: #1f2430;
  --text-2: #5b6472;
  --text-3: #8b94a3;
  --accent: #2f6fed;
  --accent-strong: #2459c4;
  --accent-weak: #eaf1fe;
  --ok: #2e7d5b;
  --ok-weak: #e8f4ee;
  --warn: #b7791f;
  --warn-weak: #fbf3e2;
  --danger: #b4453a;
  --danger-weak: #fbeceb;
  --series-1: #2f6fed;
  --series-2: #d97706;
  --series-3: #7c3aed;
  --series-4: #0f766e;
  --cmp-3w: #94a3b8;
  --cmp-2w: #0f766e;
  --cmp-1w: #d97706;

  /* Typography */
  --font: -apple-system, BlinkMacSystemFont, "Inter", "SF Pro Text",
    "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --text-xs: 11px;
  --text-sm: 12.5px;
  --text-md: 14px;
  --text-lg: 16px;
  --text-xl: 20px;
  --text-2xl: 26px;
  --text-3xl: 32px;

  /* Spacing scale */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;
  --s-12: 48px;

  /* Radius */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-full: 999px;

  /* Shadow */
  --shadow-1: 0 1px 2px rgba(31, 36, 48, 0.05);
  --shadow-2: 0 2px 8px rgba(31, 36, 48, 0.06);
  --shadow-3: 0 8px 24px rgba(31, 36, 48, 0.08);
}

/* ---------------- Base ---------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: var(--text-md);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
h1,
h2,
h3,
p,
ul,
ol,
blockquote {
  margin: 0;
}
button {
  font: inherit;
  color: inherit;
}
a {
  color: var(--accent);
  text-decoration: none;
}
[hidden] {
  display: none !important;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ---------------- Layout primitives ---------------- */
.stack {
  display: grid;
  gap: var(--s-4);
}
.stack-sm {
  display: grid;
  gap: var(--s-2);
}
.row {
  display: flex;
  gap: var(--s-3);
  align-items: center;
}
.row-between {
  display: flex;
  gap: var(--s-3);
  align-items: center;
  justify-content: space-between;
}
.wrap {
  flex-wrap: wrap;
}
.grow {
  flex: 1;
  min-width: 0;
}
.grid {
  display: grid;
  gap: var(--s-4);
}
.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.grid-auto {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.grid-main {
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
}
.muted {
  color: var(--text-2);
}
.dim {
  color: var(--text-3);
}
.numeric {
  font-variant-numeric: tabular-nums;
}
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.grid,
.kpi-grid,
.forecast-grid,
.pinned-grid,
.widget-grid,
.action-cards {
  min-width: 0;
}
.grid > *,
.kpi-grid > *,
.forecast-grid > *,
.pinned-grid > *,
.widget-grid > *,
.action-cards > * {
  min-width: 0;
}
.stat-value {
  overflow-wrap: anywhere;
}
.segmented {
  max-width: 100%;
  overflow-x: auto;
}

/* ---------------- Typography ---------------- */
.eyebrow {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}
.title-xl {
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.title-lg {
  font-size: var(--text-xl);
  font-weight: 650;
}
.title-md {
  font-size: var(--text-lg);
  font-weight: 650;
}
.body-sm {
  font-size: var(--text-sm);
}
.label {
  font-size: var(--text-xs);
  font-weight: 650;
  color: var(--text-2);
}

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 36px;
  padding: 0 var(--s-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 120ms ease, border-color 120ms ease;
}
.btn:hover {
  background: var(--surface-2);
}
.btn:disabled {
  opacity: 0.5;
  cursor: default;
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-strong);
}
.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-2);
}
.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}
.btn-danger {
  color: var(--danger);
  border-color: #eccfcb;
  background: var(--surface);
}
.btn-danger:hover {
  background: var(--danger-weak);
}
.btn-sm {
  min-height: 30px;
  padding: 0 var(--s-3);
  font-size: var(--text-xs);
}
.btn-icon {
  width: 36px;
  min-height: 36px;
  padding: 0;
}

/* ---------------- Inputs ---------------- */
.input,
.select {
  width: 100%;
  min-height: 38px;
  padding: 8px var(--s-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font-size: var(--text-sm);
}
.input::placeholder {
  color: var(--text-3);
}
.search {
  position: relative;
}
.search .input {
  padding-left: 34px;
}
.search::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 50%;
  width: 12px;
  height: 12px;
  margin-top: -7px;
  border: 2px solid var(--text-3);
  border-radius: 50%;
}
.search::after {
  content: "";
  position: absolute;
  left: 22px;
  top: 50%;
  width: 6px;
  height: 2px;
  margin-top: 3px;
  background: var(--text-3);
  transform: rotate(45deg);
  border-radius: 2px;
}
.field {
  display: grid;
  gap: var(--s-1);
}
.field > span {
  font-size: var(--text-xs);
  font-weight: 650;
  color: var(--text-2);
}

/* ---------------- Segmented control ---------------- */
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.segmented button {
  border: 0;
  background: transparent;
  border-radius: 6px;
  padding: 7px 12px;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
}
.segmented button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-1);
}

/* ---------------- Card / Stat / Chart card ---------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
.card-pad {
  padding: var(--s-5);
}
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--s-3);
  margin-bottom: var(--s-3);
}
.section-head h2 {
  font-size: var(--text-lg);
  font-weight: 650;
}
.kpi-grid {
  display: grid;
  gap: var(--s-3);
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}
.stat {
  padding: var(--s-4);
  display: grid;
  gap: var(--s-2);
  min-height: 104px;
  align-content: space-between;
}
.stat-label {
  font-size: var(--text-xs);
  font-weight: 650;
  color: var(--text-2);
}
.stat-value {
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.stat-note {
  font-size: var(--text-xs);
  color: var(--text-3);
}
.chart-card {
  padding: var(--s-4) var(--s-5) var(--s-5);
}
.chart-card .chart {
  margin-top: var(--s-2);
}

/* ---------------- Badge ---------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: var(--text-xs);
  font-weight: 650;
  white-space: nowrap;
}
.badge-ok,
.badge-shared {
  background: var(--ok-weak);
  color: var(--ok);
}
.badge-warn {
  background: var(--warn-weak);
  color: var(--warn);
}
.badge-danger {
  background: var(--danger-weak);
  color: var(--danger);
}
.badge-accent {
  background: var(--accent-weak);
  color: var(--accent-strong);
}
.badge-private {
  background: var(--surface-2);
  color: var(--text-2);
}

/* ---------------- Table / List ---------------- */
.table-wrap {
  overflow: auto;
  max-height: 420px;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
  text-align: left;
  font-size: var(--text-xs);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-3);
  font-weight: 700;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--surface-3);
  color: var(--text);
  vertical-align: middle;
}
.table tbody tr:last-child td {
  border-bottom: 0;
}
.table td.numeric,
.table th.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.nowrap {
  white-space: nowrap;
}
.list {
  display: grid;
}
.list-row {
  display: flex;
  gap: var(--s-3);
  align-items: center;
  justify-content: space-between;
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--surface-3);
}
.list-row:last-child {
  border-bottom: 0;
}
.list-row:hover {
  background: var(--surface-2);
}

/* ---------------- States ---------------- */
.empty,
.error {
  display: grid;
  place-items: center;
  gap: var(--s-2);
  text-align: center;
  padding: var(--s-8) var(--s-4);
  color: var(--text-3);
  font-size: var(--text-sm);
}
.error {
  color: var(--danger);
}
.state-bar {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: 8px 12px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: var(--text-sm);
  font-weight: 600;
}
.state-bar[data-kind="ready"] {
  background: var(--ok-weak);
  color: var(--ok);
}
.state-bar[data-kind="error"] {
  background: var(--danger-weak);
  color: var(--danger);
}
.state-bar[data-kind="empty"] {
  background: var(--surface-2);
  color: var(--text-2);
}
.skeleton {
  border-radius: var(--r-sm);
  background: linear-gradient(
    90deg,
    var(--surface-2) 25%,
    var(--surface-3) 37%,
    var(--surface-2) 63%
  );
  background-size: 400% 100%;
  animation: skeleton 1.4s ease infinite;
  min-height: 16px;
}
@keyframes skeleton {
  0% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0 50%;
  }
}
.skeleton-stat {
  height: 104px;
  border-radius: var(--r-lg);
}

/* ---------------- Bars / charts ---------------- */
.bars {
  display: grid;
  gap: var(--s-3);
}
.bar-row {
  display: grid;
  gap: 6px;
}
.bar-head {
  display: flex;
  justify-content: space-between;
  gap: var(--s-2);
  font-size: var(--text-sm);
}
.bar-name {
  font-weight: 650;
}
.bar-meta {
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.bar-track {
  height: 8px;
  background: var(--surface-2);
  border-radius: var(--r-full);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: var(--series-1);
  border-radius: var(--r-full);
}
.chart {
  width: 100%;
  height: auto;
  display: block;
}
.chart rect {
  fill: var(--series-1);
}
.chart rect.chart-secondary {
  fill: var(--series-2);
}
.chart-line {
  fill: none;
  stroke: var(--series-1);
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.chart polyline.chart-secondary {
  stroke: var(--series-2);
}
.chart polygon.chart-secondary {
  fill: rgba(217, 119, 6, 0.15);
  stroke: var(--series-2);
  stroke-width: 1.5;
}
.chart-forecast {
  stroke-dasharray: 5 4;
  stroke: var(--series-3);
}
.chart-now {
  stroke: var(--text-3);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}
.chart text {
  font-size: 10px;
  fill: var(--text-3);
}
.chart text.chart-value {
  font-size: 11px;
  font-weight: 650;
  fill: var(--text);
}
.chart text.chart-axis-value,
.chart text.chart-now-label {
  font-size: 10px;
  fill: var(--text-3);
}
.chart-pie text {
  font-size: 10px;
  fill: var(--text-2);
}
.chart-grid line {
  stroke: var(--surface-3);
  stroke-width: 1;
}
.legend {
  display: flex;
  gap: var(--s-4);
  flex-wrap: wrap;
  font-size: var(--text-xs);
  color: var(--text-2);
}
.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend i {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--series-1);
  display: inline-block;
}
.legend i.alt {
  background: var(--series-2);
}
.legend i.forecast {
  background: var(--series-3);
}

/* ---------------- Forecast cards ---------------- */
.forecast-grid {
  display: grid;
  gap: var(--s-3);
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.forecast-card {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-4);
  display: grid;
  gap: var(--s-2);
  align-content: start;
}
.forecast-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-2);
}
.forecast-value {
  font-size: var(--text-2xl);
  font-weight: 700;
}
.forecast-reasons {
  margin: 0;
  padding-left: 16px;
  color: var(--text-2);
  font-size: var(--text-xs);
  display: grid;
  gap: 3px;
}
.forecast-actual {
  font-size: var(--text-sm);
  font-weight: 650;
  color: var(--danger);
}

.form-step {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-top: var(--s-2);
}
.advanced {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-3) var(--s-4);
  background: var(--surface-2);
}
.advanced summary {
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 650;
  color: var(--text-2);
}
.advanced[open] summary {
  margin-bottom: var(--s-3);
}
.password-field {
  position: relative;
  display: block;
}
.password-field .btn {
  position: absolute;
  right: 4px;
  top: 4px;
  min-height: 30px;
}
.chart rect:hover {
  opacity: 0.85;
}
.chart-line:hover,
.chart polygon:hover {
  stroke-width: 3;
}

.ai-panel .ai-provider-row {
  align-items: center;
  margin-top: var(--s-2);
}
.ai-panel .ai-messages {
  display: grid;
  gap: var(--s-2);
  margin: var(--s-3) 0;
  max-height: 300px;
  overflow: auto;
}
.ai-msg {
  padding: 10px 12px;
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  max-width: 85%;
  white-space: pre-wrap;
}
.ai-msg-user {
  background: var(--accent-weak);
  color: var(--accent-strong);
  margin-left: auto;
}
.ai-msg-assistant {
  background: var(--surface-2);
  color: var(--text);
}
.ai-history .ai-event {
  display: grid;
  gap: var(--s-2);
  padding: var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-top: var(--s-2);
}
.ai-history .ai-event .ai-msg {
  max-width: 100%;
}
.ai-history .ai-event-detail {
  font-size: var(--text-xs);
  color: var(--text-2);
}
.ai-history .ai-event-detail div {
  margin-top: 6px;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  margin-right: 6px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: -2px;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------------- Login ---------------- */
.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--s-5);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  padding: var(--s-8);
  display: grid;
  gap: var(--s-4);
}
.login-card h1 {
  font-size: var(--text-xl);
  font-weight: 700;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
}
.brand strong {
  font-size: var(--text-xl);
  letter-spacing: 0.04em;
}
.brand span {
  font-size: var(--text-xs);
  letter-spacing: 0.16em;
  color: var(--text-3);
}
.form-error {
  min-height: 16px;
  font-size: var(--text-xs);
  color: var(--danger);
}
.form-error[data-kind="ok"] {
  color: var(--ok);
}

/* ---------------- App shell ---------------- */
.app-shell {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  min-height: 100vh;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: var(--s-5) var(--s-3);
  display: grid;
  align-content: start;
  gap: var(--s-6);
  position: sticky;
  top: 0;
  height: 100vh;
}
.side-nav {
  display: grid;
  gap: 2px;
}
.side-nav button {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  border: 0;
  background: transparent;
  border-radius: var(--r-sm);
  padding: 9px 12px;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  text-align: left;
}
.side-nav button:hover {
  background: var(--surface-2);
  color: var(--text);
}
.side-nav button[aria-current="page"] {
  background: var(--accent-weak);
  color: var(--accent-strong);
}
.nav-dot {
  width: 8px;
  height: 8px;
  border-radius: 3px;
  background: currentColor;
  opacity: 0.7;
}
.app-main {
  min-width: 0;
  max-width: 100%;
  padding: var(--s-6) var(--s-8) var(--s-12);
  display: grid;
  gap: var(--s-5);
  align-content: start;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-wrap: wrap;
}
.app-main > * {
  min-width: 0;
}
.section-head > div {
  min-width: 0;
}
.section-head .search {
  min-width: 0;
  flex: 1 1 220px;
}
.user-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: var(--surface);
  font-size: var(--text-xs);
  font-weight: 650;
  color: var(--text-2);
}
.notif {
  position: relative;
}
.notif-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn);
  border: 2px solid var(--surface);
}
.notif-panel {
  position: absolute;
  right: 0;
  top: 42px;
  width: 300px;
  z-index: 30;
  padding: var(--s-3);
  display: grid;
  gap: var(--s-2);
  box-shadow: var(--shadow-3);
}
.bottom-nav {
  display: none;
}

.notif-item {
  display: grid;
  gap: var(--s-1);
  padding: var(--s-3);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}
.notif-time {
  font-size: var(--text-xs);
  color: var(--text-3);
}

/* ---------------- Screens ---------------- */
.page {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-5);
  min-width: 0;
  max-width: 100%;
}
.filter-bar {
  display: flex;
  gap: var(--s-3);
  align-items: center;
  flex-wrap: wrap;
}
.report-row {
  display: grid;
  gap: var(--s-2);
  padding: var(--s-4);
  border-bottom: 1px solid var(--surface-3);
}
.report-row:last-child {
  border-bottom: 0;
}
.report-title {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-wrap: wrap;
}
.report-meta {
  font-size: var(--text-xs);
  color: var(--text-3);
}
.report-actions {
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
}
.report-preview {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
  padding: var(--s-3);
  max-height: 420px;
  overflow: auto;
  overscroll-behavior: contain;
}
.preview-panel .report-preview {
  background: var(--surface);
}
.preview-panel .chart {
  max-height: 360px;
}
.pinned-grid {
  display: grid;
  gap: var(--s-3);
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.pinned-card {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-4);
  display: grid;
  gap: var(--s-2);
}
.widget-grid {
  display: grid;
  gap: var(--s-3);
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.widget {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-4);
}
.widget-large,
.widget-medium {
  grid-column: span 2;
}
.widget-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-2);
  margin-bottom: var(--s-2);
}
.widget-body .chart {
  max-height: 200px;
}
.action-cards {
  display: grid;
  gap: var(--s-3);
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.action-card {
  text-align: left;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  padding: var(--s-4);
  display: grid;
  gap: var(--s-2);
  cursor: pointer;
}
.action-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-2);
}
.freshness-grid {
  display: grid;
  gap: var(--s-3);
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}
.freshness-card {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-3);
  display: grid;
  gap: 3px;
  font-size: var(--text-xs);
  color: var(--text-2);
}
.builder-form {
  display: grid;
  gap: var(--s-3);
}
.builder-form .grid-2 {
  gap: var(--s-3);
}
.chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.chip {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: var(--r-full);
  padding: 6px 11px;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
}
.chip:hover {
  background: var(--surface-2);
  color: var(--text);
}
.presets {
  display: grid;
  gap: var(--s-2);
}

/* ---------------- Responsive ---------------- */
@media (max-width: 1080px) {
  .grid-main,
  .grid-3,
  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }
  .sidebar {
    display: none;
  }
  .app-main {
    padding: var(--s-4) var(--s-4) 92px;
  }
  .grid-main,
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: minmax(0, 1fr);
  }
  .widget-large,
  .widget-medium {
    grid-column: span 1;
  }
  .bottom-nav {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    box-shadow: 0 -2px 12px rgba(31, 36, 48, 0.06);
  }
  .bottom-nav button {
    border: 0;
    background: transparent;
    display: grid;
    justify-items: center;
    gap: 2px;
    padding: 6px 2px;
    font-size: 10px;
    font-weight: 650;
    color: var(--text-3);
    cursor: pointer;
  }
  .bottom-nav button[aria-current="page"] {
    color: var(--accent);
  }
  .bottom-nav .nav-dot {
    width: 10px;
    height: 10px;
    border-radius: 4px;
  }
  .topbar {
    flex-wrap: wrap;
  }
  .filter-bar .search {
    flex: 1 1 100%;
  }
}
@media (max-width: 560px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .stat-value {
    font-size: var(--text-lg);
  }
  .report-actions .btn {
    flex: 1 1 auto;
  }
}

/* Searchable combobox (Report Builder pickers + RAW catalog) */
.combo {
  position: relative;
  width: 100%;
}
.combo-control {
  display: flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  padding: 0 6px 0 10px;
}
.combo-control:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-weak);
}
.combo-input {
  flex: 1 1 auto;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: var(--text-md);
  padding: 9px 0;
  min-width: 0;
}
.combo-toggle {
  border: 0;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  font-size: 12px;
  padding: 4px 6px;
  border-radius: 6px;
}
.combo-toggle:hover {
  background: var(--surface-2);
  color: var(--text);
}
.combo-popup {
  position: absolute;
  z-index: 40;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  display: none;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.16);
  overflow: hidden;
}
.combo.is-open .combo-popup {
  display: block;
}
.combo-meta {
  padding: 8px 12px;
  font-size: var(--text-xs);
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.combo-list {
  max-height: 280px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.combo-option {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  border-left: 3px solid transparent;
}
.combo-option-label {
  font-size: var(--text-sm);
  color: var(--text);
  font-weight: 550;
  overflow-wrap: anywhere;
}
.combo-option-meta {
  font-size: var(--text-xs);
  color: var(--text-3);
  margin-left: auto;
  text-align: right;
  white-space: nowrap;
}
.combo-option.is-active,
.combo-option:hover {
  background: var(--accent-weak);
  border-left-color: var(--accent);
}
.combo-empty {
  padding: 14px 12px;
  font-size: var(--text-sm);
  color: var(--text-3);
}
.raw-catalog .combo {
  max-width: 560px;
}
.raw-detail {
  margin-top: 12px;
  padding: 12px;
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  background: var(--surface-2);
  display: grid;
  gap: 8px;
}
.raw-detail .row {
  align-items: center;
}
