/*
 * Ikigai "premium clinical" design system (CLAUDE.md → UI design system). Every page loads this
 * first; pages only add their own layout. Served at /assets/ikigai.css.
 * Crisp, precise, calm: grey page, white cards, hairlines, soft radii, pill controls.
 * No cream, no serif headings, no shadows, no gradients, no emoji.
 * The PDF case note (src/core/pdf.ts) keeps its own copy of the colours.
 */
@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap");

:root {
  /* Feature colour: the logo teal. Text on it is always --on-brand (white fails contrast). */
  --brand: #5BBFB5;
  --on-brand: #0E2A27;
  --brand-hover: #4FB0A6;
  --teal-ink: #1F7A72;       /* links and teal text on white */
  --teal-ink-hover: #145C55;
  --teal-tint: #E6F5F3;      /* selected rows, in-progress chips */

  --text: #1D2A2E;
  --text-2: #5B6B70;         /* secondary text */
  --page: #E8EDEE;
  --page-outer: #DDE4E5;
  --surface: #FFFFFF;
  --hairline: #E3E8E9;
  --input-line: #C5CFD2;

  /* Status: background / text pairs, all 4.5:1 or better */
  --action-bg: #FFF4E0;  --action: #8A5300;   /* needs action */
  --problem-bg: #FDECEA; --problem: #B3261E;  /* problem: QC fail, overdue, errors */
  --done-bg: #E8F5EC;    --done: #1E7B3C;     /* done: passed QC, dispatched */

  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;

  --r-card: 24px;
  --r-panel: 18px;
  --r-input: 12px;
  --r-pill: 999px;
  --touch: 44px;
}

* { box-sizing: border-box; }
html { background: var(--page-outer); }
body {
  margin: 0; min-height: 100vh;
  font: 400 14px/1.5 var(--font); color: var(--text); background: var(--page);
  font-feature-settings: "tnum"; -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font); font-weight: 600; letter-spacing: -0.02em; color: var(--text); margin: 0; }
h1 { font-size: 30px; line-height: 1.2; }
h2 { font-size: 18px; line-height: 1.3; }
h3 { font-size: 15px; line-height: 1.35; }
a { color: var(--teal-ink); }
a:hover { color: var(--teal-ink-hover); }
.mono { font-family: var(--mono); font-feature-settings: normal; }
.muted { color: var(--text-2); }
.micro { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-2); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------------------------------------------------------------- Top bar */
.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--hairline);
}
.wordmark { font: 700 13px/1 var(--font); letter-spacing: 0.26em; color: var(--text); text-decoration: none; white-space: nowrap; }
.wordmark:hover { color: var(--text); }
.nav { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--hairline); border-radius: var(--r-pill); background: var(--page); flex-wrap: wrap; }
.nav a { display: inline-flex; align-items: center; min-height: 36px; padding: 0 16px; border-radius: var(--r-pill); color: var(--text-2); font-weight: 500; text-decoration: none; }
.nav a:hover { color: var(--text); background: var(--surface); }
.nav a[aria-current="page"] { background: var(--brand); color: var(--on-brand); font-weight: 600; }
.topbar .spacer { flex: 1; }
.me { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13px; }
.avatar { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-pill); background: var(--teal-tint); color: var(--teal-ink); font-weight: 600; font-size: 13px; flex: none; }

/* ---------------------------------------------------------------- Page frame */
.page { max-width: 1320px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { margin: 6px 0 0; color: var(--text-2); }

.card { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-card); padding: 24px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.panel { border: 1px solid var(--hairline); border-radius: var(--r-panel); padding: 16px 18px; background: var(--surface); }
.empty { color: var(--text-2); padding: 24px 0; text-align: center; }

/* ---------------------------------------------------------------- Buttons */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--touch); padding: 0 18px; border-radius: var(--r-pill);
  border: 1px solid var(--hairline); background: var(--surface); color: var(--teal-ink);
  font: 500 14px/1 var(--font); text-decoration: none; cursor: pointer; white-space: nowrap;
}
button:hover, .btn:hover { border-color: var(--input-line); color: var(--teal-ink-hover); background: var(--surface); }
button.primary, .btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); font-weight: 600; }
button.primary:hover, .btn.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); color: var(--on-brand); }
button.small, .btn.small { min-height: 36px; padding: 0 14px; font-size: 13px; }
label.btn { margin: 0; text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--teal-ink); }
button.link { min-height: auto; padding: 0; border: 0; background: none; color: var(--teal-ink); text-decoration: underline; font-weight: 500; }
button:disabled { opacity: .55; cursor: default; }
@media (pointer: coarse) { button.small, .btn.small { min-height: var(--touch); } }

/* ---------------------------------------------------------------- Chips */
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: var(--r-pill); font-size: 12px; font-weight: 600; line-height: 1.4; background: var(--page); color: var(--text-2); white-space: nowrap; }
.chip.progress { background: var(--teal-tint); color: var(--teal-ink); }
.chip.action { background: var(--action-bg); color: var(--action); }
.chip.problem { background: var(--problem-bg); color: var(--problem); }
.chip.done { background: var(--done-bg); color: var(--done); }

/* ---------------------------------------------------------------- Forms */
label, .label { display: block; margin: 16px 0 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-2); }
label small, .label small { text-transform: none; letter-spacing: 0; font-weight: 400; }
input, select, textarea {
  width: 100%; min-height: var(--touch); padding: 10px 14px;
  font: 400 14px/1.4 var(--font); color: var(--text); background: var(--surface);
  border: 1px solid var(--input-line); border-radius: var(--r-input);
}
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
input[type="checkbox"] { width: 18px; min-height: 18px; height: 18px; accent-color: var(--teal-ink); }
.error-text { color: var(--problem); font-size: 13px; }

/* ---------------------------------------------------------------- Tables */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 10px 12px; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-2); border-bottom: 1px solid var(--hairline); }
td { text-align: left; padding: 12px; border-bottom: 1px solid var(--hairline); vertical-align: top; }
tr:last-child td { border-bottom: 0; }

/* ---------------------------------------------------------------- Dialogs */
dialog { border: 1px solid var(--hairline); border-radius: var(--r-card); padding: 28px; width: min(460px, calc(100vw - 32px)); color: var(--text); background: var(--surface); }
dialog::backdrop { background: rgba(29, 42, 46, .32); }

@media (max-width: 720px) {
  .topbar { padding: 10px 16px; gap: 10px; }
  .page { padding: 16px; }
  .card { padding: 18px; border-radius: 20px; }
  h1 { font-size: 26px; }
}
