/* KOG RAMS — stylesheet.
   Design: a drawing title block as the organising idea. Document control information (number, revision,
   status, issue date) is always set as a ruled block; everything else is quiet and legible on site phones. */

:root {
  --ink: #1f2a37;
  --ink-2: #4b5563;
  --ink-3: #8a94a3;
  --line: #d9dde3;
  --line-strong: #aeb5bf;
  --paper: #f3f4f6;
  --panel: #ffffff;
  --amber: #f2b200;          /* document control & hazard-tape accent */
  --amber-ink: #6b4e00;
  --green: #2e8b57;
  --red: #c62828;
  --blue: #1d5fa3;
  --radius: 3px;
  --rail: 224px;
  --fs-0: 13px; --fs-1: 14.5px; --fs-2: 16px; --fs-3: 19px; --fs-4: 24px; --fs-5: 32px;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
body { margin: 0; font: var(--fs-1)/1.5 var(--font); color: var(--ink); background: var(--paper); -webkit-text-size-adjust: 100%; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5em; font-weight: 650; line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: var(--fs-4); }
h2 { font-size: var(--fs-3); }
h3 { font-size: var(--fs-2); }
p { margin: 0 0 1em; }
small, .muted { color: var(--ink-2); font-size: var(--fs-0); }
.hint { color: var(--ink-3); font-size: var(--fs-0); }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---- Shell ---- */
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; display: flex; align-items: center; gap: 14px; height: 52px; padding: 0 16px; background: var(--ink); color: #fff; }
.brand { color: #fff; font-weight: 600; letter-spacing: .02em; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { display: inline-block; background: var(--amber); color: var(--ink); padding: 1px 7px; border-radius: 2px; font-weight: 750; margin-right: 2px; }
.topsearch { flex: 1; max-width: 520px; }
.topsearch input { width: 100%; border: 0; border-radius: var(--radius); padding: 7px 11px; font: inherit; background: #2f3b4a; color: #fff; }
.topsearch input::placeholder { color: #aab3bf; }
.whoami { margin-left: auto; color: #e5e7eb; white-space: nowrap; }
.menu-toggle { display: none; background: none; border: 0; color: #fff; font-size: 22px; padding: 4px 8px; cursor: pointer; }

.sidenav { position: fixed; top: calc(52px + env(safe-area-inset-top, 0px)); left: 0; bottom: 0; width: var(--rail); padding: 14px 0; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; overflow-y: auto; z-index: 15; }
.sidenav a { display: block; padding: 8px 20px 8px 24px; color: var(--ink); border-left: 3px solid transparent; }
.sidenav a:hover { background: var(--paper); text-decoration: none; }
.sidenav a.on { border-left-color: var(--amber); font-weight: 600; background: #fdf7e3; }
.nav-group { display: block; padding: 16px 24px 4px; color: var(--ink-3); font-size: var(--fs-0); }
.nav-logout { margin-top: auto; padding: 12px 24px; }
.nav-logout button { background: none; border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 12px; font: inherit; color: var(--ink-2); cursor: pointer; width: 100%; }
.nav-scrim { display: none; }

.content { margin-left: var(--rail); padding: 24px 32px 64px; max-width: calc(var(--rail) + 1180px); }
.content-public { margin-left: 0; max-width: 820px; margin-inline: auto; padding: 20px 16px 48px; }

@media (max-width: 900px) {
  .menu-toggle { display: inline-block; }
  .topsearch { display: none; }
  .sidenav { transform: translateX(-100%); transition: transform .18s ease; box-shadow: 0 0 0 100vmax rgba(0,0,0,0); }
  body.nav-open .sidenav { transform: none; }
  body.nav-open .nav-scrim { display: block; position: fixed; inset: 0; background: rgba(31,42,55,.45); z-index: 14; }
  .content { margin-left: 0; padding: 16px 14px 48px; }
}

/* ---- Flash ---- */
.flash { padding: 10px 14px; margin-bottom: 18px; border-left: 4px solid var(--green); background: #e8f4ec; border-radius: var(--radius); }
.flash-error { border-left-color: var(--red); background: #fbe9e9; }

/* ---- Page heads & title block ---- */
.pagehead { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 20px; margin-bottom: 20px; }
.pagehead h1 { margin: 0; }
.pagehead .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.titleblock { display: grid; grid-template-columns: 2fr repeat(4, minmax(110px, 1fr)); border: 2px solid var(--ink); background: var(--panel); margin-bottom: 20px; }
.titleblock > div { padding: 8px 12px; border-right: 1px solid var(--ink); min-width: 0; }
.titleblock > div:last-child { border-right: 0; }
.titleblock .k { display: block; font-size: 11px; color: var(--ink-2); letter-spacing: .04em; }
.titleblock .v { display: block; font-size: var(--fs-3); font-weight: 650; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.titleblock .v.num { font-size: var(--fs-4); letter-spacing: .01em; }
.titleblock .sub { display: block; color: var(--ink-2); font-size: var(--fs-0); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.titleblock .status-draft .v { color: var(--ink-2); }
.titleblock .status-awaiting_approval .v { color: var(--amber-ink); }
.titleblock .status-approved .v, .titleblock .status-issued .v { color: var(--green); }
.titleblock .status-review_due .v { color: var(--red); }
.titleblock .status-superseded .v, .titleblock .status-archived .v { color: var(--ink-3); }
@media (max-width: 900px) { .titleblock { grid-template-columns: 1fr 1fr; } .titleblock > div { border-bottom: 1px solid var(--ink); } .titleblock > div:first-child { grid-column: 1 / -1; } .titleblock > div:nth-child(2n+1) { border-right: 0; } }

/* ---- Panels & grid ---- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }
.panel h2 { margin-bottom: 12px; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.stat { padding: 14px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.stat .n { font-size: var(--fs-5); font-weight: 700; line-height: 1; }
.stat .l { color: var(--ink-2); font-size: var(--fs-0); margin-top: 6px; }
.stat.warn .n { color: var(--red); }
.stat.amber .n { color: var(--amber-ink); }

/* ---- Tables ---- */
.tablewrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: var(--fs-1); }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--ink-2); font-size: var(--fs-0); background: #fafbfc; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tr.row-link:hover td { background: #f8f9fb; }
td.num, th.num { text-align: right; white-space: nowrap; }
tr.status-stripe td:first-child { border-left: 4px solid var(--line-strong); }
tr.s-draft td:first-child { border-left-color: var(--ink-3); }
tr.s-awaiting_approval td:first-child { border-left-color: var(--amber); }
tr.s-approved td:first-child, tr.s-issued td:first-child { border-left-color: var(--green); }
tr.s-review_due td:first-child { border-left-color: var(--red); }
tr.s-superseded td:first-child, tr.s-archived td:first-child { border-left-color: var(--line); }
.empty { padding: 28px 20px; color: var(--ink-2); text-align: center; }

/* ---- Forms ---- */
label { display: block; font-weight: 600; font-size: var(--fs-0); color: var(--ink-2); margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=search], input[type=url], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius); font: inherit; color: var(--ink); background: #fff; }
textarea { min-height: 88px; resize: vertical; }
input:disabled, textarea:disabled, select:disabled { background: var(--paper); color: var(--ink-2); }
.field { margin-bottom: 14px; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 18px; }
.fields .wide { grid-column: 1 / -1; }
.inline { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.inline > * { margin-bottom: 0; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--ink); }
.check input { width: 18px; height: 18px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin: 0 0 16px; }
legend { font-weight: 600; color: var(--ink-2); font-size: var(--fs-0); padding: 0 6px; }

.btn { display: inline-block; padding: 8px 14px; border: 1px solid var(--ink); border-radius: var(--radius); background: var(--ink); color: #fff; font: inherit; font-weight: 600; cursor: pointer; line-height: 1.3; white-space: nowrap; }
.btn:hover { background: #2c3a4b; text-decoration: none; }
.btn.secondary { background: #fff; color: var(--ink); border-color: var(--line-strong); }
.btn.secondary:hover { background: var(--paper); }
.btn.amber { background: var(--amber); border-color: var(--amber); color: var(--ink); }
.btn.green { background: var(--green); border-color: var(--green); }
.btn.danger { background: #fff; color: var(--red); border-color: var(--red); }
.btn.sm { padding: 4px 9px; font-size: var(--fs-0); font-weight: 500; }
.btn.block { display: block; width: 100%; text-align: center; padding: 14px; font-size: var(--fs-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
form.inline-form { display: inline; }

/* ---- Tags, bands, chips ---- */
.band { display: inline-block; min-width: 2.4em; padding: 1px 7px; border-radius: 2px; color: #fff; font-weight: 700; font-size: var(--fs-0); text-align: center; }
.chip { display: inline-block; padding: 1px 8px; border: 1px solid var(--line-strong); border-radius: 999px; font-size: 12px; color: var(--ink-2); margin: 0 4px 4px 0; background: #fff; }
.chip.amber { border-color: var(--amber); background: #fdf7e3; color: var(--amber-ink); }
.chip.red { border-color: var(--red); background: #fbe9e9; color: var(--red); }
.chip.green { border-color: var(--green); background: #e8f4ec; color: var(--green); }
.rev { font-weight: 700; }

/* ---- RAMS editor tabs ---- */
.tabs { display: flex; gap: 2px; overflow-x: auto; border-bottom: 2px solid var(--line); margin-bottom: 20px; scrollbar-width: none; }
.tabs a { padding: 9px 14px; color: var(--ink-2); white-space: nowrap; border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tabs a.on { color: var(--ink); font-weight: 650; border-bottom-color: var(--amber); }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs a .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--red); margin-left: 5px; vertical-align: middle; }

.readiness { display: flex; align-items: center; gap: 16px; }
.readiness .score { font-size: var(--fs-5); font-weight: 750; line-height: 1; }
.readiness .score.ok { color: var(--green); }
.readiness .score.bad { color: var(--red); }
.issues li { margin: 4px 0; }
.issues .warn { color: var(--amber-ink); }
.issues .bad { color: var(--red); }

/* Step / risk cards: numbered because they are a sequence */
.step { display: grid; grid-template-columns: 44px 1fr auto; gap: 14px; padding: 14px 0; border-top: 1px solid var(--line); }
.step:first-child { border-top: 0; }
.step .n { font-size: var(--fs-3); font-weight: 700; color: var(--ink-3); }
.step .controls { display: flex; flex-direction: column; gap: 4px; }
.step summary { cursor: pointer; font-weight: 600; list-style: none; }
.step summary::-webkit-details-marker { display: none; }
.step details[open] summary { margin-bottom: 10px; }
.step .meta { color: var(--ink-2); font-size: var(--fs-0); }
.risk-scores { display: flex; gap: 14px; align-items: center; margin: 4px 0 8px; flex-wrap: wrap; font-size: var(--fs-0); color: var(--ink-2); }
.arrow { color: var(--ink-3); }
@media (max-width: 700px) { .step { grid-template-columns: 32px 1fr; } .step .controls { grid-column: 1 / -1; flex-direction: row; } }

/* Matrix */
.matrix { border-collapse: collapse; font-size: var(--fs-0); }
.matrix td, .matrix th { border: 1px solid #fff; text-align: center; padding: 6px 8px; min-width: 36px; }
.matrix th { background: var(--paper); color: var(--ink-2); font-weight: 600; }
.matrix td { color: #fff; font-weight: 700; }
.matrix td.sel { outline: 3px solid var(--ink); outline-offset: -3px; }

/* Picker lists */
.picker { max-height: 360px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.picker label { display: flex; gap: 10px; align-items: flex-start; padding: 8px 12px; border-bottom: 1px solid var(--line); font-weight: 500; color: var(--ink); margin: 0; cursor: pointer; }
.picker label:hover { background: var(--paper); }
.picker label:last-child { border-bottom: 0; }
.picker input { margin-top: 3px; flex: none; }
.picker .cat { font-size: 11px; color: var(--ink-3); display: block; }
.picker-filter { margin-bottom: 8px; }

/* Timeline (project history / approvals) */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0 8px 18px; border-left: 2px solid var(--line); position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 14px; width: 10px; height: 10px; border-radius: 50%; background: var(--line-strong); }
.timeline li.approved::before, .timeline li.issued::before { background: var(--green); }
.timeline li.rejected::before, .timeline li.changes_requested::before { background: var(--red); }
.timeline li.submitted::before { background: var(--amber); }
.timeline .when { color: var(--ink-3); font-size: var(--fs-0); }

/* QR */
.qr { width: 150px; height: 150px; }
.qr svg { width: 100%; height: 100%; }

/* ---- Login ---- */
.login { max-width: 380px; margin: 10vh auto 0; }
.login .brand { color: var(--ink); font-size: var(--fs-4); display: block; margin-bottom: 20px; }

/* ---- Public sign page ---- */
.signpad { border: 2px dashed var(--line-strong); border-radius: var(--radius); background: #fff; touch-action: none; width: 100%; height: 180px; display: block; }
.ack { padding: 14px 16px; background: #fdf7e3; border: 1px solid var(--amber); border-radius: var(--radius); margin: 14px 0; }
.sig-list img { height: 42px; border: 1px solid var(--line); background: #fff; }
.bigtitle { font-size: var(--fs-4); font-weight: 750; letter-spacing: -0.01em; }

/* Keep document numbers and dates on one line inside tables */
td a[href^="/rams/"], td .rev, td.muted { white-space: nowrap; }
