:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --sidebar: #151b26;
  --sidebar-soft: #202838;
  --text: #182033;
  --muted: #667085;
  --line: #dfe4eb;
  --line-strong: #cbd3de;
  --blue: #1f5eff;
  --blue-dark: #1647c7;
  --blue-soft: #eaf0ff;
  --green: #16865c;
  --green-soft: #e8f6f0;
  --amber: #a96800;
  --amber-soft: #fff3d6;
  --red: #c53b45;
  --red-soft: #fdecef;
  --violet: #6b4fc4;
  --shadow: 0 8px 24px rgba(25, 36, 55, .07);
  --radius: 7px;
  font-family: "Segoe UI", "Microsoft YaHei UI", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-height: 100vh; background: var(--bg); font-size: 14px; }
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.login-panel { width: min(380px, 100%); display: grid; gap: 20px; padding: 28px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.login-panel > div { display: grid; gap: 5px; }
.login-panel h1 { margin: 0; font-size: 20px; letter-spacing: 0; }
.login-panel p { margin: 0; color: var(--muted); }
.login-error { margin: -7px 0 0 !important; padding: 9px 10px; border-radius: 6px; color: var(--red) !important; background: var(--red-soft); }
button, input, textarea, select { font: inherit; letter-spacing: 0; }
button, a, input, textarea, select { outline: none; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { box-shadow: 0 0 0 3px rgba(31, 94, 255, .2); }
::selection { color: #fff; background: var(--blue); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #c5ccd7; border: 3px solid transparent; border-radius: 8px; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; z-index: 30; height: 100vh; display: flex; flex-direction: column; padding: 18px 12px; color: #fff; background: var(--sidebar); }
.brand { display: flex; align-items: center; gap: 11px; min-height: 52px; padding: 0 8px 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand img { flex: 0 0 auto; }
.brand div { min-width: 0; display: grid; gap: 2px; }
.brand strong { overflow: hidden; font-size: 14px; white-space: nowrap; text-overflow: ellipsis; }
.brand span { color: #98a5b9; font-size: 11px; }
.nav { display: grid; gap: 4px; padding: 18px 0; }
.nav a { min-height: 42px; display: flex; align-items: center; gap: 11px; padding: 0 12px; border-radius: 6px; color: #aeb8c8; text-decoration: none; font-weight: 600; transition: background .16s ease, color .16s ease; }
.nav a:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav a.active { color: #fff; background: var(--blue); }
.nav svg { width: 18px; height: 18px; }
.sidebar-foot { margin-top: auto; min-height: 62px; display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 6px; background: var(--sidebar-soft); }
.sidebar-foot div { display: grid; gap: 2px; }
.sidebar-foot strong { font-size: 12px; }
.sidebar-foot span:not(.service-dot) { color: #9eabba; font-size: 11px; }
.service-dot { width: 8px; height: 8px; border-radius: 50%; background: #36c98a; box-shadow: 0 0 0 4px rgba(54,201,138,.12); }

.main { min-width: 0; padding: 0 28px 40px; }
.topbar { position: sticky; top: 0; z-index: 20; min-height: 68px; display: flex; align-items: center; gap: 16px; margin: 0 -28px; padding: 0 28px; border-bottom: 1px solid var(--line); background: rgba(244,246,249,.96); backdrop-filter: blur(10px); }
.page-context { min-width: 170px; display: grid; gap: 2px; }
.page-context strong { font-size: 14px; }
.page-context span { color: var(--muted); font-size: 11px; }
.global-search { width: min(360px, 35vw); display: flex; align-items: center; gap: 8px; margin-left: auto; padding: 0 11px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.global-search:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(31,94,255,.1); }
.global-search svg, .toolbar-search svg { width: 16px; color: #8791a2; }
.global-search input, .toolbar-search input { width: 100%; height: 38px; padding: 0; border: 0; background: transparent; }
.icon-btn { width: 38px; height: 38px; display: inline-grid; flex: 0 0 auto; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 6px; color: #4f5c70; background: var(--surface); cursor: pointer; }
.icon-btn:hover { color: var(--blue); border-color: #b9c8ef; background: var(--blue-soft); }
.icon-btn svg { width: 17px; height: 17px; }
.mobile-only { display: none; }

.page { display: none; padding-top: 28px; }
.page.active { display: block; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.page-heading h1 { margin: 0 0 5px; font-size: 24px; line-height: 1.25; letter-spacing: 0; }
.page-heading p, .panel-head p { margin: 0; color: var(--muted); line-height: 1.5; }

.btn { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 0 14px; border: 1px solid transparent; border-radius: 6px; cursor: pointer; font-weight: 650; white-space: nowrap; }
.btn svg { width: 16px; height: 16px; }
.btn.primary { color: #fff; background: var(--blue); }
.btn.primary:hover { background: var(--blue-dark); }
.btn.secondary { color: #344054; border-color: var(--line-strong); background: var(--surface); }
.btn.secondary:hover { border-color: #aebbd0; background: var(--surface-soft); }
.btn.danger { color: var(--red); border-color: #efb9be; background: var(--red-soft); }
.btn.danger:hover { color: #fff; background: var(--red); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.is-busy, .icon-btn.is-busy { cursor: wait; }
.text-btn { padding: 3px 0; border: 0; color: var(--blue); background: transparent; cursor: pointer; font-weight: 650; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.metric { min-height: 124px; display: grid; align-content: center; gap: 5px; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); text-align: left; background: var(--surface); box-shadow: 0 2px 8px rgba(25,36,55,.025); cursor: pointer; }
.metric:hover { border-color: #b9c8ef; box-shadow: var(--shadow); }
.metric span { color: var(--muted); font-size: 12px; font-weight: 650; }
.metric strong { font-size: 30px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.metric small { color: #8a94a5; }
.metric.healthy strong { color: var(--green); }
.metric.warning strong { color: var(--amber); }
.metric.danger strong { color: var(--red); }

.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 2px 8px rgba(25,36,55,.025); }
.panel-head { min-height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0 0 4px; font-size: 15px; }
.panel-head > svg { width: 20px; color: var(--blue); }
.overview-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(320px, .9fr); gap: 14px; }
.jobs-panel { grid-column: 1 / -1; }
.health-layout { min-height: 260px; display: grid; grid-template-columns: minmax(0, 1fr) 220px; align-items: center; gap: 28px; padding: 24px; }
.health-bar { height: 32px; display: flex; overflow: hidden; border-radius: 5px; background: #edf0f4; }
.health-bar span { min-width: 3px; }
.health-legend { display: grid; gap: 8px; }
.legend-row { display: grid; grid-template-columns: 9px 1fr auto; align-items: center; gap: 9px; min-height: 30px; }
.legend-row i { width: 9px; height: 9px; border-radius: 2px; }
.legend-row span { color: var(--muted); }
.legend-row b { font-variant-numeric: tabular-nums; }
.compact-list { min-height: 260px; }
.compact-row { min-height: 58px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 10px 18px; border-bottom: 1px solid #edf0f4; }
.row-button { width: 100%; border: 0; color: inherit; text-align: left; background: transparent; cursor: pointer; }
.row-button:hover { background: #f9fbff; }
.compact-row:last-child { border-bottom: 0; }
.compact-row strong { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.compact-row small { color: var(--muted); }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(290px, .65fr); gap: 14px; margin-bottom: 14px; }
.worker-strip { min-height: 72px; display: flex; align-items: center; gap: 24px; margin-bottom: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.worker-identity { min-width: 220px; display: flex; align-items: center; gap: 11px; }
.worker-identity div { min-width: 0; display: grid; gap: 3px; }
.worker-identity strong, .worker-identity span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.worker-identity span { color: var(--muted); font-size: 11px; }
.service-dot.offline { background: #a6afbd; box-shadow: 0 0 0 4px rgba(166,175,189,.14); }
.worker-stats { display: flex; gap: 18px; color: var(--muted); font-size: 12px; }
.worker-stats b { margin-left: 4px; color: var(--text); font-variant-numeric: tabular-nums; }
.worker-actions { display: flex; gap: 8px; margin-left: auto; }
.auto-test-strip { min-height: 60px; display: flex; align-items: center; gap: 24px; margin-bottom: 14px; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.auto-test-identity { min-width: 250px; display: flex; align-items: center; gap: 11px; }
.auto-test-identity div { min-width: 0; display: grid; gap: 3px; }
.auto-test-identity strong, .auto-test-identity span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.auto-test-identity span { color: var(--muted); font-size: 11px; }
.auto-test-stats { min-width: 0; display: flex; flex: 1 1 auto; gap: 20px; color: var(--muted); font-size: 12px; }
.auto-test-stats b { margin-left: 4px; color: var(--text); font-variant-numeric: tabular-nums; }
.import-panel textarea { width: calc(100% - 36px); min-height: 220px; display: block; margin: 18px; padding: 13px; resize: vertical; border: 1px solid var(--line-strong); border-radius: 6px; color: var(--text); background: #fbfcfe; font-family: Consolas, "Cascadia Mono", monospace; font-size: 12px; line-height: 1.65; }
.import-panel textarea:focus { border-color: var(--blue); background: #fff; box-shadow: 0 0 0 3px rgba(31,94,255,.1); }
.panel-actions { display: flex; justify-content: flex-end; gap: 9px; padding: 0 18px 18px; }
.inline-feedback { margin: 0 18px 14px; padding: 10px 12px; border-radius: 6px; color: #765111; background: var(--amber-soft); line-height: 1.5; }
.inline-feedback.success { color: #116342; background: var(--green-soft); }
.hidden { display: none !important; }
.action-panel { padding-bottom: 18px; }
.action-summary { display: grid; justify-items: center; padding: 32px 18px 22px; }
.action-summary strong { font-size: 44px; font-variant-numeric: tabular-nums; }
.action-summary span { color: var(--muted); }
.action-panel .field, .action-panel .btn, .scope-note { margin-left: 18px; margin-right: 18px; }
.action-panel .btn.wide { width: calc(100% - 36px); }
.scope-note { display: flex; align-items: flex-start; gap: 8px; margin-top: 16px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.scope-note svg { width: 16px; flex: 0 0 auto; color: var(--green); }

.toolbar { min-height: 58px; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; background: var(--surface); }
.toolbar-search { width: 290px; display: flex; align-items: center; gap: 8px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-soft); }
.toolbar select, .field input, .field select { height: 38px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 6px; color: var(--text); background: #fff; }
.toolbar-count { margin-left: auto; color: var(--muted); font-size: 12px; }
.table-panel { border-radius: 0 0 var(--radius) var(--radius); }
.table-scroll { width: 100%; overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { height: 48px; padding: 9px 12px; border-bottom: 1px solid #e9edf2; text-align: left; vertical-align: middle; }
th { position: sticky; top: 0; z-index: 2; color: #687386; background: #f8fafc; font-size: 11px; font-weight: 700; text-transform: uppercase; }
td { font-size: 12.5px; }
tbody tr:hover { background: #f9fbff; }
tbody tr:last-child td { border-bottom: 0; }
.accounts-table table { min-width: 1252px; table-layout: fixed; }
.account-col-check { width: 42px; }
.account-col-email { width: 230px; }
.account-col-status { width: 180px; }
.account-col-graph, .account-col-mail { width: 105px; }
.account-col-error { width: 210px; }
.account-col-tested { width: 130px; }
.account-col-auto { width: 140px; }
.account-col-action { width: 110px; }
.check-cell { width: 42px; text-align: center; }
.email-cell button { width: 100%; display: block; overflow: hidden; padding: 0; border: 0; color: var(--blue-dark); background: transparent; text-align: left; white-space: nowrap; text-overflow: ellipsis; cursor: pointer; font-weight: 650; }
.accounts-table td:nth-child(3) small { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.error-cell { overflow: hidden; color: var(--muted); white-space: nowrap; text-overflow: ellipsis; }
.accounts-table th:nth-child(7), .accounts-table td:nth-child(7) { white-space: nowrap; }
.auto-test-cell { display: grid; gap: 2px; line-height: 1.35; }
.auto-test-cell small { overflow: hidden; color: var(--muted); white-space: nowrap; text-overflow: ellipsis; }
.auto-test-cell.paused strong { color: var(--red); }
.row-actions { display: flex; align-items: center; gap: 6px; }
.empty { padding: 30px !important; color: var(--muted); text-align: center !important; }
.pagination { position: sticky; bottom: 0; z-index: 3; min-height: 54px; display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 8px 12px; border-top: 1px solid var(--line); background: var(--surface); }
.pagination span { color: var(--muted); font-size: 12px; }
.status-tag { min-height: 24px; display: inline-flex; align-items: center; justify-content: center; padding: 2px 8px; border: 1px solid transparent; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.status-tag.healthy { color: var(--green); border-color: #b9e1d0; background: var(--green-soft); }
.status-tag.limited, .status-tag.reauth_required { color: var(--amber); border-color: #ead39a; background: var(--amber-soft); }
.status-tag.restricted, .status-tag.oauth_error, .status-tag.graph_error { color: var(--red); border-color: #edbdc1; background: var(--red-soft); }
.status-tag.network_error { color: var(--violet); border-color: #d8cdf3; background: #f1edfb; }
.status-tag.untested, .status-tag.neutral, .status-tag.cancelled, .status-tag.queued { color: #596579; border-color: #d6dce5; background: #f0f3f6; }
.status-tag.running { color: var(--blue-dark); border-color: #c4d1f5; background: var(--blue-soft); }
.status-tag.cancelling { color: var(--amber); border-color: #ead39a; background: var(--amber-soft); }
.status-tag.waiting_worker { color: var(--amber); border-color: #ead39a; background: var(--amber-soft); }
.status-tag.retesting { color: var(--blue-dark); border-color: #c4d1f5; background: var(--blue-soft); }
.status-tag.failed { color: var(--red); border-color: #edbdc1; background: var(--red-soft); }
.status-tag.completed { color: var(--green); border-color: #b9e1d0; background: var(--green-soft); }
.mini-status { display: inline-flex; align-items: center; gap: 6px; }
.mini-status::before { width: 7px; height: 7px; border-radius: 50%; background: #a6afbd; content: ""; }
.mini-status.ok::before { background: var(--green); }
.mini-status.fail::before { background: var(--red); }

.mail-page { height: calc(100vh - 68px); padding-top: 0; }
.mail-page.active { display: flex; flex-direction: column; }
.mail-toolbar { min-height: 66px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
.mail-account { min-width: 0; display: grid; gap: 2px; }
.mail-account strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.mail-account span { color: var(--muted); font-size: 11px; }
.mail-mode { display: flex; margin-left: auto; padding: 3px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-soft); }
.mail-mode button { min-height: 32px; padding: 0 12px; border: 0; border-radius: 4px; color: var(--muted); background: transparent; cursor: pointer; font-size: 12px; font-weight: 650; }
.mail-mode button.active { color: var(--blue-dark); background: var(--surface); box-shadow: 0 1px 3px rgba(25,36,55,.12); }
.mail-workspace { min-height: 0; flex: 1 1 auto; display: grid; grid-template-columns: minmax(300px, 34%) minmax(0, 1fr); margin: 0 -28px -40px; border-top: 0; background: var(--surface); }
.mail-list-pane { min-height: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); }
.mail-list { min-height: 0; overflow-y: auto; }
.mail-item { width: 100%; min-height: 104px; display: grid; gap: 5px; padding: 14px 18px; border: 0; border-bottom: 1px solid var(--line); color: var(--text); text-align: left; background: var(--surface); cursor: pointer; }
.mail-item:hover { background: #f8faff; }
.mail-item.active { background: var(--blue-soft); }
.mail-item.unread .mail-item-from, .mail-item.unread .mail-item-subject { font-weight: 750; }
.mail-item-head { min-width: 0; display: flex; align-items: baseline; gap: 10px; }
.mail-item-from { overflow: hidden; flex: 1 1 auto; white-space: nowrap; text-overflow: ellipsis; }
.mail-item time { flex: 0 0 auto; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.mail-item-subject, .mail-item-preview { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.mail-item-preview { color: var(--muted); font-size: 12px; }
.mail-more { min-height: 44px; flex: 0 0 auto; border-top: 1px solid var(--line); }
.mail-reader { min-width: 0; overflow-y: auto; background: #fff; }
.mail-reader-empty { min-height: 100%; display: grid; place-content: center; justify-items: center; gap: 10px; color: var(--muted); }
.mail-reader-empty svg { width: 28px; height: 28px; }
.mail-message-head { display: grid; gap: 12px; padding: 24px 28px 18px; border-bottom: 1px solid var(--line); }
.mail-message-head h2 { margin: 0; overflow-wrap: anywhere; font-size: 20px; line-height: 1.4; }
.mail-message-meta { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 5px 10px; align-items: start; color: var(--muted); font-size: 12px; }
.mail-message-meta strong { color: var(--text); }
.mail-message-meta .recipients { min-width: 0; overflow-wrap: anywhere; }
.mail-message-meta time { grid-column: 3; grid-row: 1 / span 2; white-space: nowrap; font-variant-numeric: tabular-nums; }
.mail-body-frame { width: 100%; min-height: calc(100% - 130px); display: block; border: 0; background: #fff; }
.mail-error { min-height: 100%; display: grid; place-content: center; justify-items: center; gap: 8px; padding: 30px; color: var(--muted); text-align: center; }
.mail-error strong { color: var(--red); }

.settings { border-top: 1px solid var(--line); }
.settings-section { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 40px; padding: 26px 0; border-bottom: 1px solid var(--line); }
.settings-section h2 { margin: 0 0 6px; font-size: 15px; }
.settings-section p { margin: 0; color: var(--muted); line-height: 1.55; }
.settings-fields { display: grid; gap: 15px; }
.settings-fields.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.settings-actions { display: flex; justify-content: center; padding: 24px 0 8px; }
.field { display: grid; gap: 7px; }
.field span { color: #566174; font-size: 12px; font-weight: 650; }
.field input { width: 100%; }
.input-action { display: flex; align-items: center; gap: 8px; }
.input-action input { min-width: 0; flex: 1 1 auto; }
.input-action input[readonly] { color: #4d596d; background: var(--surface-soft); }
.input-action .icon-btn { width: 38px; height: 38px; }
.remote-config-state { min-height: 38px; display: flex; align-items: center; padding: 9px 11px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); background: var(--surface-soft); }
.remote-config-state.online { color: var(--green); border-color: #b9e1d0; background: var(--green-soft); }
.remote-config-state.error { color: var(--red); border-color: #edbdc1; background: var(--red-soft); }
.config-editor { width: 100%; min-height: 320px; padding: 12px; resize: vertical; border: 1px solid var(--line-strong); border-radius: 6px; color: var(--text); background: #fbfcfe; font-family: Consolas, "Cascadia Mono", monospace; font-size: 12px; line-height: 1.55; tab-size: 4; }
.config-editor:disabled { color: #8993a3; background: #f1f3f6; cursor: not-allowed; }
.remote-config-actions { display: flex; justify-content: flex-end; gap: 8px; }
.check-field { min-height: 38px; display: flex; align-items: center; gap: 9px; color: #566174; font-size: 12px; font-weight: 650; }
.check-field input { width: 16px; height: 16px; margin: 0; accent-color: var(--blue); }
.span-two { grid-column: 1 / -1; }
.job-name small, td > small { display: block; margin-top: 3px; color: var(--muted); font-weight: 400; }

.log-panel { overflow: hidden; }
.log-list { min-height: 420px; max-height: calc(100vh - 230px); overflow: auto; }
.log-row { display: grid; grid-template-columns: 155px 72px 92px minmax(0, 1fr); align-items: start; gap: 12px; padding: 11px 14px; border-bottom: 1px solid #e9edf2; font-family: Consolas, "Cascadia Mono", monospace; font-size: 12px; line-height: 1.5; }
.log-row:hover { background: #fafcff; }
.log-row time { color: #7d8798; }
.log-row .category { color: var(--blue-dark); }
.log-row.error .level { color: var(--red); font-weight: 700; }
.log-row.info .level { color: var(--green); font-weight: 700; }
.log-row p { margin: 0; overflow-wrap: anywhere; }

.drawer { position: fixed; top: 0; right: 0; z-index: 60; width: min(480px, 92vw); height: 100vh; display: flex; flex-direction: column; background: var(--surface); box-shadow: -18px 0 42px rgba(25,36,55,.14); transform: translateX(105%); transition: transform .2s ease-out; }
.drawer.open { transform: translateX(0); }
.drawer-backdrop { position: fixed; inset: 0; z-index: 55; visibility: hidden; background: rgba(17,24,39,.28); opacity: 0; transition: opacity .2s ease-out; }
.drawer-backdrop.open { visibility: visible; opacity: 1; }
.drawer-head { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { max-width: 360px; margin: 3px 0 0; overflow: hidden; font-size: 17px; white-space: nowrap; text-overflow: ellipsis; }
.muted { color: var(--muted); font-size: 11px; }
.drawer-body { padding: 18px; overflow: auto; }
.drawer-actions { display: flex; justify-content: flex-end; gap: 9px; padding-top: 16px; }
.detail-grid { display: grid; grid-template-columns: 130px 1fr; gap: 0; border-top: 1px solid var(--line); }
.detail-grid dt, .detail-grid dd { min-height: 42px; margin: 0; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.detail-grid dt { color: var(--muted); }
.detail-grid dd { overflow-wrap: anywhere; }
.history-list { display: grid; margin-top: 12px; }
.detail-heading { margin: 24px 0 0; font-size: 14px; }
.history-row { display: grid; gap: 4px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.history-row div { display: flex; justify-content: space-between; gap: 10px; }
.history-row small, .history-row p { margin: 0; color: var(--muted); }
.toast-region { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: grid; gap: 8px; }
.toast { width: min(360px, calc(100vw - 36px)); padding: 12px 14px; border-radius: 6px; color: #fff; background: #263247; box-shadow: var(--shadow); animation: toast-in .2s ease-out; }
.toast.error { background: #9f2f39; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 1120px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-grid, .workspace-grid { grid-template-columns: 1fr; }
  .jobs-panel { grid-column: auto; }
  .health-layout { min-height: 220px; }
}

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; width: min(280px, 84vw); transform: translateX(-105%); transition: transform .2s ease-out; box-shadow: 16px 0 36px rgba(17,24,39,.22); }
  body.menu-open .sidebar { transform: translateX(0); }
  .mobile-only { display: inline-grid; }
  .main { padding: 0 18px 30px; }
  .topbar { margin: 0 -18px; padding: 0 18px; }
  .page-context { min-width: 0; }
  .page-context span { display: none; }
  .global-search { width: min(300px, 50vw); }
  .settings-section { grid-template-columns: 1fr; gap: 18px; }
  .worker-strip { align-items: flex-start; flex-wrap: wrap; }
  .auto-test-strip { align-items: flex-start; flex-wrap: wrap; }
  .auto-test-stats { width: 100%; flex-wrap: wrap; }
  .worker-actions { width: 100%; margin-left: 0; }
  .mail-workspace { margin-right: -18px; margin-bottom: -30px; margin-left: -18px; }
}

@media (max-width: 620px) {
  .main { padding: 0 12px 24px; }
  .topbar { min-height: 60px; margin: 0 -12px; padding: 0 12px; gap: 9px; }
  .global-search { display: none; }
  .page { padding-top: 20px; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .page-heading h1 { font-size: 21px; }
  .page-heading .btn { width: 100%; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .metric { min-height: 108px; padding: 13px; }
  .metric strong { font-size: 25px; }
  .health-layout { grid-template-columns: 1fr; gap: 20px; }
  .toolbar { align-items: stretch; flex-wrap: wrap; }
  .toolbar-search { width: 100%; }
  .toolbar select, .toolbar .btn { flex: 1 1 145px; }
  .toolbar-count { width: 100%; margin-left: 0; }
  .worker-stats { width: 100%; justify-content: space-between; }
  .worker-actions { flex-wrap: wrap; }
  .worker-actions .btn { flex: 1 1 130px; }
  .mail-page { height: calc(100vh - 60px); }
  .mail-toolbar { min-height: 72px; flex-wrap: wrap; padding: 8px 0; }
  .mail-account { max-width: calc(100% - 102px); }
  .mail-mode { width: calc(100% - 50px); order: 3; margin-left: 0; }
  .mail-mode button { flex: 1 1 50%; }
  .mail-workspace { grid-template-columns: 1fr; margin-right: -12px; margin-bottom: -24px; margin-left: -12px; }
  .mail-list-pane { border-right: 0; }
  .mail-workspace.reading .mail-list-pane { display: none; }
  .mail-reader { display: none; }
  .mail-workspace.reading .mail-reader { display: block; }
  .mail-message-head { padding: 18px; }
  .mail-message-meta { grid-template-columns: auto minmax(0, 1fr); }
  .mail-message-meta time { grid-column: 2; grid-row: auto; }
  .settings-fields.two { grid-template-columns: 1fr; }
  .span-two { grid-column: auto; }
  .input-action { flex-wrap: wrap; }
  .input-action input { flex-basis: calc(100% - 92px); }
  .input-action .btn { flex: 1 1 140px; }
  .log-row { grid-template-columns: 1fr auto; }
  .log-row .category { display: none; }
  .log-row p { grid-column: 1 / -1; }
}
