:root {
  --brand: #1f4e8c;
  --brand-soft: #e8eff8;
  --accent: #00a3a3;
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1c2430;
  --muted: #667085;
  --line: #dde3ea;
  --ok: #1a8f4c;     --ok-bg: #e4f5ea;
  --warn: #b26a00;   --warn-bg: #fff1d6;
  --bad: #c0362c;    --bad-bg: #fde8e6;
  --info: #1f5fb5;   --info-bg: #e5eefb;
  --neutral-bg: #eceff3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14.5px; line-height: 1.45; color: var(--text); background: var(--bg);
}
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.2; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
a { color: var(--brand); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; }
.stack > * + * { margin-top: 12px; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.topbar {
  background: var(--brand); color: #fff; display: flex; align-items: center;
  gap: 14px; padding: 10px 18px; position: sticky; top: 0; z-index: 20;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; }
.topbar .brand img { height: 30px; width: auto; display: block; background: #fff; border-radius: 6px; padding: 2px; }
.brandmark { display: inline-flex; align-items: center; gap: 10px; }
.mark { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff; flex: none;
  background: linear-gradient(135deg, #0057FF, #00C2FF); box-shadow: 0 0 0 1px rgba(255,255,255,.35), 0 4px 12px -4px rgba(0,0,0,.45); }
.brand-t { display: flex; flex-direction: column; line-height: 1.15; }
.brand-t b { font-weight: 700; font-size: 15px; letter-spacing: .01em; }
.brand-t small { font-size: 11px; opacity: .85; letter-spacing: .06em; text-transform: uppercase; }
.brand-t b, .topbar button { white-space: nowrap; }
@media (max-width: 520px) { .topbar { gap: 8px; padding: 10px 12px; } .topbar .brand-t small { display: none; } .topbar .who { font-size: .75rem; } .topbar .who b { max-width: 90px; overflow: hidden; text-overflow: ellipsis; } .mark { width: 30px; height: 30px; border-radius: 9px; } }
.topbar .spacer { flex: 1; }
.topbar .who { text-align: right; font-size: .85rem; opacity: .95; }
.topbar .who b { display: block; }
.topbar button.ghost { color: #fff; border-color: rgba(255,255,255,.5); background: transparent; }
.topbar button.ghost:hover { background: rgba(255,255,255,.12); }
.menu-btn { display: none; }

.shell { display: flex; min-height: calc(100vh - 52px); }
.sidenav {
  width: 220px; flex: 0 0 220px; background: var(--card); border-right: 1px solid var(--line);
  padding: 12px 8px; position: sticky; top: 52px; height: calc(100vh - 52px); overflow-y: auto;
}
.sidenav a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 12px; border-radius: 8px; color: var(--text); text-decoration: none; margin-bottom: 2px;
}
.sidenav a:hover { background: var(--neutral-bg); }
.sidenav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.sidenav .badge {
  background: var(--bad); color: #fff; border-radius: 999px; min-width: 20px; height: 20px;
  padding: 0 6px; font-size: .75rem; display: inline-flex; align-items: center; justify-content: center;
}
main#main { flex: 1; padding: 22px; min-width: 0; max-width: 1200px; }

/* ---------- components ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px;
}
.card.error { border-color: var(--bad); color: var(--bad); }
.card.banner { border-left: 4px solid var(--warn); background: var(--warn-bg); }
.card.banner.info { border-left-color: var(--info); background: var(--info-bg); }
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.stat { text-align: left; }
.stat .num { font-size: 1.9rem; font-weight: 700; color: var(--brand); line-height: 1.1; }
.stat .lbl { color: var(--muted); font-size: .85rem; }
.stat a { text-decoration: none; color: inherit; display: block; }

.btn, button {
  font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--text); padding: 7px 14px;
}
.btn:hover, button:hover { background: var(--neutral-bg); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); background: var(--brand); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.small, button.small { padding: 4px 10px; font-size: .85rem; }
button:disabled { opacity: .55; cursor: not-allowed; }
.icon-btn { border: none; background: transparent; font-size: 1.4rem; line-height: 1; padding: 2px 8px; }

label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-weight: 600; margin-bottom: 4px; font-size: .9rem; }
label.field .hint { font-weight: 400; color: var(--muted); font-size: .8rem; }
input, select, textarea {
  font: inherit; width: 100%; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
input[type=checkbox] { width: auto; }
textarea { min-height: 80px; resize: vertical; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }

.chip {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600;
  background: var(--neutral-bg); color: var(--muted); white-space: nowrap;
}
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.info { background: var(--info-bg); color: var(--info); }

table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th, table.tbl td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.tbl th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #fafbfc; }
table.tbl tr:hover td { background: #fafbfc; }
.table-wrap { overflow-x: auto; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button {
  border: none; background: transparent; padding: 9px 14px; border-bottom: 3px solid transparent;
  border-radius: 0; color: var(--muted); font-weight: 600;
}
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }
.tabs .count { background: var(--bad); color: #fff; border-radius: 999px; font-size: .72rem; padding: 1px 7px; margin-left: 6px; }

.item { border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-bottom: 10px; background: #fff; }
.item .head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 6px 12px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.timeline { border-left: 3px solid var(--line); margin: 8px 0 0 6px; padding-left: 12px; }
.timeline .tl { margin-bottom: 8px; }
.empty { text-align: center; color: var(--muted); padding: 26px 10px; }
.loading { color: var(--muted); padding: 30px; text-align: center; }
.warnbox { background: var(--warn-bg); border: 1px solid #f0d28f; border-radius: 8px; padding: 10px 12px; margin: 10px 0; }
.okbox { background: var(--ok-bg); border: 1px solid #b7e2c5; border-radius: 8px; padding: 10px 12px; margin: 10px 0; }

/* ---------- planner (calendar) ---------- */
.planner { border-collapse: collapse; font-size: .8rem; }
.planner th, .planner td { border: 1px solid var(--line); padding: 3px 4px; text-align: center; min-width: 26px; }
.planner th.name, .planner td.name { text-align: left; min-width: 150px; position: sticky; left: 0; background: #fff; z-index: 1; }
.planner th.wk { background: #f1f3f6; color: var(--muted); }
.planner td.we { background: #f6f7f9; }
.planner td.off-ok { background: var(--ok); color: #fff; }
.planner td.off-pending { background: #f2b84b; color: #fff; }
.planner tfoot td { font-weight: 700; background: #fafbfc; }
.planner tfoot td.hot { background: var(--bad-bg); color: var(--bad); }
.legend span { display: inline-flex; align-items: center; gap: 6px; margin-right: 14px; font-size: .82rem; }
.legend i { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }

/* ---------- modal & toast ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(16, 24, 40, .5); z-index: 50;
  display: flex; align-items: flex-start; justify-content: center; padding: 6vh 12px; overflow-y: auto;
}
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 560px; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.modal.wide { max-width: 860px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; }
.modal-body { padding: 16px 18px; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 80; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #1c2430; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); max-width: 360px; }
.toast.err { background: var(--bad); }

/* ---------- auth screen ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 18px; background: linear-gradient(160deg, var(--brand-soft), var(--bg)); }
.auth-card { background: #fff; border-radius: 14px; padding: 26px; width: 100%; max-width: 430px; box-shadow: 0 8px 30px rgba(16,24,40,.12); }
.auth-card .logo { text-align: center; margin-bottom: 14px; }
.auth-card .logo img { max-height: 54px; }
.auth-card .logo .brandmark { justify-content: center; }
.auth-card .logo .mark { width: 44px; height: 44px; border-radius: 13px; box-shadow: 0 4px 14px -4px rgba(0,87,255,.55); }
.auth-card .logo .mark svg { width: 24px; height: 24px; }
.auth-card .logo .brand-t b { color: var(--fg, #0b1b33); font-size: 1.4rem; }
.auth-card h1 { text-align: center; font-size: 1.35rem; }
.langs { text-align: right; margin-bottom: 6px; }
.err-text { color: var(--bad); margin: 8px 0; }
.ok-text { color: var(--ok); margin: 8px 0; }

@media (max-width: 820px) {
  .menu-btn { display: inline-block; }
  .sidenav { position: fixed; left: -240px; top: 52px; z-index: 30; transition: left .2s; height: calc(100vh - 52px); }
  .sidenav.open { left: 0; box-shadow: 4px 0 20px rgba(0,0,0,.2); }
  main#main { padding: 14px; }
  .kv { grid-template-columns: 1fr; }
}
@media print {
  .topbar, .sidenav, #toasts, button { display: none !important; }
  main#main { padding: 0; max-width: none; }
}

/* sign-in tick boxes */
.tick { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; cursor: pointer; line-height: 1.3; }
.tick input[type=checkbox] { width: 18px; height: 18px; margin-top: 2px; flex: none; }

/* Forms & links sections */
.link-section { margin: 18px 0 8px; }
.link-section-title { margin: 0 0 10px; font-size: 1.05rem; color: var(--brand); display: flex; align-items: center; gap: 8px; }
.link-section-title::after { content: ''; flex: 1; height: 1px; background: var(--line, #dfe5ea); }

/* ======================================================================
   Visual refresh - same look as the scorecard dashboard (tile colours, soft cards).
   The banner stays the hub dark blue (--brand).
   ====================================================================== */
:root {
  --met: #138a4b;   --met-bg: #e6f6ed;
  --near: #a86a00;  --near-bg: #fff3d9;
  --miss: #c0362c;  --miss-bg: #fdeceb;
  --edit: #7a3ff2;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 14px -6px rgba(16, 24, 40, .10);
}
body { letter-spacing: .005em; }
.card { border-color: #e3e8ef; }
.card > h2:first-child { font-size: 1.05rem; letter-spacing: .01em; }
.item { transition: box-shadow .15s, border-color .15s; }
.item:hover { border-color: #cdd6e2; box-shadow: 0 2px 10px -4px rgba(16, 24, 40, .12); }
.btn.primary, button.primary { box-shadow: 0 1px 2px rgba(31, 78, 140, .35); }
.chip { letter-spacing: .01em; }
.tabs { gap: 2px; }
.tabs button:hover { color: var(--brand); background: var(--brand-soft); }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.page-head { margin-bottom: 10px; }
.page-head h1 { margin-bottom: 2px; }
.big { font-size: 1.9rem; font-weight: 700; color: var(--brand); line-height: 1.1; }
.strong { font-weight: 700; }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

/* menu groups */
.nav-group { margin: 14px 12px 4px; font-size: .7rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.nav-group:first-child { margin-top: 4px; }
.sidenav a.active { box-shadow: inset 3px 0 0 var(--brand); }

/* KPI tiles */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid #e3e8ef; border-top: 4px solid #cbd3de; border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.kpi.met { border-top-color: var(--met); } .kpi.near { border-top-color: #e0a100; } .kpi.miss { border-top-color: var(--miss); }
.kpi-l { font-size: .78rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.kpi-v { font-size: 1.7rem; font-weight: 700; line-height: 1.15; }
.kpi.met .kpi-v { color: var(--met); } .kpi.near .kpi-v { color: var(--near); } .kpi.miss .kpi-v { color: var(--miss); }
.kpi-t { font-size: .78rem; color: var(--muted); min-height: 1.1em; }
.kpi-f { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 4px; color: var(--muted); min-height: 26px; }
.kpi.met .kpi-f { color: var(--met); } .kpi.near .kpi-f { color: var(--near); } .kpi.miss .kpi-f { color: var(--miss); }
.spark { width: 96px; height: 26px; flex: none; }
.delta { font-size: .78rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--neutral-bg); color: var(--muted); white-space: nowrap; }
.delta.good { background: var(--met-bg); color: var(--met); } .delta.badd { background: var(--miss-bg); color: var(--miss); }

/* result tables */
table.dash td.num, table.dash th { white-space: nowrap; }
table.dash td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.dash td.met { background: var(--met-bg); color: var(--met); font-weight: 600; }
table.dash td.near { background: var(--near-bg); color: var(--near); font-weight: 600; }
table.dash td.miss { background: var(--miss-bg); color: var(--miss); font-weight: 600; }
table.dash td.fig { cursor: default; position: relative; }
table.dash td.fig.editable { cursor: pointer; }
table.dash td.fig.editable:hover { outline: 2px solid var(--accent); outline-offset: -2px; }
table.dash td.fig.locked { background-image: repeating-linear-gradient(135deg, transparent 0 6px, rgba(0, 0, 0, .035) 6px 12px); }
table.dash td.edited::after, td.edited::after { content: ''; position: absolute; top: 3px; right: 3px; width: 7px; height: 7px; border-radius: 50%; background: var(--edit); }
table.dash td.edited { position: relative; }

/* right-click menu */
.ctx { position: fixed; z-index: 90; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(16, 24, 40, .22); padding: 4px; min-width: 190px; }
.ctx button { display: block; width: 100%; text-align: left; border: none; background: transparent; padding: 8px 12px; border-radius: 7px; }
.ctx button:hover { background: var(--brand-soft); }

/* small helpers used by the conduct / integration screens */
.item .row.small, label.row.small { gap: 6px; }
.timeline .tl .row { gap: 8px; }
.okbox.small, .warnbox.small { padding: 8px 10px; }
.modal-body h3 { margin-top: 14px; }
.modal-body table.tbl { font-size: .88rem; }
