/* Soft UI tokens shared by the workspace, management pages and login. */
:root {
  --ink: #303345;
  --muted: #656779;
  --line: #ebeaf1;
  --surface: #fff;
  --soft: #f5f5f9;
  --primary: #7060a8;
  --primary-dark: #5d4d93;
  --primary-soft: #efebf8;
  --danger: #a04f61;
  --warning: #86632d;
  --blue: #7060a8;
  --focus-ring: rgb(112 96 168 / 22%);
  --panel-shadow: 0 12px 32px rgb(91 76 143 / 7%);
  --control-shadow: 0 5px 14px rgb(91 76 143 / 9%);
  --hover-shadow: 0 12px 24px rgb(112 96 168 / 18%);
  --sidebar-width: 248px;
  --topbar-height: 76px;
}

body:is(.app-body, .auth-body) {
  color: var(--ink); background: #f7f8fb;
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}
body [hidden] { display: none !important; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
a { transition: color .25s ease-in-out, background-color .25s ease-in-out; }
a:hover { color: var(--primary-dark); }
.ui-icon { stroke-width: 1.7; }

/* A light, spacious shell keeps navigation distinct from page content. */
.app-sidebar { padding: 28px 16px 20px; border: 0; background: #fff; box-shadow: 4px 0 32px rgb(91 76 143 / 4%); }
.sidebar-brand, .sidebar-brand:hover { color: var(--ink); gap: 12px; padding-inline: 4px; }
.sidebar-brand strong { font-size: 16px; font-weight: 650; }
.sidebar-brand small { color: var(--muted); font-size: 11px; margin-top: 3px; }
.sidebar-brand-mark { width: 44px; height: 44px; flex-basis: 44px; border: 0; border-radius: 16px; background: var(--primary-soft); color: var(--primary-dark); box-shadow: var(--control-shadow); }
.sidebar-brand-mark b:first-child { background: var(--primary); color: #fff; }
.side-nav { padding-top: 40px; }
.side-nav-group + .side-nav-group { margin-top: 28px; }
.side-nav-label { margin: 0 14px 12px; color: var(--muted); font-size: 12px; font-weight: 500; letter-spacing: 0; }
.side-nav-link { min-height: 56px; padding: 8px 12px; gap: 12px; border-radius: 16px; color: #56586e; font-size: 14px; font-weight: 500; transition: background-color .25s ease-in-out, color .25s ease-in-out, box-shadow .25s ease-in-out, transform .25s ease-in-out; }
.side-nav-link .ui-icon { box-sizing: content-box; width: 18px; height: 18px; flex-basis: 18px; padding: 7px; border-radius: 50%; background: #f4f2f8; }
.side-nav-link:hover { background: #f7f5fb; color: var(--primary-dark); transform: translateY(-2px); }
.side-nav-link.active { background: var(--primary-soft); color: var(--primary-dark); box-shadow: 0 6px 16px rgb(112 96 168 / 8%); }
.side-nav-link.active .ui-icon { background: #e3ddf2; }
.side-nav-link.active::before, .side-nav-link.active::after { display: none; }
.sidebar-account { grid-template-columns: 40px minmax(0, 1fr) 44px; gap: 8px; border-color: var(--line); padding: 20px 0 0; }
.account-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-dark); }
.account-copy strong { color: var(--ink); font-weight: 600; }
.account-copy small { color: var(--muted); }
.app-topbar { padding-inline: 32px; border: 0; background: #f7f8fb; }
.topbar-context { flex-direction: row; align-items: center; gap: 16px; }
.topbar-context small { color: var(--muted); font-size: 12px; font-weight: 400; }
.topbar-context strong { display: flex; align-items: center; gap: 16px; font-size: 14px; font-weight: 600; }
.topbar-context strong::before { content: "/"; color: #9190a0; font-weight: 400; }
.service-state { color: var(--muted); font-size: 12px; }
.service-state i { background: #57836e; box-shadow: 0 0 0 4px #e7f0ea; }
.api-state-chip { padding: 10px 14px; border: 0; border-radius: 16px; background: #fff; color: #61527f; font-size: 12px; font-weight: 500; box-shadow: var(--control-shadow); }
.api-state-chip i { background: #a7834a; }
.api-state-chip.ready i { background: #57836e; }
body.app-body .topbar-engine { height: 36px; gap: 2px; padding: 3px 4px; margin: 0; border-radius: 12px; }
.topbar-engine .engine-indicator { display: flex; align-items: center; justify-content: center; flex: 0 0 28px; width: 28px; height: 28px; }
.topbar-engine i { flex: 0 0 6px; width: 6px; height: 6px; background: #9c9aa8; }
.topbar-engine.ready i { background: #3a9266; box-shadow: 0 0 0 4px #eaf5ee; }
.topbar-engine.failed i { background: #d04c61; box-shadow: 0 0 0 4px #fbeef0; }
.topbar-engine.checking i { background: #b68a39; box-shadow: 0 0 0 4px #faf3e5; }
.topbar-engine .engine-status { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
body.app-body .topbar-engine .engine-test { width: 28px; height: 28px; min-width: 28px; min-height: 28px; padding: 0; border-radius: 8px; background: transparent; color: var(--muted); box-shadow: none; }
body.app-body .topbar-engine .engine-test .ui-icon { width: 14px; height: 14px; flex-basis: 14px; }
body.app-body .topbar-engine .engine-test:hover { background: var(--primary-soft); color: var(--primary-dark); }
body.app-body .page { max-width: none; padding: 28px 32px 72px; }
body.app-body .page-heading { margin-bottom: 32px; gap: 24px; }
body.app-body .page-heading h1 { margin-bottom: 10px; color: var(--ink); font-size: 30px; line-height: 1.35; font-weight: 650; letter-spacing: -.5px; }
body.app-body .page-heading p { max-width: 70ch; color: var(--muted); font-size: 14px; line-height: 1.85; }

/* All controls share a 44px minimum target and soft hover / press feedback. */
body:is(.app-body, .auth-body) :is(button, .button) {
  min-height: 44px; padding: 12px 24px; gap: 8px; border: 0; border-radius: 16px;
  font-size: 14px; font-weight: 600; line-height: 1.45;
  transition: transform .25s ease-in-out, box-shadow .25s ease-in-out, background-color .25s ease-in-out, color .25s ease-in-out;
}
body:is(.app-body, .auth-body) :is(button, .button) .ui-icon { width: 18px; height: 18px; flex-basis: 18px; }
body:is(.app-body, .auth-body) .primary { color: #fff; background: var(--primary); box-shadow: 0 7px 18px rgb(112 96 168 / 22%); }
body:is(.app-body, .auth-body) .primary:hover:not(:disabled) { background: var(--primary-dark); }
body:is(.app-body, .auth-body) .secondary { color: #56506a; background: #fff; box-shadow: var(--control-shadow); }
body:is(.app-body, .auth-body) .secondary:hover:not(:disabled) { color: var(--primary-dark); background: var(--primary-soft); }
body:is(.app-body, .auth-body) .danger { color: var(--danger); background: #f9eef1; box-shadow: 0 5px 14px rgb(160 79 97 / 8%); }
body:is(.app-body, .auth-body) .danger:hover:not(:disabled) { background: #f3e2e7; }
body:is(.app-body, .auth-body) .danger-solid { color: #fff; background: var(--danger); box-shadow: 0 7px 18px rgb(160 79 97 / 18%); }
body:is(.app-body, .auth-body) .danger-solid:hover { background: #894253; }
body.app-body :is(.compact, .text-button) { min-height: 44px; padding: 10px 16px; border-radius: 16px; font-size: 13px; }
body.app-body .text-button { color: var(--primary-dark); background: var(--primary-soft); box-shadow: var(--control-shadow); }
body.app-body .danger-text { color: var(--danger); background: #f9eef1; }
body.app-body .job-actions { gap: 10px; }
body.app-body .job-actions .task-action { min-width: 86px; min-height: 44px; padding: 10px 16px; border-radius: 16px; background: var(--primary-soft); color: var(--primary-dark); box-shadow: var(--control-shadow); }
body.app-body .job-actions .task-action-view:hover { background: #e4ddf4; }
body.app-body .job-actions .task-action-delete { background: #f9eef1; color: var(--danger); box-shadow: 0 5px 14px rgb(160 79 97 / 8%); }
body.app-body .job-actions .task-action-delete:hover { background: #f3e2e7; }
body:is(.app-body, .auth-body) :is(button, .button):hover:not(:disabled):not(.disabled-link):not(.sidebar-backdrop) { transform: translateY(-2px); box-shadow: var(--hover-shadow); }
body:is(.app-body, .auth-body) :is(button, .button):active:not(:disabled):not(.sidebar-backdrop), .side-nav-link:active { transform: scale(.98); box-shadow: inset 0 3px 8px rgb(91 76 143 / 14%); }
body:is(.app-body, .auth-body) :is(a, button, input, select, textarea, [tabindex]):focus-visible { outline: 2px solid transparent; outline-offset: 3px; box-shadow: 0 0 0 5px var(--focus-ring), var(--control-shadow); }
body:is(.app-body, .auth-body) button:disabled, body.app-body .disabled-link { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
body.app-body .icon-button { min-width: 44px; min-height: 44px; width: 44px; height: 44px; padding: 0; color: var(--muted); background: #f3f1f8; box-shadow: none; }
body.app-body .icon-button:hover { color: var(--primary-dark); background: var(--primary-soft); }
body.app-body .back-link { position: relative; display: inline-flex; align-items: center; min-width: 180px; min-height: 52px; margin-bottom: 24px; padding: 8px 22px 8px 8px; gap: 12px; background: #fff; color: var(--primary-dark); border-radius: 18px; box-shadow: var(--control-shadow); font-weight: 600; }
.back-link .back-icon { display: grid; place-items: center; width: 36px; height: 36px; flex: 0 0 36px; border-radius: 50%; color: var(--primary-dark); background: var(--primary-soft); }
body.app-body .back-link:hover { background: var(--primary-soft); }
.back-link:hover .back-icon { background: #e2daef; }

/* Native form semantics, with a light fill and a broad focus halo. */
body:is(.app-body, .auth-body) :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
  min-height: 48px; padding: 13px 18px; border: 0; border-radius: 16px; background-color: var(--soft); color: var(--ink); box-shadow: none;
  transition: background-color .25s ease-in-out, box-shadow .25s ease-in-out;
}
body:is(.app-body, .auth-body) :is(input, select, textarea)::placeholder { color: #727386; }
body:is(.app-body, .auth-body) :is(input, select, textarea):hover:not(:disabled) { background-color: #f0eef6; }
body:is(.app-body, .auth-body) :is(input, select, textarea):focus { outline: 2px solid transparent; background-color: #fff; box-shadow: 0 0 0 5px var(--focus-ring), 0 5px 18px rgb(112 96 168 / 9%); }
body:is(.app-body, .auth-body) :is(input, select, textarea):disabled { background-color: #f1f1f5; color: #747485; cursor: not-allowed; }
body:is(.app-body, .auth-body) label { color: #505267; font-size: 14px; font-weight: 500; }
body.app-body label small { max-width: 70ch; margin-top: 10px; color: var(--muted); font-size: 12px; line-height: 1.8; }
body.app-body select {
  appearance: none; padding-right: 42px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%237060a8' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 16px center;
}
@supports (appearance: base-select) {
  body.app-body select, body.app-body select::picker(select) { appearance: base-select; }
  body.app-body select { align-items: center; padding-right: 18px; background-image: none; }
  body.app-body select::picker-icon { color: var(--primary); font-size: 13px; transition: rotate .25s ease-in-out; }
  body.app-body select:open::picker-icon { rotate: 180deg; }
  body.app-body select::picker(select) { margin-block: 10px; padding: 8px; border: 0; border-radius: 20px; background: #fff; color: var(--ink); max-height: min(360px, 65vh); overflow-y: auto; box-shadow: 0 14px 40px rgb(91 76 143 / 18%); font: inherit; }
  body.app-body select:is([data-provider-select], [data-engine-select])::picker(select) { min-width: 240px; max-height: min(480px, 65vh); }
  body.app-body select hr { margin: 8px; border: 0; border-top: 1px solid var(--line); }
  body.app-body select option { min-height: 44px; padding: 12px 16px; gap: 12px; border-radius: 16px; font-size: 14px; white-space: normal; }
  body.app-body select option:checked { background: var(--primary-soft); color: var(--primary-dark); font-weight: 600; }
  body.app-body select option:hover, body.app-body select option:focus { background: #f4f1fa; outline: 0; }
  body.app-body select option::checkmark { order: 1; margin-left: auto; color: var(--primary); }
}
/* Compact header controls override the larger defaults used inside forms. */
body.app-body .topbar-engine select[data-engine-select] { width: 84px; min-height: 30px; height: 30px; margin: 0; padding: 4px 22px 4px 4px; border: 0; border-radius: 8px; font-size: 12px; line-height: 20px; background-color: transparent; background-position: right 6px center; }
@supports (appearance: base-select) {
  body.app-body .topbar-engine select[data-engine-select] { padding-right: 4px; }
  body.app-body .topbar-engine select::picker-icon { font-size: 11px; }
}
/* The visible check is 22px; the input retains a full 44px pointer target. */
body.app-body input[type="checkbox"] { appearance: none; width: 44px; height: 44px; min-height: 44px; margin: 0; padding: 0; border: 0; border-radius: 16px; vertical-align: middle; cursor: pointer; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Crect x='2' y='2' width='20' height='20' rx='7' fill='%23f5f5f9' stroke='%23938aa9' stroke-width='1.5'/%3E%3C/svg%3E") center / 24px no-repeat; box-shadow: none; }
body.app-body input[type="checkbox"]:checked { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Crect x='2' y='2' width='20' height='20' rx='7' fill='%237060a8'/%3E%3Cpath d='m7 12 3 3 7-7' fill='none' stroke='white' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
body.app-body input[type="checkbox"]:indeterminate { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Crect x='2' y='2' width='20' height='20' rx='7' fill='%237060a8'/%3E%3Cpath d='M7 12h10' fill='none' stroke='white' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E"); }
body.app-body .checkbox-cell { width: 60px; padding-inline: 8px; }

/* Standalone surfaces; content inside each surface stays flat. */
body.app-body :is(.upload-band, .form-section, .job-progress, .inline-form, .table-wrap, .file-rows, .metric-card, .search-form) { border: 0; border-radius: 24px; background: #fff; box-shadow: var(--panel-shadow); }
body.app-body :is(.upload-band, .form-section, .job-progress, .inline-form, .search-form) { padding: 32px; }
body.app-body :is(.upload-band, .form-section, .job-progress, .metric-card) { transition: transform .3s ease-in-out, box-shadow .3s ease-in-out; }
@media (hover: hover) and (pointer: fine) {
  body.app-body :is(.upload-band, .form-section, .job-progress, .metric-card):hover { transform: translateY(-2px); box-shadow: 0 18px 40px rgb(91 76 143 / 10%); }
}
.dashboard-stats { gap: 24px; margin-bottom: 28px; }
.metric-card { grid-template-columns: minmax(0, 1fr) 48px; min-height: 116px; padding: 24px; gap: 12px; }
.metric-icon { grid-column: 2; grid-row: 1; width: 48px; height: 48px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-dark); }
.metric-card:nth-child(2) .metric-icon { background: #edf0f8; color: #5a6d99; }
.metric-card:nth-child(3) .metric-icon { background: #eaf3ee; color: #48775d; }
.metric-card:nth-child(4) .metric-icon { background: #f8edf0; color: var(--danger); }
.metric-copy { grid-column: 1; grid-row: 1; align-self: stretch; justify-content: space-between; gap: 12px; }
.metric-copy span { color: var(--muted); font-size: 13px; }
.metric-copy strong { color: var(--ink); font-size: 32px; font-weight: 600; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.upload-panel-header { border: 0; padding: 0; margin-bottom: 24px; }
.upload-panel-header h2 { color: var(--ink); font-size: 20px; font-weight: 600; }
.upload-panel-header span { color: var(--muted); font-size: 12px; }
.dashboard-upload .upload-form { gap: 28px; }
.dashboard-upload .file-picker { min-height: 120px; padding: 24px 28px; gap: 24px; border: 0; border-radius: 20px; background: #faf9fd; transition: background-color .25s ease-in-out, box-shadow .25s ease-in-out; }
.dashboard-upload .file-picker:hover { background: #faf9fd; }
.dashboard-upload .file-picker:focus-within { background: #faf9fd; box-shadow: 0 0 0 5px var(--focus-ring); }
.upload-file-symbol { width: 64px; height: 64px; flex: 0 0 64px; border: 0; border-radius: 50%; background: var(--primary-soft); color: var(--primary); }
.file-picker strong { font-size: 15px; font-weight: 600; }
.file-picker small { line-height: 1.8; }
.file-format-list { gap: 10px; }
.file-format-list b { padding: 2px 0; border: 0; background: transparent; color: var(--muted); font-size: 10px; font-weight: 500; }
.task-options { grid-template-columns: repeat(3, minmax(100px, 1fr)) minmax(185px, 1.5fr); gap: 16px; }
.task-options label > span { color: var(--muted); font-size: 13px; font-weight: 500; }
.selected-files-panel { border-color: var(--line); padding-top: 24px; }
.selected-files { border: 0; border-radius: 0; background: transparent; }
.selected-file-row { grid-template-columns: 48px minmax(0, 1fr) 44px; padding: 16px 20px; gap: 16px; border-color: var(--line); border-radius: 16px; }
.selected-file-row:hover { background: #faf9fd; }
.selected-file-type { min-height: 32px; border: 0; border-radius: 12px; background: var(--primary-soft); color: var(--primary-dark); }
.selected-files-summary strong { color: var(--ink); }
.selected-files-summary span, .selected-file-size { color: var(--muted); }
body.app-body .selected-file-remove { width: 44px; height: 44px; min-height: 44px; flex-basis: 44px; padding: 0; border-radius: 16px; color: var(--muted); }
body.app-body .selected-files-clear { min-height: 44px; padding: 10px 16px; color: var(--muted); }
body.app-body .section-block { margin-top: 32px; }
body.app-body .section-title { gap: 16px; margin-bottom: 20px; }
body.app-body :is(.section-title h2, .form-section h2) { color: var(--ink); font-size: 20px; font-weight: 600; }
body.app-body .section-title > span { border: 0; border-radius: 16px; padding: 8px 12px; background: #efedf6; color: #625574; font-size: 12px; font-weight: 400; }
body.app-body .table-wrap { scrollbar-width: thin; scrollbar-color: #c9c2da transparent; }
body.app-body table { font-size: 13px; }
body.app-body th { height: 56px; padding: 16px; background: #f1f0f7; color: #615a75; font-size: 12px; font-weight: 500; border-color: var(--line); white-space: nowrap; }
body.app-body td { height: 76px; padding: 16px; border-color: #f0eef5; }
body.app-body td small { color: var(--muted); }
body.app-body tbody tr:hover td { background: #fbfafd; }
body.app-body tbody tr:has([data-select-item]:checked) td { background: #f4f0fa; }
.jobs-table td { white-space: nowrap; }
.jobs-table td:nth-child(2) { max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
.job-id { display: inline-flex; align-items: center; min-width: 44px; min-height: 44px; font-weight: 600; border-radius: 16px; }
body.app-body td.actions { display: table-cell; }
body.app-body td.actions > form { display: inline-flex; align-items: center; gap: 10px; }
body.app-body :is(.term-input, .abbreviation-input, .abbreviation-type-select) { min-height: 44px; padding: 12px; border-radius: 16px; font-size: 13px; }
body.app-body .abbreviation-type-select { padding-right: 28px; }
.table-wrap .actions { gap: 10px; }
body.app-body .user-row-actions { gap: 24px; min-width: max-content; }
.user-row-actions > form { flex: 0 0 auto; }
.user-row-actions .reset-form { display: flex; align-items: center; gap: 16px; }
body.app-body .user-row-actions .reset-form input { width: clamp(220px, 16vw, 300px); min-width: 220px; margin: 0; }
body.app-body .user-row-actions button { min-height: 48px; }
body.app-body .glossary-toolbar { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 16px; padding: 16px 0; border: 0; background: transparent; box-shadow: none; overflow: visible; white-space: normal; color: var(--muted); font-size: 12px; }
.glossary-toolbar-actions { flex-wrap: wrap; gap: 12px; }
.glossary-toolbar-summary { margin-left: auto; }
body.app-body :is(.glossary-toolbar, .log-toolbar) select { width: 88px; min-height: 44px; padding-block: 10px; font-size: 13px; background-color: #fff; box-shadow: var(--control-shadow); }
body.app-body .search-form { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 24px; padding: 24px; }
.search-form input:not([type="hidden"]) { flex: 1 1 220px; width: auto; min-width: 0; }
.search-form select { flex: 0 1 160px; }
body.app-body .glossary-add-form { grid-template-columns: minmax(150px, 1fr) minmax(180px, 1.25fr) 100px 130px auto auto; gap: 16px; }
body.app-body .log-toolbar { padding-block: 8px; box-shadow: none; color: var(--muted); font-size: 13px; }
body.app-body .pagination { gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: 13px; margin-top: 24px; }
body.app-body .pagination .button { min-height: 44px; padding: 12px 18px; font-size: 13px; }
body.app-body .pagination input { min-height: 44px; width: 72px; padding: 12px; background-color: #fff; box-shadow: var(--control-shadow); }
.pagination-jump { margin-left: 8px; }
.row-progress { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.row-progress-track { width: 48px; height: 6px; background: #eeebf5; border-radius: 16px; overflow: hidden; }
.row-progress-track i { display: block; height: 100%; border-radius: inherit; background: #9383ba; }
.row-progress.failed .row-progress-track i { background: #bc8693; }

/* Text accompanies every status; softened colors keep readable contrast. */
body.app-body .status { min-width: 0; display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border: 0; border-radius: 16px; font-size: 12px; line-height: 1.5; font-weight: 500; white-space: nowrap; color: #636277; background: #f0eff5; }
body.app-body .status::before { content: ""; width: 6px; height: 6px; flex: 0 0 6px; border-radius: 50%; background: currentColor; }
body.app-body .status.completed { background: #eaf3ee; color: #437256; }
body.app-body .status.running { background: var(--primary-soft); color: var(--primary-dark); }
body.app-body .status.failed { background: #f9edf0; color: #9b4b60; }
body.app-body :is(.status.warning, .status.needs_review) { background: #f8f1e5; color: #82612c; }
body.app-body :is(.status.stopped, .status.disabled) { background: #f0eff5; color: #636277; }
body.app-body button.status { min-height: 44px; }
body:is(.app-body, .auth-body) .alert { padding: 20px 24px; border: 0; border-radius: 20px; background: var(--primary-soft); color: #635089; box-shadow: none; font-size: 14px; line-height: 1.8; }
body:is(.app-body, .auth-body) .alert.success { background: #eaf3ee; color: #437256; }
body:is(.app-body, .auth-body) .alert.warning { background: #f8f1e5; color: #82612c; }
body:is(.app-body, .auth-body) .alert.error { background: #f9edf0; color: #9b4b60; }
.flash-message { display: flex; align-items: center; gap: 12px; }
.flash-message > .ui-icon { box-sizing: content-box; padding: 10px; border-radius: 50%; background: rgb(255 255 255 / 55%); }
.flash-message > span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
body:is(.app-body, .auth-body) .flash-close { min-height: 44px; width: 44px; flex: 0 0 44px; padding: 0; border-radius: 16px; background: transparent; color: inherit; }
.flash-close:hover { background: rgb(255 255 255 / 65%); }
body.app-body .alert.alert-toast { width: min(460px, calc(100vw - 40px)); padding: 16px 20px; border-radius: 24px; background: #fff; box-shadow: var(--hover-shadow); }
.progress-track { height: 8px; border-radius: 16px; background: #eeebf5; margin-block: 24px; }
.progress-fill { border-radius: inherit; background: #9383ba; }
.progress-meta > strong { color: var(--primary-dark); font-size: 28px; font-weight: 600; font-variant-numeric: tabular-nums; }
.job-progress[data-status="failed"] .progress-fill { background: #bc8693; }
.job-progress[data-status="failed"] .progress-meta > strong { color: var(--danger); }
.job-progress p { font-size: 14px; line-height: 1.8; }
.error-detail { margin-top: 20px; padding: 16px 0 0; border: 0; border-top: 1px solid var(--line); background: transparent; color: var(--danger); font: inherit; font-size: 14px; line-height: 1.8; overflow-wrap: anywhere; }
.file-row { padding: 28px 32px; gap: 24px; border-color: var(--line); }
.file-row > .file-summary { flex-direction: row !important; align-items: center; gap: 16px; }
.file-summary > div { min-width: 0; }
.file-summary strong { color: var(--ink); font-size: 14px; font-weight: 600; }
.file-summary small { color: var(--muted); font-size: 12px; line-height: 1.8; }
.document-file-icon { display: grid; place-items: center; width: 48px; height: 48px; flex: 0 0 48px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); }
.file-actions { gap: 12px; }
body.app-body .file-actions :is(.status, .button) { min-height: 48px; padding: 12px 18px; border-radius: 16px; font-size: 13px; line-height: 1.45; }
.job-heading-summary { display: flex; align-items: center; flex: 1; min-width: 0; gap: 20px; }
body.app-body .job-heading-summary h1 { flex: 0 0 auto; margin: 0; white-space: nowrap; }
body.app-body .job-heading-summary .job-metadata { min-width: 0; max-width: none; margin: 0; padding-block: 6px; white-space: nowrap; overflow-x: auto; scrollbar-width: thin; scrollbar-color: #c9c2da transparent; }
.job-metadata:focus-visible { border-radius: 16px; }
.job-heading-actions { flex: 0 0 auto; justify-content: flex-end; margin-top: 0; gap: 12px; }
.settings-form { gap: 28px; }
.form-section > p { max-width: 70ch; color: var(--muted); font-size: 14px; line-height: 1.85; }
.form-grid { gap: 28px; margin-top: 28px; }
.form-actions { gap: 16px; padding-top: 4px; }
.task-file-error { padding: 16px 20px; border: 0; border-radius: 16px; color: var(--danger); background: #f9edf0; line-height: 1.8; }
body.app-body .empty { height: 160px; color: var(--muted); font-size: 14px; }
.glossary-ai-status { padding: 12px 0 0; border-radius: 0; background: transparent; color: var(--muted); font-size: 13px; line-height: 1.8; }
.glossary-ai-status.success { background: transparent; color: #437256; }
.glossary-ai-status.error { background: transparent; color: var(--danger); }

/* Native dialogs preserve keyboard focus, Escape and form confirmation. */
.confirm-dialog { width: min(460px, calc(100vw - 32px)); max-height: calc(100dvh - 40px); padding: 0; overflow: auto; border: 0; border-radius: 24px; color: var(--ink); background: #fff; box-shadow: 0 24px 72px rgb(69 52 114 / 22%); }
.confirm-dialog::backdrop, .candidate-conflict-dialog::backdrop { background: rgb(48 43 65 / 32%); }
.confirm-panel { padding: 32px; }
.confirm-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.confirm-symbol { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 50%; background: var(--primary-soft); color: var(--primary); }
.confirm-dialog.is-destructive .confirm-symbol { background: #f9edf0; color: var(--danger); }
.confirm-dialog h2 { margin: 0 0 12px; font-size: 22px; font-weight: 600; }
.confirm-dialog p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.85; white-space: pre-line; overflow-wrap: anywhere; }
.confirm-dialog .confirm-note { color: #926271; font-size: 12px; margin-top: 10px; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 32px; }
.candidate-conflict-dialog { border-radius: 24px; background: #fff; box-shadow: 0 24px 72px rgb(69 52 114 / 22%); }
.candidate-conflict-panel { border: 0; border-radius: 24px; }
.candidate-conflict-panel :is(header, footer, .candidate-comparison-list, .candidate-glossary-comparison) { padding: 24px 32px; border-color: var(--line); }
.candidate-conflict-explanation { padding: 20px 32px; border: 0; background: #f8f1e5; color: #82612c; }
.candidate-comparison-item { padding: 16px 0; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; }
.candidate-comparison-item.current { background: transparent; border-color: var(--line); }
.comparison-current { padding: 6px 10px; border-radius: 16px; background: #eaf3ee; color: #437256; }
body.app-body .dialog-close { min-width: 44px; min-height: 44px; padding: 8px; border-radius: 16px; background: var(--soft); color: var(--muted); }
.is-submitting button[type="submit"], .is-submitting button:not([type]), body.app-body button.is-pending { pointer-events: none; }
.is-pending::before { content: ""; width: 14px; height: 14px; flex-shrink: 0; border: 1px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: ui-spin .8s linear infinite; }
@keyframes ui-spin { to { transform: rotate(360deg); } }

/* Login uses the same palette without adding another card container. */
.login-identity { background: #eeebf6; color: #51416d; }
.login-identity::after { display: none; }
.login-brand-name span, .login-identity-caption span { color: #6c5e82; }
.login-mark { height: 48px; border: 0; border-radius: 16px; background: #e2dcee; }
.login-mark span:first-child { background: var(--primary); color: #fff; }
.login-mark span:last-child { color: var(--primary-dark); }
.login-document-back { border: 0; border-radius: 24px; background: #d8cee9; }
.login-document { border-radius: 24px; background: #fff; box-shadow: 0 24px 55px rgb(91 76 143 / 18%); }
.login-document-head span { padding: 6px 10px; border-radius: 12px; background: var(--primary-soft); color: var(--primary-dark); }
.login-document-title { background: #8c7ba9; border-radius: 16px; }
.login-document-line { background: #d4ccdf; border-radius: 16px; }
.login-document-table { border-radius: 12px; overflow: hidden; background: #ded7e9; }
.login-document-table i { background: #f5f2f9; }
.login-language-row, .login-language-row span:last-child { color: var(--primary-dark); }
.login-access, .page.login-page { background: #f7f8fb; }
body.auth-body .login-form input { min-height: 52px; margin-top: 12px; background-color: #fff; box-shadow: var(--control-shadow); }
body.auth-body .login-form input:focus { box-shadow: 0 0 0 5px var(--focus-ring), var(--control-shadow); }
.login-form { gap: 28px; }
.login-support, .login-footer { color: var(--muted); }

@media (max-width: 1380px) {
  body.app-body .jobs-table :is(th, td) { padding-inline: 12px; }
  body.app-body .job-actions { flex-wrap: wrap; width: 182px; min-width: 182px; }
}
@media (max-width: 1250px) {
  body.app-body .glossary-add-form, .user-form { grid-template-columns: 1fr 1fr; }
  .task-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-stats { gap: 20px; }
  .metric-card { padding: 24px 20px; }
}
@media (max-width: 1000px) {
  .job-heading-row { flex-wrap: wrap; }
  .job-heading-summary { flex-basis: 100%; }
  .file-row { flex-wrap: wrap; }
}
@media (max-width: 900px) {
  .app-topbar { height: 72px; padding-inline: 24px; }
  .app-sidebar { box-shadow: 14px 0 36px rgb(91 76 143 / 15%); }
  body.app-body .sidebar-backdrop { padding: 0; border-radius: 0; background: rgb(48 43 65 / 32%); box-shadow: none; }
  body.app-body .page { padding: 24px 24px 56px; }
  .dashboard-stats { gap: 24px; }
}
@media (max-width: 760px) {
  body.app-body .page-heading { align-items: flex-start; gap: 20px; margin-bottom: 24px; }
  body.app-body .page-heading h1 { font-size: 26px; }
  body.app-body :is(.upload-band, .form-section, .job-progress, .inline-form) { padding: 24px; }
  body.app-body .dashboard-upload .upload-form { grid-template-columns: 1fr; }
  .task-options { grid-column: 1; }
  .dashboard-upload .file-picker { padding: 24px 20px; gap: 20px; }
  .upload-file-symbol { width: 48px; height: 48px; flex-basis: 48px; }
  .file-picker strong { font-size: 14px; }
  .file-picker small { font-size: 12px; }
  .file-row { padding: 24px; }
  .file-actions { justify-content: flex-start; }
  .job-heading-summary { width: 100%; gap: 16px; }
  .job-heading-actions { justify-content: flex-start; flex-wrap: wrap; }
  body.app-body .search-form { align-items: stretch; }
  .search-form select { flex: 1 1 120px; }
  .glossary-toolbar-actions { width: 100%; gap: 12px; }
  .glossary-toolbar-summary { margin-left: 0; }
  .glossary-toolbar-page-size { margin-left: auto; }
  .pagination-jump { margin-left: 0; }
  .topbar-context small, .topbar-context strong::before { display: none; }
  .form-grid { gap: 24px; }
  .selected-file-row { grid-template-columns: 42px minmax(0, 1fr) 44px; }
}
@media (max-width: 480px) {
  .app-topbar { padding-inline: 16px; gap: 12px; }
  .topbar-context strong { font-size: 13px; }
  .api-state-chip { padding: 10px; font-size: 11px; }
  .topbar-context { display: none; }
  .topbar-actions { margin-left: auto; min-width: 0; }
  .selected-file-row { padding-inline: 16px; gap: 12px; }
  .dashboard-upload .file-picker { padding-inline: 20px; }
  body.app-body .page { padding-inline: 16px; }
  .dashboard-stats { gap: 16px; }
  .metric-card { min-height: 116px; padding: 20px; grid-template-columns: minmax(0, 1fr) 32px; gap: 8px; }
  .metric-icon { width: 32px; height: 32px; }
  .metric-icon .ui-icon { width: 17px; height: 17px; }
  .metric-copy strong { font-size: 28px; }
  .metric-copy span { font-size: 12px; }
  body.app-body .glossary-add-form, .user-form { grid-template-columns: 1fr; }
  .task-options { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 12px; }
  body.app-body .task-options select { padding-left: 12px; padding-right: 12px; font-size: 13px; }
  body.app-body .task-options .output-format-select { grid-column: 1 / -1; }
  body.app-body .section-title > span { padding-inline: 8px; font-size: 11px; }
  .confirm-panel { padding: 24px; }
}
@media (forced-colors: active) {
  body.app-body input[type="checkbox"] { appearance: auto; background-image: none; }
  body:is(.app-body, .auth-body) :is(button, .button, input, select, textarea) { border: 1px solid ButtonText; }
  body:is(.app-body, .auth-body) :is(a, button, input, select, textarea, [tabindex]):focus-visible { outline-color: Highlight; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  body:is(.app-body, .auth-body) :is(button, .button, .side-nav-link, .upload-band, .form-section, .job-progress, .metric-card):is(:hover, :active) { transform: none; }
}
