:root {
  --navy: #1F3864; --navy-2: #2B4A80; --ink: #14213D; --ink-2: #3D4A5C; --muted: #5A6678;
  --line: #D9DEE8; --line-2: #E9EDF3; --bg: #F5F6F8; --card: #FFFFFF; --accent: #B8651E; --accent-soft: #FBEFE3;
  --good: #0b7a0b; --good-bg: #E6F4E6; --warn: #8A5A00; --warn-bg: #FFF4D6; --serious: #A84A1F; --serious-bg: #FDEBE2;
  --crit: #B42323; --crit-bg: #FBE5E5; --info: #1F5FA8; --info-bg: #E5EEF9; --neutral-bg: #EEF0F4;
  --radius: 8px; --shadow: 0 1px 2px rgba(20,33,61,.06), 0 1px 1px rgba(20,33,61,.04);
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.45; }
a { color: var(--navy-2); }
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 16px 0 8px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--navy); color: #DCE3F0; padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { color: #fff; font-weight: 700; font-size: 15px; padding: 4px 8px 2px; }
.brand small { display: block; color: #AFC0DD; font-weight: 400; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; margin-top: 2px; }
.side nav { margin-top: 18px; display: flex; flex-direction: column; gap: 2px; }
.side nav .grp { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: #8FA3C6; margin: 14px 8px 4px; }
.side nav a { color: #DCE3F0; text-decoration: none; padding: 7px 10px; border-radius: 6px; display: flex; justify-content: space-between; align-items: center; }
.side nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.side nav a.on { background: rgba(255,255,255,.14); color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 #E39A4F; }
.side .pill { background: #E39A4F; color: #14213D; border-radius: 10px; font-size: 11px; padding: 0 7px; font-weight: 700; }
.side .me { border-top: 1px solid rgba(255,255,255,.12); margin-top: 18px; padding: 12px 8px 0; font-size: 12px; color: #AFC0DD; }
.side .me b { color: #fff; display: block; font-size: 13px; }
.side .me form { display: inline; }
.side .me button { background: none; border: 0; color: #AFC0DD; padding: 0; cursor: pointer; text-decoration: underline; font: inherit; }
main { padding: 24px 28px 48px; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); }
.topbar { background: var(--navy); color: #fff; }
.topbar .in { max-width: 1080px; margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.topbar a { color: #DCE3F0; text-decoration: none; padding: 6px 8px; border-radius: 6px; }
.topbar a.on, .topbar a:hover { background: rgba(255,255,255,.12); color: #fff; }
.topbar .brand { padding: 0; margin-right: 10px; }
.topbar .sp { flex: 1; }
.topbar form button { background: none; border: 1px solid rgba(255,255,255,.35); color: #fff; border-radius: 6px; padding: 5px 10px; cursor: pointer; }
.narrow { max-width: 1080px; margin: 0 auto; padding: 24px 20px 48px; }

/* ---------- cards & grid ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); min-width: 0; }
.card + .card { margin-top: 16px; }
.card h2 { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card h2 a { font-size: 12px; font-weight: 500; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-wide { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.stack > * + * { margin-top: 16px; }

/* stat tiles */
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); text-decoration: none; color: inherit; display: block; }
a.tile:hover { border-color: var(--navy-2); }
.tile .lbl { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.tile .val { font-size: 28px; font-weight: 700; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.tile .val small { font-size: 14px; color: var(--muted); font-weight: 500; }
.tile .foot { font-size: 12px; color: var(--ink-2); }
.tile.alert { border-left: 4px solid var(--crit); }
.tile.warn { border-left: 4px solid #E0A100; }
.tile.ok { border-left: 4px solid var(--good); }

/* meters */
.meter { height: 8px; background: var(--line-2); border-radius: 4px; overflow: hidden; display: flex; gap: 2px; }
.meter > span { display: block; height: 100%; background: var(--navy-2); border-radius: 4px; }
.meter.big { height: 14px; }
.seg-approved { background: #0ca30c !important; }
.seg-submitted { background: #2B6CB0 !important; }
.seg-progress { background: #E0A100 !important; }
.seg-todo { background: #B9C2D0 !important; }
.seg-rework { background: #d03b3b !important; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: 12px; color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.secrow { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) 70px; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.secrow:last-child { border-bottom: 0; }
.secrow a { text-decoration: none; color: var(--ink); }
.secrow a:hover { text-decoration: underline; }

/* badges */
.b { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--neutral-bg); color: var(--ink-2); }
.b::before { font-size: 10px; }
.b-ok { background: var(--good-bg); color: var(--good); } .b-ok::before { content: "\2714"; }
.b-warn { background: var(--warn-bg); color: var(--warn); } .b-warn::before { content: "\25B2"; }
.b-bad { background: var(--crit-bg); color: var(--crit); } .b-bad::before { content: "\2716"; }
.b-info { background: var(--info-bg); color: var(--info); } .b-info::before { content: "\25CF"; }
.b-serious { background: var(--serious-bg); color: var(--serious); } .b-serious::before { content: "!"; font-weight: 900; }
.b-plain::before { content: none; }
.tag { display: inline-block; font-size: 11px; padding: 0 6px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); background: #fff; white-space: nowrap; }
.is-overdue { color: var(--crit); font-weight: 600; }
.is-soon { color: var(--serious); font-weight: 600; }
.is-upcoming { color: var(--warn); }

/* tables */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #FAFBFC; position: sticky; top: 0; }
tr:hover td { background: #FAFBFD; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 8px 0; border-bottom: 1px solid var(--line-2); display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.list li:last-child { border-bottom: 0; }
.empty { color: var(--muted); padding: 10px 0; }

/* forms */
label { display: block; font-weight: 600; font-size: 12.5px; margin: 10px 0 4px; color: var(--ink-2); }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #C5CCD8; border-radius: 6px; font: inherit; color: var(--ink); background: #fff; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid #2B6CB0; outline-offset: 1px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 14px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.check input { width: auto; }
.btn { display: inline-block; background: var(--navy); color: #fff; border: 1px solid var(--navy); padding: 8px 14px; border-radius: 6px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--navy-2); }
.btn.sec { background: #fff; color: var(--navy); border-color: #B7C1D3; }
.btn.sec:hover { background: #F1F4F9; }
.btn.warn { background: var(--crit); border-color: var(--crit); }
.btn.sm { padding: 4px 10px; font-size: 12.5px; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 14px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; margin-bottom: 14px; }
.filters select, .filters input { width: auto; min-width: 150px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs a { padding: 8px 12px; text-decoration: none; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--navy); border-color: var(--accent); font-weight: 600; }
.flash { background: var(--good-bg); border: 1px solid #B5DDB5; color: #0A520A; padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; }
.error { background: var(--crit-bg); border: 1px solid #F0B9B9; color: #8A1616; padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; }
.notice { background: var(--warn-bg); border: 1px solid #F1D58A; color: #6B4600; padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; }
.inline { display: inline; }
details { border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; background: #fff; }
details + details { margin-top: 8px; }
summary { cursor: pointer; font-weight: 600; }
pre.report { white-space: pre-wrap; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 14px; }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 6px 12px; }
.kv dt { color: var(--muted); font-size: 12.5px; }
.kv dd { margin: 0; }
.quote { background: #FAFBFC; border-left: 3px solid var(--line); padding: 10px 12px; white-space: pre-wrap; font-size: 13px; }
.scss { border-left-color: var(--accent); background: var(--accent-soft); }
.qtable td:first-child { width: 48%; }
.qtable .opt { white-space: nowrap; }
.qtable .opt label { display: inline-flex; gap: 4px; font-weight: 500; margin: 0 8px 0 0; }
.qtable .opt input { width: auto; }
.cal-month { margin-top: 18px; }
.cal-month h3 { border-bottom: 2px solid var(--navy); padding-bottom: 4px; }
.auth { max-width: 400px; margin: 9vh auto; padding: 0 16px; }
.auth .card { padding: 26px; }
.auth .brand-line { text-align: center; margin-bottom: 18px; }
.auth .brand-line b { display: block; color: var(--navy); font-size: 17px; }
.status-big { font-size: 20px; font-weight: 700; }

@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-wide { grid-template-columns: 1fr; } }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .side nav { flex-direction: row; flex-wrap: wrap; } .side nav .grp { display: none; }
  main { padding: 16px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
}
@media print { .side, .topbar, .btns, .filters, form button { display: none !important; } .shell { display: block; } body { background: #fff; } .card { box-shadow: none; } }

/* AI review */
.ai-box { border: 1px dashed #B7C1D3; border-radius: 6px; padding: 10px 12px; margin: 8px 0; background: #FAFBFD; }
.ai-checks { list-style: none; margin: 6px 0; padding: 0; font-size: 12.5px; }
.ai-checks li { display: flex; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--line-2); }
.ai-checks li:last-child { border-bottom: 0; }
.ai-ico { width: 18px; flex: none; font-weight: 700; text-align: center; }
.ai-pass .ai-ico { color: var(--good); } .ai-fail .ai-ico { color: var(--crit); } .ai-unclear .ai-ico { color: var(--warn); }
.linkbtn { background: none; border: 0; padding: 0; color: var(--navy-2); text-decoration: underline; cursor: pointer; font: inherit; }
.ai-note { background: var(--warn-bg); border: 1px solid #F1D58A; border-radius: 6px; padding: 8px 10px; margin-top: 6px; color: #6B4600; }
.checkrow { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.batchbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 16px; position: sticky; top: 8px; z-index: 2; }
