:root {
  color-scheme: dark;
  font-family: Inter, Segoe UI, Arial, sans-serif;
  --page: #0b1320;
  --panel: #142235;
  --panel-raised: #192a40;
  --text: #edf4ff;
  --muted: #a4b5cc;
  --subtle: #8499b4;
  --border: #2c4059;
  --link: #83b8ff;
  --accent: #438fe9;
  --accent-hover: #67a8f3;
  --sidebar: #0e1a2b;
  --nav-text: #c6d7eb;
  --nav-active: #214977;
  --input: #101d2e;
  --table-head: #1b2c42;
  --row-alt: #192b40;
  --row-hover: #284361;
  --upload: #132944;
  --shadow: 0 5px 18px #0003;
}
:root[data-theme="light"] {
  color-scheme: light;
  --page: #f4f8fd;
  --panel: #fff;
  --panel-raised: #fff;
  --text: #1d2c40;
  --muted: #67788f;
  --subtle: #72839a;
  --border: #dfe8f3;
  --link: #1764c7;
  --accent: #1764c7;
  --accent-hover: #1258b3;
  --sidebar: #172d46;
  --nav-text: #c9d9eb;
  --nav-active: #1e60b8;
  --input: #fff;
  --table-head: #f7faff;
  --row-alt: #f2f7fc;
  --row-hover: #e3f0ff;
  --upload: #f8fbff;
  --shadow: 0 3px 12px #182e4909;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--text); background: var(--page); }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 30px; margin: 0 0 7px; }
h2 { font-size: 19px; margin: 0 0 18px; }
p { line-height: 1.5; }
.muted, .hint, .page-head p { color: var(--muted); }
.hint { font-size: 13px; margin: 6px 0 20px; }
.premium-banner {
  min-height: 44px; display: flex; align-items: center; justify-content: center;
  gap: 10px; padding: 8px 16px; text-align: center;
  background: linear-gradient(100deg, #38265e, #674491 52%, #2c4e84);
  color: #fff; border-bottom: 1px solid #a77cd2; font-size: 13px;
}
.premium-banner strong { letter-spacing: .04em; }
.premium-banner span:last-child { color: #eee4fb; }
.premium-mark { color: #f8d381; font-size: 18px; }
.shell { display: grid; grid-template-columns: 230px minmax(0, 1fr); min-height: calc(100vh - 44px); }
.sidebar { background: var(--sidebar); color: #fff; padding: 26px 16px; display: flex; flex-direction: column; }
.brand { font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 10px; padding: 2px 13px 33px; }
.brand-icon, .hero-icon { display: inline-grid; place-items: center; background: var(--accent); color: #fff; border-radius: 9px; width: 34px; height: 34px; font-size: 25px; }
.sidebar nav { display: grid; gap: 5px; }
.sidebar nav a { color: var(--nav-text); padding: 12px 14px; border-radius: 8px; font-weight: 600; font-size: 14px; }
.sidebar nav a:hover, .sidebar nav a.active { background: var(--nav-active); color: #fff; text-decoration: none; }
.sidebar-foot { margin-top: auto; padding: 16px; color: #8da8c5; font-size: 12px; line-height: 1.6; }
.main-wrap { min-width: 0; }
.topbar { min-height: 70px; background: var(--panel); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 12px 36px; color: var(--muted); }
.topbar-user { display: flex; align-items: center; justify-content: flex-end; gap: 12px; color: var(--text); font-weight: 600; flex-wrap: wrap; }
.topbar-user form { display: inline; }
.role { text-transform: capitalize; background: var(--table-head); color: var(--link); padding: 5px 8px; border-radius: 5px; font-size: 12px; }
.text-button { border: 0; background: transparent; color: var(--link); cursor: pointer; font: inherit; padding: 5px 0; }
.theme-toggle { border: 1px solid var(--border); background: var(--panel-raised); color: var(--text); border-radius: 7px; cursor: pointer; font: inherit; font-size: 13px; padding: 7px 10px; white-space: nowrap; }
.theme-toggle:hover { border-color: var(--accent); }
.content { max-width: 1600px; margin: 0 auto; padding: 32px 36px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 25px; }
.page-head p { margin: 0; }
.primary, .secondary { font: inherit; font-weight: 650; border-radius: 7px; padding: 11px 18px; cursor: pointer; display: inline-block; }
.primary { background: var(--accent); color: #fff; border: 1px solid var(--accent); }
.primary:hover { background: var(--accent-hover); color: #fff; text-decoration: none; }
.secondary { background: var(--panel); color: var(--link); border: 1px solid var(--border); }
.secondary:hover { text-decoration: none; background: var(--table-head); }
.primary:disabled { opacity: .5; cursor: not-allowed; }
.button { white-space: nowrap; }
.full { width: 100%; }
.compact { padding: 6px 10px; }
.panel, .stat { background: var(--panel); border: 1px solid var(--border); border-radius: 11px; box-shadow: var(--shadow); }
.panel { padding: 24px; margin-bottom: 24px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; }
.panel-head h2 { margin: 0 0 15px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 17px; margin-bottom: 23px; }
.stat { padding: 24px; display: grid; gap: 8px; }
.stat span { color: var(--muted); font-size: 14px; }
.stat strong { font-size: 29px; }
.stat small { color: var(--subtle); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }
.form-grid .panel { margin: 0; }
.form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 12px; }
label { display: block; font-size: 14px; font-weight: 650; margin: 0 0 18px; }
input, select { font: inherit; width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 7px; background: var(--input); color: var(--text); margin-top: 7px; }
input:focus, select:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.upload-zone { border: 2px dashed var(--border); border-radius: 11px; min-height: 210px; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 9px; color: var(--link); background: var(--upload); cursor: pointer; text-align: center; }
.upload-zone span { font-weight: 400; color: var(--muted); }
.upload-zone .upload-icon { font-size: 42px; color: var(--link); }
.upload-zone input { max-width: 290px; font-size: 12px; border: 0; background: transparent; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); background: var(--table-head); font-weight: 650; }
th, td { padding: 15px 18px; border-bottom: 1px solid var(--border); vertical-align: top; }
.jobs-table { min-width: 1450px; }
.recent-jobs-table { min-width: 820px; }
tr:last-child td { border-bottom: 0; }
.jobs-table tbody tr:nth-child(even) { background: var(--row-alt); }
.jobs-table tbody tr:hover { background: var(--row-hover); }
.empty { padding: 32px; text-align: center; color: var(--muted); }
.badge { display: inline-block; text-transform: capitalize; font-size: 12px; font-weight: 700; border-radius: 5px; padding: 5px 9px; background: #455670; color: #fff; }
.badge.success { background: #174d3b; color: #a3f1c9; }
.badge.failed, .badge.interrupted { background: #5b2730; color: #ffc1c6; }
.badge.running { background: #1c457c; color: #bfddff; }
.badge.queued { background: #58441e; color: #ffe1a0; }
.badge.large { font-size: 15px; padding: 8px 13px; }
.job-status { display: flex; justify-content: space-between; align-items: center; gap: 12px; color: var(--muted); }
.progress { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 30px 0 10px; }
.progress span { height: 7px; background: var(--border); border-radius: 7px; }
.progress .done { background: var(--accent); }
.success-box { background: #123b30; border: 1px solid #2e7860; border-radius: 8px; padding: 20px; margin: 25px 0; }
.success-box strong { color: #a3f1c9; }
.detail-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin: 28px 0; }
.detail-grid dt { color: var(--muted); font-size: 13px; }
.detail-grid dd { margin: 5px 0 0; font-weight: 650; overflow-wrap: anywhere; }
.alert { padding: 12px 16px; border-radius: 7px; margin: 0 0 20px; }
.alert.error { background: #572a33; color: #ffd0d0; }
.alert.success { background: #174b39; color: #b7f6d4; }
.login-shell { min-height: calc(100vh - 44px); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 30px; }
.public-toolbar { width: min(800px, 100%); display: flex; justify-content: flex-end; margin-bottom: 15px; }
.login-card { display: grid; grid-template-columns: 1fr 1fr; width: min(800px, 100%); background: var(--panel); border: 1px solid var(--border); box-shadow: 0 10px 40px #0003; border-radius: 13px; overflow: hidden; }
.login-intro { background: linear-gradient(140deg, var(--upload), var(--panel)); padding: 50px; display: flex; flex-direction: column; justify-content: center; }
.hero-icon { width: 54px; height: 54px; font-size: 36px; }
.login-intro h1 { margin-top: 20px; }
.login-points { display: grid; gap: 13px; margin-top: 20px; color: var(--muted); }
.login-form { padding: 55px 45px; }
.login-form h2 { font-size: 24px; margin-bottom: 5px; }
.login-form .muted { margin-bottom: 29px; }
.row-actions { display: flex; align-items: center; gap: 10px; }
.row-actions form { margin: 0; }
.edit-row td { background: var(--table-head); }
.edit-user-form { display: grid; grid-template-columns: 1fr 1fr auto; align-items: end; gap: 12px; }
.edit-user-form label { margin: 0; }
.edit-user-form button { margin-bottom: 1px; white-space: nowrap; }
.optional { color: var(--muted); font-weight: 400; }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 18px; }
:root[data-theme="light"] .badge { background: #e8eef7; color: #536a83; }
:root[data-theme="light"] .badge.success { background: #dcf5e9; color: #167a50; }
:root[data-theme="light"] .badge.failed, :root[data-theme="light"] .badge.interrupted { background: #ffebeb; color: #b63039; }
:root[data-theme="light"] .badge.running { background: #e5efff; color: #145fc0; }
:root[data-theme="light"] .badge.queued { background: #fff2d8; color: #94600b; }
:root[data-theme="light"] .success-box { background: #eaf8f1; border-color: #bce8d3; }
:root[data-theme="light"] .success-box strong { color: #14764d; }
:root[data-theme="light"] .alert.error { background: #ffeded; color: #ab3038; }
:root[data-theme="light"] .alert.success { background: #e9f8ef; color: #187448; }
@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .detail-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .form-actions { grid-column: 1; }
  .edit-user-form { grid-template-columns: 1fr; }
}
@media (max-width: 650px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { padding: 14px; }
  .brand { padding: 0 0 12px; }
  .sidebar nav { display: flex; overflow-x: auto; }
  .sidebar nav a { white-space: nowrap; }
  .sidebar-foot { display: none; }
  .topbar { padding: 12px 16px; }
  .topbar > span { display: none; }
  .content { padding: 22px 15px; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .stats { grid-template-columns: 1fr 1fr; }
  .login-card { grid-template-columns: 1fr; }
  .login-intro { padding: 26px; }
  .login-form { padding: 28px; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .premium-banner span:last-child { display: none; }
}

.pdf-review-section { border-top: 1px solid var(--border); margin-top: 26px; padding-top: 26px; scroll-margin-top: 20px; }
.review-summary { background: var(--table-head); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.review-table { min-width: 880px; }
.review-table td { overflow-wrap: anywhere; }
.review-evidence { white-space: pre-wrap; min-width: 240px; }
.review-pill { display: inline-block; border-radius: 5px; padding: 4px 7px; background: var(--table-head); color: var(--text); font-size: 12px; font-weight: 700; }
.review-pill.pass { background: #174d3b; color: #a3f1c9; }
.review-pill.warning, .review-pill.unassessable { background: #58441e; color: #ffe1a0; }
.review-pill.fail { background: #5b2730; color: #ffc1c6; }
:root[data-theme="light"] .review-pill.pass { background: #dcf5e9; color: #167a50; }
:root[data-theme="light"] .review-pill.warning, :root[data-theme="light"] .review-pill.unassessable { background: #fff2d8; color: #94600b; }
:root[data-theme="light"] .review-pill.fail { background: #ffebeb; color: #b63039; }

/* Admin job filters */
.jobs-filter-bar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 18px;
  margin-bottom: 22px;
  padding: 18px 22px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(115deg, var(--panel), var(--upload));
  box-shadow: var(--shadow);
}
.jobs-filter-heading { display: flex; align-items: center; gap: 13px; }
.jobs-filter-heading > div { display: grid; gap: 3px; }
.jobs-filter-heading strong { font-size: 15px; letter-spacing: .01em; }
.jobs-filter-heading span:last-child { color: var(--muted); font-size: 13px; }
.jobs-filter-icon {
  display: grid; place-items: center; width: 38px; height: 38px;
  border: 1px solid #a77cd266; border-radius: 11px;
  background: linear-gradient(145deg, #694494, #344f90); color: #f8d381;
}
.jobs-filter-form { display: flex; align-items: center; gap: 12px; }
.user-filter { position: relative; min-width: 230px; }
.user-filter summary {
  list-style: none; display: flex; align-items: center; justify-content: space-between;
  gap: 20px; min-height: 50px; padding: 7px 15px;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--panel-raised); cursor: pointer;
  box-shadow: 0 2px 7px #0001;
}
.user-filter summary::-webkit-details-marker { display: none; }
.user-filter summary:hover, .user-filter[open] summary { border-color: var(--accent); }
.user-filter summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.user-filter-summary { display: grid; gap: 2px; }
.user-filter-label { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.user-filter-summary strong { font-size: 14px; }
.user-filter-chevron { width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .18s; }
.user-filter[open] .user-filter-chevron { transform: rotate(225deg); }
.user-filter-menu {
  position: absolute; top: calc(100% + 8px); right: 0; width: min(340px, calc(100vw - 30px));
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--panel-raised); box-shadow: 0 16px 40px #0005; overflow: hidden;
}
.user-filter-menu-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 16px 17px 11px; }
.user-filter-menu-head strong { font-size: 14px; }
.user-filter-menu-head span { color: var(--muted); font-size: 12px; }
.user-filter-options { max-height: 280px; overflow-y: auto; padding: 0 8px 8px; }
.user-filter-option {
  display: flex; align-items: center; gap: 11px; margin: 0; padding: 9px;
  border-radius: 8px; cursor: pointer; font-weight: 400;
}
.user-filter-option:hover { background: var(--table-head); }
.user-filter-option:has(input:checked) { background: var(--upload); }
.user-filter-option input { width: 16px; height: 16px; margin: 0; flex: 0 0 auto; accent-color: var(--accent); cursor: pointer; }
.user-filter-avatar {
  display: grid; place-items: center; width: 32px; height: 32px; flex: 0 0 auto;
  border-radius: 50%; background: linear-gradient(145deg, #7354a4, #377fb0);
  color: white; font-size: 12px; font-weight: 700;
}
.user-filter-identity { min-width: 0; display: grid; gap: 2px; }
.user-filter-identity strong, .user-filter-identity small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-filter-identity strong { font-size: 13px; }
.user-filter-identity small { color: var(--muted); font-size: 11px; }
.user-filter-actions {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border-top: 1px solid var(--border); padding: 12px 15px;
}
.user-filter-actions button { padding: 8px 13px; font-size: 13px; }
.user-filter-actions a, .jobs-filter-reset { font-size: 13px; font-weight: 650; }
.jobs-filter-reset { white-space: nowrap; }
@media (max-width: 650px) {
  .jobs-filter-bar { align-items: stretch; padding: 16px; }
  .jobs-filter-form { width: 100%; }
  .user-filter { flex: 1; min-width: 0; }
  .user-filter-menu { left: 0; right: auto; }
}
