/* Palette mirrors Daily Jobs/job_runner.py so this feels like the same shop. */
:root {
  --dark: #1e272e;
  --white: #ffffff;
  --header-bg: #192a56;
  --section-bg: #375a7f;
  --ok: #27ae60;
  --warn: #f39c12;
  --err: #e74c3c;
  --muted: #7f8c8d;
  --row-alt: #ebf0f8;
  --light-green: #e8f5e9;
  --light-red:   #fdedec;
  --light-amber: #fef9e7;
  --border:      #dfe3ea;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: var(--dark);
  background: #f4f6fa;
}

/* ---------- Top banner / tabs ---------- */
.banner {
  background: var(--header-bg);
  color: var(--white);
  padding: 8px 18px;
  display: flex;
  align-items: center;
  gap: 18px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
.banner-title { font-weight: 700; font-size: 17px; letter-spacing: 0.3px; flex: 0 0 auto; }
.banner-meta { display: flex; align-items: center; gap: 12px; font-size: 12px; margin-left: auto; }
#refresh-btn, #refresh-whats-new-btn {
  background: var(--section-bg);
  color: var(--white);
  border: 0;
  padding: 5px 11px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
}
#refresh-btn:hover, #refresh-whats-new-btn:hover { filter: brightness(1.15); }
#refresh-btn:disabled, #refresh-whats-new-btn:disabled { opacity: 0.5; cursor: default; }

.tabs { display: flex; gap: 2px; }
.tabs .tab {
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.7);
  border: 0;
  padding: 8px 18px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  border-radius: 4px 4px 0 0;
  border-bottom: 3px solid transparent;
}
.tabs .tab:hover { background: rgba(255,255,255,0.10); color: var(--white); }
.tabs .tab.active {
  background: #f4f6fa;
  color: var(--header-bg);
  border-bottom-color: var(--white);
}

main { max-width: 1380px; margin: 0 auto; padding: 14px; }

.tab-pane { display: none; }
.tab-pane.active { display: block; }

.panel {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 18px;
  margin-bottom: 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.panel h2 {
  margin: 0 0 10px 0;
  font-size: 15px;
  color: var(--section-bg);
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.panel h2 .hint { margin-left: auto; }
.muted { color: var(--muted); }
.small { font-size: 12px; font-weight: 400; }
.bad { color: var(--err); font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Health banner ---------- */
.banner-panel { padding: 10px 14px; }
.health-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 14px;
  border-left: 6px solid var(--muted);
  background: var(--row-alt);
}
.health-banner.green { background: var(--light-green); border-left-color: var(--ok); }
.health-banner.amber { background: var(--light-amber); border-left-color: var(--warn); }
.health-banner.red   { background: var(--light-red);   border-left-color: var(--err); }
.banner-icon { font-size: 18px; line-height: 1; }
.health-banner.green .banner-icon { color: var(--ok); }
.health-banner.amber .banner-icon { color: var(--warn); }
.health-banner.red   .banner-icon { color: var(--err); }
.banner-label {
  font-weight: 800;
  letter-spacing: 0.6px;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 3px;
  background: rgba(0,0,0,0.05);
}
.banner-summary { flex: 1; }

.alerts-details { margin-top: 8px; font-size: 12px; }
.alerts-details summary { cursor: pointer; color: var(--muted); padding: 4px 0; }
.alerts-list { list-style: none; margin: 6px 0 0 0; padding: 0; }
.alerts-list li {
  padding: 6px 9px;
  margin-bottom: 4px;
  border-radius: 4px;
  border-left: 3px solid var(--muted);
  background: var(--row-alt);
  font-size: 12px;
}
.alerts-list li.warn { border-left-color: var(--warn); background: var(--light-amber); }
.alerts-list li.crit { border-left-color: var(--err);  background: var(--light-red); }
.alerts-list li.info { border-left-color: var(--section-bg); }

/* ---------- Status strip tiles ---------- */
.status-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(195px, 1fr));
  gap: 8px;
}
.tile {
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: 4px;
  padding: 8px 10px;
  background: var(--white);
  text-decoration: none;
  color: inherit;
  display: block;
  transition: background 0.15s;
}
.tile:hover { background: var(--row-alt); }
.tile.green  { border-left-color: var(--ok);   background: var(--light-green); color: var(--ok); }
.tile.amber  { border-left-color: var(--warn); background: var(--light-amber); color: var(--warn); }
.tile.red    { border-left-color: var(--err);  background: var(--light-red); color: var(--err); }
.tile-name   { font-weight: 700; font-size: 12px; display: flex; justify-content: space-between; color: var(--dark); }
.tile-metric { font-size: 18px; font-weight: 700; margin-top: 2px; color: var(--dark); }
.tile-baseline { font-weight: 400; color: var(--muted); font-size: 13px; }
.tile-sub    { font-size: 11px; color: var(--muted); margin-top: 2px; }
.tile-sub .bad { color: var(--err); font-weight: 600; }
.tile-spark  { margin: 4px 0 2px 0; line-height: 0; }
.sparkline { width: 100%; height: 28px; display: block; }

/* ---------- Charts ---------- */
.chart { width: 100%; height: 320px; }
.chart.tall { height: 420px; }

/* Chart with right-side companion table */
.chart-with-table {
  display: grid;
  grid-template-columns: 1fr 290px;
  gap: 14px;
  align-items: start;
}
@media (max-width: 1100px) {
  .chart-with-table { grid-template-columns: 1fr; }
}
.linked-table {
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--row-alt);
  padding: 8px 10px;
  font-size: 12px;
  max-height: 320px;
  overflow-y: auto;
}
.linked-table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}
.now-btn {
  border: 1px solid var(--border);
  background: var(--white);
  padding: 1px 7px;
  font-size: 11px;
  border-radius: 3px;
  cursor: pointer;
}
.now-btn:hover { background: var(--row-alt); }

table.mini { font-size: 11px; }
table.mini th { background: transparent; font-weight: 600; color: var(--muted); padding: 3px 4px; border: 0; }
table.mini td { padding: 3px 4px; border: 0; border-bottom: 1px dotted var(--border); }
table.mini tfoot td { border-top: 1px solid var(--border); font-weight: 600; padding-top: 5px; }
table.mini a { color: var(--section-bg); text-decoration: none; }
table.mini a:hover { text-decoration: underline; }
table.mini .bad { color: var(--err); }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 12px; }
table th, table td { padding: 5px 8px; border-bottom: 1px solid var(--border); text-align: left; }
table th { background: var(--row-alt); font-weight: 600; }
table th.num, table td.num { text-align: right; }
table tr:nth-child(even) td { background: #fafbfd; }

/* ---------- Picker buttons (queue threshold, runtime mode, etc) ---------- */
/* Sticky trends controls — stay pinned at the top of the viewport while
   scrolling through the trend panels. Background + shadow ensure the panels
   underneath don't bleed through visually. */
.trends-sticky {
  position: sticky;
  top: 0;
  z-index: 10;
  margin-bottom: 14px;
  background: var(--white);
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.trends-controls-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.trends-controls-row input[type="date"] {
  font-size: 13px;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--white);
}

.threshold-picker { display: inline-flex; align-items: center; gap: 5px; margin: 4px 0 8px 0; }
.threshold-picker.inline { margin: 0; }
.threshold-picker button {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 3px 9px;
  cursor: pointer;
  font-size: 12px;
  color: var(--dark);
}
.threshold-picker button.active {
  background: var(--section-bg);
  color: var(--white);
  border-color: var(--section-bg);
}

/* ---------- Reservation detail page ---------- */
.back-link { display: inline-block; margin: 4px 0 10px 0; color: var(--section-bg); text-decoration: none; font-size: 13px; }
.window-picker { margin-bottom: 10px; }
.window-btn {
  background: var(--white);
  border: 1px solid var(--border);
  padding: 4px 10px;
  margin-right: 5px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}
.window-btn.active { background: var(--section-bg); color: var(--white); border-color: var(--section-bg); }

.resv-summary { display: flex; flex-wrap: wrap; gap: 12px; font-size: 13px; }
.resv-summary .kv { background: var(--row-alt); padding: 6px 10px; border-radius: 4px; }
.resv-summary .kv .k { color: var(--muted); font-size: 11px; }
.resv-summary .kv .v { font-weight: 700; font-size: 15px; }

.inline-btn {
  background: var(--section-bg);
  color: var(--white);
  border: 0;
  padding: 4px 10px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 11px;
  margin-left: auto;
}
.inline-btn:disabled { opacity: 0.5; cursor: default; }

/* Source / state badges */
.src-badge, .state-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 8px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.src-composer        { background: #d6eaff; color: #1e3a5f; }
.src-scheduled       { background: #ffe9c7; color: #6b4400; }
.src-interactive     { background: #e8f5e9; color: #1d6f3a; }
.src-service-account { background: #ece4f9; color: #41216d; }
.src-unknown         { background: var(--row-alt); color: var(--muted); }

.state-RUNNING { background: var(--light-green); color: var(--ok); }
.state-PENDING { background: var(--light-amber); color: var(--warn); }

.row-warn td { background: #fff5e6 !important; }

.bq-link {
  color: var(--section-bg);
  text-decoration: none;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.bq-link:hover { text-decoration: underline; }
