/* frontend/styles.css */
@import "./theme.css";
@import url("https://fonts.googleapis.com/css2?family=Sora:wght@400;500;600;700&display=swap");

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg-alt);
  color: var(--fg1);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.container { max-width: 1280px; margin: 0 auto; padding: 0 24px 24px; }

/* Header — sticky, full-width, single-row, inverted palette (navy on cream) */
.header {
  position: sticky; top: 0; z-index: 50;
  background: var(--accent);
  color: var(--fg1-on-dark);
  border-radius: 0;
  box-shadow: 0 2px 6px rgba(11,31,50,0.18);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}
.header-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.header-title h1 { font-size: 18px; font-weight: 700; margin: 0; color: var(--fg1-on-dark); white-space: nowrap; }
.header-title .title-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.header-logo {
  width: 48px; height: 48px; flex-shrink: 0;
  background: var(--logo-url) center/contain no-repeat;
}
.timestamp { color: var(--fg2-on-dark); font-size: 12px; }
.timestamp.stale { color: var(--highlight); font-weight: 600; }

.header .controls { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; flex: 1; justify-content: flex-end; }
.controls .control-group { display: flex; flex-direction: column; gap: 2px; }
.controls .control-group label { font-size: 10px; text-transform: uppercase; color: var(--fg3-on-dark); letter-spacing: 0.06em; line-height: 1; }
.controls .control-group select {
  padding: 5px 8px; border: 1px solid rgba(255,255,255,0.18); border-radius: 6px;
  background: rgba(255,255,255,0.08); color: var(--fg1-on-dark);
  font-family: inherit; font-size: 13px; cursor: pointer; min-width: 110px;
}
.controls .control-group select option { background: var(--surface); color: var(--fg1); }

.refresh-btn {
  padding: 7px 14px; background: var(--highlight); color: var(--accent);
  border: none; border-radius: 6px; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 700;
  display: inline-flex; align-items: center; gap: 6px;
  flex-shrink: 0;
}
.refresh-btn:hover { filter: brightness(1.08); }
.refresh-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.refresh-btn .spinner { width: 14px; height: 14px; border: 2px solid var(--accent); border-top-color: transparent; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Module shell */
.module { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 24px; margin-bottom: 24px; }
.module h2 { font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--fg2); margin: 0 0 16px; }

/* KPI tiles */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.kpi-tile { padding: 16px; border: 1px solid var(--border); border-radius: 8px; }
.kpi-label { font-size: 12px; text-transform: uppercase; color: var(--fg3); letter-spacing: 0.05em; }
.kpi-value { font-size: 32px; font-weight: 700; color: var(--fg1); margin: 6px 0; }
.kpi-delta { font-size: 12px; display: inline-flex; align-items: center; gap: 4px; }
.kpi-delta.up { color: var(--success); }
.kpi-delta.down { color: var(--danger); }
.kpi-delta .flag { font-size: 14px; }

/* Funnel bars */
.funnel-row { display: grid; grid-template-columns: 220px 1fr 90px 90px 20px; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.funnel-row:last-child { border-bottom: none; }
.funnel-label { font-size: 13px; color: var(--fg1); font-weight: 500; }
.funnel-bar-track { height: 10px; background: var(--surface-sunken); border-radius: 5px; overflow: hidden; }
.funnel-bar-fill { height: 100%; background: var(--accent); border-radius: 5px; transition: width 200ms; }
.funnel-pct { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--fg1); }
.funnel-prior { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--fg3); }

/* Cycle time */
.cycle-row { display: grid; grid-template-columns: 1fr 100px 100px 20px; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.cycle-row:last-child { border-bottom: none; }
.cycle-label { font-size: 13px; }
.cycle-value { font-variant-numeric: tabular-nums; font-weight: 600; }
.cycle-prior { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--fg3); }

/* Source bars */
.source-row { display: grid; grid-template-columns: 160px 1fr 80px; gap: 12px; align-items: center; padding: 6px 0; }
.source-label { font-size: 13px; color: var(--fg1); }
.source-bar-track { height: 10px; background: var(--surface-sunken); border-radius: 5px; overflow: hidden; }
.source-bar-fill { height: 100%; background: var(--splash); border-radius: 5px; }
.source-count { font-variant-numeric: tabular-nums; font-size: 13px; font-weight: 600; }

/* Volume chart */
.volume-chart-wrap { height: 280px; }

/* Error/banner states */
.banner { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; }
.banner.warning { background: #FBEFCF; color: #5A3A00; border-left: 4px solid var(--warning); }
.banner.error { background: #FBE9E5; color: var(--danger); border-left: 4px solid var(--danger); }

/* Toast */
.toast { position: fixed; bottom: 24px; right: 24px; padding: 12px 18px; background: var(--accent); color: white; border-radius: 8px; box-shadow: var(--shadow); animation: slidein 200ms ease-out; }
@keyframes slidein { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Partial-week asterisk */
.partial-note { font-size: 11px; color: var(--fg3); margin-top: 8px; font-style: italic; }
