/* ==========================================================================
   用工风险管理 — light 3D theme
   Matte navy / steel-blue palette, layered ceramic surfaces, line icons in
   small raised tiles. Depth is used for hierarchy: canvas → panel → tile.
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;

  /* surfaces */
  --canvas: #eceff4;
  --surface: #ffffff;
  --surface-subtle: #f5f7fa;
  --surface-sunken: #eef1f5;
  --border: #dce2ea;
  --border-strong: #c2cbd8;

  /* text */
  --text: #142033;
  --secondary: #3e4d63;
  --muted: #5a677a;

  /* steel-blue accent (token names kept from the earlier theme) */
  --blue: #2c4f85;
  --blue-hover: #213e6b;
  --blue-tint: #e6ecf5;
  --steel: #6a809f;
  --nav-hover: #eef2f7;
  --focus: #2b62bd;

  /* semantic */
  --danger: #a0303d;
  --danger-tint: #f8ecee;
  --danger-edge: #ecccd1;
  --warning: #7a4e12;
  --warning-tint: #f7f0e2;
  --warning-edge: #e6d6b6;

  /* navigation (dark matte navy) */
  --nav-bg: #182840;
  --nav-bg-deep: #132136;
  --nav-text: #d8e0eb;
  --nav-muted: #a2b1c6;
  --nav-edge: rgb(190 207 230 / 14%);
  --nav-focus: #a6c4f0;

  /* shape + depth */
  --radius: 14px;
  --radius-sm: 9px;
  --highlight: inset 0 1px 0 rgb(255 255 255 / 90%);
  --shadow: 0 1px 2px rgb(20 32 51 / 6%), 0 6px 18px -10px rgb(20 32 51 / 22%);
  --shadow-raised: 0 1px 2px rgb(20 32 51 / 8%), 0 14px 30px -14px rgb(20 32 51 / 32%);
  --shadow-overlay: 0 30px 70px -20px rgb(12 22 40 / 48%), 0 8px 22px rgb(12 22 40 / 14%);
  --surface-raised: linear-gradient(180deg, #ffffff 0%, #f9fafc 100%);
  --tile-face: linear-gradient(180deg, #ffffff 0%, #e8edf4 100%);
  --tile-shadow: inset 0 1px 0 #fff, inset 0 -1px 0 rgb(122 141 170 / 28%), 0 1px 2px rgb(20 32 51 / 12%), 0 3px 6px -3px rgb(20 32 51 / 22%);
  --ease: cubic-bezier(.2, .7, .2, 1);

  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Noto Sans SC", sans-serif;
  font-synthesis-weight: none;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--canvas); color: var(--text); }
body:has(dialog[open]) { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: wait; opacity: .6; }
a { color: var(--blue); text-underline-offset: 2px; }
h1, h2, h3 { letter-spacing: -.01em; }
.ico { width: 18px; height: 18px; flex: none; display: inline-block; vertical-align: middle; }
.muted { color: var(--muted); }
.danger { color: var(--danger); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

:where(button, a, input, select, textarea, summary):focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[tabindex="-1"]:focus { outline: none; }

.skip {
  position: absolute; left: 12px; top: -80px; z-index: 50;
  padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--surface); color: var(--blue-hover); font-weight: 650;
  box-shadow: var(--shadow-raised);
}
.skip:focus { top: 12px; }

/* ---------- Dimensional tiles (icons) ---------- */
.tile {
  display: grid; place-items: center; flex: none;
  width: 32px; height: 32px;
  border: 1px solid #d3dbe6; border-radius: 9px;
  background: var(--tile-face);
  color: var(--blue);
  box-shadow: var(--tile-shadow);
}
.tile .ico { width: 17px; height: 17px; }
.tile.lg { width: 44px; height: 44px; border-radius: 12px; }
.tile.lg .ico { width: 22px; height: 22px; }
.tile.red { color: var(--danger); }
.tile.gold { color: var(--warning); }
.tile.blue { color: var(--blue); }
.tile.num { color: var(--blue-hover); font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Touch HUD ---------- */
:root {
  --hud-dock-clearance: calc(114px + env(safe-area-inset-bottom, 0px));
  --hud-dock-inset: 14px;
}

.shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100dvh;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% -18%, #f7faff 0, transparent 65%), var(--canvas);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 0 4px; font-size: 15px; font-weight: 700; }
.brand-name { min-width: 0; line-height: 1.35; overflow-wrap: anywhere; }
.logo {
  display: grid; place-items: center; flex: none;
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(180deg, #f6f8fc, #cfd9e8);
  color: var(--blue-hover);
  box-shadow: inset 0 1px 0 #fff, inset 0 -2px 0 rgb(70 96 140 / 25%), 0 4px 10px rgb(6 14 28 / 35%);
}
.logo .ico { width: 21px; height: 21px; }
.main {
  grid-row: 2; min-width: 0; min-height: 0;
  overflow: auto; overscroll-behavior: contain; outline: none;
  scroll-padding-block: 12px;
}

.topbar, .login-top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 64px;
  padding-inline: max(clamp(16px, 3vw, 40px), env(safe-area-inset-left, 0px))
                 max(clamp(16px, 3vw, 40px), env(safe-area-inset-right, 0px));
}
.topbar {
  grid-row: 1; position: relative; z-index: 10;
  padding-top: env(safe-area-inset-top, 0px);
  color: var(--nav-text);
  background: linear-gradient(180deg, #23344d, #172840);
  border-bottom: 1px solid #42546d;
  box-shadow: inset 0 -1px 0 #a8b9d133, 0 4px 13px #16263d26;
}
.topbar :where(button,select,a):focus-visible, .nav button:focus-visible { outline-color: var(--nav-focus); }
.company-select {
  position: relative; display: flex; align-items: center; gap: 9px;
  min-width: 0; width: clamp(160px, 27vw, 330px); margin-right: auto; padding: 0 11px;
  border: 1px solid var(--nav-edge); border-radius: 10px;
  background: #101e32b0; color: var(--nav-muted);
  box-shadow: inset 0 2px 4px #080f1d45;
}
.company-select .ico { width: 17px; height: 17px; }
.company-label { flex: none; color: var(--nav-muted); font-size: 11px; white-space: nowrap; }
.company-select select {
  width: 100%; min-width: 0; min-height: 44px;
  padding: 8px 21px 8px 0; border: 0; background: transparent;
  color: #f1f5fb; font-size: 14px; text-overflow: ellipsis; appearance: none;
}
.company-select select:focus-visible { outline-offset: 3px; }
.company-select option { color: var(--text); background: var(--surface); }
.company-select .company-chevron { position: absolute; right: 9px; width: 14px; height: 14px; pointer-events: none; }
.top-meta { display: flex; flex: none; align-items: center; gap: 13px; color: var(--nav-muted); font-size: 12px; }
.environment {
  display: inline-flex; gap: 6px; align-items: center; padding: 3px 9px;
  border: 1px solid var(--border); border-radius: 99px; white-space: nowrap;
  background: var(--surface); color: var(--secondary); font-size: 11px;
  box-shadow: var(--highlight), 0 1px 2px rgb(20 32 51 / 6%);
}
.environment i { width: 6px; height: 6px; border-radius: 50%; background: var(--steel); }
.top-meta .environment { background: #ffffff0d; color: var(--nav-text); border-color: var(--nav-edge); box-shadow: none; }
.top-meta .environment i { background: #9ab7e3; }
.top-account { display: flex; align-items: center; flex: none; gap: 9px; padding-left: 12px; border-left: 1px solid var(--nav-edge); }
.avatar {
  display: grid; place-items: center; flex: none; width: 35px; height: 35px; border-radius: 50%;
  background: linear-gradient(180deg, #f3f6fb, #c8d4e5); color: var(--blue-hover); font-weight: 700;
  box-shadow: inset 0 1px 0 #fff, 0 2px 6px rgb(0 0 0 / 30%);
}
.account-name { min-width: 0; max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 650; }
.iconbtn {
  display: grid; place-items: center; flex: none; width: 44px; height: 44px; padding: 0;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--secondary);
}
.top-account .iconbtn { color: var(--nav-text); }
.arrow { width: 14px; height: 14px; color: var(--muted); }

.hud-footer {
  grid-row: 3;
  padding: 7px 0 calc(var(--hud-dock-inset) + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid #d5deea;
  background: linear-gradient(180deg, #f4f7fb, #e6ecf5);
  box-shadow: 0 -4px 12px #273f5b0a;
  z-index: 8;
}
.nav {
  position: relative;
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 5px;
  width: min(742px, calc(100% - 32px)); margin-inline: auto; padding: 7px;
  border: 1px solid #51627a; border-radius: 18px;
  background: linear-gradient(180deg, #283952f8, #17263bf8);
  color: var(--nav-text);
  box-shadow: inset 0 1px #b5c7e944, inset 0 -2px #0c182b80, 0 4px 12px #14253d35;
  backdrop-filter: blur(14px);
}
.nav button {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 0; min-height: 66px; gap: 3px; padding: 5px 4px;
  border: 1px solid transparent; border-radius: 11px;
  background: transparent; color: var(--nav-text);
  font-size: 12px; font-weight: 600; line-height: 1.2; white-space: nowrap;
  transition: background-color 140ms ease, box-shadow 140ms ease;
}
.nav-ico {
  display: grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 8px;
  border: 1px solid #ffffff18; background: linear-gradient(180deg, #ffffff14, #ffffff06);
  box-shadow: inset 0 1px #ffffff14;
}
.nav-ico .ico { width: 18px; height: 18px; }
.nav button.selected {
  border-color: #f8fbff;
  background: linear-gradient(180deg, #f9fbff, #dce6f3);
  color: #172d4e;
  box-shadow: inset 0 -2px #7a8daa4d, 0 5px 12px #0006;
}
.nav button.selected .nav-ico { border-color: #c4d1e3; background: var(--tile-face); color: var(--blue); box-shadow: var(--tile-shadow); }
.nav button:active { transform: translateY(1px); }
.nav-label-short { display: none; }

.content {
  width: min(1560px, 100%); margin-inline: auto;
  padding: clamp(20px, 3vw, 36px)
           max(clamp(14px, 3vw, 40px), env(safe-area-inset-right, 0px))
           25px
           max(clamp(14px, 3vw, 40px), env(safe-area-inset-left, 0px));
}
.shell .btn, body:has(.shell) dialog .btn { min-height: 44px; }
body:has(.shell) #toast { bottom: var(--hud-dock-clearance); }

/* ---------- Page heading ---------- */
.head { display: flex; justify-content: space-between; align-items: center; gap: 16px 24px; margin-bottom: 24px; }
.head-title { display: flex; align-items: center; gap: 14px; min-width: 0; }
.head h1 { margin: 0; font-size: clamp(22px, 2.2vw, 28px); font-weight: 700; line-height: 1.25; }
.head p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 40px; padding: 7px 14px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #ffffff, #f2f5f9);
  color: var(--text); font-weight: 600; line-height: 1.3; text-decoration: none; white-space: nowrap;
  box-shadow: var(--highlight), 0 1px 2px rgb(20 32 51 / 8%);
  transition: background-color 140ms ease, box-shadow 140ms ease, border-color 140ms ease, transform 140ms ease;
}
.btn .ico { width: 17px; height: 17px; color: var(--blue); }
.btn:active { transform: translateY(1px); box-shadow: inset 0 1px 3px rgb(20 32 51 / 16%); }
.btn.primary {
  border-color: var(--blue-hover);
  background: linear-gradient(180deg, #3a5f97, var(--blue));
  color: #fff;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 22%), inset 0 -1px 0 rgb(0 0 0 / 18%), 0 2px 6px -1px rgb(33 62 107 / 45%);
}
.btn.primary .ico { color: currentColor; }
.btn.primary:active { box-shadow: inset 0 2px 4px rgb(0 0 0 / 25%); }
.btn.quiet { min-height: 36px; padding: 5px 10px; border-color: transparent; background: transparent; box-shadow: none; color: var(--blue); font-size: 13px; }
.btn.block { width: 100%; }
a.btn[aria-disabled="true"] { opacity: .55; pointer-events: none; }
.textbtn { min-height: 32px; padding: 4px 0; border: 0; background: none; color: var(--blue); font-weight: 600; text-align: left; }

/* ---------- Metrics ---------- */
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.metric {
  position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: 10px;
  min-width: 0; padding: 16px 16px 15px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-raised); color: var(--text); text-align: left;
  box-shadow: var(--highlight), var(--shadow);
  transition: box-shadow 160ms var(--ease), transform 160ms var(--ease), border-color 160ms ease;
}
.metric .label { color: var(--secondary); font-size: 13px; font-weight: 600; }
.metric strong { grid-column: 1 / -1; margin: 12px 0 2px; font-size: 32px; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.metric small { grid-column: 1 / -1; color: var(--muted); font-size: 12px; }
.metric:active { transform: translateY(1px); }

/* ---------- Panels ---------- */
.board { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(260px, 1fr); gap: 16px; align-items: start; }
.stack { display: grid; gap: 16px; min-width: 0; }
.stack .panel { margin: 0; }
.rules-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 16px; align-items: start; }
.rules-grid .panel { margin: 0; }
.panel {
  min-width: 0; margin-bottom: 16px; overflow: hidden;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--highlight), var(--shadow);
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 14px;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #ffffff, #f8f9fb);
}
.panel-title { display: flex; align-items: center; gap: 11px; min-width: 0; }
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 700; }
.panel-head p { margin: 1px 0 0; color: var(--muted); font-size: 12px; }
.panel-meta { color: var(--muted); font-size: 12px; }
.panel-body { padding: 16px 18px; }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }

/* risk queue */
.worklist { margin: 0; padding: 0; list-style: none; }
.worklist li + li { border-top: 1px solid var(--border); }
.workrow {
  display: flex; gap: 12px; align-items: center; width: 100%; min-height: 64px;
  padding: 11px 18px; border: 0; background: var(--surface); color: var(--text); text-align: left;
  transition: background-color 120ms ease;
}
.workrow:focus-visible { outline-offset: -3px; }
.workrow > .arrow { flex: none; }
.risk-marker { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--steel); box-shadow: 0 0 0 3px rgb(106 128 159 / 18%); }
.risk-marker.high { background: #c2485a; box-shadow: 0 0 0 3px rgb(194 72 90 / 18%); }
.risk-marker.medium { background: #b07f30; box-shadow: 0 0 0 3px rgb(176 127 48 / 18%); }
.rowmain { flex: 1; min-width: 0; }
.rowmain b, .rowmain small { display: block; overflow-wrap: anywhere; }
.rowmain b { font-weight: 600; }
.rowmain small { margin-top: 2px; color: var(--muted); font-size: 12px; }
.sev { font-weight: 600; color: var(--secondary); }
.sev.high { color: var(--danger); }
.sev.medium { color: var(--warning); }

/* remediation pipeline */
.pipeline { display: grid; gap: 2px; margin: -6px -8px; padding: 0; list-style: none; }
.pipeline li { position: relative; }
.pipeline li:not(:last-child)::before {
  content: ""; position: absolute; left: 20px; top: 50%; height: calc(100% + 2px); width: 1px;
  background: var(--border-strong);
}
.stage {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: 12px minmax(0, 1fr) auto 14px; align-items: center; gap: 12px;
  width: 100%; min-height: 44px; padding: 6px 10px 6px 15px;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text); text-align: left;
}
.node { width: 11px; height: 11px; border: 2px solid var(--steel); border-radius: 50%; background: var(--surface); }
.node.filled { border-color: var(--blue); background: var(--blue); box-shadow: 0 0 0 3px var(--blue-tint); }
.stage-label { color: var(--secondary); }
.stage strong { font-size: 16px; font-variant-numeric: tabular-nums; }

/* pills */
.pill {
  display: inline-flex; align-items: center; padding: 2px 8px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface-sunken); color: var(--secondary);
  font-size: 12px; font-weight: 600; line-height: 1.5; white-space: nowrap;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 70%);
}
.pill.high { border-color: var(--danger-edge); background: var(--danger-tint); color: var(--danger); }
.pill.medium, .pill.manual, .pill.published { border-color: var(--warning-edge); background: var(--warning-tint); color: var(--warning); }
.pill.active, .pill.submitted, .pill.processing, .pill.pending, .pill.draft { border-color: #cbd6e6; background: var(--blue-tint); color: var(--blue-hover); }

/* staff */
.staff-total { display: flex; align-items: baseline; gap: 7px; margin: -2px 0 10px; color: var(--muted); font-size: 13px; }
.staff-total strong { color: var(--text); font-size: 30px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.staff-bar { display: flex; height: 10px; gap: 3px; overflow: hidden; border-radius: 6px; background: var(--surface-sunken); box-shadow: inset 0 1px 2px rgb(20 32 51 / 14%); }
.staff-bar span, .staff-legend i { display: inline-block; min-width: 4px; background: #aab6c7; }
.staff-bar .active, .staff-legend .active { background: linear-gradient(180deg, #4a6ea3, var(--blue)); }
.staff-bar .onboarding, .staff-legend .onboarding { background: linear-gradient(180deg, #a3b8d6, #8199bd); }
.staff-legend { display: grid; gap: 8px; margin: 16px 0 0; padding: 0; list-style: none; }
.staff-legend li { display: flex; align-items: center; justify-content: space-between; color: var(--secondary); font-size: 13px; }
.staff-legend i { width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; }
.staff-legend strong { color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- Toolbar + inputs ---------- */
.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #fbfcfd, #f5f7fa);
}
.search { position: relative; display: flex; flex: 0 1 300px; min-width: 200px; }
.search .ico { position: absolute; left: 11px; top: 50%; width: 16px; height: 16px; color: var(--muted); transform: translateY(-50%); pointer-events: none; }
.search input { width: 100%; padding-left: 34px; }
.result-count { margin-left: auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.inline-field { display: flex; align-items: center; gap: 8px; color: var(--secondary); font-size: 13px; font-weight: 600; }
.inline-field select { min-width: 200px; }

input, select, textarea {
  min-height: 40px; padding: 7px 11px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background-color: #fcfdfe; color: var(--text);
  box-shadow: inset 0 1px 2px rgb(20 32 51 / 7%);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: inset 0 1px 2px rgb(20 32 51 / 7%), 0 0 0 3px rgb(44 79 133 / 14%); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 1px; }
select:not(#company) { appearance: none; padding-right: 32px; background: #fcfdfe url('/assets/icons/down.svg') right 10px center / 14px no-repeat; }
input::placeholder, textarea::placeholder { color: #7a8697; }
input[type="search"]::-webkit-search-decoration { appearance: none; }
textarea { width: 100%; min-height: 96px; resize: vertical; line-height: 1.6; }
input[type="file"] {
  width: 100%; min-height: 64px; padding: 14px;
  border: 1px dashed var(--border-strong); background: var(--surface-subtle); box-shadow: none; cursor: pointer;
}
input[type="file"]::file-selector-button {
  margin-right: 10px; padding: 7px 12px;
  border: 1px solid var(--border-strong); border-radius: 8px;
  background: linear-gradient(180deg, #fff, #eef2f7); color: var(--blue-hover); font-weight: 600; cursor: pointer;
  box-shadow: var(--highlight), 0 1px 2px rgb(20 32 51 / 8%);
}

/* ---------- Tables ---------- */
.tablebox { overflow: auto; }
.table { width: 100%; min-width: 640px; border-collapse: collapse; }
.table th, .table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; text-align: left; }
.table th { background: var(--surface-subtle); color: var(--secondary); font-size: 12px; font-weight: 600; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table small { display: block; color: var(--muted); font-size: 12px; }
.table td:last-child { white-space: nowrap; }
.filename, .hash { overflow-wrap: anywhere; }
.process-line { display: flex; justify-content: space-between; gap: 12px; align-items: center; min-height: 44px; border-bottom: 1px solid var(--border); }
.process-line:last-child { border-bottom: 0; }
.process-line small { color: var(--danger); white-space: nowrap; font-variant-numeric: tabular-nums; }
.flow-batches .table { min-width: 0; }
.flow-batches .table td:nth-child(2) { overflow-wrap: anywhere; }
.flow-picker .panel-head { border-bottom: 0; }

/* checklists */
.subhead { margin: 0 0 8px; font-size: 13px; font-weight: 700; }
.checks { display: grid; list-style: none; margin: 0; padding: 0; }
.checks li { display: grid; grid-template-columns: minmax(84px, auto) minmax(0, 1fr); gap: 4px 14px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.checks li:first-child { padding-top: 0; }
.checks li:last-child { border-bottom: 0; padding-bottom: 0; }
.checks b { font-weight: 650; }
.checks span { color: var(--secondary); }
.checks.bullets li { display: flex; gap: 10px; color: var(--secondary); }
.checks.bullets li::before { content: ""; flex: none; width: 6px; height: 6px; margin-top: .65em; border-radius: 50%; background: var(--warning); }

/* ---------- Detail content ---------- */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 2px 0; margin: 0 0 16px; padding: 4px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-subtle); box-shadow: inset 0 1px 2px rgb(20 32 51 / 5%); }
.facts > div { min-width: 0; padding: 8px 10px; }
.facts .wide { grid-column: 1 / -1; }
.facts dt { color: var(--muted); font-size: 12px; }
.facts dd { margin: 2px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.note { margin: 0 0 14px; color: var(--secondary); }
.subsection { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.risk-summary { display: grid; gap: 10px; margin-bottom: 4px; }
.risk-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.detailgrid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.detailgrid .panel { margin: 0; box-shadow: var(--highlight); }
.citation { margin: 0 0 14px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-subtle); }
.citation p { margin: 0 0 10px; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.ocr-text { margin: 0; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-subtle); font: 13px/1.65 ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.log { display: grid; gap: 12px; }
.log-entry { position: relative; padding: 0 0 2px 16px; }
.log-entry::before { content: ""; position: absolute; left: 0; top: .45em; width: 7px; height: 7px; border: 2px solid var(--steel); border-radius: 50%; background: var(--surface); }
.log-entry:not(:last-child)::after { content: ""; position: absolute; left: 3px; top: 1.3em; bottom: -12px; width: 1px; background: var(--border-strong); }
.log-entry b { font-size: 13px; }
.log-entry small { display: block; color: var(--muted); font-size: 12px; }
.log-entry p { margin: 4px 0 0; }

/* PDF catalog */
.catalog-preview { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 14px; }
.catalog-preview input { width: 88px; }
.catalog-table { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.catalog-row { display: grid; grid-template-columns: 150px minmax(160px, 1fr) auto; align-items: center; gap: 10px 12px; padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface); }
.catalog-row:nth-child(odd):not(.catalog-labels) { background: var(--surface-subtle); }
.catalog-row:last-child { border-bottom: 0; }
.catalog-row small { display: block; color: var(--muted); font-size: 12px; }
.catalog-row small.danger { color: var(--danger); }
.catalog-labels { padding-block: 8px; background: var(--surface-sunken); color: var(--secondary); font-size: 12px; font-weight: 600; }
.catalog-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.catalog-split input { width: 76px; }

/* ---------- Dialog ---------- */
dialog {
  width: min(680px, calc(100vw - 32px)); max-height: calc(100dvh - 40px);
  overflow: auto; overscroll-behavior: contain; padding: 0;
  border: 1px solid #c9d3e1; border-radius: 18px;
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-overlay);
}
dialog[data-size="sm"] { width: min(520px, calc(100vw - 32px)); }
dialog[data-size="lg"] { width: min(920px, calc(100vw - 32px)); }
dialog::backdrop { background: rgb(14 24 42 / 52%); backdrop-filter: blur(2px); }
.modalhead {
  position: sticky; top: 0; z-index: 2;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 12px 12px 22px; border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #ffffff, #f7f9fb);
}
dialog h2 { margin: 0; font-size: 17px; font-weight: 700; overflow-wrap: anywhere; }
.modalbody { padding: 20px 22px 22px; }
.modalbody > p:first-child { margin-top: 0; }
.formgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.full { grid-column: 1 / -1; }
.formsection { min-width: 0; margin: 0; padding: 0; border: 0; }
.formsection + .formsection { padding-top: 18px; border-top: 1px solid var(--border); }
.formsection legend { padding: 0; margin-bottom: 12px; color: var(--blue-hover); font-size: 13px; font-weight: 700; }
.field { display: grid; gap: 6px; min-width: 0; color: var(--secondary); font-size: 13px; font-weight: 600; }
.field small { color: var(--muted); font-size: 12px; font-weight: 400; }
.field input, .field select { width: 100%; min-width: 0; color: var(--text); font-weight: 400; }
.field textarea { font-weight: 400; }
.modalactions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 18px; }
/* Keep the commit actions reachable in long dialogs */
.modalbody > .modalactions:last-child, .modalbody form > .modalactions {
  position: sticky; bottom: 0; z-index: 1;
  margin: 18px -22px -22px; padding: 12px 22px 14px;
  border-top: 1px solid var(--border); background: rgb(255 255 255 / 94%);
  backdrop-filter: blur(6px);
}
.subsection form > .modalactions { position: static; margin: 16px 0 0; padding: 0; border: 0; background: none; backdrop-filter: none; }
.error { margin: 10px 0 0; padding: 8px 12px; border: 1px solid var(--danger-edge); border-radius: 8px; background: var(--danger-tint); color: var(--danger); }
.error:empty { display: none; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; inset: auto 20px 20px auto; z-index: 60;
  max-width: min(440px, calc(100vw - 40px)); margin: 0; padding: 11px 16px;
  border: 1px solid rgb(255 255 255 / 10%); border-radius: 10px;
  background: #1a2a44; color: #fff;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 10%), 0 12px 30px -8px rgb(12 22 40 / 50%);
}
#toast:empty { display: none; }

/* ---------- Login ---------- */
.login { min-height: 100dvh; display: grid; grid-template-rows: auto 1fr auto; }
.login-copyright {
  padding: 0 16px calc(20px + env(safe-area-inset-bottom, 0px));
  color: var(--muted); text-align: center; font-size: 12px;
}
.login-top { background: transparent; border-bottom-color: transparent; box-shadow: none; }
.login-top .logo { background: linear-gradient(180deg, #fff, #dbe3ee); box-shadow: var(--tile-shadow); }
.login-box { display: grid; place-items: center; padding: clamp(16px, 4vw, 56px); }
.login-frame {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  width: min(1020px, 100%); min-height: 540px; overflow: hidden;
  border: 1px solid #d3dce8; border-radius: 24px; background: var(--surface);
  box-shadow: var(--highlight), 0 30px 60px -30px rgb(20 40 70 / 45%), 0 4px 12px rgb(20 40 70 / 8%);
}
.login-illustration { position: relative; overflow: hidden; background: #13284d; }
.login-illustration img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 58%; }
.login-card { align-self: center; width: min(100%, 420px); margin: auto; padding: clamp(24px, 4vw, 48px); }
.eyebrow { margin: 0 0 10px; color: var(--steel); font-size: 12px; font-weight: 600; letter-spacing: .06em; }
.login-card h1 { margin: 0 0 6px; font-size: clamp(24px, 2.6vw, 30px); font-weight: 700; line-height: 1.25; }
.login-card > p.muted { margin: 0; }
.login-card form { display: grid; gap: 14px; margin-top: 26px; }
.login-card .primary { min-height: 44px; margin-top: 4px; }
.login-demo { display: grid; gap: 10px; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }

.fatal { display: grid; place-items: center; min-height: 100dvh; padding: 20px; }
.fatal .panel { width: min(460px, 100%); }
.fatal h1 { margin: 0 0 6px; font-size: 20px; }

/* ---------- Pointer-only hover (avoids sticky hover on touch) ---------- */
@media (hover: hover) {
  a:hover { text-decoration: underline; }
  .btn:hover { border-color: #aab5c5; background: linear-gradient(180deg, #ffffff, #eaeff5); text-decoration: none; }
  .btn.primary:hover { border-color: #1a3459; background: linear-gradient(180deg, #33578d, var(--blue-hover)); }
  .btn.quiet:hover { background: var(--blue-tint); border-color: transparent; }
  .textbtn:hover { text-decoration: underline; }
  .nav button:not(.selected):hover { background: rgb(255 255 255 / 7%); color: #fff; }
  .top-account .iconbtn:hover { background: rgb(255 255 255 / 9%); color: #fff; }
  .iconbtn:not(.top-account .iconbtn):hover { background: var(--nav-hover); color: var(--text); }
  .metric:hover { border-color: var(--border-strong); box-shadow: var(--highlight), var(--shadow-raised); transform: translateY(-1px); }
  .workrow:hover, .table tbody tr:hover { background: #f4f7fb; }
  .stage:hover { background: var(--surface-subtle); }
  input:hover, select:not(#company):hover, textarea:hover { border-color: #a9b4c4; }
}

/* ---------- Responsive ---------- */
@media (min-width: 1200px) {
  .overview-board { grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr) minmax(0, 1fr); }
  .overview-board .stack { display: contents; }
}
@media (max-width: 920px) {
  .board { grid-template-columns: minmax(0, 1fr); }
  .stack { grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); align-items: start; }
}
@media (max-width: 900px) {
  .top-meta .date-display { display: none; }
  .detailgrid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .head { flex-direction: column; align-items: stretch; gap: 14px; margin-bottom: 18px; }
  .head .actions .btn { flex: 1 1 auto; }
  .tile.lg { width: 40px; height: 40px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
  .metric { padding: 13px 13px 12px; }
  .metric strong { font-size: 26px; margin-top: 10px; }
  .board, .stack { gap: 12px; }
  .date-display { display: none; }
  .content { padding-inline: max(12px, env(safe-area-inset-left, 0px)) max(12px, env(safe-area-inset-right, 0px)); }
  .panel-head, .panel-body { padding-inline: 14px; }
  .workrow { gap: 10px; padding-inline: 14px; }
  .toolbar { padding: 12px 14px; }
  .search { flex: 1 1 100%; min-width: 0; }
  #filter { flex: 1 1 auto; }
  .inline-field { flex-wrap: wrap; width: 100%; }
  .inline-field select { flex: 1 1 100%; min-width: 0; }
  .checks li { grid-template-columns: 1fr; }

  /* tables become labelled cards; ARIA roles keep table semantics */
  .tablebox { overflow: visible; }
  .table, .table tbody, .table tr, .table td { display: block; min-width: 0; }
  .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .table tr { padding: 12px 14px; border-bottom: 1px solid var(--border); }
  .table tr:last-child { border-bottom: 0; }
  .table td { display: grid; grid-template-columns: 6.5em minmax(0, 1fr); gap: 10px; padding: 3px 0; border: 0; white-space: normal; overflow-wrap: anywhere; }
  .table td::before { content: attr(data-label); color: var(--muted); font-size: 12px; line-height: 1.9; }
  .table td:first-child { display: block; padding-bottom: 6px; }
  .table td:first-child::before { content: none; }
  .table td:last-child { white-space: normal; }
  .table td .pill { justify-self: start; }

  dialog, dialog[data-size] { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); border-radius: 14px; }
  .modalhead { padding-left: 16px; }
  .modalbody { padding: 16px 16px 18px; }
  .modalbody > .modalactions:last-child, .modalbody form > .modalactions { margin: 16px -16px -18px; padding: 12px 16px; }
  .modalactions .btn { flex: 1 1 auto; }
  .catalog-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); }
  .catalog-labels span:last-child { display: none; }
  .catalog-actions { grid-column: 1 / -1; }

  .login-frame { grid-template-columns: 1fr; min-height: 0; border-radius: 18px; }
  .login-illustration { min-height: 168px; }
  .login-card { width: 100%; padding: 22px 20px 24px; }
  .login-top { min-height: 52px; }
  :root { --hud-dock-inset: 8px; --hud-dock-clearance: calc(84px + env(safe-area-inset-bottom, 0px)); }
  .topbar {
    display: grid; grid-template-columns: minmax(0, 1fr) auto;
    padding-bottom: 8px; gap: 4px 9px;
  }
  .topbar .brand { min-height: 49px; padding: 0; }
  .topbar .company-select { grid-row: 2; grid-column: 1 / -1; width: 100%; }
  .top-account { grid-row: 1; grid-column: 2; border: 0; padding: 0; gap: 5px; }
  .top-meta { display: none; }
  .hud-footer { padding-top: 5px; }
  .nav { width: min(520px, calc(100% - 12px)); gap: 1px; padding: 4px; border-radius: 13px; }
  .nav button { min-height: 55px; padding: 2px; font-size: 11px; }
  .nav-ico { width: 25px; height: 25px; }
  .nav-ico .ico { width: 16px; height: 16px; }
  .nav-label-full { display: none; }
  .nav-label-short { display: block; }
  #toast { inset: auto 12px 12px 12px; max-width: none; }
}
@media (max-width: 540px) {
  .account-name { display: none; }
  .formgrid { grid-template-columns: 1fr; }
}
@media (max-width: 380px) {
  .login-top .environment { display: none; }
}

/* Prevent iOS zoom-on-focus: form controls need ≥16px text on touch screens */
@media (pointer: coarse) {
  input, select, textarea, .company-select select { font-size: 16px; }
}

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  dialog[open] { animation: dialog-in 180ms var(--ease); }
  dialog[open]::backdrop { animation: fade-in 180ms ease; }
}
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(.985); } }
@keyframes fade-in { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
  .btn:active, .metric:active, .metric:hover, .nav button:active { transform: none; }
}

/* ---------- High contrast ---------- */
@media (forced-colors: active) {
  .tile, .pill, .btn, .metric, .panel, .nav button.selected { border: 1px solid CanvasText; }
  .risk-marker, .node, .staff-bar span, .staff-legend i { forced-color-adjust: none; }
}

/* ---------- Staff distribution widths (set from real counts in app.js) ---------- */
.staff-bar .share-1 { flex: 1; }
.staff-bar .share-2 { flex: 2; }
.staff-bar .share-3 { flex: 3; }
.staff-bar .share-4 { flex: 4; }
.staff-bar .share-5 { flex: 5; }
.staff-bar .share-6 { flex: 6; }
.staff-bar .share-7 { flex: 7; }
.staff-bar .share-8 { flex: 8; }
.staff-bar .share-9 { flex: 9; }
.staff-bar .share-10 { flex: 10; }
.staff-bar .share-11 { flex: 11; }
.staff-bar .share-12 { flex: 12; }
.staff-bar .share-13 { flex: 13; }
.staff-bar .share-14 { flex: 14; }
.staff-bar .share-15 { flex: 15; }
.staff-bar .share-16 { flex: 16; }
.staff-bar .share-17 { flex: 17; }
.staff-bar .share-18 { flex: 18; }
.staff-bar .share-19 { flex: 19; }
.staff-bar .share-20 { flex: 20; }
