/* Milestone theme, shared by every page.
   Tokens and component shapes follow the organisation's Claude Design
   system, "Milestone Content Studio Design System" (Untitled UI scales with
   Milestone Blue #2970FF, Inter, 8px controls, 12px cards, quiet borders).
   Pages load Inter and Roboto Mono from Google Fonts in their <head>. The
   older variable names (--primary, --ink, --grey-500 …) stay as aliases so
   every page's own rules pick up the system. */

:root {
  /* Design system scales */
  --white: #ffffff;
  --gray-25: #fcfcfd; --gray-50: #f9fafb; --gray-100: #f2f4f7; --gray-200: #eaecf0; --gray-300: #d0d5dd;
  --gray-400: #98a2b3; --gray-500: #667085; --gray-600: #475467; --gray-700: #344054; --gray-800: #1d2939; --gray-900: #101828;
  --primary-25: #f5faff; --primary-50: #eff8ff; --primary-100: #d1e9ff; --primary-200: #b2ddff; --primary-300: #84caff;
  --primary-500: #2e90fa; --primary-600: #2970ff; --primary-700: #155eef; --primary-800: #1849a9;
  --error-50: #fef3f2; --error-200: #fecdca; --error-300: #fda29b; --error-600: #d92d20; --error-700: #b42318;
  --warning-50: #fffaeb; --warning-200: #fedf89; --warning-500: #f79009; --warning-700: #b54708;
  --success-50: #ecfdf3; --success-200: #a6f4c5; --success-500: #12b76a; --success-700: #027a48;
  --purple-50: #f4ebff; --purple-200: #e9d7fe; --purple-700: #6941c6;
  --indigo-50: #eef4ff; --indigo-200: #c7d7fe; --indigo-700: #3538cd;

  --shadow-xs: 0 1px 2px 0 rgba(16, 24, 40, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(16, 24, 40, 0.10), 0 1px 2px 0 rgba(16, 24, 40, 0.06);
  --shadow-md: 0 4px 8px -2px rgba(16, 24, 40, 0.10), 0 2px 4px -2px rgba(16, 24, 40, 0.06);
  --shadow-lg-ds: 0 12px 16px -4px rgba(16, 24, 40, 0.08), 0 4px 6px -2px rgba(16, 24, 40, 0.03);
  --ring: 0 0 0 4px rgba(41, 112, 255, 0.24);
  --ring-error: 0 0 0 4px rgba(240, 68, 56, 0.24);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);

  /* Surfaces */
  --bg: var(--gray-50);
  --card: var(--white);
  --card-hover: var(--gray-50);
  --subtle: var(--gray-50);
  --border: var(--gray-200);
  --border-2: var(--gray-200);
  --border-input: var(--gray-300);
  --line: var(--gray-200);

  /* Text */
  --ink: var(--gray-900);
  --text: var(--gray-700);
  --grey-600: var(--gray-600);
  --grey-500: var(--gray-500);
  --grey-400: var(--gray-400);

  /* Brand */
  --primary: var(--primary-600);
  --primary-hover: var(--primary-700);
  --group: var(--primary-600);
  --tint: var(--primary-50);
  --tint-2: var(--primary-25);
  --tint-border: var(--primary-200);
  --nav-active: var(--gray-50);

  /* Status (text / background / border) */
  --success: var(--success-700); --success-bg: var(--success-50); --success-border: var(--success-200);
  --warning: var(--warning-700); --warning-bg: var(--warning-50); --warning-border: var(--warning-200);
  --danger: var(--error-700);    --danger-bg: var(--error-50);    --danger-border: var(--error-200);
  --violet: var(--purple-700);   --violet-bg: var(--purple-50);   --violet-border: var(--purple-200);
  --teal: var(--indigo-700);     --teal-bg: var(--indigo-50);     --teal-border: var(--indigo-200);

  /* Shape and type */
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: var(--shadow-xs);
  --shadow-lg: var(--shadow-lg-ds);
  --font: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: 'Roboto Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;

  /* Older names the pages still use */
  --bg-card: var(--card);
  --bg-card-hover: var(--card-hover);
  --bg-input: var(--subtle);
  --surface: var(--card);
  --surface2: var(--subtle);
  --border-focus: var(--primary);
  --text-dim: var(--grey-600);
  --text-muted: var(--grey-500);
  --accent: var(--primary);
  --accent-hover: var(--primary-hover);
  --accent-glow: var(--tint);
  --green: var(--success);   --green-glow: var(--success-bg);
  --orange: var(--warning);  --orange-glow: var(--warning-bg);
  --red: var(--danger);      --red-glow: var(--danger-bg);
  --purple: var(--violet);   --purple-glow: var(--violet-bg);
  --cyan: var(--teal);       --cyan-glow: var(--teal-bg);

  --sidebar-w: 264px;
  --sidebar-w-collapsed: 80px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
/* `hidden` always hides, even on components that set their own display. */
[hidden] { display: none !important; }

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 20px;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01';
}

code, pre, kbd { font-family: var(--mono); }
a { color: var(--primary-700); text-underline-offset: 2px; }
a:hover { color: var(--primary-800); }

:where(a, summary):focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
:where(button, input, select, textarea):focus-visible { outline: none; box-shadow: var(--ring); }
button:not(:disabled), summary { cursor: pointer; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 4px; }

/* ─── App shell: sidebar + top bar ─────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  width: var(--sidebar-w); flex-shrink: 0;
  display: flex; flex-direction: column;
  background: var(--card); border-right: 1px solid var(--border);
  transition: width 0.2s var(--ease);
  z-index: 60;
}
.sidebar-logo { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 72px; padding: 0 20px; border-bottom: 1px solid var(--border); }
.sidebar-logo a { display: inline-flex; align-items: center; min-width: 0; }
.sidebar-logo .logo-full { display: block; height: 26px; width: auto; }
.sidebar-logo .logo-mark { display: none; width: 32px; height: 32px; border-radius: 6px; background: var(--primary-600); color: #fff; align-items: center; justify-content: center; }
.sidebar .nav-toggle { display: none; }

.sidebar-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 16px 12px; display: flex; flex-direction: column; gap: 2px; }
.nav-group { margin: 14px 0 6px; padding: 0 12px; font-size: 12px; font-weight: 600; line-height: 18px; color: var(--grey-500); white-space: nowrap; }
.nav-group:first-child { margin-top: 0; }

.sublink {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px; border-radius: 6px;
  color: var(--gray-700); font-size: 14px; font-weight: 500; line-height: 20px; text-decoration: none; white-space: nowrap;
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease);
}
.sublink svg { width: 20px; height: 20px; flex-shrink: 0; color: var(--grey-500); }
.sublink .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sublink:hover { background: var(--gray-50); color: var(--ink); }
.sublink.on { background: var(--gray-50); color: var(--ink); font-weight: 600; }
.sublink.on svg { color: var(--primary-600); }
.nav-badge { min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--error-50); color: var(--error-700); border: 1px solid var(--error-200); font-size: 12px; font-weight: 500; line-height: 18px; text-align: center; }

.sidebar-foot { padding: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
.sidebar-foot .collapse-btn { width: 100%; border: 0; background: none; font: inherit; text-align: left; }
.sidebar-foot .org { padding: 6px 12px 2px; font-size: 12px; color: var(--grey-400); white-space: nowrap; }

/* Collapsed: an icon rail (the choice is kept per browser). */
html.nav-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
html.nav-collapsed .sidebar-logo { padding: 0; justify-content: center; }
html.nav-collapsed .sidebar-logo .logo-full { display: none; }
html.nav-collapsed .sidebar-logo .logo-mark { display: inline-flex; }
html.nav-collapsed .sublink { justify-content: center; padding: 10px; }
html.nav-collapsed .sublink .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
html.nav-collapsed .sidebar-foot .org { display: none; }
html.nav-collapsed .nav-group { height: 1px; margin: 12px 8px; padding: 0; overflow: hidden; color: transparent; background: var(--border); }
html.nav-collapsed .sublink .nav-badge { position: absolute; top: 4px; right: 8px; min-width: 0; width: 9px; height: 9px; padding: 0; border: 2px solid var(--card); background: var(--error-600); font-size: 0; }
html.nav-collapsed .collapse-btn svg { transform: rotate(180deg); }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 72px; padding: 12px 32px;
  background: var(--card); border-bottom: 1px solid var(--border);
}
.topbar-title { font-size: 18px; font-weight: 600; line-height: 28px; color: var(--ink); }
.topbar-sub { font-size: 14px; line-height: 20px; color: var(--grey-500); }
.topbar-user { display: flex; align-items: center; gap: 12px; margin-left: auto; font-size: 14px; font-weight: 500; color: var(--gray-700); }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--primary-50); color: var(--primary-700); border: 1px solid var(--primary-200); font-size: 13px; font-weight: 600; flex-shrink: 0; }

.app-content { flex: 1; min-width: 0; }

@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar, html.nav-collapsed .sidebar { position: static; width: 100%; height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .sidebar-logo, html.nav-collapsed .sidebar-logo { height: 60px; padding: 0 16px; justify-content: space-between; border-bottom: 0; }
  html.nav-collapsed .sidebar-logo .logo-full { display: block; }
  html.nav-collapsed .sidebar-logo .logo-mark { display: none; }
  .sidebar .nav-toggle { display: inline-flex; }
  .sidebar-nav { display: none; padding: 4px 12px 12px; }
  .sidebar.open .sidebar-nav { display: flex; }
  html.nav-collapsed .sublink { justify-content: flex-start; padding: 8px 12px; }
  html.nav-collapsed .sublink .lbl { position: static; width: auto; height: auto; overflow: hidden; clip: auto; }
  html.nav-collapsed .nav-group { height: auto; margin: 14px 0 6px; padding: 0 12px; color: var(--grey-500); background: none; }
  html.nav-collapsed .sublink .nav-badge { position: static; width: auto; height: auto; min-width: 20px; padding: 0 6px; font-size: 12px; border: 1px solid var(--error-200); background: var(--error-50); }
  .sidebar-foot { display: none; }
  .topbar { position: static; min-height: 0; padding: 12px 16px; }
}
@media (max-width: 600px) {
  .topbar-sub, #appUserName { display: none; }
}

/* ─── Buttons (design system: primary, secondary, tertiary, destructive) ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border: 1px solid transparent; border-radius: 8px;
  font: 600 14px/20px var(--font); white-space: nowrap; text-decoration: none;
  box-shadow: var(--shadow-xs);
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease), border-color 0.15s var(--ease);
}
.btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.btn:disabled { background: var(--gray-100) !important; border-color: var(--gray-200) !important; color: var(--gray-400) !important; box-shadow: none; cursor: not-allowed; }
.btn-primary, .btn-success { background: var(--primary-600); border-color: var(--primary-600); color: #fff; }
.btn-primary:hover:not(:disabled), .btn-success:hover:not(:disabled) { background: var(--primary-700); border-color: var(--primary-700); color: #fff; }
.btn-secondary, .btn-outline { background: var(--card); border-color: var(--border-input); color: var(--gray-700); }
.btn-secondary:hover:not(:disabled), .btn-outline:hover:not(:disabled) { background: var(--gray-50); color: var(--gray-800); }
.btn-accent { background: var(--primary-50); border-color: var(--primary-200); color: var(--primary-700); }
.btn-accent:hover:not(:disabled) { background: var(--primary-100); }
.btn-danger { background: var(--card); border-color: var(--error-300); color: var(--error-700); }
.btn-danger:hover:not(:disabled) { background: var(--error-50); }
.btn-destructive { background: var(--error-600); border-color: var(--error-600); color: #fff; }
.btn-destructive:hover:not(:disabled) { background: var(--error-700); border-color: var(--error-700); }
.btn-ghost { background: transparent; color: var(--gray-600); box-shadow: none; }
.btn-ghost:hover:not(:disabled) { background: var(--gray-50); color: var(--gray-800); }
.btn-sm { padding: 7px 12px; gap: 6px; font-size: 13px; line-height: 20px; }
.btn-sm svg { width: 16px; height: 16px; }
.btn-block { width: 100%; }
/* A link-styled button with a chevron: "All sites", "Back to the assessment". */
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--grey-600); font-size: 14px; font-weight: 600; text-decoration: none; }
.back:hover { color: var(--ink); }
.back svg { width: 16px; height: 16px; }

/* ─── Form fields ──────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 500; color: var(--gray-700); }
.input {
  width: 100%; min-width: 0;
  padding: 9px 14px; border: 1px solid var(--border-input); border-radius: 8px;
  background: var(--card); color: var(--ink); font: 400 14px/20px var(--font);
  box-shadow: var(--shadow-xs);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.input::placeholder { color: var(--grey-500); }
.input:focus { border-color: var(--primary-300); outline: none; box-shadow: var(--shadow-xs), var(--ring); }
.input-sm { width: auto; padding: 6px 10px; font-size: 13px; }
select.input, select.input-sm { padding-right: 32px; appearance: none; background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center; }
label.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; color: var(--gray-700); cursor: pointer; }
label.check input, input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary-600); }

/* ─── Cards, badges, misc ──────────────────────────────────────────────── */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 999px; border: 1px solid transparent; font-size: 12px; font-weight: 500; line-height: 18px; white-space: nowrap; }
.badge-blue { background: var(--primary-50); color: var(--primary-700); border-color: var(--primary-200); }
.badge-green { background: var(--success-50); color: var(--success-700); border-color: var(--success-200); }
.badge-amber { background: var(--warning-50); color: var(--warning-700); border-color: var(--warning-200); }
.badge-red { background: var(--error-50); color: var(--error-700); border-color: var(--error-200); }
.badge-grey { background: var(--gray-100); color: var(--gray-700); border-color: var(--gray-200); }

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition-duration: 0s !important; animation-duration: 0s !important; }
}

/* ─── Explanations (public/assets/tip.js, from /glossary.js) ───────────────
   A label with an explanation shows it on hover (title); abbreviations get
   a short note under the section where they first appear on the page. */
.term { cursor: help; }
.term:hover { text-decoration: underline dotted var(--gray-400); text-underline-offset: 3px; }
.abbr-notes { grid-column: 1 / -1; flex: 1 1 100%; width: 100%; margin-top: 16px; padding-top: 12px; border-top: 1px dashed var(--border); font-size: 12px; line-height: 18px; color: var(--grey-500); }
.abbr-notes .abbr-title { margin-bottom: 4px; font-weight: 600; color: var(--grey-600); }
.abbr-notes dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 2px 32px; }
.abbr-notes dt, .abbr-notes dd { display: inline; margin: 0; }
.abbr-notes dt { font-weight: 600; color: var(--gray-700); margin-right: 6px; }
@media print { .abbr-notes { break-inside: avoid; } }

/* ─── Expandable sections: one chevron for every <details> ─────────────── */
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before {
  content: ''; display: inline-block; flex-shrink: 0; width: 16px; height: 16px; margin-right: 6px; vertical-align: -3px;
  background: currentColor; opacity: 0.7; transition: transform 0.15s var(--ease);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 18l6-6-6-6'/%3E%3C/svg%3E") no-repeat center / 16px;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 18l6-6-6-6'/%3E%3C/svg%3E") no-repeat center / 16px;
}
details[open] > summary::before { transform: rotate(90deg); }
@media print { details > summary::before { display: none; } }
