/* 365 Compliance — styled to match the UKRP Direct website:
   warm paper, one deep green accent, serif headings over system sans, small radii, no webfonts.
   Dense enough for all-day operational use; status is always text as well as colour. */
:root {
  --paper: #faf8f4; --paper-sunk: #f1ede5; --paper-raised: #ffffff;
  --ink: #16181a; --ink-body: #3f464a; --ink-muted: #5f676c;
  --rule: #d9d3c8; --rule-strong: #b9b2a4;
  --accent: #0e5340; --accent-hover: #0a3f31; --accent-wash: #e8efe9; --danger: #8a2620;
  --ok: #0e5340; --warn: #7a4b00; --bad: #8a2620; --info: #0e5340;
  --font-serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, 'Times New Roman', serif;
  --font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --radius: 3px;
  --focus: #0e5340;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink-body);
  font-family: var(--font-sans); font-size: 15px; line-height: 1.55;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 2px;
}
h1, h2, h3 { color: var(--ink); font-family: var(--font-serif); font-weight: 600; line-height: 1.16; margin: 0; }
h1 { font-size: 1.65rem; letter-spacing: -0.01em; }
h2 { font-size: 1.2rem; margin: 26px 0 8px; }
h3 { font-size: 1.02rem; margin: 18px 0 6px; }
p { margin: 0 0 10px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92em; background: var(--paper-sunk); padding: 1px 4px; border-radius: var(--radius); }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; background: var(--paper-raised); padding: 8px; z-index: 10; border: var(--rule) 1px solid; }

/* header / nav */
.top { display: flex; align-items: center; gap: 18px; padding: 12px 20px; background: var(--paper-raised); border-bottom: 1px solid var(--rule); }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand img { display: block; }
.brand-text { display: inline-flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-family: var(--font-serif); font-size: 1.02rem; font-weight: 600; letter-spacing: 0.01em; }
.brand-by { font-size: 0.72rem; color: var(--ink-muted); letter-spacing: 0.04em; text-transform: uppercase; }
.who { margin-left: auto; color: var(--ink-muted); font-size: 0.82rem; }
.role { color: var(--ink-muted); opacity: 0.8; }
.inline { display: inline; margin: 0; }
button.link { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }

.shell { display: grid; grid-template-columns: 208px minmax(0, 1fr); min-height: calc(100vh - 62px); }
/* no navigation (sign-in, invitation): the content owns the width */
.shell--bare { grid-template-columns: minmax(0, 1fr); }
nav.side { border-right: 1px solid var(--rule); padding: 14px 0; background: var(--paper-raised); }
nav.side a { display: block; padding: 6px 20px; color: var(--ink-body); text-decoration: none; font-size: 0.86rem; border-left: 2px solid transparent; }
nav.side a:hover { background: var(--paper-sunk); color: var(--ink); }
nav.side a.active { border-left-color: var(--accent); color: var(--ink); font-weight: 600; background: var(--accent-wash); }
.count { background: var(--accent); color: #fff; border-radius: 10px; padding: 0 6px; font-size: 0.7rem; font-weight: 600; }
main { padding: 22px 26px 56px; min-width: 0; }
.foot { border-top: 1px solid var(--rule); padding: 14px 20px; font-size: 0.76rem; color: var(--ink-muted); background: var(--paper-raised); }
.muted, .hint { color: var(--ink-muted); }
.hint { font-size: 0.82rem; margin: 4px 0 0; }
.right { text-align: right; } .nowrap { white-space: nowrap; }
.stack { display: grid; gap: 10px; }

/* tables: ruled, not boxed */
table { border-collapse: collapse; width: 100%; background: var(--paper-raised); font-size: 0.875rem; }
caption { text-align: left; font-family: var(--font-serif); font-size: 0.95rem; font-weight: 600; color: var(--ink); padding: 8px 0 6px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--rule); vertical-align: top; }
thead th { font-size: 0.72rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-muted); font-weight: 600; border-bottom: 1px solid var(--rule-strong); }
tbody tr:hover { background: #fdfcf9; }
td.empty { color: var(--ink-muted); font-style: italic; }
.table-wrap { overflow-x: auto; }

/* status: text first, colour second */
.badge { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 0.74rem; border: 1px solid currentColor; white-space: nowrap; letter-spacing: 0.01em; }
.badge.ok { color: var(--accent); background: var(--accent-wash); }
.badge.warn { color: var(--warn); background: #fbf3e2; }
.badge.bad { color: var(--bad); background: #fbf1ef; }
.badge.info { color: var(--accent); }
.badge.muted { color: var(--ink-muted); background: var(--paper-sunk); }

.metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 10px; margin: 14px 0 6px; }
.metric { display: block; padding: 11px 13px; background: var(--paper-raised); border: 1px solid var(--rule); border-left: 3px solid var(--rule-strong); text-decoration: none; color: var(--ink); border-radius: var(--radius); }
.metric:hover { border-color: var(--rule-strong); background: #fdfcf9; }
.metric.ok { border-left-color: var(--accent); } .metric.warn { border-left-color: var(--warn); }
.metric.bad { border-left-color: var(--bad); } .metric.info { border-left-color: var(--accent); }
.metric-value { display: block; font-family: var(--font-serif); font-size: 1.5rem; font-weight: 600; line-height: 1.1; }
.metric-label { display: block; font-size: 0.8rem; color: var(--ink-body); }
.metric-note { display: block; font-size: 0.74rem; color: var(--ink-muted); }

.flash { padding: 9px 12px; margin: 0 0 14px; border: 1px solid var(--rule); border-left-width: 3px; border-radius: var(--radius); background: var(--paper-raised); }
.flash.ok { border-left-color: var(--accent); background: var(--accent-wash); }
.flash.error { border-left-color: var(--bad); background: #fbf1ef; }

/* forms */
form.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px 18px; align-items: end; background: var(--paper-raised); border: 1px solid var(--rule); padding: 16px; border-radius: var(--radius); }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-size: 0.82rem; font-weight: 600; color: var(--ink); }
.field .req { color: var(--danger); }
input, select, textarea { font: inherit; font-family: inherit; padding: 7px 9px; border: 1px solid var(--rule-strong); background: var(--paper-raised); color: var(--ink); border-radius: var(--radius); width: 100%; }
input:hover, select:hover, textarea:hover { border-color: var(--ink-muted); }
button, .button { font: inherit; font-family: var(--font-sans); padding: 8px 16px; border: 1px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer; border-radius: var(--radius); text-decoration: none; display: inline-block; font-size: 0.88rem; }
button:hover, .button:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
button.secondary, .button.secondary { background: var(--paper-raised); color: var(--accent); }
button.secondary:hover, .button.secondary:hover { background: var(--accent-wash); color: var(--accent-hover); }
button[disabled] { opacity: 0.5; cursor: not-allowed; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; align-items: center; }

/* sign-in and invitation pages: a narrow panel, never a full-width form */
.auth {
  max-width: 34rem; margin: 0 auto; padding: 6vh 0 0;
  display: flex; flex-direction: column; justify-content: center;
}
.shell--bare main { display: flex; align-items: flex-start; justify-content: center; padding: 0 20px 60px; }
.shell--bare .auth { width: 100%; }
.auth h1 { font-size: 1.9rem; margin: 0 0 6px; }
.auth > p.muted { font-size: 0.95rem; margin-bottom: 20px; }
.auth form.grid { grid-template-columns: 1fr; gap: 16px; padding: 24px; }
.auth .field label { font-size: 0.86rem; }
.auth input { padding: 11px 12px; font-size: 1rem; }
.auth .actions { margin-top: 6px; }
.auth .actions button, .auth .button { width: 100%; padding: 12px 16px; font-size: 0.95rem; text-align: center; }
.auth pre, .auth code { word-break: break-all; }

/* detail pages */
.tabs { display: flex; gap: 2px; flex-wrap: wrap; border-bottom: 1px solid var(--rule); margin: 14px 0 18px; }
.tabs a { padding: 7px 11px; text-decoration: none; color: var(--ink-body); border: 1px solid transparent; border-bottom: none; font-size: 0.86rem; }
.tabs a[aria-current="page"] { background: var(--paper-raised); border-color: var(--rule); color: var(--ink); font-weight: 600; }
dl.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 7px 22px; margin: 0; }
dl.facts dt { color: var(--ink-muted); font-size: 0.8rem; }
dl.facts dd { margin: 0; color: var(--ink); }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 9px 0; border-bottom: 1px solid var(--rule); }
.timeline time { color: var(--ink-muted); font-size: 0.8rem; }

pre.letter { background: var(--paper-raised); border: 1px solid var(--rule); padding: 18px; white-space: pre-wrap; font-family: var(--font-serif); font-size: 0.9rem; line-height: 1.5; max-height: 520px; overflow: auto; border-radius: var(--radius); }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  nav.side { display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--rule); padding: 0; }
  nav.side a { white-space: nowrap; border-left: 0; border-bottom: 2px solid transparent; }
  nav.side a.active { border-left: 0; border-bottom-color: var(--accent); }
  main { padding: 16px 14px 40px; }
}
@media print { nav.side, .top, .foot { display: none; } main { padding: 0; } }
