/* Siwon Cases: the one stylesheet (no build step, no external resources: CSP default-src 'self').
   Identity: docs/BRAND.md. Palette from Siwon's website (royal #1E42A6, bright #3399FE, ink #101014); type: Inter. */

/* ---- fonts: Inter (OFL, static/fonts/Inter-OFL.txt), variable weight 100-900 ----------------------------------- */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("/static/fonts/inter-latin-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("/static/fonts/inter-latin-ext-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---- tokens --------------------------------------------------------------------------------------------------- */
:root {
  color-scheme: light;

  --brand-50: #eef4ff;
  --brand-100: #dce8ff;
  --brand-200: #bdd4ff;
  --brand-300: #8fb8ff;
  --brand-400: #3399fe;   /* bright */
  --brand-500: #2a6be0;
  --brand-600: #1e42a6;   /* royal: the primary colour */
  --brand-700: #183789;
  --brand-800: #142d6e;
  --brand-900: #0f2152;

  --ink: #101014;
  --text: #1f2430;
  --muted: #5b6475;
  --subtle: #8a93a3;
  --line: #e4e7ec;
  --line-strong: #d0d5dd;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f9fafb;

  --success: #11734f;  --success-bg: #e7f6ee;  --success-line: #b5e3cb;
  --warning: #a24a06;  --warning-bg: #fef3e2;  --warning-line: #f7d29b;
  --danger: #b42318;   --danger-bg: #fdeceb;   --danger-line: #f5c0bb;
  --info: var(--brand-600); --info-bg: var(--brand-50); --info-line: var(--brand-200);
  --violet: #5b3fc4;   --violet-bg: #f0ecfd;
  --teal: #0b6e79;     --teal-bg: #e3f5f6;

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Apple SD Gothic Neo", "Malgun Gothic",
    "Noto Sans KR", "Noto Sans CJK KR", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 12px 32px -8px rgba(16, 24, 40, 0.18), 0 4px 8px -4px rgba(16, 24, 40, 0.08);
  --ring: 0 0 0 3px rgba(51, 153, 254, 0.35);

  --header-h: 60px;
  --content-w: 1280px;
}

/* ---- base ----------------------------------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  font-feature-settings: "cv11", "ss01";  /* Inter: single-storey a, open digits */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4 { color: var(--ink); line-height: 1.25; margin: 0 0 0.5rem; letter-spacing: -0.011em; }
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0 0 0.75rem; }
a { color: var(--brand-600); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--brand-700); }
img, svg { display: block; max-width: 100%; }
code, .mono { font-family: var(--font-mono); font-size: 0.9em; }
strong, b { font-weight: 600; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.25rem 0; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-sm); }
.icon { width: 18px; height: 18px; flex: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
.muted { color: var(--muted); }
.subtle { color: var(--subtle); }
.small { font-size: 0.85rem; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

/* ---- app shell: header ---------------------------------------------------------------------------------------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.app-header-inner {
  display: flex;
  align-items: center;
  gap: 1.75rem;
  height: var(--header-h);
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 0 1.5rem;
}
.brand { display: flex; align-items: center; gap: 0.6rem; text-decoration: none; flex: none; }
.brand img { width: 32px; height: 32px; }
.brand-name { font-size: 1.05rem; font-weight: 700; color: var(--ink); letter-spacing: -0.015em; white-space: nowrap; }
.brand-name span { color: var(--brand-600); font-weight: 600; }

.app-nav { display: flex; align-items: stretch; gap: 0.25rem; height: 100%; flex: 1; min-width: 0; overflow-x: auto; }
.app-nav a {
  display: flex;
  align-items: center;
  padding: 0 0.75rem;
  color: var(--muted);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.app-nav a:hover { color: var(--ink); }
.app-nav a[aria-current="page"] { color: var(--brand-600); border-bottom-color: var(--brand-600); }

/* user menu: a <details> dropdown (static/app.js closes it on outside click / Escape) */
.user-menu { position: relative; margin-left: auto; flex: none; }
.user-menu > summary {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.3rem 0.5rem 0.3rem 0.3rem;
  border-radius: 999px;
  cursor: pointer;
  list-style: none;
}
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu > summary:hover, .user-menu[open] > summary { background: var(--surface-2); }
.user-menu .chev { width: 16px; height: 16px; color: var(--subtle); transition: transform 150ms ease; }
.user-menu[open] .chev { transform: rotate(180deg); }
.user-summary-name { font-weight: 600; color: var(--ink); font-size: 0.9rem; line-height: 1.2; }
.user-summary-role { color: var(--muted); font-size: 0.78rem; line-height: 1.2; text-transform: capitalize; }
.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 260px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 0.4rem;
}
.menu-head { padding: 0.6rem 0.7rem 0.7rem; border-bottom: 1px solid var(--line); margin-bottom: 0.35rem; }
.menu-head .email { color: var(--muted); font-size: 0.85rem; word-break: break-all; }
.menu-item {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.7rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.menu-item:hover { background: var(--surface-2); color: var(--ink); }
.menu-item .icon { width: 16px; height: 16px; color: var(--muted); }

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--brand-400), var(--brand-600));
  color: #fff;
  font-size: 0.8rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  flex: none;
}
.avatar.lg { width: 48px; height: 48px; font-size: 1.05rem; }

/* ---- page ----------------------------------------------------------------------------------------------------- */
.page { flex: 1; width: 100%; max-width: var(--content-w); margin: 0 auto; padding: 2rem 1.5rem 3rem; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-header h1 { margin: 0; }
.page-header .lede { color: var(--muted); margin: 0.3rem 0 0; }
.eyebrow { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--brand-600); margin-bottom: 0.35rem; }
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.grid { display: grid; gap: 1.25rem; align-items: start; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.sidebar { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }

.app-footer { border-top: 1px solid var(--line); background: var(--surface); }
.app-footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 1rem 1.5rem;
  color: var(--subtle);
  font-size: 0.8rem;
}

/* ---- cards ---------------------------------------------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-body { padding: 1.25rem 1.4rem; }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.4rem;
  border-bottom: 1px solid var(--line);
}
.card-header h2, .card-header h3 { margin: 0; font-size: 1rem; }
.card-footer { padding: 0.85rem 1.4rem; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* a person: avatar + name */
.profile { display: flex; align-items: center; gap: 0.85rem; margin-bottom: 1.25rem; }
.profile-name { font-weight: 650; color: var(--ink); font-size: 1.02rem; }

/* key / value list */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 0.6rem 1.5rem; margin: 0; }
.kv dt { color: var(--muted); font-size: 0.875rem; }
.kv dd { margin: 0; color: var(--ink); font-weight: 500; min-width: 0; overflow-wrap: anywhere; }

/* a list of items with an icon */
.feature-list { list-style: none; margin: 0; padding: 0; }
.feature-list li { display: flex; gap: 0.85rem; padding: 0.85rem 0; border-top: 1px solid var(--line); }
.feature-list li:first-child { border-top: 0; padding-top: 0.2rem; }
.feature-list .feature-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: var(--brand-50);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.feature-list .feature-icon { color: var(--brand-600); }
.feature-list .feature-icon .icon { width: 18px; height: 18px; }
.feature-list .title { font-weight: 600; color: var(--ink); display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.feature-list .desc { color: var(--muted); font-size: 0.875rem; margin-top: 0.1rem; }

/* ---- buttons -------------------------------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 38px;
  padding: 0 1rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 550;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.btn:hover { background: var(--surface-2); color: var(--ink); }
.btn img { width: 18px; height: 18px; }
.btn-primary { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.btn-primary:hover { background: var(--brand-700); border-color: var(--brand-700); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #912018; border-color: #912018; color: #fff; }
.btn-sm { height: 32px; padding: 0 0.75rem; font-size: 0.85rem; }
.btn-lg { height: 46px; padding: 0 1.25rem; font-size: 0.95rem; }
.btn-block { display: flex; width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }

/* "Sign in with Google" (Google's branding guidelines: white, grey outline, the four-colour G) */
.btn-google { height: 46px; border-color: #747775; color: #1f1f1f; font-weight: 500; box-shadow: none; gap: 0.75rem; }
.btn-google:hover { background: #f8faff; border-color: #5f6368; color: #1f1f1f; }
.btn-google img { width: 20px; height: 20px; }

/* ---- badges and status chips ---------------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  height: 22px;
  padding: 0 0.55rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 550;
  line-height: 1;
  white-space: nowrap;
}
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 999px; background: currentColor; }
.badge-brand { background: var(--brand-50); border-color: var(--brand-100); color: var(--brand-700); }
.badge-success { background: var(--success-bg); border-color: var(--success-line); color: var(--success); }
.badge-warning { background: var(--warning-bg); border-color: var(--warning-line); color: var(--warning); }
.badge-danger { background: var(--danger-bg); border-color: var(--danger-line); color: var(--danger); }
.badge-violet { background: var(--violet-bg); border-color: #dcd3fb; color: var(--violet); }
.badge-teal { background: var(--teal-bg); border-color: #b9e3e6; color: var(--teal); }
.badge-confidential { background: #fff1f3; border-color: #fecdd6; color: #a11043; }
.badge.cap { text-transform: capitalize; }
/* the 8 case statuses [R-1.8] */
.status-active { background: var(--brand-50); border-color: var(--brand-100); color: var(--brand-700); }
.status-hold { background: #f2f4f7; border-color: var(--line-strong); color: #475467; }
.status-waiting_review { background: var(--violet-bg); border-color: #dcd3fb; color: var(--violet); }
.status-ready_to_submit { background: var(--teal-bg); border-color: #b9e3e6; color: var(--teal); }
.status-submitted { background: var(--success-bg); border-color: var(--success-line); color: var(--success); }
.status-additional_request { background: var(--warning-bg); border-color: var(--warning-line); color: var(--warning); }
.status-cancelled { background: #f2f4f7; border-color: var(--line); color: var(--subtle); text-decoration: line-through; }
.status-closed { background: #f2f4f7; border-color: var(--line); color: #475467; }
/* priority */
.priority-urgent { background: var(--danger-bg); border-color: var(--danger-line); color: var(--danger); }
.priority-high { background: var(--warning-bg); border-color: var(--warning-line); color: var(--warning); }

/* ---- alerts --------------------------------------------------------------------------------------------------- */
.alert {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  padding: 0.8rem 1rem;
  border: 1px solid var(--info-line);
  border-radius: var(--radius);
  background: var(--info-bg);
  color: var(--brand-800);
  font-size: 0.9rem;
}
.alert .icon { width: 18px; height: 18px; margin-top: 0.1rem; flex: none; }
.alert-success { background: var(--success-bg); border-color: var(--success-line); color: #0b5139; }
.alert-warning { background: var(--warning-bg); border-color: var(--warning-line); color: #7a3705; }
.alert-danger { background: var(--danger-bg); border-color: var(--danger-line); color: #8a1c13; }

/* ---- forms ---------------------------------------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1rem; }
.label { font-size: 0.875rem; font-weight: 550; color: var(--ink); }
.label .optional { color: var(--subtle); font-weight: 400; }
.help { font-size: 0.8rem; color: var(--muted); }
.error-text { font-size: 0.8rem; color: var(--danger); }
.input, .select, .textarea {
  width: 100%;
  height: 40px;
  padding: 0 0.8rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.925rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.textarea { height: auto; min-height: 110px; padding: 0.6rem 0.8rem; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--subtle); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand-400); box-shadow: var(--ring); }
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--danger); }
.check { display: inline-flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--brand-600); }
.form-row { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.form-card { max-width: 880px; }
.form-card .card-header, .history-card .card-header { flex-wrap: wrap; gap: 0.2rem 1rem; }
.card-header h2 { white-space: nowrap; }
.form-card .alert { margin-bottom: 1.25rem; }
.form-actions { display: flex; justify-content: flex-end; align-items: center; gap: 0.5rem; }
.card-body + .card-footer.form-actions, .form-card .card-footer { border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.input-static { display: flex; align-items: center; background: var(--surface-2); color: var(--muted); box-shadow: none; }
.note-form { border-bottom: 1px solid var(--line); }
.note-form .form-actions { margin-top: 0.6rem; }

/* filter bar above a list */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; margin-bottom: 1rem; }
.toolbar .input, .toolbar .select { width: auto; height: 36px; }
.chip-filter {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 0.8rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
}
.chip-filter:hover { color: var(--ink); border-color: var(--subtle); }
.chip-filter[aria-pressed="true"] { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }

/* ---- tables (case lists work like a spreadsheet: sortable columns, dense rows) -------------------------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.9rem; }
.table th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: left;
  white-space: nowrap;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--line);
}
.table th a { color: inherit; text-decoration: none; }
.table th a:hover { color: var(--ink); }
.table td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fafbff; }
.table .case-id { font-family: var(--font-mono); font-weight: 600; color: var(--brand-600); text-decoration: none; white-space: nowrap; }
.table td.num, .table th.num { text-align: right; }

/* ---- empty state ---------------------------------------------------------------------------------------------- */
.empty { text-align: center; padding: 2.5rem 1.5rem; color: var(--muted); }
.empty img { width: 56px; height: 56px; margin: 0 auto 1rem; }
.empty h3 { margin-bottom: 0.25rem; }

/* ---- tabs ----------------------------------------------------------------------------------------------------- */
.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--line); margin-bottom: 1.25rem; overflow-x: auto; }
.tabs a { padding: 0.6rem 0.9rem; color: var(--muted); font-weight: 500; text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--brand-600); border-bottom-color: var(--brand-600); }

/* ---- sign-in page: split screen ------------------------------------------------------------------------------- */
.auth { flex: 1; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: 100vh; }
.auth-brand {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 2rem;
  padding: 3rem 3.5rem;
  color: #fff;
  background:
    radial-gradient(1200px 600px at 110% -10%, rgba(51, 153, 254, 0.55), transparent 60%),
    radial-gradient(900px 500px at -20% 120%, rgba(15, 33, 82, 0.9), transparent 60%),
    linear-gradient(160deg, var(--brand-600) 0%, var(--brand-800) 100%);
}
.auth-brand::after {  /* a faint grid, like ruled case paper */
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(180deg, transparent, #000 30%, #000 70%, transparent);
  pointer-events: none;
}
.auth-brand > * { position: relative; z-index: 1; }
.auth-logo { width: 220px; height: auto; }
.auth-pitch h2 { color: #fff; font-size: 2.1rem; font-weight: 700; letter-spacing: -0.025em; line-height: 1.15; max-width: 26rem; margin-bottom: 0.85rem; }
.auth-pitch p { color: rgba(255, 255, 255, 0.78); font-size: 1.02rem; max-width: 28rem; }
.auth-points { list-style: none; padding: 0; margin: 1.75rem 0 0; display: grid; gap: 0.85rem; }
.auth-points li { display: flex; gap: 0.75rem; align-items: flex-start; color: rgba(255, 255, 255, 0.92); }
.auth-points .icon { width: 22px; height: 22px; flex: none; margin-top: 1px; color: var(--brand-200); }
.auth-foot { color: rgba(255, 255, 255, 0.6); font-size: 0.8rem; }

.auth-panel { display: flex; align-items: center; justify-content: center; padding: 3rem 1.5rem; background: var(--surface); }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .mark { width: 48px; height: 48px; margin-bottom: 1.5rem; }
.auth-card h1 { font-size: 1.65rem; margin-bottom: 0.4rem; }
.auth-card .lede { color: var(--muted); margin-bottom: 1.75rem; }
.auth-card .alert { margin-bottom: 1.25rem; }
.auth-card .fineprint { margin-top: 1.5rem; color: var(--subtle); font-size: 0.8rem; line-height: 1.5; }
.auth-card .fineprint strong { color: var(--muted); font-weight: 600; }

/* ---- error page ----------------------------------------------------------------------------------------------- */
.error-page { flex: 1; display: flex; align-items: center; justify-content: center; padding: 4rem 1.5rem; text-align: center; }
.error-page .code { font-size: 4.5rem; font-weight: 800; letter-spacing: -0.04em; line-height: 1; color: var(--brand-100); margin-bottom: 0.75rem; }
.error-page .lede { color: var(--muted); max-width: 28rem; margin: 0 auto 1.5rem; }

/* ---- M2: case page, profiles, lists of rows -------------------------------------------------------------------- */
.stack { display: grid; gap: 1.25rem; align-content: start; min-width: 0; }
.grow { flex: 1; min-width: 0; }
.cap { text-transform: capitalize; }
.icon-xs { width: 13px; height: 13px; }
.badges { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.6rem; }
.badges .badge { gap: 0.3rem; }
.avatar.sm { width: 30px; height: 30px; font-size: 0.72rem; }
.avatar.square { border-radius: var(--radius-sm); background: linear-gradient(135deg, #5b6b8a, #2e3a55); }
.rows { list-style: none; margin: 0; padding: 0.35rem 0; }
.rows li { display: flex; align-items: center; gap: 0.8rem; padding: 0.7rem 1.4rem; border-top: 1px solid var(--line); }
.rows li:first-child { border-top: 0; }
.rows .case-id { font-family: var(--font-mono); font-size: 0.85rem; font-weight: 600; color: var(--brand-600); text-decoration: none; white-space: nowrap; }
.row-title { font-weight: 600; color: var(--ink); text-decoration: none; }
a.row-title:hover { color: var(--brand-600); text-decoration: underline; }
.notes li { align-items: flex-start; }
.note-meta { margin-bottom: 0.15rem; }
.note-body { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); }
.table-scroll { overflow-x: auto; }
.card .table th { background: var(--surface-2); }

/* ---- search: the top bar's box with its suggestions, and the search page -------------------------------------- */
.header-search { position: relative; flex: 0 1 320px; min-width: 0; }
.header-search .input { height: 36px; padding-left: 2.2rem; background: var(--surface-2); box-shadow: none; }
.header-search .input:focus { background: var(--surface); }
.header-search-icon { position: absolute; left: 0.7rem; top: 9px; width: 18px; height: 18px; color: var(--subtle); pointer-events: none; }
.suggest { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 30; }
.suggest-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 0.35rem; max-height: 70vh; overflow-y: auto; }
.suggest-item { display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.6rem; border-radius: var(--radius-sm); color: var(--text); text-decoration: none; font-size: 0.9rem; }
.suggest-item:hover, .suggest-item:focus { background: var(--brand-50); color: var(--ink); }
.suggest-item .case-id { font-family: var(--font-mono); font-weight: 600; color: var(--brand-600); font-size: 0.85rem; }
.suggest-item .grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest-kind { color: var(--subtle); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; }
.suggest-empty { padding: 0.6rem; color: var(--muted); font-size: 0.875rem; }
.search-form { display: flex; gap: 0.6rem; margin-bottom: 1.5rem; max-width: 720px; }
.search-form .input { height: 42px; }
.search-form .btn { height: 42px; }

/* ---- htmx: indicator styles (htmx's own inline <style> is off, see base.html) --------------------------------- */
.htmx-indicator { opacity: 0; transition: opacity 200ms ease-in; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

/* ---- responsive ----------------------------------------------------------------------------------------------- */
@media (max-width: 960px) {
  .app-header-inner { gap: 1rem; }
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.sidebar { grid-template-columns: minmax(0, 1fr); }
  .case-layout > aside { order: -1; }  /* phone / tablet: the people first */
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-brand { padding: 2rem 1.5rem; gap: 1.25rem; }
  .auth-pitch h2 { font-size: 1.5rem; }
  .auth-points, .auth-foot { display: none; }
}
@media (max-width: 720px) {
  .app-header-inner { gap: 0.75rem; padding: 0 1rem; }
  .brand-name, .user-summary-text, .header-search { display: none; }
  .page { padding: 1.25rem 1rem 2rem; }
  .grid.cols-2, .grid.cols-3 { grid-template-columns: minmax(0, 1fr); }
  h1 { font-size: 1.35rem; }
  .app-footer-inner { flex-direction: column; gap: 0.25rem; padding: 1rem; }
  /* phone: table rows become cards (cells carry data-label) */
  .table-cards thead { display: none; }
  .table-cards tr { display: block; padding: 0.75rem 1rem; border-bottom: 1px solid var(--line); }
  .table-cards td { display: flex; justify-content: space-between; gap: 1rem; padding: 0.2rem 0; border: 0; }
  .table-cards td::before { content: attr(data-label); color: var(--muted); font-size: 0.8rem; }
}

@media print {
  .app-header, .app-footer, .actions, .toolbar { display: none; }
  body { background: #fff; }
  .card, .table-wrap { box-shadow: none; }
}

/* ---- the History tab (M3) ---------------------------------------------------------------------------------------- */
.history { list-style: none; margin: 0; padding: 0; }
.history > li { padding: 0.9rem 1.4rem; border-top: 1px solid var(--line); }
.history > li:first-child { border-top: 0; }
.history-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.25rem 1rem; }
.change-table { width: 100%; margin-top: 0.6rem; border-collapse: collapse; font-size: 0.85rem; }
.change-table th { text-align: left; font-weight: 600; color: var(--muted); padding: 0.35rem 0.6rem; border-bottom: 1px solid var(--line); }
.change-table td { padding: 0.35rem 0.6rem; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
.change-table tr:last-child td { border-bottom: 0; }
.change-table td:first-child { width: 28%; color: var(--muted); }
.change-table td.before { color: var(--subtle); text-decoration: line-through; text-decoration-color: var(--line-strong); }

/* ---- people panel actions, requests, flash (M4) ------------------------------------------------------------------- */
.inline-form { display: inline-flex; gap: 0.35rem; margin: 0; }
.panel-action { border-top: 1px solid var(--line); }
.panel-action > summary {
  display: flex; align-items: center; gap: 0.45rem; padding: 0.8rem 1.4rem; cursor: pointer; list-style: none;
  font-size: 0.9rem; font-weight: 550; color: var(--brand-600);
}
.panel-action > summary::-webkit-details-marker { display: none; }
.panel-action > summary:hover { background: var(--surface-2); }
.panel-action[open] > summary { color: var(--ink); }
.panel-action > form { padding: 0.25rem 1.4rem 1.1rem; }
.panel-subhead { padding: 0.7rem 1.4rem 0; border-top: 1px solid var(--line); font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.request-row { align-items: flex-start; }
.flash { margin-bottom: 1.25rem; }
.needs-owner { margin-bottom: 1.25rem; border-color: var(--warning-line); }

/* ---- profiles and links (M5) ------------------------------------------------------------------------------------ */
.find-form { display: flex; gap: 0.5rem; padding: 0.25rem 1.4rem 0.9rem; }
.find-form .input { flex: 1; }
.find-empty { padding: 0 1.4rem 1rem; }
.rows.compact li { padding: 0.55rem 1.4rem; }
.select-sm { height: 32px; width: auto; font-size: 0.85rem; padding: 0 0.5rem; }
.duplicates { margin-bottom: 1.25rem; max-width: 880px; border-color: var(--warning-line); }
.duplicates .card-header h2 { display: flex; align-items: center; gap: 0.45rem; }
.duplicates .rows { margin: 0.5rem -1.4rem 0.75rem; }
.profile-history { margin-top: 1.25rem; }

/* ---- the lists: My cases and the Master list (M6) --------------------------------------------------------------- */
.counts-card { margin-bottom: 1.25rem; }
.counts { display: flex; flex-wrap: wrap; gap: 1.25rem 2rem; padding: 1.1rem 1.4rem; align-items: flex-start; }
.count-total { display: flex; align-items: center; gap: 0.75rem; padding-right: 2rem; border-right: 1px solid var(--line); }
.count-n { font-size: 2rem; font-weight: 650; letter-spacing: -0.02em; color: var(--ink); line-height: 1; }
.count-group { display: grid; gap: 0.45rem; min-width: 0; flex: 1 1 260px; }
.count-label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.2rem 0.65rem; border: 1px solid var(--line);
        border-radius: 999px; background: var(--surface, #fff); color: var(--ink); font-size: 0.82rem; text-decoration: none; }
.chip b { font-weight: 650; }
.chip .badge { padding: 0 0.4rem; }
.chip:hover { border-color: var(--brand-100); background: var(--brand-50); }
.chip.active { border-color: var(--brand-700); background: var(--brand-50); color: var(--brand-700); font-weight: 550; }
.case-list-card .card-header { gap: 1rem; }
.quick-filters { display: flex; flex-wrap: wrap; gap: 0.4rem; padding: 0.9rem 1.4rem 0; }
.filter-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem; padding: 0.9rem 1.4rem 1rem;
              border-bottom: 1px solid var(--line); }
.filter { display: grid; gap: 0.25rem; }
.filter .label { font-size: 0.75rem; color: var(--muted); font-weight: 550; }
.filter .select-sm { min-width: 9rem; }
.filter-check { display: inline-flex; align-items: center; gap: 0.4rem; height: 32px; font-size: 0.85rem; }
.filter-actions { display: flex; gap: 0.4rem; margin-left: auto; }
.case-list th { white-space: nowrap; }
.sort-link { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 0.2rem; }
.sort-link:hover, .sort-link.active { color: var(--brand-700); }
.sort-arrow.up .icon { transform: rotate(180deg); }
.case-cell { min-width: 14rem; }
.case-name { font-weight: 550; color: var(--ink); }
.due-soon { color: var(--warning); font-size: 0.8rem; font-weight: 550; white-space: nowrap; }
.pager { display: flex; justify-content: space-between; align-items: center; }
@media (max-width: 760px) {
  .count-total { border-right: 0; padding-right: 0; }
  .filter-bar { padding: 0.75rem 1rem; }
  .filter { flex: 1 1 45%; }
  .filter .select-sm { width: 100%; min-width: 0; }
  .filter-actions { margin-left: 0; }
  .case-list .case-cell { min-width: 0; }
  .table-cards td.case-cell { display: block; }
  .table-cards td.case-cell::before { display: block; }
}
@media (max-width: 720px) {
  .table-cards td > .cell { display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: flex-end;
                            gap: 0.35rem; text-align: right; }
}
@media (max-width: 720px) {
  .app-nav { gap: 0; }
  .app-nav a { padding: 0 0.5rem; font-size: 0.875rem; }
  .user-menu .chev { display: none; }
}

/* ---- admin (M7) ------------------------------------------------------------------------------------------------- */
.grid.two { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: start; }
@media (max-width: 960px) { .grid.two { grid-template-columns: 1fr; } }
.user-cell { display: inline-grid; gap: 0.1rem; }
tr.inactive td { color: var(--muted); }
.check-row { display: flex; align-items: flex-start; gap: 0.6rem; padding: 0.55rem 0; font-size: 0.9rem; }
.check-row input { margin-top: 0.25rem; }
fieldset.field { border: 0; padding: 0; margin: 0; }
.input-sm { height: 32px; font-size: 0.875rem; padding: 0 0.6rem; }
.list-edit { display: flex; align-items: center; gap: 0.6rem; width: 100%; }
.list-edit .input-sm { flex: 1; min-width: 0; }
.type-code { min-width: 5.5rem; font-weight: 600; color: var(--brand-700); }
.list-add { display: flex; gap: 0.5rem; align-items: center; }
.list-add .input-sm:first-of-type { width: 8rem; flex: none; }
.list-add .input-sm { flex: 1; min-width: 0; }
.token-once { margin-bottom: 1.25rem; }
.token-once > div { display: grid; gap: 0.4rem; }
.token-value { display: block; padding: 0.55rem 0.75rem; background: #fff; border: 1px solid var(--success-line); border-radius: 8px;
               font-size: 0.9rem; word-break: break-all; user-select: all; color: var(--ink); }
.views-card { margin-top: 1.25rem; }
.views-card h2 { display: flex; align-items: center; gap: 0.4rem; }

/* M9: the import page */
.input-file { height: auto; padding: 0.55rem 0.8rem; }
.input-file::file-selector-button { font: inherit; font-size: 0.875rem; font-weight: 550; margin-right: 0.8rem;
  padding: 0.35rem 0.8rem; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--ink); cursor: pointer; }
.import-steps { margin: 0; padding-left: 1.2rem; display: grid; gap: 0.6rem; font-size: 0.9rem; }
.import-steps li::marker { font-weight: 700; color: var(--brand-700); }
.import-report { margin-bottom: 1.25rem; }
.import-form { margin-bottom: 1.25rem; }
