/* dashboards_common — shared warm, neutral-light design system.
   Mirrors theme.COLORS / WARM_SCALE / FONT as CSS variables so Plotly charts sit
   seamlessly inside panels. Inter loads from Google when online, with robust
   system-sans fallbacks. Every class referenced by the .py components is defined
   here. */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

:root {
  /* --- mirror of theme.COLORS --- */
  --bg: #ffffff;
  --panel: #ffffff;
  --ink: #291a11;
  --muted: #8d8178;
  --grid: rgba(141, 64, 28, 0.10);
  --accent: #d8681d;

  /* --- friendly aliases used across the spec --- */
  /* warm accents preserved; surface fills neutralised to white / light neutral */
  --cream-bg: #ffffff;
  --amber-orange: rgb(216, 104, 29);
  --deep-brown: rgb(41, 26, 17);
  --peach: #e6e8ec;
  --burnt: rgb(141, 64, 28);
  --sand: #eef0f3;
  --amber: rgb(222, 146, 71);
  --rust: rgb(180, 94, 43);

  /* --- status accents (KPI pass/warn/fail) --- */
  --pass: #4f8a3d;
  --warn: #c98a1e;
  --fail: #c0492b;

  /* --- surfaces / structure --- */
  --panel-bg: #ffffff;
  --panel-solid: #ffffff;
  --panel-border: #d9d9de;
  --hairline: rgba(28, 24, 36, 0.08);
  --soft-shadow: 0 10px 30px rgba(28, 24, 36, 0.06);
  --focus-ring: 0 0 0 3px rgba(216, 104, 29, 0.22);
  --radius: 16px;
  --rail-width: 92px;

  --font: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--deep-brown);
  background: var(--cream-bg) fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.section-label {
  font-size: 12px; font-weight: 600; letter-spacing: 0.14em;
  color: var(--burnt); text-transform: uppercase;
}
.muted { color: var(--muted); font-size: 12px; }

/* --------------------------------------------------------------------------- */
/* App shell: sidebar rail + main column                                        */
/* --------------------------------------------------------------------------- */
.app-shell {
  display: grid;
  grid-template-columns: var(--rail-width) minmax(0, 1fr);
  min-height: 100vh;
}

.app-main {
  grid-column: 2;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px 28px 40px;
  overflow-x: hidden;
}

/* --------------------------------------------------------------------------- */
/* Sidebar (icon rail)                                                          */
/* --------------------------------------------------------------------------- */
.sidebar {
  grid-column: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  padding: 18px 8px;
  background: #ffffff;
  border-right: 1px solid var(--panel-border);
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar__brand {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  text-align: center;
}
.sidebar__logo-img {
  display: block;
  width: 40px; height: auto;
  margin: 0 auto;
}
.sidebar__nav {
  display: flex; flex-direction: column; align-items: stretch; gap: 6px;
  width: 100%;
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 4px; border-radius: 14px;
  color: var(--burnt); text-decoration: none; cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}
.nav-item:hover { background: rgba(28, 24, 36, 0.05); }
.nav-item:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.nav-item__icon { width: 22px; height: 22px; }
.nav-item__label { font-size: 9px; font-weight: 600; letter-spacing: 0.02em; }
.nav-item.is-active {
  color: var(--amber-orange);
  background: rgba(216, 104, 29, 0.12);
  border-color: rgba(216, 104, 29, 0.28);
}

/* --------------------------------------------------------------------------- */
/* Top bar                                                                      */
/* --------------------------------------------------------------------------- */
.top-bar {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}
.top-bar__heading { display: flex; flex-direction: row; align-items: center; gap: 12px; min-width: 0; }
.top-bar__titlewrap { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.top-bar__logo { height: 40px; width: auto; display: block; flex: none; }
.top-bar__title {
  margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.01em;
  color: var(--deep-brown);
}
.breadcrumb {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  font-size: 12px; color: var(--muted);
}
.breadcrumb__item { color: var(--burnt); }
.breadcrumb__item:last-child { color: var(--deep-brown); font-weight: 600; }
.breadcrumb__sep { color: var(--peach); }

.top-bar__actions { display: flex; align-items: center; gap: 10px; }

/* Buttons */
.btn {
  font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  padding: 8px 16px; border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: var(--panel-solid); color: var(--deep-brown);
  transition: background 0.12s ease, transform 0.12s ease, box-shadow 0.12s ease;
}
.btn:hover { background: var(--sand); transform: translateY(-1px); }
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn--primary {
  color: #fff8ef; border-color: transparent;
  background: linear-gradient(135deg, var(--amber-orange), var(--rust));
}
.btn--primary:hover { filter: brightness(1.04); background: linear-gradient(135deg, var(--amber-orange), var(--rust)); }
.btn--icon {
  padding: 8px 12px; line-height: 1; font-size: 16px; min-width: 40px;
}

/* --------------------------------------------------------------------------- */
/* Run header strip                                                             */
/* --------------------------------------------------------------------------- */
.run-header {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: none;
}
.run-header__glyph {
  width: 34px; height: 34px; flex-shrink: 0; color: var(--amber-orange);
}
.run-header__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.run-header__id {
  font-size: 18px; font-weight: 700; letter-spacing: 0.01em; color: var(--deep-brown);
}
.run-header__meta { font-size: 12px; color: var(--burnt); }

/* --------------------------------------------------------------------------- */
/* Generic panel + responsive panel grid                                        */
/* --------------------------------------------------------------------------- */
.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: none;
  padding: 18px;
}
.panel__title {
  margin: 0 0 12px; font-size: 13px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--burnt);
}
.panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

/* --------------------------------------------------------------------------- */
/* KPI strip + tiles                                                            */
/* --------------------------------------------------------------------------- */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}
.kpi-tile {
  display: flex; flex-direction: column; gap: 4px;
  padding: 14px 16px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-left: 3px solid var(--peach);
  border-radius: 14px;
  box-shadow: none;
}
.kpi-tile__label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--burnt);
}
.kpi-tile__valuerow { display: flex; align-items: baseline; gap: 6px; }
.kpi-tile__value {
  font-size: 26px; font-weight: 700; line-height: 1.05; color: var(--deep-brown);
}
.kpi-tile__unit { font-size: 12px; font-weight: 500; color: var(--muted); }
.kpi-tile__subcaption { font-size: 11px; color: var(--muted); }

.kpi-tile--pass { border-left-color: var(--pass); }
.kpi-tile--pass .kpi-tile__value { color: var(--pass); }
.kpi-tile--warn { border-left-color: var(--warn); }
.kpi-tile--warn .kpi-tile__value { color: var(--warn); }
.kpi-tile--fail { border-left-color: var(--fail); }
.kpi-tile--fail .kpi-tile__value { color: var(--fail); }

/* --------------------------------------------------------------------------- */
/* Table                                                                        */
/* --------------------------------------------------------------------------- */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td {
  padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--hairline);
}
.data-table th {
  font-size: 10px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--burnt); background: rgba(28, 24, 36, 0.04);
}
.data-table td { color: var(--deep-brown); }
.data-table tbody tr:hover { background: rgba(28, 24, 36, 0.03); }
.data-table td.is-numeric, .data-table th.is-numeric { text-align: right; font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------------- */
/* Segmented toggle                                                             */
/* --------------------------------------------------------------------------- */
.segmented {
  display: inline-flex; padding: 3px; gap: 2px;
  background: rgba(28, 24, 36, 0.05);
  border: 1px solid var(--panel-border); border-radius: 12px;
}
.segmented__option {
  font-family: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
  padding: 6px 14px; border-radius: 9px; border: none;
  background: transparent; color: var(--burnt);
  transition: background 0.12s ease, color 0.12s ease;
}
.segmented__option:hover { color: var(--deep-brown); }
.segmented__option:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.segmented__option.is-active {
  background: var(--panel-solid); color: var(--amber-orange);
  box-shadow: 0 1px 4px rgba(41, 26, 17, 0.12);
}

/* --------------------------------------------------------------------------- */
/* State panels: loading / empty / error                                        */
/* --------------------------------------------------------------------------- */
.state-panel {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; text-align: center;
  min-height: 220px; padding: 32px;
  background: var(--panel-bg);
  border: 1px dashed var(--panel-border);
  border-radius: var(--radius);
}
.state-panel__message { font-size: 14px; color: var(--burnt); max-width: 42ch; }
.state-panel__glyph {
  width: 46px; height: 46px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700;
  color: var(--burnt); background: rgba(28, 24, 36, 0.06);
}
.state-panel__spinner {
  width: 34px; height: 34px; border-radius: 999px;
  border: 3px solid rgba(216, 104, 29, 0.22);
  border-top-color: var(--amber-orange);
  animation: state-spin 0.8s linear infinite;
}
@keyframes state-spin { to { transform: rotate(360deg); } }

.state-panel--empty .state-panel__glyph { color: var(--muted); }
.state-panel--error {
  border-color: rgba(192, 73, 43, 0.4);
  background: rgba(192, 73, 43, 0.06);
}
.state-panel--error .state-panel__glyph { color: #fff8ef; background: var(--fail); }
.state-panel--error .state-panel__message { color: var(--fail); }

/* --------------------------------------------------------------------------- */
/* Responsive                                                                   */
/* --------------------------------------------------------------------------- */
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    grid-column: 1; flex-direction: row; height: auto; position: static;
    border-right: none; border-bottom: 1px solid var(--panel-border);
    justify-content: flex-start; gap: 14px; padding: 10px 14px;
  }
  .sidebar__nav { flex-direction: row; width: auto; }
  .app-main { grid-column: 1; padding: 18px 16px 32px; }
  .top-bar { flex-direction: column; align-items: flex-start; }
}
