/* DPO Portal – one stylesheet for portal + console. Portal brand colours arrive as --brand / --accent. */
:root {
  --brand: #1f3a5f;
  --accent: #e0a526;
  --ink: #1b2430;
  --ink-2: #4a5566;
  --muted: #6b7686;
  --line: #dfe3ea;
  --bg: #f4f6f9;
  --card: #ffffff;
  --success: #1e7b4f;
  --success-bg: #e6f4ec;
  --warning: #8a5a00;
  --warning-bg: #fdf3dc;
  --danger: #b42318;
  --danger-bg: #fdecea;
  --info: #1d5fa8;
  --info-bg: #e8f1fb;
  --dpo: #5b3fa0;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
body.admin { --brand: #23314d; --accent: #3b82c4; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.55; color: var(--ink); background: var(--bg); }
a { color: var(--brand); }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.3rem; margin-top: 1.4em; }
h3 { font-size: 1.05rem; margin-top: 1em; }
.card > h2:first-child, .card > h3:first-child, section > h2:first-child { margin-top: 0; }
code { font-family: var(--mono); font-size: .9em; background: #eef1f5; padding: .05em .3em; border-radius: 4px; }
pre.code { font-family: var(--mono); font-size: .82rem; background: #1e2633; color: #e7ecf3; padding: 12px; border-radius: 8px; overflow-x: auto; white-space: pre; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 8px; top: 8px; background: #fff; padding: 8px; z-index: 10; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.main { padding-top: 24px; padding-bottom: 64px; min-height: 70vh; }

/* ---------- top bar */
.topbar { background: var(--brand); color: #fff; }
.topbar-inner { display: flex; align-items: center; gap: 16px; min-height: 64px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; margin-right: auto; }
.brand-logo { max-height: 40px; max-width: 200px; background: #fff; padding: 4px 8px; border-radius: 6px; }
.brand-name { font-weight: 700; font-size: 1.1rem; }
.brand-sub { font-size: .8rem; opacity: .8; border-left: 1px solid rgba(255,255,255,.4); padding-left: 12px; }
.mainnav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.mainnav > a { color: #fff; text-decoration: none; padding: 8px 12px; border-radius: 6px; opacity: .9; }
.mainnav > a:hover, .mainnav > a.active { background: rgba(255,255,255,.14); opacity: 1; }
.mainnav > a.btn { margin-left: 8px; }
.nav-toggle { display: none; background: none; border: 0; color: #fff; font-size: 1.5rem; cursor: pointer; }
.usermenu { position: relative; margin-left: 8px; }
.usermenu summary { list-style: none; cursor: pointer; padding: 8px 12px; border-radius: 6px; background: rgba(255,255,255,.1); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu-panel { position: absolute; right: 0; top: 110%; background: #fff; color: var(--ink); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.15); min-width: 180px; padding: 6px; z-index: 5; }
.usermenu-panel a, .usermenu-panel .linkish { display: block; padding: 8px 10px; color: var(--ink); text-decoration: none; border-radius: 6px; width: 100%; text-align: left; }
.usermenu-panel a:hover, .usermenu-panel .linkish:hover { background: var(--bg); }
.linkish { background: none; border: 0; font: inherit; cursor: pointer; color: inherit; padding: 0; }

.footer { border-top: 1px solid var(--line); background: #fff; color: var(--muted); font-size: .875rem; }
.footer-inner { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-top: 16px; padding-bottom: 16px; }

/* ---------- building blocks */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card-danger { border-color: #f3b8b2; border-top: 4px solid var(--danger); }
.narrow { max-width: 560px; margin-left: auto; margin-right: auto; }
.narrow-wide { max-width: 760px; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row input:not([type=checkbox]):not([type=file]), .row select { width: auto; flex: 1 1 180px; }
.inline { display: inline; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 24px; }
.span-2 { grid-column: span 2; }
.layout-side { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.page-head h1, .page-head h2 { margin: 0; }
.crumbs { font-size: .875rem; color: var(--muted); margin: 0 0 8px; }
.lead { font-size: 1.1rem; color: var(--ink-2); max-width: 70ch; }
.muted { color: var(--muted); } .small { font-size: .875rem; } .nowrap { white-space: nowrap; }
.text-danger { color: var(--danger); }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.eyebrow { text-transform: uppercase; letter-spacing: .06em; font-size: .75rem; color: var(--muted); font-weight: 600; margin: 0 0 4px; }
.plain-list { list-style: none; padding: 0; margin: 0 0 12px; }
.plain-list li { padding: 6px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.list-row { display: flex; flex-direction: column; padding: 8px 0; border-bottom: 1px solid var(--line); }
.empty { text-align: center; color: var(--muted); }

/* ---------- buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; line-height: 1.2; }
.btn:hover { border-color: #b9c1cd; background: #fafbfc; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand); filter: brightness(1.12); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #1b1b1b; }
.btn-accent:hover { background: var(--accent); filter: brightness(1.06); }
body.admin .btn-accent { color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: transparent; }
.btn-small { padding: 5px 10px; font-size: .875rem; }
.btn-block { width: 100%; }
.btn-icon { background: none; border: 0; cursor: pointer; color: var(--muted); font-size: 1rem; padding: 2px 6px; border-radius: 4px; }
.btn-icon:hover { background: var(--danger-bg); color: var(--danger); }
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- forms */
.field { margin-bottom: 14px; }
.field > label, .field > .label { display: block; font-weight: 600; margin-bottom: 4px; }
.help { color: var(--muted); font-size: .875rem; margin: 0 0 6px; }
.help p { margin: 0 0 4px; }
.req { color: var(--danger); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=search], input:not([type]), select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #c8cfd9; border-radius: 8px; font: inherit; background: #fff; color: var(--ink); }
input:disabled, select:disabled, textarea:disabled { background: #f1f3f6; color: var(--ink-2); }
input[type=color] { width: 64px; height: 40px; padding: 2px; border: 1px solid #c8cfd9; border-radius: 8px; }
textarea { resize: vertical; }
textarea.mono { font-family: var(--mono); font-size: .85rem; }
textarea.invalid { border-color: var(--danger); background: var(--danger-bg); }
.radios { display: flex; gap: 18px; flex-wrap: wrap; }
.radios.stacked, .checks { display: flex; flex-direction: column; gap: 6px; }
.radio, .check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; cursor: pointer; }
.radio input, .check input { margin-top: 4px; flex: none; width: 18px; height: 18px; accent-color: var(--brand); }
fieldset.intake { border: 1px dashed var(--line); border-radius: 8px; padding: 12px 16px 2px; margin: 0 0 14px; }
fieldset.intake legend { font-weight: 600; padding: 0 6px; color: var(--ink-2); }
.code-input { font-family: var(--mono); font-size: 1.6rem; letter-spacing: .4em; text-align: center; }
.search { max-width: 340px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filters select { width: auto; }
.sticky-actions { position: sticky; bottom: 0; background: rgba(244,246,249,.95); backdrop-filter: blur(4px); padding: 12px 0; display: flex; gap: 10px;
  justify-content: flex-end; align-items: center; border-top: 1px solid var(--line); margin-top: 8px; z-index: 2; }
progress { width: 100px; height: 8px; accent-color: var(--brand); }

/* ---------- tables */
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; }
.card .table-wrap { border: 0; margin: 0; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #fafbfc; }
.table tr:last-child td { border-bottom: 0; }
.row-overdue td { background: var(--danger-bg); }
.row-soon td { background: var(--warning-bg); }
.row-muted td { opacity: .55; }
.edit-table td { padding: 6px; } .edit-table input, .edit-table select, .edit-table textarea { min-width: 120px; }

/* ---------- badges, alerts */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; background: #eef1f5; color: var(--ink-2); white-space: nowrap; vertical-align: middle; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-dpo { background: #efe9fb; color: var(--dpo); }
.due { font-size: .85rem; white-space: nowrap; } .due-overdue { color: var(--danger); font-weight: 700; } .due-soon { color: var(--warning); font-weight: 600; }
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; border: 1px solid transparent; }
.alert ul { margin: 6px 0 0; padding-left: 20px; }
.alert-success { background: var(--success-bg); color: var(--success); border-color: #b7e0c8; }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: #f1d79c; }
.alert-danger { background: var(--danger-bg); color: var(--danger); border-color: #f3b8b2; }
.alert-info { background: var(--info-bg); color: var(--info); border-color: #bcd6f2; }

/* ---------- tabs */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--ink-2); border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.tabs a.active, .tabs a:hover { color: var(--brand); border-bottom-color: var(--brand); }

/* ---------- auth */
.auth-card { max-width: 440px; margin: 40px auto; padding: 32px; }
.auth-card h1 { font-size: 1.4rem; }
.auth-logo { max-height: 64px; max-width: 240px; display: block; margin-bottom: 16px; }

/* ---------- portal home */
.hero { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; margin-bottom: 8px; }
.dpo-card .btn { margin-top: 12px; }
.urgent-strip { margin: 8px 0 8px; }
.urgent { display: block; background: var(--danger-bg); border: 1px solid #f3b8b2; color: var(--danger); padding: 14px 18px; border-radius: var(--radius); text-decoration: none; }
.urgent:hover { background: #fbdcd8; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.tile { display: flex; flex-direction: column; gap: 4px; background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: var(--radius);
  padding: 14px 16px; text-decoration: none; color: var(--ink); box-shadow: var(--shadow); transition: transform .08s, box-shadow .08s; }
.tile:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(16,24,40,.12); }
.tile-problem { border-left-color: var(--danger); }
.tile-howto { border-left-color: var(--accent); }
.tile .icon { font-size: 1.4rem; }
.tile-title { font-weight: 700; }
.tile-sub { font-size: .875rem; color: var(--muted); }
.link-card { text-decoration: none; color: var(--ink); display: block; }
.link-card:hover { border-color: var(--brand); }
.link-card p { color: var(--muted); margin: 0; }
.cta { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; background: #fffdf6; }
.cta p { margin: 0; font-weight: 600; }

/* ---------- prose */
.prose { max-width: 75ch; }
.prose h2 { font-size: 1.2rem; } .prose h3 { font-size: 1.05rem; }
.prose ul, .prose ol { padding-left: 1.3em; } .prose li { margin: .2em 0; }
.prose blockquote { border-left: 4px solid var(--accent); margin: 1em 0; padding: .2em 1em; background: #fffbf0; }
.prose table { border-collapse: collapse; } .prose td, .prose th { border: 1px solid var(--line); padding: 6px 10px; }
.article { padding: 28px 32px; }

/* ---------- FAQ */
.faq { background: #fff; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; }
.faq summary { cursor: pointer; padding: 14px 16px; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::after { content: "+"; font-size: 1.3rem; line-height: 1; color: var(--muted); }
.faq[open] summary::after { content: "–"; }
.faq summary::-webkit-details-marker { display: none; }
.faq .prose { padding: 0 16px 12px; }

/* ---------- decision tree */
.tree-runner { max-width: 820px; }
.tree-trail { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.trail-item { font-size: .875rem; padding: 6px 12px; background: #fff; border: 1px solid var(--line); border-radius: 6px; }
.tree-node { padding: 24px; }
.tree-node h2 { margin-top: 0; font-size: 1.25rem; }
.tree-options { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.tree-option { min-width: 120px; }
.tree-option:hover { border-color: var(--brand); color: var(--brand); }
.tree-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.tree-controls { display: flex; gap: 8px; }
.tree-outcome { border-top: 5px solid var(--info); }
.sev-success { border-top-color: var(--success); } .sev-warning { border-top-color: #d99a00; } .sev-danger { border-top-color: var(--danger); background: #fffafa; }
.trail-list { margin: 6px 0; padding-left: 1.3em; }

/* ---------- tickets */
.thread { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.msg { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.msg-dpo { border-left: 4px solid var(--dpo); }
.msg-staff { border-left: 4px solid var(--brand); }
.msg-system { background: transparent; border: 0; padding: 2px 16px; }
.msg-internal { background: #fffbea; border-style: dashed; }
.msg-head { margin-bottom: 6px; }
.meta { display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; margin: 0; font-size: .9rem; }
.meta dt { color: var(--muted); } .meta dd { margin: 0; overflow-wrap: anywhere; }
.meta.wide { grid-template-columns: 220px 1fr; }

/* ---------- assessments */
.section-nav { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 16px; }
.section-nav a { font-size: .8rem; padding: 4px 10px; background: #fff; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; color: var(--ink-2); }
.form-section h3 { font-size: 1.15rem; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.section-intro { background: #f7f9fc; border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; font-size: .925rem; }
.section-intro p:last-child { margin-bottom: 0; }
.info-block { background: var(--info-bg); border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; font-size: .925rem; }
.info-block p:last-child { margin-bottom: 0; }
.dpo-field { background: #faf8ff; border-left: 3px solid var(--dpo); padding: 8px 12px; border-radius: 0 8px 8px 0; }
.dpo-review { border-top: 4px solid var(--dpo); }
.dpo-opinion { border-left: 4px solid var(--dpo); }
.answer { padding: 6px 0; }
.answer-list { margin: 0; padding-left: 1.2em; }
.score { border-radius: var(--radius); padding: 14px 18px; margin-bottom: 16px; border: 1px solid var(--line); background: #fff; }
.score-high { border-left: 5px solid var(--danger); } .score-medium { border-left: 5px solid #d99a00; } .score-low { border-left: 5px solid var(--success); }
.score p { margin: 6px 0 0; }
.logo-preview { max-width: 100%; max-height: 80px; background: #f1f3f6; padding: 8px; border-radius: 6px; }

/* ---------- console */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; text-decoration: none; color: var(--ink-2); }
.stat-n { font-size: 1.8rem; font-weight: 700; color: var(--ink); line-height: 1.1; }
.stat-danger { border-color: #f3b8b2; background: var(--danger-bg); } .stat-danger .stat-n { color: var(--danger); }
body.plain { background: var(--bg); }

/* ---------- responsive */
@media (max-width: 900px) {
  .layout-side, .hero { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .grid-2 { grid-template-columns: 1fr; } .span-2 { grid-column: auto; }
  .nav-toggle { display: block; }
  .mainnav { display: none; width: 100%; flex-direction: column; align-items: stretch; padding-bottom: 12px; }
  .mainnav.open { display: flex; }
  .mainnav > a.btn { margin: 8px 0 0; }
  .usermenu { margin: 8px 0 0; } .usermenu-panel { position: static; box-shadow: none; }
  .article { padding: 20px; }
  .meta.wide { grid-template-columns: 1fr; }
  h1 { font-size: 1.45rem; }
}
@media print {
  .topbar, .footer, .sticky-actions, .tree-controls, form .btn { display: none !important; }
  body { background: #fff; } .card { box-shadow: none; }
}
