/* ============================================================
   HOUSE STYLE — base.css  (Mina's shared design system)
   Light theme is DEFAULT (standing rule); dark = <html data-theme="dark">.
   Per product: override --accentH / --accentS only.
   Copy-paste markup for every component: components.html
   ============================================================ */

/* ---------- Tokens ---------- */
:root {
  /* accent: per-product hue/sat; lightness flips per theme for contrast */
  --accentH: 243; --accentS: 75%; --accentL: 46%;
  --accent: hsl(var(--accentH) var(--accentS) var(--accentL));
  --accent-hover: hsl(var(--accentH) var(--accentS) calc(var(--accentL) - 6%));
  --accent-soft: hsl(var(--accentH) var(--accentS) var(--accentL) / .12);
  --on-accent: #fff;

  /* neutrals — light (DEFAULT) */
  --bg: #f7f7f8; --surface: #ffffff; --surface-2: #f0f0f3;
  --text: #1a1a1f; --text-2: #55555f; --text-3: #8e8e99;
  --border: #e3e3e9; --border-strong: #cfcfd8;

  /* status */
  --ok: #15803d; --warn: #b45309; --bad: #b91c1c;
  --ok-soft: rgb(21 128 61 / .12);
  --warn-soft: rgb(180 83 9 / .12);
  --bad-soft: rgb(185 28 28 / .12);

  /* shape + depth */
  --radius: 10px; --radius-sm: 6px; --radius-full: 999px;
  --shadow-1: 0 1px 2px rgb(16 16 20 / .06);
  --shadow-2: 0 6px 20px rgb(16 16 20 / .10);

  --container: 1080px;
  color-scheme: light;
}

[data-theme="dark"] {
  --accentL: 62%;
  --bg: #131316; --surface: #1c1c21; --surface-2: #26262d;
  --text: #f2f2f4; --text-2: #a3a3ae; --text-3: #71717c;
  --border: #2c2c34; --border-strong: #3d3d47;
  --ok: #4ade80; --warn: #fbbf24; --bad: #f87171;
  --ok-soft: rgb(74 222 128 / .14);
  --warn-soft: rgb(251 191 36 / .14);
  --bad-soft: rgb(248 113 113 / .14);
  --shadow-1: none;
  --shadow-2: 0 6px 20px rgb(0 0 0 / .45);
  color-scheme: dark;
}

/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 400 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  min-height: 100svh;
  -webkit-font-smoothing: antialiased;
}
img, svg, video { display: block; max-width: 100%; }
input, button, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ---------- Type ---------- */
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.02em; text-wrap: balance; }
h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); font-weight: 700; }
h2 { font-size: clamp(1.35rem, 3vw, 1.6rem); font-weight: 700; }
h3 { font-size: 1.125rem; font-weight: 600; }
p { text-wrap: pretty; }
.lead { font-size: 1.125rem; color: var(--text-2); }
.muted { color: var(--text-2); }
.small, small { font-size: .875rem; }
.label {
  font-size: .75rem; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-3);
}
.num { font-variant-numeric: tabular-nums; }
.prose { max-width: 65ch; }

/* ---------- Layout ---------- */
.container { max-width: var(--container); margin-inline: auto; padding-inline: 20px; }
.section { padding-block: 64px; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50; height: 60px;
  display: flex; align-items: center;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header .container {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
}
.brand { font-weight: 700; font-size: 1.05rem; color: var(--text); letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px; border: 1px solid transparent;
  border-radius: var(--radius); background: var(--accent); color: var(--on-accent);
  font-weight: 600; cursor: pointer; text-decoration: none;
  transition: background .15s ease, transform .15s ease, box-shadow .15s ease;
}
.btn:hover {
  background: var(--accent-hover); text-decoration: none;
  transform: translateY(-1px); box-shadow: var(--shadow-1);
}
.btn:active { transform: none; }
.btn:disabled, .btn[aria-busy="true"] { opacity: .6; cursor: not-allowed; transform: none; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { min-height: 34px; padding: 0 12px; border-radius: var(--radius-sm); font-size: .875rem; }
.spin {
  width: 16px; height: 16px; flex: none;
  border: 2px solid rgb(255 255 255 / .4); border-top-color: #fff;
  border-radius: 50%; animation: spin .7s linear infinite;
}
.btn-secondary .spin, .btn-ghost .spin { border-color: var(--border-strong); border-top-color: var(--text-2); }
@keyframes spin { to { transform: rotate(1turn); } }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; }
.field label { font-weight: 600; font-size: .9rem; }
.input,
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="url"], input[type="search"],
select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { min-height: 96px; resize: vertical; }
.input:focus, input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field .hint { font-size: .8rem; color: var(--text-3); }
.field.error .input, .field.error input { border-color: var(--bad); }
.field .error-msg { font-size: .8rem; color: var(--bad); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-1); padding: 24px;
}
.card h3 { margin-bottom: 8px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px;
  border-radius: var(--radius-full); font-size: .8rem; font-weight: 600;
  background: var(--surface-2); color: var(--text-2);
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

/* ---------- Progress bars (HOUSE RULE: any wait >1s; any metric with a target) ---------- */
.pbar { height: 8px; background: var(--surface-2); border-radius: var(--radius-full); overflow: hidden; }
.pbar > span {
  display: block; height: 100%; width: 0; background: var(--accent);
  border-radius: inherit; transition: width .3s ease;
}
.pbar.indet > span { width: 40%; animation: pbar-slide 1.1s ease-in-out infinite; }
@keyframes pbar-slide { from { margin-left: -40%; } to { margin-left: 100%; } }
.pbar.ok > span { background: var(--ok); }
.pbar.warn > span { background: var(--warn); }
.pbar.bad > span { background: var(--bad); }
.metric { display: grid; gap: 6px; }
.metric .metric-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.metric .metric-head b { font-variant-numeric: tabular-nums; }

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
}
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); }
th {
  font-size: .75rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-3); background: var(--surface-2);
  position: sticky; top: 0;
}
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; top: 72px; right: 20px; z-index: 100;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-2);
  padding: 12px 16px; max-width: 320px;
  animation: toast-in .2s ease;
}
.toast.ok { border-left-color: var(--ok); }
.toast.bad { border-left-color: var(--bad); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } }

/* ---------- Skeleton & empty states ---------- */
.skeleton {
  border-radius: var(--radius-sm); color: transparent !important;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%);
  background-size: 200% 100%; animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.empty { text-align: center; padding: 48px 20px; color: var(--text-2); }
.empty .empty-icon { font-size: 2rem; margin-bottom: 8px; }

/* ---------- Theme toggle ---------- */
.theme-toggle {
  width: 38px; height: 38px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--border-strong);
  border-radius: var(--radius-full); cursor: pointer; font-size: 1rem;
  transition: background .15s ease;
}
.theme-toggle:hover { background: var(--surface-2); }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border); margin-top: 64px;
  padding: 32px 0; color: var(--text-3); font-size: .875rem;
}

/* ---------- Motion & mobile ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
@media (max-width: 640px) {
  .section { padding-block: 40px; }
  .card { padding: 18px; }
  .toast { left: 20px; right: 20px; max-width: none; }
}
