/* eTRUE design system: tokens and components shared by every page.
   Page stylesheets (dashboard/styles.css, annotation/styles.css) build on these. */

:root {
  /* Surfaces */
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-muted: #f7f8fa;
  --surface-sunken: #eef1f4;
  --line: #dfe3e8;
  --line-strong: #c7ced6;

  /* Text */
  --ink: #17202a;
  --ink-soft: #3a4553;
  --muted: #5d6877;
  --faint: #8a94a1;

  /* Accent */
  --accent: #0f5f6e;
  --accent-hover: #0b4d59;
  --accent-soft: #e4f1f3;
  --accent-line: #b7d6dc;
  --on-accent: #ffffff;

  /* Semantic */
  --success: #23704a;
  --success-soft: #e3f2e9;
  --success-line: #b7dcc5;
  --warning: #8a5a00;
  --warning-soft: #fbf0d6;
  --warning-line: #e9c97a;
  --danger: #b1352b;
  --danger-hover: #952a21;
  --danger-soft: #fbe8e6;
  --danger-line: #eeb4ad;
  --info: #2d5b94;
  --info-soft: #e6eef8;
  --info-line: #c4d6ee;

  /* Shape and depth */
  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 10px;
  --shadow-sm: 0 1px 2px rgb(16 24 40 / 6%);
  --shadow: 0 1px 3px rgb(16 24 40 / 8%), 0 1px 2px rgb(16 24 40 / 4%);
  --shadow-lg: 0 16px 40px rgb(16 24 40 / 16%);
  --focus-ring: 0 0 0 3px rgb(15 95 110 / 26%);

  /* Type */
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-md: 14px;
  --text-base: 15px;
  --text-lg: 17px;
  --text-xl: 20px;
  --text-2xl: 26px;
  --text-3xl: 32px;

  /* Layout */
  --header-height: 60px;
  --sticky-top: var(--header-height);
}

*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: light; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { color: inherit; font-weight: 600; letter-spacing: -0.01em; line-height: 1.25; }
button, input, select, textarea { color: inherit; font: inherit; }
button { cursor: pointer; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); }
[hidden] { display: none !important; }
code, pre, kbd, samp { font-family: var(--font-mono); font-size: 0.92em; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Application header (all pages) */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 28px;
  min-height: var(--header-height);
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 10px;
  width: max-content;
  color: var(--ink);
  text-decoration: none;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  color: var(--on-accent);
  background: var(--accent);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.04em;
}
.brand strong, .brand small { display: block; line-height: 1.2; }
.brand strong { font-size: var(--text-base); font-weight: 700; letter-spacing: 0.01em; }
.brand small { color: var(--muted); font-size: var(--text-xs); }
.app-nav { display: flex; align-self: stretch; gap: 2px; }
.app-nav a {
  display: inline-flex;
  align-items: center;
  margin-bottom: -1px;
  padding: 0 12px;
  color: var(--ink-soft);
  border-bottom: 2px solid transparent;
  font-size: var(--text-md);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.app-nav a:hover { color: var(--ink); background: var(--surface-muted); }
.app-nav a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.app-header-end {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
  font-size: var(--text-md);
}
.app-header-end form { margin: 0; }
.account-name { color: var(--muted); white-space: nowrap; }
.link-button {
  padding: 0;
  color: var(--ink-soft);
  background: none;
  border: 0;
  font-weight: 500;
}
.link-button:hover { color: var(--accent); text-decoration: underline; }
.save-state { color: var(--muted); font-size: var(--text-sm); font-weight: 500; white-space: nowrap; }
.save-state.saving { color: var(--info); }
.save-state.error { color: var(--danger); }

/* Buttons */
.primary, .secondary, .danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 7px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: var(--text-md);
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.primary { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }
.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.secondary { color: var(--ink); background: var(--surface); border-color: var(--line-strong); }
.secondary:hover:not(:disabled) { background: var(--surface-muted); border-color: var(--faint); }
.danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.danger:hover:not(:disabled) { background: var(--danger-hover); border-color: var(--danger-hover); }
button:disabled { cursor: not-allowed; opacity: 0.5; }
.icon-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-size: 18px;
  line-height: 1;
}
.icon-button:hover { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-line); }

/* Form controls */
label { display: grid; gap: 6px; color: var(--ink-soft); font-size: var(--text-md); font-weight: 500; }
input, select, textarea {
  width: 100%;
  min-height: 36px;
  padding: 7px 10px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; margin: 0; accent-color: var(--accent); }
textarea { min-height: 80px; line-height: 1.5; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: var(--focus-ring); }
input:disabled, select:disabled, textarea:disabled { color: var(--muted); background: var(--surface-muted); }
.form-error {
  margin: 0;
  padding: 9px 12px;
  color: var(--danger) !important;
  background: var(--danger-soft);
  border: 1px solid var(--danger-line);
  border-radius: var(--radius);
  font-size: var(--text-sm);
}

/* Workflow and job status badges */
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: max-content;
  padding: 1px 8px;
  color: var(--ink-soft);
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
}
.status::before { width: 6px; height: 6px; background: currentColor; border-radius: 50%; content: ""; }
.status.annotating, .status.reviewing, .status.running { color: var(--info); background: var(--info-soft); border-color: var(--info-line); }
.status.awaiting_review, .status.needs_adjudication, .status.pending { color: var(--warning); background: var(--warning-soft); border-color: var(--warning-line); }
.status.changes_requested, .status.failed { color: var(--danger); background: var(--danger-soft); border-color: var(--danger-line); }
.status.approved, .status.done { color: var(--success); background: var(--success-soft); border-color: var(--success-line); }

/* Overlays */
dialog {
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: 0;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgb(15 23 32 / 55%); }
#toast, .toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 60;
  max-width: min(420px, calc(100vw - 40px));
  padding: 11px 14px;
  color: #fff;
  background: var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-md);
}

@media (max-width: 760px) {
  :root { --sticky-top: 0px; }
  .app-header { position: static; flex-wrap: wrap; gap: 0 12px; padding: 10px 14px 0; }
  .app-header-end { gap: 12px; }
  .account-name { display: none; }
  .app-nav {
    order: 3;
    width: calc(100% + 28px);
    min-height: 44px;
    margin: 10px -14px 0;
    padding: 0 6px;
    overflow-x: auto;
    border-top: 1px solid var(--line);
  }
  .save-state {
    position: fixed;
    right: 12px;
    bottom: 12px;
    z-index: 45;
    padding: 6px 10px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
