/* Roofing Supplement AI - operator console theme.
   Self-hosted Poppins (CSP-safe: served from /static, no external CDN). */

@font-face {
  font-family: "Poppins"; font-style: normal; font-weight: 400;
  font-display: swap; src: url("/static/fonts/poppins-400.woff2") format("woff2");
}
@font-face {
  font-family: "Poppins"; font-style: normal; font-weight: 500;
  font-display: swap; src: url("/static/fonts/poppins-500.woff2") format("woff2");
}
@font-face {
  font-family: "Poppins"; font-style: normal; font-weight: 600;
  font-display: swap; src: url("/static/fonts/poppins-600.woff2") format("woff2");
}
@font-face {
  font-family: "Poppins"; font-style: normal; font-weight: 700;
  font-display: swap; src: url("/static/fonts/poppins-700.woff2") format("woff2");
}

:root {
  /* Brand */
  --blue: #0B5ACF;
  --blue-hover: #0949a8;
  --blue-tint: #eaf1fc;
  --blue-border: #cddffb;
  /* Surfaces */
  --bg: #fffff5;
  --surface: #ffffff;
  --surface-2: #fbfbf3;
  /* Text */
  --ink: #16233b;
  --muted: #5d6772;
  /* Lines */
  --line: #e9e6d6;
  --line-cool: #eceef3;
  /* Semantic */
  --ok: #157a4e; --ok-bg: #e9f7ef; --ok-line: #c2e6d1;
  --warn: #8a6912; --warn-bg: #fbf3db; --warn-line: #ecd9a1;
  --err: #b23b3b; --err-bg: #fcecec; --err-line: #f1c9c9;
  /* Scale */
  --r: 12px; --r-sm: 8px; --r-pill: 999px;
  --shadow: 0 1px 2px rgba(16, 35, 59, .05), 0 2px 6px rgba(16, 35, 59, .05);
  --ring: 0 0 0 3px rgba(11, 90, 207, .22);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Poppins", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---- Top bar ---------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600;
  letter-spacing: -0.01em; color: var(--ink); }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--blue); color: #fff;
}
.brand-mark svg { width: 18px; height: 18px; }
.env {
  font-size: 12px; font-weight: 500; color: var(--blue);
  background: var(--blue-tint); border: 1px solid var(--blue-border);
  border-radius: var(--r-pill); padding: 3px 12px;
}

/* ---- Layout ----------------------------------------------------------- */
.wrap { max-width: 1040px; margin: 28px auto 64px; padding: 0 24px; }
h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; margin: 0; }
h2 { font-size: 15px; font-weight: 600; letter-spacing: -0.01em;
  margin: 28px 0 10px; color: var(--ink); }
h3 { font-size: 13px; font-weight: 600; margin: 0 0 6px; }
.rowbar { display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline { display: inline; margin: 0; }
.muted { color: var(--muted); font-size: 13px; }

/* ---- Icons ------------------------------------------------------------ */
.icon {
  width: 1.05em; height: 1.05em; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
  vertical-align: -0.15em;
}

/* ---- Buttons ---------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--blue); color: #fff; text-decoration: none;
  border: 1px solid var(--blue); border-radius: var(--r-sm);
  padding: 9px 14px; font: inherit; font-weight: 500; font-size: 13.5px;
  cursor: pointer; transition: background .12s ease, box-shadow .12s ease,
    border-color .12s ease, transform .04s ease;
}
.btn:hover { background: var(--blue-hover); border-color: var(--blue-hover); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn .icon { width: 16px; height: 16px; }
.btn.ghost { background: var(--surface); color: var(--blue); border-color: var(--blue-border); }
.btn.ghost:hover { background: var(--blue-tint); border-color: var(--blue); }
.btn.subtle { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn.subtle:hover { background: var(--surface-2); border-color: var(--muted); }
.btn.danger { background: var(--err); border-color: var(--err); }
.btn.danger:hover { background: #9c2f2f; border-color: #9c2f2f; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.block { width: 100%; justify-content: center; }

/* ---- Cards ------------------------------------------------------------ */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 20px; box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card h2 { margin-top: 0; }
.card.danger { border-color: var(--err-line); background: #fffafa; }
.card.danger h2 { color: var(--err); }

/* ---- Forms ------------------------------------------------------------ */
.form label { display: block; margin-bottom: 14px; font-size: 13px;
  font-weight: 500; color: var(--ink); }
.form input, .form select {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px;
  font: inherit; font-size: 14px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-sm); transition: border-color .12s ease, box-shadow .12s ease;
}
.form input::placeholder { color: #9aa2ae; }
.form input:focus, .form select:focus {
  outline: none; border-color: var(--blue); box-shadow: var(--ring);
}
.form button { margin-top: 4px; }
.confirm { display: flex; align-items: flex-start; gap: 8px; font-weight: 500;
  margin: 4px 0 14px; }
.confirm input { width: auto; margin: 3px 0 0; }

/* ---- Alerts ----------------------------------------------------------- */
.alert { border-radius: var(--r-sm); padding: 12px 14px; margin-bottom: 18px;
  font-size: 13.5px; border: 1px solid transparent; }
.alert.error { background: var(--err-bg); border-color: var(--err-line); color: var(--err); }
.alert.ok { background: var(--ok-bg); border-color: var(--ok-line); color: #0f5f3c; }
.alert a { color: inherit; font-weight: 600; }

/* ---- One-time link box ------------------------------------------------ */
.linkbox { display: flex; gap: 8px; margin: 10px 0; }
.linkbox input {
  flex: 1; padding: 9px 11px; border: 1px solid var(--ok-line);
  border-radius: var(--r-sm); background: #fff;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 12.5px;
}
.linkbox button {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--blue-border); background: var(--surface); color: var(--blue);
  border-radius: var(--r-sm); padding: 9px 13px; font: inherit; font-weight: 500;
  font-size: 13px; cursor: pointer;
}
.linkbox button:hover { background: var(--blue-tint); }

/* ---- Tables ----------------------------------------------------------- */
.table-scroll { overflow-x: auto; border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow); background: var(--surface); }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th, table.grid td {
  border-bottom: 1px solid var(--line-cool); padding: 11px 14px;
  text-align: left; white-space: nowrap; }
table.grid thead th {
  background: var(--blue-tint); color: var(--blue);
  font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
}
table.grid tbody tr:last-child td { border-bottom: none; }
table.grid tbody tr:hover { background: var(--surface-2); }
table.grid a { color: var(--blue); font-weight: 500; text-decoration: none;
  display: inline-flex; align-items: center; gap: 4px; }
table.grid a:hover { text-decoration: underline; }

/* ---- Status + badges -------------------------------------------------- */
.status { display: inline-block; font-weight: 500; padding: 2px 10px;
  border-radius: var(--r-pill); background: var(--line-cool); color: var(--ink);
  font-size: 12px; }
.badge { display: inline-block; font-size: 10.5px; font-weight: 600;
  border-radius: var(--r-pill); padding: 2px 9px; text-transform: uppercase;
  letter-spacing: 0.04em; }
.badge.ok { background: var(--ok-bg); color: var(--ok); border: 1px solid var(--ok-line); }
.badge.warn { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-line); }

/* ---- Key/value list --------------------------------------------------- */
.kv { display: flex; justify-content: space-between; gap: 16px;
  padding: 9px 0; border-bottom: 1px solid var(--line-cool); font-size: 13.5px; }
.kv:last-child { border-bottom: none; }
.kv > span { color: var(--muted); }
.kv > b { font-weight: 500; text-align: right; }

/* ---- Freshness -------------------------------------------------------- */
.fresh-fresh { color: var(--ok); }
.fresh-warn { color: var(--warn); }
.fresh-stale { color: var(--err); }
.fresh-sample { color: var(--muted); }

/* ---- Login ------------------------------------------------------------ */
.login-shell { max-width: 400px; margin: 8vh auto 0; padding: 0 20px; }
.login-shell .login-head { text-align: center; margin-bottom: 20px; }
.login-shell .brand-mark { width: 44px; height: 44px; border-radius: 12px; margin: 0 auto 14px; }
.login-shell .brand-mark svg { width: 24px; height: 24px; }
.login-shell h1 { font-size: 20px; }
.login-shell .muted { margin-top: 6px; }

/* ---- Responsive ------------------------------------------------------- */
@media (max-width: 640px) {
  .wrap { padding: 0 16px; margin-top: 20px; }
  .topbar { padding: 12px 16px; }
  h1 { font-size: 21px; }
  .rowbar { align-items: stretch; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
