/* ─── Reset ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ─── Desk Signal Classic light tokens (DESIGN.md) ─── */
:root {
  --bg:            #F3F2ED;
  --surface:       #FFFFFF;
  --surface-alt:   #EBE9E2;
  --border:        #D9D5CB;
  --border-strong: #C9C4B8;
  --text:          #141412;
  --text-secondary:#3A3934;
  --text-muted:    #5E5C54;
  --primary:       #141412;
  --accent:        #C8922A;
  --accent-strong: #B07818;
  --accent-light:  rgba(200, 146, 42, 0.16);
  --on-accent:     #FFFFFF;
  --positive:      #167A42;
  --positive-light:rgba(22, 122, 66, 0.10);
  --negative:      #B83232;
  --warning:       #B07020;
  --warning-light: rgba(176, 112, 32, 0.10);
  --off-bg:        #FBF3E6;
  --off-border:    #E8C98A;
  --nav-bg:        #FFFFFF;
  --nav-text:      #141412;
  --nav-muted:     #5E5C54;
  --nav-active:    #C8922A;
  --scan-gap:      6px;
  --panel-pad:     8px;
  --radius-xs:     2px;
  --radius-sm:     3px;
  --radius-md:     4px;
  --font-body:     'DM Sans', sans-serif;
  --font-heading:  'Playfair Display', serif;
}

html, body, #root { height: 100%; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ─── Keyframes ─── */
@keyframes fadeUp {
  from { transform: translateY(10px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
@keyframes dot {
  from { opacity: 0.3; transform: scale(0.8); }
  to   { opacity: 1;   transform: scale(1.2); }
}
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes donutGrow {
  from { stroke-dashoffset: var(--circumference); }
  to   { stroke-dashoffset: var(--final-offset); }
}

/* UX-DR18: Reduce Motion — skip non-essential transitions/animations */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ─── Dashboard: KPI Grid ─── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

/* ─── Dashboard: Two-col Panels ─── */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

/* ─── Dashboard: Data Table ─── */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left; padding: 8px 10px;
  font-size: 9px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .08em;
  font-weight: 700; border-bottom: 2px solid var(--border);
}
.data-table th.right { text-align: right; }
.data-table td { padding: 10px 10px; border-bottom: 1px solid var(--surface-alt); color: var(--text); }
.data-table td.right { text-align: right; }
.data-table tr:last-child td { border-bottom: none; }

/* ─── Agent Markdown ─── */
.msg-markdown p { margin: 0 0 6px; }
.msg-markdown p:last-child { margin-bottom: 0; }
.msg-markdown ul, .msg-markdown ol { margin: 4px 0 6px 16px; padding: 0; }
.msg-markdown li { margin-bottom: 3px; }
.msg-markdown strong { color: var(--text); font-weight: 700; }
.msg-markdown code {
  background: var(--surface-alt); border-radius: 3px;
  padding: 1px 4px; font-size: 12px;
}

/* ─── Login (preserved from current) ─── */
.login-body {
  background: var(--bg); display: flex;
  align-items: center; justify-content: center;
  min-height: 100vh; font-family: var(--font-body); color: var(--text);
}
.login-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 44px 48px; width: 380px; text-align: center;
}
.login-logo {
  width: 48px; height: 48px; background: var(--accent);
  border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: var(--on-accent); font-size: 22px; margin: 0 auto 18px;
}
.login-title { font-family: var(--font-heading); font-size: 22px; font-weight: 500; margin-bottom: 6px; }
.login-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 28px; }
.login-error {
  background: rgba(184, 50, 50, 0.08); color: var(--negative);
  border: 1px solid rgba(184, 50, 50, 0.3); border-radius: var(--radius-sm);
  padding: 8px 12px; font-size: 12px; margin-bottom: 16px;
}
.login-input {
  width: 100%; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 14px; font-size: 13px;
  font-family: var(--font-body); color: var(--text);
  margin-bottom: 12px; outline: none; display: block;
}
.login-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(200,146,42,.25); }
.login-btn {
  width: 100%; background: var(--accent); color: var(--on-accent);
  border: none; border-radius: var(--radius-sm); padding: 11px;
  font-size: 14px; font-weight: 700; cursor: pointer;
  font-family: var(--font-body); display: block;
}
.login-btn:hover { opacity: 0.85; }

/* ─── Responsive ─── */
@media (max-width: 768px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 420px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .login-card { padding: 32px 24px; width: 100%; margin: 16px; }
}

/* ─── Desktop sidebar / stats panel visibility ─── */
.sidebar-desktop { display: block; }
.stats-panel { display: block; }
.bottom-nav { display: none; }

@media (max-width: 768px) {
  .sidebar-desktop { display: none !important; }
  /* Ambient stats: side panel is not mounted on narrow; sheet overlay is used instead (Story 1.6). */
  .bottom-nav { display: flex !important; }
}

/* Narrow-Web ambient stats sheet (parity with mobile StatsSheet) */
.stats-sheet-overlay {
  position: fixed;
  inset: 0;
  /* Above BottomNav (z-index 100) so the sheet is truly modal on narrow Web */
  z-index: 120;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: rgba(0, 0, 0, 0.3);
}
.stats-sheet {
  max-height: 85vh;
  background: var(--surface);
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.stats-sheet .stats-panel,
.stats-sheet .stats-panel-sheet {
  width: 100% !important;
  border-left: none !important;
  max-height: calc(85vh - 48px);
}
.stats-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.stats-sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin: 10px auto 0;
}
