:root {
  --bg: #0d0d0f;
  --panel: #16161a;
  --panel-2: #1d1d22;
  --line: #2a2a31;
  --text: #ececf0;
  --muted: #8a8a96;
  --accent: #d97757;       /* Claude-ish terracotta */
  --safe: #4ade80;
  --warn: #fbbf24;
  --crit: #f87171;
  --radius: 16px;
  font-synthesis: none;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.error { color: var(--crit); min-height: 1.2em; font-size: 0.85rem; }

button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 12px;
  padding: 0.7rem 1.1rem;
  background: var(--accent);
  color: #1a1a1a;
  font-weight: 600;
  transition: filter 0.15s, background 0.15s;
}
button:hover { filter: brightness(1.08); }
button.ghost { background: var(--panel-2); color: var(--text); }
button.ghost:hover { background: var(--line); }
button.danger { color: var(--crit); }
button.full { width: 100%; margin-top: 0.5rem; }

input {
  width: 100%;
  font: inherit;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  padding: 0.7rem 0.9rem;
  margin: 0.35rem 0;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea {
  width: 100%; font: inherit; font-size: 0.8rem; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 12px; color: var(--text);
  padding: 0.7rem 0.9rem; margin: 0.35rem 0; resize: vertical; min-height: 70px;
}
code { background: var(--panel-2); padding: 0.1em 0.35em; border-radius: 6px; font-size: 0.85em; }

/* ---- Login ---- */
.login { display: grid; place-items: center; min-height: 100dvh; padding: 1.5rem; }
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2rem;
  width: min(380px, 100%);
  display: flex; flex-direction: column; gap: 0.6rem;
}
.login-card h1 { font-size: 1.4rem; }

/* ---- App shell ---- */
.app { max-width: 720px; margin: 0 auto; padding: 1rem; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 0.25rem 1rem; }
.brand { display: flex; align-items: center; gap: 0.6rem; }
.brand h1 { font-size: 1.25rem; letter-spacing: -0.02em; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.actions { display: flex; gap: 0.5rem; }
.actions .ghost { padding: 0.5rem 0.75rem; font-size: 1.1rem; line-height: 1; }

.providers { display: flex; flex-direction: column; gap: 1.25rem; }

.provider-block h2 {
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--muted); margin: 0 0.25rem 0.6rem;
}
.provider-block .pill {
  font-size: 0.7rem; padding: 0.15em 0.6em; border-radius: 999px;
  background: var(--panel-2); color: var(--muted); margin-left: 0.5rem;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 0.75rem;
}
.metric-top { display: flex; justify-content: space-between; align-items: baseline; }
.metric-label { font-weight: 600; }
.metric-pct { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
.metric-pct.safe { color: var(--safe); }
.metric-pct.warn { color: var(--warn); }
.metric-pct.crit { color: var(--crit); }

.bar { height: 8px; background: var(--panel-2); border-radius: 999px; overflow: hidden; margin: 0.7rem 0 0.5rem; }
.bar > span { display: block; height: 100%; border-radius: 999px; transition: width 0.5s ease; }
.bar > span.safe { background: var(--safe); }
.bar > span.warn { background: var(--warn); }
.bar > span.crit { background: var(--crit); }

.metric-foot { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--muted); }

.metric.pending { opacity: 0.6; }
.metric-pct.muted { color: var(--muted); font-weight: 600; }
.note { margin: 0.25rem 0.25rem 0; }
.pct-unit { font-size: 0.6em; font-weight: 600; color: var(--muted); margin-left: 0.3em; text-transform: uppercase; letter-spacing: 0.05em; }
.subtitle { margin: 0 0.25rem 1rem; }

/* ---- Trend chart ---- */
.trend { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; margin-top: 0.5rem; }
.trend-head { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; }
.trend-head h2 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); }
#chart-metric { width: auto; max-width: 60%; margin: 0; padding: 0.4rem 0.6rem; font-size: 0.82rem; }
.ranges { display: flex; gap: 0.4rem; margin: 0.75rem 0; flex-wrap: wrap; }
.range-btn { background: var(--panel-2); color: var(--muted); padding: 0.35rem 0.7rem; font-size: 0.8rem; border-radius: 9px; }
.range-btn.active { background: var(--accent); color: #1a1a1a; }
#chart { width: 100%; height: 160px; display: block; }

.empty, .err-row {
  background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 1.25rem; text-align: center; color: var(--muted);
}
.err-row { border-style: solid; color: var(--crit); }

.foot { display: flex; justify-content: space-between; padding: 1.25rem 0.25rem; font-size: 0.78rem; }

/* ---- Drawer ---- */
.drawer { position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: flex; justify-content: flex-end; z-index: 50; }
.drawer-panel {
  background: var(--bg); width: min(420px, 100%); height: 100%; overflow-y: auto;
  padding: 1.25rem; border-left: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 1rem;
}
.drawer-head { display: flex; justify-content: space-between; align-items: center; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; }
.card h3 { margin-bottom: 0.5rem; }
.card .row { display: flex; gap: 0.5rem; margin-top: 0.4rem; }
.status { font-size: 0.82rem; margin-top: 0.5rem; min-height: 1.2em; }
.status.ok { color: var(--safe); }
.status.bad { color: var(--crit); }

/* ---- How-to + toast ---- */
.howto { margin-top: 0.85rem; }
.howto summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 0.85rem; }
.howto ol { margin: 0.6rem 0 0.4rem 1.1rem; display: flex; flex-direction: column; gap: 0.3rem; }
.howto kbd {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 5px;
  padding: 0.05em 0.4em; font-size: 0.8em;
}
.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%);
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  padding: 0.7rem 1.1rem; border-radius: 12px; z-index: 100; max-width: 90vw;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}
.toast.bad { border-color: var(--crit); color: var(--crit); }
