:root {
  color-scheme: light;
  --ink: #14253f;
  --muted: #627087;
  --line: #d8e0eb;
  --soft: #f3f6fa;
  --paper: #ffffff;
  --navy: #0b2f56;
  --blue: #1768ac;
  --teal: #0f766e;
  --amber: #a15c05;
  --red: #a23a32;
  --shadow: 0 14px 36px rgba(25, 48, 78, .10);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--soft); color: var(--ink); }
body { min-width: 320px; }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
a { color: var(--blue); }

.topbar {
  min-height: 76px;
  padding: 14px clamp(18px, 3vw, 40px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  color: white;
  background: linear-gradient(110deg, #08294b 0%, #0d4771 62%, #0f766e 145%);
  border-bottom: 1px solid rgba(255,255,255,.12);
}

.brand { display: flex; align-items: center; gap: 13px; min-width: 0; }
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: none;
  border: 1px solid rgba(255,255,255,.45);
  border-radius: 12px;
  background: rgba(255,255,255,.10);
  font-size: .82rem;
  font-weight: 800;
  letter-spacing: .08em;
}
.brand h1 { margin: 0; font-size: clamp(1.05rem, 2vw, 1.32rem); line-height: 1.2; }
.brand p { margin: 3px 0 0; color: #c9d9e8; font-size: .85rem; }
.dataset-count { color: #dce8f1; font-size: .88rem; white-space: nowrap; }
.app-version { padding: 0; border: 0; background: transparent; color: #bcd0e0; font-size: .72rem; font-weight: 750; white-space: nowrap; }
.version-history-trigger { cursor: pointer; }
.version-history-trigger:hover, .version-history-trigger:focus-visible { text-decoration: underline; }
.version-history-trigger:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; border-radius: 2px; }
.account-actions { display: flex; align-items: center; gap: 9px; }
.top-action { min-height: 32px; padding: 0 10px; border: 1px solid rgba(255,255,255,.38); border-radius: 7px; background: rgba(255,255,255,.10); color: white; font-size: .76rem; font-weight: 750; }
.top-action:hover { background: rgba(255,255,255,.18); }
.whats-new-button:not([hidden]) { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.new-indicator { display: none; min-width: 30px; padding: 2px 5px; border-radius: 999px; background: #f7d35b; color: #18344e; font-size: .62rem; font-weight: 850; letter-spacing: .04em; line-height: 1.1; }
.whats-new-button:disabled { opacity: .48; cursor: not-allowed; }
.whats-new-button.release-unread { border-color: #f7d35b; background: rgba(247,211,91,.24); }
.whats-new-button.release-unread .new-indicator { display: inline-flex; }
.view-tabs { display: flex; gap: 4px; padding: 4px; border: 1px solid rgba(255,255,255,.2); border-radius: 10px; background: rgba(0,0,0,.10); }
.view-tabs button { min-height: 34px; padding: 0 13px; border: 0; border-radius: 7px; background: transparent; color: #d7e4ee; font-size: .82rem; font-weight: 750; }
.view-tabs button.active { background: white; color: var(--navy); box-shadow: 0 2px 8px rgba(0,0,0,.16); }
.customer-selector { display: flex; align-items: center; gap: 7px; padding: 0 4px 0 8px; color: #d7e4ee; font-size: .73rem; font-weight: 750; }
.customer-selector select { min-width: 170px; height: 30px; padding: 0 28px 0 9px; border: 0; border-radius: 6px; background: white; color: var(--navy); font-size: .76rem; font-weight: 700; }
.tab-status { margin-left: .35rem; padding: .12rem .38rem; border-radius: 999px; font-size: .68rem; font-weight: 700; letter-spacing: .02em; background: rgba(255,255,255,.14); }
.view-tabs button.active .tab-status { background: #e7eff5; }

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
}

.browser {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: #eef3f8;
  border-right: 1px solid var(--line);
}

.browser-controls { padding: 18px; border-bottom: 1px solid var(--line); background: #f8fafc; }
.search-field { position: relative; display: block; }
.search-field svg {
  position: absolute;
  left: 13px;
  top: 50%;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: #758197;
  stroke-width: 2;
  transform: translateY(-50%);
}
.search-field input {
  width: 100%;
  height: 44px;
  padding: 0 14px 0 41px;
  border: 1px solid #c9d4e1;
  border-radius: 10px;
  background: white;
  color: var(--ink);
  outline: none;
}
.search-field input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(23,104,172,.13); }

.filters { margin-top: 13px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.filters label span { display: block; margin: 0 0 5px; color: var(--muted); font-size: .75rem; font-weight: 700; }
.filters select {
  width: 100%;
  height: 38px;
  padding: 0 30px 0 10px;
  border: 1px solid #c9d4e1;
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font-size: .84rem;
}
.result-summary { margin-top: 14px; display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: .82rem; }
.result-summary button { padding: 4px 0; border: 0; background: transparent; color: var(--blue); font-weight: 700; }
.result-summary .excel-export { width: 210px; height: 32px; padding: 4px 12px; display: inline-flex; align-items: center; justify-content: flex-start; gap: 8px; border: 1px solid var(--blue); border-radius: 4px; background: #eaf2fb; color: var(--blue); }
.excel-export span { white-space: nowrap; }
.excel-export svg { width: 22px; height: 22px; display: block; }
.excel-export:disabled { opacity: .55; cursor: not-allowed; }
.excel-file-ready { margin: 8px 0 0; font-size: .82rem; color: var(--muted); }
.excel-file-ready a { margin-left: 4px; color: var(--blue); font-weight: 700; overflow-wrap: anywhere; }

.record-list { flex: 1; overflow-y: auto; padding: 10px; }
.record-card {
  width: 100%;
  margin: 0 0 7px;
  padding: 13px 14px;
  display: grid;
  grid-template-columns: 32px minmax(0,1fr) auto;
  align-items: start;
  gap: 11px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: inherit;
  text-align: left;
}
.record-card:hover { background: white; border-color: #d7e0ea; }
.record-card.selected { background: white; border-color: #9fbdd7; box-shadow: 0 4px 14px rgba(26,67,103,.08); }
.record-card.review-approved { border-left-color: var(--teal); }
.record-card.review-edit { border-left-color: var(--amber); }
.record-card.review-rejected { border-left-color: var(--red); opacity: .72; }
.rank-chip {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: #dce8f2;
  color: var(--navy);
  font-size: .77rem;
  font-weight: 800;
}
.record-copy { min-width: 0; }
.record-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .92rem; }
.record-copy span { display: block; margin-top: 4px; overflow: hidden; color: var(--muted); font-size: .77rem; text-overflow: ellipsis; white-space: nowrap; }
.score { color: var(--navy); font-size: .83rem; font-weight: 800; text-align: right; }
.score-classification { display: block; margin-top: 3px; color: var(--muted); font-size: .67rem; font-weight: 700; line-height: 1.15; white-space: nowrap; }
.no-results { padding: 36px 18px; text-align: center; color: var(--muted); }

.detail { min-width: 0; overflow-y: auto; padding: clamp(20px, 3.2vw, 46px); }
.detail-inner { width: min(980px, 100%); margin: 0 auto; }
.detail-header { padding: 0 0 24px; border-bottom: 1px solid var(--line); }
.detail-kicker { margin: 0 0 8px; color: var(--muted); font-size: .82rem; font-weight: 700; letter-spacing: .02em; }
.detail-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.detail-title-row h2 { margin: 0; max-width: 700px; font-size: clamp(1.65rem, 4vw, 2.45rem); line-height: 1.08; letter-spacing: -.035em; }
.score-ring {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  flex: none;
  border: 7px solid #cfe2ef;
  border-top-color: var(--blue);
  border-radius: 50%;
  background: white;
  color: var(--navy);
  font-size: 1.22rem;
  font-weight: 850;
}
.score-summary { display: flex; align-items: center; gap: 9px; }
.score-summary .score-classification { max-width: 112px; text-align: right; }
.headline-meta { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.badge { padding: 6px 10px; border-radius: 999px; background: #e7eef5; color: #344b63; font-size: .76rem; font-weight: 750; }
.badge.good { background: #dcefeb; color: #08645d; }
.badge.medium { background: #fff0d8; color: #8a5106; }
.badge.low { background: #f7e3e1; color: #8e352f; }
.record-tabs { margin: 12px 0 0; display: flex; align-items: flex-end; gap: 7px; padding: 4px 4px 0; border: 1px solid var(--line); border-bottom: 0; border-radius: 10px 10px 0 0; background: #e9eff5; }
.record-tabs button { min-height: 34px; flex: 1; padding: 0 10px; border: 1px solid #adbbcb; border-radius: 7px; background: #fff; color: #334b64; font-size: .78rem; font-weight: 750; box-shadow: 0 1px 2px rgba(20,37,63,.06); }
.record-tabs button:hover { border-color: var(--blue); background: #f2f7fc; color: var(--navy); }
.record-tabs button:focus-visible { outline: 3px solid rgba(23,104,172,.28); outline-offset: 2px; }
.record-tabs button.active { min-height: 38px; margin-bottom: -2px; border-color: var(--navy); border-radius: 7px 7px 0 0; background: var(--navy); color: white; box-shadow: 0 2px 7px rgba(11,47,86,.24); }
.record-tab-content { margin-top: 4px; }
.active-tab-frame { margin-top: 0; padding: 12px; border: 2px solid var(--navy); border-radius: 0 0 12px 12px; background: rgba(241,247,252,.38); overflow-x: hidden; }
.active-tab-frame > :first-child { margin-top: 0; }

.quick-facts { margin: 24px 0; display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
.fact { padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
.fact span { display: block; margin-bottom: 5px; color: var(--muted); font-size: .75rem; font-weight: 750; text-transform: uppercase; letter-spacing: .035em; }
.fact strong { font-size: .95rem; line-height: 1.4; }

.section-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.panel { min-width: 0; padding: 20px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); box-shadow: 0 5px 18px rgba(31,57,87,.035); }
.panel.full { grid-column: 1 / -1; }
.panel h3 { margin: 0 0 15px; color: var(--navy); font-size: 1rem; }
.field + .field { margin-top: 15px; padding-top: 15px; border-top: 1px solid #e6ebf1; }
.field-label { margin: 0 0 5px; color: var(--muted); font-size: .76rem; font-weight: 800; text-transform: uppercase; letter-spacing: .035em; }
.field-value { margin: 0; color: #2d3e54; font-size: .94rem; line-height: 1.55; overflow-wrap: anywhere; }
.family-list { display: flex; flex-wrap: wrap; gap: 7px; }
.family-list span { padding: 7px 10px; border-radius: 8px; background: #edf3f8; color: #314a63; font-size: .82rem; font-weight: 700; }
.links { display: flex; flex-wrap: wrap; gap: 8px; }
.links a { padding: 8px 11px; border: 1px solid #b8cbe0; border-radius: 8px; background: #f7fafc; font-size: .83rem; font-weight: 700; text-decoration: none; }
.links a:hover { background: #eaf2f8; }
.empty-value { color: #8a96a7; font-style: italic; }
.customer-match { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(0, 2fr); gap: 14px; align-items: end; }
.customer-match label span { display: block; margin-bottom: 6px; color: var(--muted); font-size: .76rem; font-weight: 800; text-transform: uppercase; letter-spacing: .035em; }
.customer-match select { width: 100%; min-height: 42px; padding: 0 34px 0 11px; border: 1px solid #b9c9d9; border-radius: 9px; background: white; color: var(--ink); }
.customer-match-result { min-height: 42px; padding: 10px 12px; border-radius: 9px; background: #edf4f8; color: #2d475f; font-size: .9rem; line-height: 1.45; }
.customer-match-result button { margin-left: 8px; padding: 4px 8px; border: 1px solid #9db5ca; border-radius: 6px; background: white; color: var(--blue); font-weight: 750; }

.review-panel { margin: 10px 0 8px; padding: 10px; border: 1px solid var(--line); border-left: 4px solid #94a3b8; border-radius: 9px; background: white; }
.review-panel.review-approved { border-left-color: var(--teal); background: #f3fbf9; }
.review-panel.review-edit { border-left-color: var(--amber); background: #fffaf1; }
.review-panel.review-rejected { border-left-color: var(--red); background: #fff7f6; }
.admin-approval-comments { white-space: pre-wrap; }
.review-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.review-heading strong { display: block; font-size: .85rem; }
.review-actions { display: flex; gap: 6px; }
.review-actions button, .save-note { min-height: 30px; padding: 0 10px; border: 1px solid #b7c6d5; border-radius: 7px; background: white; color: var(--navy); font-size: .75rem; font-weight: 750; }
.review-actions button[data-review-decision="approved"] { color: var(--teal); }
.review-actions button[data-review-decision="edit"] { color: var(--amber); }
.review-actions button[data-review-decision="rejected"] { color: var(--red); }
.review-note { display: block; margin-top: 8px; color: var(--muted); font-size: .72rem; font-weight: 700; }
.review-note span { display: block; margin-bottom: 5px; }
.review-note textarea { width: 100%; min-height: 38px; resize: vertical; padding: 7px 9px; border: 1px solid #c9d4e1; border-radius: 7px; color: var(--ink); font: inherit; font-weight: 400; }
.save-note { margin-top: 6px; margin-left: 0; }
.save-note:disabled { opacity: .48; cursor: not-allowed; background: #eef2f6; color: #6e7d8c; }
.review-help { margin: 5px 0 0 98px; color: var(--muted); font-size: .68rem; }
.overview-content { min-height: 0; }
.employer-diary { margin-top: 14px; border-left-color: var(--blue); }
.employer-diary h3 { margin: 0 0 8px; color: var(--navy); font-size: 1rem; }
.diary-entry { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.diary-entry textarea { min-height: 104px; }
.diary-editor textarea { min-height: clamp(360px, 50vh, 680px); font: inherit; font-size: 1rem; line-height: 1.55; }

.record-nav { margin-top: 18px; display: flex; justify-content: space-between; gap: 12px; }
.record-nav button { min-height: 42px; padding: 0 15px; border: 1px solid #b7c6d5; border-radius: 9px; background: white; color: var(--navy); font-weight: 750; }
.record-nav button:disabled { opacity: .42; cursor: default; }
.empty-state { min-height: 70vh; display: grid; place-content: center; text-align: center; color: var(--muted); }
.empty-state h2 { margin: 0 0 8px; color: var(--ink); }
.empty-state p { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.auth-screen { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 24px; background: linear-gradient(135deg,#071f3a 0%,#0d4771 58%,#0f766e 125%); }
.auth-screen[hidden] { display: none; }
.auth-card { width: min(440px,100%); padding: 30px; border-radius: 18px; background: white; box-shadow: 0 28px 80px rgba(0,0,0,.28); }
.auth-mark { margin-bottom: 18px; border-color: #9eb6ca; background: #e8f0f6; color: var(--navy); }
.auth-card h2 { margin: 0 0 8px; font-size: 1.65rem; }
.auth-card > p { margin: 0 0 22px; color: var(--muted); line-height: 1.55; }
.auth-card label span, .form-grid label span { display: block; margin-bottom: 5px; color: var(--muted); font-size: .78rem; font-weight: 750; }
.auth-card input, .form-grid input, .form-grid select { width: 100%; min-height: 42px; padding: 0 11px; border: 1px solid #bdcad8; border-radius: 8px; background: white; color: var(--ink); }
.auth-tabs { margin: 0 0 18px; display: grid; grid-template-columns: repeat(3,1fr); gap: 4px; padding: 4px; border-radius: 9px; background: #edf2f6; }
.auth-tabs button { min-height: 34px; padding: 4px 6px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: .72rem; font-weight: 750; }
.auth-tabs button.active { background: white; color: var(--navy); box-shadow: 0 2px 7px rgba(20,37,63,.11); }
.auth-form[hidden], .auth-tabs[hidden] { display: none; }
.auth-form label + label { display: block; margin-top: 11px; }
.auth-card form button { width: 100%; min-height: 43px; margin-top: 12px; border: 0; border-radius: 8px; background: var(--navy); color: white; font-weight: 800; }
.auth-help-button { width: 100%; margin-top: 13px; padding: 8px; border: 0; background: transparent; color: var(--blue); font-weight: 750; }
.auth-help-button:hover { text-decoration: underline; }
.auth-card .auth-version { display: block; width: 100%; min-height: 0; margin: 14px 0 0 !important; padding: 0; border: 0; background: transparent; color: #8a96a7; font-size: .72rem; text-align: center; }
.auth-message, .form-message { min-height: 20px; margin: 12px 0 0 !important; color: var(--teal) !important; font-size: .82rem; }
.auth-message.error, .form-message.error { color: var(--red) !important; }

.admin-dialog { width: min(680px,calc(100% - 32px)); padding: 0; border: 0; border-radius: 15px; color: var(--ink); box-shadow: 0 26px 76px rgba(0,0,0,.28); }
.admin-dialog::backdrop { background: rgba(4,20,37,.72); backdrop-filter: blur(3px); }
.admin-dialog form, .instructions-dialog { padding: 22px; }
.admin-dialog .dialog-body { padding: 22px; }
.wide-dialog { width: min(900px,calc(100% - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; }
.instructions-dialog { max-height: calc(100dvh - 32px); overflow-y: auto; }
.version-history-dialog { width: min(920px,calc(100% - 32px)); }
.whats-new-dialog { width: min(820px,calc(100% - 32px)); }
.whats-new-content { display: grid; gap: 14px; }
.whats-new-entry { border: 1px solid var(--line); border-radius: 11px; padding: 16px; background: #fff; }
.whats-new-entry h3 { margin: 4px 0 14px; color: var(--navy); font-size: 1.08rem; }
.whats-new-meta { margin: 0; color: var(--muted); font-size: .8rem; font-weight: 750; }
.whats-new-section + .whats-new-section { margin-top: 16px; padding-top: 16px; border-top: 1px solid #e6ebf1; }
.whats-new-section h4 { margin: 0 0 7px; color: var(--navy); font-size: .94rem; }
.whats-new-section p { margin: 7px 0; color: #34465d; font-size: .9rem; line-height: 1.5; }
.whats-new-section ul { margin: 8px 0; padding-left: 21px; color: #34465d; font-size: .9rem; line-height: 1.5; }
.version-history-table { margin-top: 18px; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; }
.version-history-row { display: grid; grid-template-columns: minmax(150px,.42fr) minmax(0,1.58fr); gap: 16px; padding: 12px 14px; border-top: 1px solid #e6ebf1; color: #34465d; font-size: .88rem; line-height: 1.45; }
.version-history-row:first-child { border-top: 0; }
.version-history-row > strong { color: var(--navy); }
.version-history-head { position: sticky; top: 0; z-index: 1; border-top: 0; background: #edf3f8; color: var(--navy); font-size: .78rem; text-transform: uppercase; letter-spacing: .035em; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.dialog-heading h2 { margin: 0; font-size: 1.35rem; }
.dialog-heading > button { width: 34px; height: 34px; border: 0; border-radius: 50%; background: #edf2f6; color: var(--navy); font-size: 1.3rem; }
.dialog-intro { margin: 8px 0 18px; color: var(--muted); font-size: .88rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.form-grid label:first-child, .form-grid label:nth-child(2) { grid-column: span 1; }
.form-grid .full-field { grid-column: 1 / -1; }
.form-grid textarea { width: 100%; padding: 9px 11px; border: 1px solid #bdcad8; border-radius: 8px; color: var(--ink); font: inherit; resize: vertical; }
.password-grid { grid-template-columns: 1fr; }
.dialog-actions { margin-top: 18px; display: flex; justify-content: flex-end; gap: 8px; }
.dialog-actions button { min-height: 38px; padding: 0 13px; border: 1px solid #b7c6d5; border-radius: 8px; background: white; color: var(--navy); font-weight: 750; }
.dialog-actions .primary-action { border-color: var(--navy); background: var(--navy); color: white; }
.instruction-steps { margin: 18px 0; padding-left: 24px; color: #34465d; }
.instruction-steps li { margin-bottom: 12px; line-height: 1.45; }
.instruction-steps strong { color: var(--ink); }
.instruction-section { margin-top: 18px; }
.instruction-section + .instruction-section { padding-top: 16px; border-top: 1px solid var(--line); }
.instruction-section h3 { margin: 0 0 9px; color: var(--navy); font-size: 1rem; }
.instruction-section p { margin: 0 0 9px; color: #34465d; font-size: .9rem; line-height: 1.5; }
.instruction-section .instruction-steps { margin: 10px 0; }
.instruction-note { padding: 11px 13px; border-left: 4px solid var(--amber); border-radius: 7px; background: #fff7e8; color: #66502d; font-size: .84rem; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 30; max-width: 380px; padding: 11px 14px; border-radius: 9px; background: #102942; color: white; box-shadow: 0 9px 28px rgba(0,0,0,.25); opacity: 0; transform: translateY(10px); pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: none; }
.decision-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.decision-actions button { min-height: 32px; padding: 0 10px; border: 1px solid #b7c6d5; border-radius: 7px; background: white; color: var(--navy); font-size: .75rem; font-weight: 750; }
.decision-actions button.active { background: var(--navy); color: white; }
.inline-action { min-height: 34px; margin-top: 10px; padding: 0 11px; border: 1px solid #b7c6d5; border-radius: 7px; background: white; color: var(--navy); font-size: .76rem; font-weight: 750; }
.filter-rule-groups { display: grid; gap: 14px; }
.filter-rule-group { border: 1px solid var(--line); border-radius: 11px; overflow: hidden; background: white; }
.filter-rule-group h3 { margin: 0; padding: 10px 13px; background: #edf3f8; color: var(--navy); font-size: .9rem; }
.filter-rule { display: grid; grid-template-columns: 105px minmax(180px, 1.25fr) minmax(180px, 1fr); gap: 12px; padding: 11px 13px; border-top: 1px solid #e5ebf1; font-size: .8rem; line-height: 1.4; }
.filter-rule:first-of-type { border-top: 0; }
.filter-rule strong { color: var(--navy); }
.filter-rule span { color: #41546a; }
.request-form { margin-top: 16px; padding: 16px !important; border: 1px solid var(--line); border-radius: 11px; background: #f8fafc; }
.request-history { margin-top: 20px; }
.request-history h3 { color: var(--navy); font-size: 1rem; }
.request-item { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.request-item:first-child { border-top: 0; }
.request-item p { margin: 3px 0 0; color: var(--muted); font-size: .8rem; }
.request-status { max-width: 180px; align-self: start; padding: 5px 9px; border-radius: 999px; background: #e7eef5; color: #344b63; font-size: .72rem; font-weight: 800; line-height: 1.25; text-align: center; }
.request-status-approved, .request-status-completed { background: #dcefeb; color: #08645d; }
.request-status-rejected { background: #f7e3e1; color: #8e352f; }
.request-decision-reason { margin-top: 8px !important; color: #34465d !important; }
.request-decision-editor { display: grid; grid-template-columns: minmax(190px,.7fr) minmax(260px,1.3fr) auto; gap: 9px; align-items: end; margin-top: 11px; padding: 11px; border: 1px solid #cbd6e1; border-radius: 9px; background: #f8fafc; }
.request-decision-editor label span { display: block; margin-bottom: 5px; color: var(--muted); font-size: .72rem; font-weight: 800; }
.request-decision-editor select, .request-decision-editor textarea { width: 100%; min-height: 38px; padding: 7px 9px; border: 1px solid #b7c6d5; border-radius: 7px; background: white; color: var(--ink); font: inherit; font-size: .8rem; }
.request-decision-editor textarea { resize: vertical; }
.request-decision-editor button, .request-complete { min-height: 38px; padding: 0 10px; border: 1px solid var(--navy); border-radius: 7px; background: var(--navy); color: white; font-size: .75rem; font-weight: 800; }
.request-complete { margin-top: 10px; }
.feedback-action { margin-top: 10px; }
.feedback-history { margin-top: 12px; padding-top: 10px; border-top: 1px solid #e3e9ef; }
.feedback-history h4 { margin: 0 0 7px; color: var(--navy); font-size: .77rem; }
.feedback-list { display: grid; gap: 8px; }
.feedback-item { display: grid; grid-template-columns: 150px minmax(0,1fr); gap: 12px; padding: 9px 0; border-top: 1px solid #edf1f5; }
.feedback-item:first-child { border-top: 0; }
.feedback-item time { color: var(--muted); font-size: .72rem; font-weight: 700; }
.feedback-item strong { color: #875c13; font-size: .72rem; font-weight: 800; text-transform: capitalize; }
.feedback-item p { margin: 4px 0 0; color: var(--ink); font-size: .8rem; white-space: pre-wrap; }
.feedback-review-history { display: grid; gap: 7px; margin-top: 9px; padding: 9px 10px; border-left: 3px solid #99b8cf; border-radius: 0 7px 7px 0; background: #f3f8fb; }
.feedback-review-history > div { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 3px 10px; }
.feedback-review-history strong { color: var(--navy); text-transform: none; }
.feedback-review-history time { grid-column: 2; grid-row: 1; font-size: .68rem; text-align: right; }
.feedback-review-history p { grid-column: 1 / -1; margin: 0; color: #34465d; }
.feedback-review-editor { display: grid; grid-template-columns: minmax(185px,.75fr) minmax(240px,1.25fr) auto; gap: 9px; align-items: end; margin-top: 10px; padding: 10px; border: 1px solid #b9cbe0; border-radius: 8px; background: #f8fafc; }
.feedback-review-editor label span { display: block; margin-bottom: 5px; color: var(--muted); font-size: .72rem; font-weight: 800; }
.feedback-review-editor select, .feedback-review-editor textarea { width: 100%; min-height: 38px; padding: 7px 9px; border: 1px solid #b7c6d5; border-radius: 7px; background: white; color: var(--ink); font: inherit; font-size: .8rem; }
.feedback-review-editor textarea { resize: vertical; }
.feedback-review-editor button { min-height: 38px; padding: 0 10px; border: 1px solid var(--navy); border-radius: 7px; background: var(--navy); color: white; font-size: .75rem; font-weight: 800; }
.summary-cards { display: grid; grid-template-columns: repeat(auto-fit,minmax(135px,1fr)); gap: 12px; margin: 8px 0 18px; }
.summary-cards > div { padding: 16px; border: 1px solid var(--line); border-radius: 11px; background: #f8fafc; }
.summary-cards span { display: block; min-height: 34px; color: var(--muted); font-size: .76rem; font-weight: 750; line-height: 1.35; }
.summary-cards strong { display: block; margin-top: 7px; color: var(--navy); font-size: 1.65rem; }
.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.summary-breakdown { padding: 16px; border: 1px solid var(--line); border-radius: 11px; background: white; }
.summary-breakdown h3 { margin: 0 0 8px; color: var(--navy); font-size: .94rem; }
.summary-breakdown div { display: flex; justify-content: space-between; gap: 14px; padding: 8px 0; border-top: 1px solid #e7ecf1; color: #41546a; font-size: .83rem; }
.summary-breakdown div:first-of-type { border-top: 0; }
.summary-breakdown strong { color: var(--navy); }
.history-list { display: grid; }
.history-item { display: grid; grid-template-columns: 150px minmax(0,1fr); gap: 16px; padding: 13px 0; border-top: 1px solid #e6ebf1; }
.history-item:first-child { border-top: 0; }
.history-item time { color: var(--muted); font-size: .77rem; font-weight: 700; }
.history-item strong { color: var(--ink); font-size: .88rem; }
.history-item p { margin: 4px 0 0; color: var(--muted); font-size: .76rem; text-transform: capitalize; }
.evidence-review { border-left: 4px solid #7b8b9c; }
.review-status-current { border-left-color: #2f8f6b; }
.review-status-due_soon { border-left-color: #d59a31; }
.review-status-overdue, .review-status-review_required { border-left-color: #bd5660; }
.review-status-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.review-status-heading h3 { margin: 0; }
.review-status-pill { padding: 5px 9px; border-radius: 999px; background: #e9eef3; color: #40546a; font-size: .72rem; font-weight: 800; }
.review-status-current .review-status-pill { background: #dff3e9; color: #22694f; }
.review-status-due_soon .review-status-pill { background: #fff0d5; color: #875c13; }
.review-status-overdue .review-status-pill, .review-status-review_required .review-status-pill { background: #fbe3e6; color: #943c46; }
.review-facts { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 10px; margin-top: 12px; }
.review-facts > div { padding: 10px; border: 1px solid #e2e8ee; border-radius: 8px; background: #f8fafc; }
.review-facts span { display: block; margin-bottom: 4px; color: var(--muted); font-size: .68rem; font-weight: 750; text-transform: uppercase; }
.review-facts strong { color: var(--navy); font-size: .8rem; }
.review-controls { display: grid; grid-template-columns: minmax(150px,1fr) minmax(150px,1fr) auto; align-items: end; gap: 10px; margin-top: 12px; padding-top: 12px; border-top: 1px solid #e1e7ed; }
.review-controls label span { display: block; margin-bottom: 4px; color: var(--muted); font-size: .7rem; font-weight: 750; }
.review-controls input { width: 100%; min-height: 34px; padding: 0 9px; border: 1px solid #bdc9d5; border-radius: 7px; color: var(--ink); background: white; }
.review-control-actions { display: flex; gap: 6px; }
.review-control-actions button { min-height: 34px; padding: 0 10px; border: 1px solid #aebdcc; border-radius: 7px; background: white; color: var(--navy); font-size: .72rem; font-weight: 800; }
.review-control-actions .primary-review-action { border-color: var(--navy); background: var(--navy); color: white; }

/* The header occupies its natural height; the workspace receives the remaining viewport. */
@media (min-width: 821px) {
  html, body { height: 100%; }
  body { min-height: 100dvh; display: grid; grid-template-rows: auto minmax(0,1fr); overflow: hidden; }
  .topbar {
    min-height: 56px;
    height: auto;
    padding: 7px clamp(10px, 1.5vw, 20px);
    display: grid;
    grid-template-columns: minmax(150px, auto) minmax(0, auto) minmax(0, 1fr);
    align-items: center;
    gap: clamp(6px, .9vw, 16px);
  }
  .brand { gap: 9px; }
  .brand-mark { width: 34px; height: 34px; border-radius: 9px; font-size: .72rem; }
  .brand h1 { font-size: 1rem; }
  .brand p { margin-top: 1px; font-size: .75rem; }
  .dataset-count { font-size: .78rem; }
  .view-tabs { min-width: 0; flex-wrap: nowrap; padding: 3px; }
  .view-tabs button { min-height: 30px; padding: 0 clamp(6px, .8vw, 10px); font-size: .76rem; white-space: nowrap; }
  .customer-selector { min-width: 0; gap: 4px; padding-left: 5px; }
  .customer-selector select { width: clamp(118px, 13vw, 145px); min-width: 0; height: 27px; font-size: .72rem; }
  .account-actions { min-width: 0; margin-left: auto; flex-wrap: nowrap; justify-content: flex-end; gap: clamp(4px, .65vw, 9px); }
  .top-action { min-height: 30px; padding: 0 clamp(6px, .75vw, 10px); font-size: .74rem; white-space: nowrap; }
  .app-version { flex: none; font-size: .69rem; }

  .workspace { height: auto; min-height: 0; grid-template-columns: minmax(280px, 320px) minmax(0, 1fr); }
  .browser { height: 100%; min-height: 0; overflow: hidden; }
  .browser-controls { padding: 10px; }
  .search-field svg { left: 10px; width: 16px; height: 16px; }
  .search-field input { height: 34px; padding-left: 33px; border-radius: 8px; font-size: .8rem; }
  .filters { margin-top: 8px; gap: 6px 8px; }
  .filters label span { margin-bottom: 3px; font-size: .7rem; }
  .filters select { height: 31px; padding-left: 8px; font-size: .76rem; }
  .result-summary { margin-top: 8px; font-size: .75rem; }
  .record-list { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; padding: 7px; }
  .record-card { margin-bottom: 4px; padding: 8px 9px; grid-template-columns: 27px minmax(0,1fr) auto; gap: 8px; border-radius: 8px; }
  .rank-chip { width: 27px; height: 27px; border-radius: 7px; font-size: .7rem; }
  .record-copy strong { font-size: .82rem; }
  .record-copy span { margin-top: 2px; font-size: .7rem; }
  .score { font-size: .75rem; }

  .detail { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; padding: 12px 16px; }
  .detail-inner { width: 100%; max-width: none; }
  .detail-header { padding-bottom: 8px; }
  .detail-kicker { margin-bottom: 3px; font-size: .72rem; }
  .detail-title-row { gap: 12px; }
  .detail-title-row h2 { max-width: none; font-size: clamp(1.35rem, 2.2vw, 1.8rem); }
  .score-ring { width: 48px; height: 48px; border-width: 5px; font-size: .95rem; }
  .headline-meta { margin-top: 6px; gap: 5px; }
  .badge { padding: 3px 7px; font-size: .68rem; }
  .record-tabs { margin: 6px 0 0; padding: 3px 3px 0; }
  .record-tabs button { min-height: 28px; font-size: .69rem; }

  .quick-facts { margin: 8px 0; gap: 7px; }
  .review-panel { margin: 7px 0; padding: 7px 9px; }
  .review-note { margin-top: 5px; }
  .review-note textarea { min-height: 32px; padding: 5px 7px; font-size: .72rem; }
  .review-help { margin-top: 3px; }
  .overview-content { min-height: 0; }
  .employer-diary { margin-top: 9px; }
  .employer-diary h3 { font-size: .86rem; }
  .diary-entry textarea { min-height: 82px; }
  .diary-editor textarea { min-height: clamp(300px, 46vh, 560px); font-size: 1rem; line-height: 1.55; }
  .fact { padding: 7px 9px; border-radius: 8px; }
  .fact span { margin-bottom: 2px; font-size: .66rem; }
  .fact strong { font-size: .79rem; line-height: 1.25; }

  /* A pair of record sections must fill the complete framed width. */
  .section-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
  .panel { padding: 9px 10px; border-radius: 9px; box-shadow: none; }
  .panel h3 { margin-bottom: 7px; font-size: .82rem; }
  .field + .field { margin-top: 6px; padding-top: 6px; }
  .field-label { margin-bottom: 2px; font-size: .66rem; }
  .field-value { font-size: .76rem; line-height: 1.3; }
  .family-list { gap: 4px; }
  .family-list span { padding: 4px 6px; border-radius: 6px; font-size: .71rem; }
  .links { gap: 4px; }
  .links a { padding: 4px 6px; border-radius: 6px; font-size: .71rem; }
  .customer-match { grid-template-columns: minmax(180px, .8fr) minmax(0, 2fr); gap: 8px; }
  .customer-match label span { margin-bottom: 3px; font-size: .66rem; }
  .customer-match select { min-height: 32px; font-size: .76rem; }
  .customer-match-result { min-height: 32px; padding: 6px 8px; font-size: .75rem; line-height: 1.25; }
  .customer-match-result button { padding: 2px 6px; font-size: .72rem; }
  .record-nav { margin-top: 7px; }
  .record-nav button { min-height: 31px; padding: 0 10px; border-radius: 7px; font-size: .75rem; }

  body:not([data-view="global"]) .section-grid > .panel.full:first-child { grid-column: 1 / -1; }
  body:not([data-view="global"]) .section-grid > .panel.full:last-child { grid-column: 1 / -1; }
  body[data-view="global"] .section-grid > .panel.full { grid-column: 1 / -1; }
}

/* Intermediate desktop/tablet layout: keep the normal workspace and header
   structure compact. Only genuinely narrow screens use the mobile layout. */
@media (min-width: 821px) and (max-width: 1180px) {
  .workspace { grid-template-columns: clamp(240px, 26vw, 300px) minmax(0,1fr); }
  .detail { padding: 12px; }
  .brand h1 { font-size: .94rem; }
  .brand p { font-size: .7rem; }
  .view-tabs button { padding: 0 6px; font-size: .72rem; }
  .customer-selector { font-size: .68rem; }
  .customer-selector select { width: 118px; font-size: .68rem; }
  .top-action { min-height: 28px; padding: 0 6px; font-size: .68rem; }
  .dataset-count { display: none; }
  .record-tabs { flex-wrap: nowrap; }
  .record-tabs button { min-width: 0; padding: 0 6px; }
  .quick-facts { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .section-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .customer-match { grid-template-columns: minmax(150px, .8fr) minmax(0, 2fr); }
  .diary-editor textarea { min-height: clamp(300px, 42vh, 520px); }
}

/* At the tablet-portrait edge, keep all controls reachable without allowing
   the page itself to overflow. The toolbar remains one horizontal strip. */
@media (min-width: 821px) and (max-width: 980px) {
  .topbar { grid-template-columns: minmax(150px,auto) minmax(0,1fr); }
  .view-tabs { grid-column: 2; grid-row: 1; overflow-x: auto; scrollbar-width: thin; }
  .account-actions {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: thin;
  }
}

@media (max-width: 820px) {
  .summary-cards, .summary-grid { grid-template-columns: 1fr 1fr; }
  .history-item { grid-template-columns: 1fr; gap: 4px; }
  .review-facts { grid-template-columns: 1fr 1fr; }
  .review-controls { grid-template-columns: 1fr 1fr; }
  .review-control-actions { grid-column: 1 / -1; }
}

@media (max-width: 520px) {
  .summary-cards, .summary-grid { grid-template-columns: 1fr; }
  .review-facts, .review-controls { grid-template-columns: 1fr; }
  .review-control-actions { grid-column: auto; flex-direction: column; }
  .version-history-row { grid-template-columns: 1fr; gap: 4px; }
  .version-history-head { display: none; }
}


@media (max-width: 820px) {
  html, body { height: auto; overflow: visible; }
  body { display: block; min-height: 100dvh; }
  .topbar { min-height: 70px; flex-wrap: wrap; }
  .view-tabs { order: 3; width: 100%; }
  .view-tabs button { flex: 0 0 auto; }
  .customer-selector { flex: 1; }
  .customer-selector select { min-width: 0; width: 100%; }
  .dataset-count { display: none; }
  .account-actions { margin-left: auto; }
  .workspace { height: auto; min-height: 0; grid-template-columns: 1fr; }
  .browser { max-height: 52vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .record-list { min-height: 210px; }
  .detail { padding: 24px 18px 46px; overflow: visible; }
  .quick-facts { grid-template-columns: 1fr; }
  .section-grid { grid-template-columns: 1fr; }
  .panel.full { grid-column: auto; }
  .customer-match { grid-template-columns: 1fr; }
  .review-heading { align-items: flex-start; flex-direction: column; }
  .review-note { grid-template-columns: 1fr; }
  .save-note, .review-help { margin-left: 0; }
  .overview-content { min-height: 0; }
  .diary-editor textarea { min-height: 360px; }
  .form-grid { grid-template-columns: 1fr; }
  .request-item { grid-template-columns: 1fr; }
  .request-status { max-width: none; justify-self: start; }
  .request-decision-editor { grid-template-columns: 1fr; }
  .feedback-review-editor { grid-template-columns: 1fr; }
  .filter-rule { grid-template-columns: 1fr; gap: 4px; }
  .record-tabs { overflow-x: auto; }
  .record-tabs button { min-width: max-content; }
}

@media (max-width: 480px) {
  .brand-mark { display: none; }
  .filters { grid-template-columns: 1fr; }
  .browser { max-height: 66vh; }
  .detail-title-row { display: block; }
  .score-ring { margin-top: 16px; width: 62px; height: 62px; }
}

/* Short landscape phone viewports need the same split workspace as a desktop,
   but with compact controls and independent vertical scrolling. This overrides
   both the narrow mobile stack and the compact desktop mode by viewport height. */
@media (orientation: landscape) and (max-height: 520px) {
  html, body { height: 100%; overflow: hidden; }
  body { min-height: 100dvh; display: grid; grid-template-rows: auto minmax(0,1fr); }
  .topbar { min-height: 0; padding: 5px 10px; gap: 5px 8px; }
  .workspace { height: auto; min-height: 0; grid-template-columns: minmax(210px,31vw) minmax(0,1fr); }
  .browser { height: 100%; min-height: 0; max-height: none; overflow: hidden; border-right: 1px solid var(--line); border-bottom: 0; }
  .browser-controls { max-height: calc(100% - 72px); overflow-y: auto; overflow-x: hidden; padding: 6px 8px; }
  .search-field input { height: 30px; font-size: .76rem; }
  .search-field svg { left: 9px; width: 14px; height: 14px; }
  .filters { margin-top: 5px; gap: 4px 6px; grid-template-columns: 1fr 1fr; }
  .filters label span { margin-bottom: 2px; font-size: .62rem; }
  .filters select { height: 27px; padding-left: 6px; font-size: .68rem; }
  .result-summary { margin-top: 5px; display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 4px 7px; font-size: .68rem; }
  .result-summary .excel-export { grid-column: 1 / -1; width: 100%; height: 28px; padding: 3px 6px; gap: 5px; justify-content: center; }
  .excel-export svg { width: 18px; height: 18px; }
  .record-list { min-height: 72px; padding: 5px; overflow-y: auto; }
  .record-card { margin-bottom: 3px; padding: 6px 7px; grid-template-columns: 24px minmax(0,1fr) auto; gap: 6px; }
  .rank-chip { width: 24px; height: 24px; border-radius: 6px; font-size: .65rem; }
  .record-copy strong { font-size: .76rem; }
  .record-copy span { margin-top: 1px; font-size: .65rem; }
  .score { font-size: .68rem; }
  .score-classification { margin-top: 1px; font-size: .58rem; }
  .detail { height: 100%; min-height: 0; overflow-y: auto; padding: 9px 10px 18px; }
  .detail-header { padding-bottom: 6px; }
  .detail-kicker { margin-bottom: 2px; font-size: .65rem; }
  .detail-title-row { display: flex; gap: 8px; }
  .detail-title-row h2 { font-size: clamp(1.08rem,3.8vw,1.45rem); }
  .score-ring { width: 40px; height: 40px; margin-top: 0; border-width: 4px; font-size: .78rem; }
  .score-summary { gap: 5px; }
  .score-summary .score-classification { max-width: 82px; font-size: .58rem; }
  .headline-meta { margin-top: 5px; gap: 4px; }
  .badge { padding: 3px 6px; font-size: .62rem; }
  .record-tabs { margin-top: 5px; flex-wrap: nowrap; overflow-x: auto; }
  .record-tabs button { min-width: max-content; min-height: 27px; padding: 0 6px; font-size: .65rem; }
  .quick-facts { margin: 7px 0; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 5px; }
  .fact { padding: 6px 7px; }
  .fact span { font-size: .58rem; }
  .fact strong { font-size: .7rem; }
  .section-grid { grid-template-columns: 1fr; gap: 7px; }
  .panel { padding: 8px; }
  .panel h3 { margin-bottom: 6px; font-size: .8rem; }
  .field + .field { margin-top: 6px; padding-top: 6px; }
  .field-label { font-size: .61rem; }
  .field-value { font-size: .76rem; line-height: 1.4; }
  .review-panel { margin: 6px 0; padding: 7px; }
  .diary-editor textarea { min-height: 230px; }
}
