:root {
  --navy: #17365d;
  --navy-2: #244c79;
  --navy-3: #eef4fa;
  --green: #2f855a;
  --green-dark: #236b47;
  --green-soft: #edf8f2;
  --amber: #b7791f;
  --amber-soft: #fff8e8;
  --red: #c53030;
  --red-soft: #fff1f1;
  --blue-soft: #eef6ff;
  --ink: #17212b;
  --muted: #657383;
  --line: #dce3ea;
  --line-strong: #c6d0da;
  --surface: #ffffff;
  --page: #f4f7fa;
  --shadow: 0 10px 28px rgba(23, 54, 93, 0.09);
  --radius: 12px;
  --sidebar-width: 238px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--page); }
html.ui-locked, html.ui-locked body { overflow: hidden; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--page);
  font-family: Arial, "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--navy-2); }

.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;
}

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  background: var(--navy);
  color: #fff;
  box-shadow: 4px 0 18px rgba(12, 36, 64, 0.13);
}

.brand {
  display: flex;
  gap: 11px;
  align-items: center;
  padding: 24px 20px 22px;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 10px;
  color: var(--navy);
  background: #fff;
  font-size: 21px;
  font-weight: 800;
}
.brand strong { display: block; font-size: 13px; letter-spacing: .03em; }
.brand span { display: block; margin-top: 2px; color: #bdd0e4; font-size: 12px; }

.main-nav { display: grid; gap: 4px; padding: 18px 12px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 12px;
  color: #dce9f5;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.is-active { color: #fff; background: rgba(255,255,255,.15); font-weight: 700; }
.nav-icon {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(255,255,255,.26);
  border-radius: 7px;
  font-size: 12px;
}
.sidebar-note {
  margin: auto 14px 18px;
  padding: 13px;
  color: #dce9f5;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 10px;
  background: rgba(255,255,255,.06);
  font-size: 12px;
}
.sidebar-note strong { color: #fff; }
.sidebar-note p { margin: 5px 0 0; }
.sidebar-user {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  margin: 0 14px 18px;
  padding: 10px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 10px;
  background: rgba(255,255,255,.06);
}
.user-avatar {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  color: var(--navy);
  background: #fff;
  font-weight: 800;
}
.user-copy { min-width: 0; }
.user-copy strong, .user-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-copy strong { color: #fff; font-size: 12px; }
.user-copy span { color: #bdd0e4; font-size: 11px; }
.sidebar-user form { margin: 0; }
.sidebar-signout { padding: 3px 0; color: #dce9f5; border: 0; background: transparent; font-size: 11px; }
.sidebar-signout:hover { color: #fff; text-decoration: underline; }

.main-content { min-height: 100vh; margin-left: var(--sidebar-width); }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 82px;
  padding: 15px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.97);
}
.topbar h1 { margin: 0; font-size: 20px; color: var(--navy); }
.topbar p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.global-search input { width: 260px; }
.menu-button { display: none; border: 0; background: transparent; font-size: 22px; color: var(--navy); }
.current-user-chip {
  display: grid;
  min-width: 112px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}
.current-user-chip span, .current-user-chip small { overflow: hidden; max-width: 170px; text-overflow: ellipsis; white-space: nowrap; }
.current-user-chip span { color: var(--ink); font-size: 12px; font-weight: 700; }
.current-user-chip small { color: var(--muted); font-size: 10px; }
.role-disabled { display: none !important; }

input, select, textarea {
  min-height: 38px;
  padding: 8px 10px;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--navy-2); box-shadow: 0 0 0 3px rgba(36,76,121,.12); }
textarea { min-height: 86px; resize: vertical; }

.button {
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 700;
}
.button-primary { color: #fff; background: var(--green); }
.button-primary:hover { background: var(--green-dark); }
.button-secondary { color: #fff; background: var(--navy); }
.button-secondary:hover { background: var(--navy-2); }
.button-ghost { color: var(--ink); border-color: var(--line-strong); background: #fff; }
.text-button { padding: 2px; border: 0; background: transparent; color: var(--navy-2); font-weight: 700; }
.icon-button { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--muted); font-size: 22px; }

.connection-banner {
  margin: 18px 28px 0;
  padding: 10px 13px;
  color: #7c2d12;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  background: #fff7ed;
}
.is-hidden { display: none !important; }
.view { display: none; padding: 22px 28px 36px; }
.view.is-active { display: block; }

.notice {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
  padding: 13px 15px;
  border-radius: var(--radius);
}
.notice strong { color: var(--navy); }
.notice p { margin: 3px 0 0; color: var(--muted); }
.notice-safe { border: 1px solid #cfe9da; background: var(--green-soft); }
.notice-safe > span { white-space: nowrap; color: var(--green-dark); font-weight: 700; }

.metric-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.metric-card { padding: 15px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.metric-card span { display: block; color: var(--muted); font-size: 12px; }
.metric-card strong { display: block; margin-top: 4px; color: var(--navy); font-size: 25px; line-height: 1.2; }
.metric-card small { display: block; margin-top: 4px; color: var(--muted); }
.metric-card.is-alert { border-color: #f4b9b9; background: var(--red-soft); }
.metric-card.is-alert strong { color: var(--red); }
.metric-card.is-warning { border-color: #edd69c; background: var(--amber-soft); }

.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.panel {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(23, 54, 93, 0.035);
}
.panel-span-2 { grid-column: 1 / -1; }
.panel-header { display: flex; align-items: start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.panel h2 { margin: 0; color: var(--navy); font-size: 16px; }
.panel-header p, .data-card > p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }

.task-list { display: grid; gap: 8px; }
.task-row {
  display: grid;
  grid-template-columns: 94px minmax(180px, 1.4fr) minmax(140px, 1fr) 90px 90px;
  align-items: center;
  gap: 10px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
}
.task-row:hover { border-color: #aec1d5; }
.task-row strong { font-size: 13px; }
.task-row small { color: var(--muted); }
.task-row.is-overdue { border-left: 4px solid var(--red); }
.task-row.is-today { border-left: 4px solid var(--amber); }

.badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 23px;
  padding: 2px 8px;
  border-radius: 999px;
  color: #445363;
  background: #eef2f6;
  font-size: 12px;
  white-space: nowrap;
}
.badge-green { color: #216743; background: #e7f6ed; }
.badge-red { color: #a52323; background: #fdecec; }
.badge-amber { color: #8b5b0f; background: #fff3d5; }
.badge-blue { color: #234f7c; background: #eaf3fb; }
.badge-muted { color: #596776; background: #eff2f4; }

.stage-summary { display: grid; gap: 8px; }
.stage-summary-row { display: grid; grid-template-columns: 110px 1fr 28px; align-items: center; gap: 9px; }
.stage-summary-row span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage-bar { height: 8px; overflow: hidden; border-radius: 999px; background: #edf1f5; }
.stage-bar i { display: block; height: 100%; border-radius: inherit; background: var(--navy-2); }

.risk-list { display: grid; gap: 8px; }
.risk-item { display: flex; gap: 9px; padding: 9px 10px; border-radius: 8px; background: #fafbfc; }
.risk-dot { width: 8px; height: 8px; margin-top: 6px; flex: 0 0 auto; border-radius: 50%; background: var(--amber); }
.risk-item strong { display: block; font-size: 13px; }
.risk-item p { margin: 1px 0 0; color: var(--muted); font-size: 12px; }

.daily-flow { display: grid; grid-template-columns: repeat(5, 1fr); gap: 9px; }
.flow-card { padding: 11px; border: 1px solid var(--line); border-radius: 9px; }
.flow-card span { color: var(--muted); font-size: 12px; }
.flow-card strong { display: block; margin-top: 2px; color: var(--navy); font-size: 18px; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.filters input { width: 230px; }
.filters select { min-width: 128px; }
.wide-filter select { min-width: 330px; }

.table-panel { padding: 0; overflow: hidden; }
.table-count { padding: 12px 15px; color: var(--muted); border-bottom: 1px solid var(--line); font-size: 12px; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 10px 12px; color: #fff; background: var(--navy); font-size: 12px; font-weight: 700; text-align: left; white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid #e8edf2; vertical-align: top; }
tbody tr:hover { background: #f8fafc; }
td strong { display: block; }
td small { color: var(--muted); }
.row-action { border: 0; background: transparent; color: var(--navy-2); font-weight: 700; }
.cell-clamp { display: -webkit-box; overflow: hidden; max-width: 320px; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

.pipeline-board { display: grid; grid-auto-columns: minmax(258px, 1fr); grid-auto-flow: column; gap: 12px; overflow-x: auto; padding-bottom: 12px; }
.pipeline-column { min-height: 460px; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: #eef2f6; }
.pipeline-column-header { display: flex; justify-content: space-between; gap: 8px; padding: 4px 3px 10px; color: var(--navy); font-weight: 700; }
.pipeline-cards { display: grid; gap: 9px; }
.opportunity-card { padding: 12px; border: 1px solid #dce3ea; border-radius: 9px; background: #fff; box-shadow: 0 2px 5px rgba(20,50,82,.04); }
.opportunity-card:hover { border-color: #9eb4c9; }
.opportunity-card h3 { margin: 0; font-size: 14px; }
.opportunity-card p { margin: 6px 0; color: var(--muted); font-size: 12px; }
.opportunity-meta { display: flex; flex-wrap: wrap; gap: 5px; }
.opportunity-next { margin-top: 9px; padding-top: 8px; border-top: 1px solid #edf0f3; }

.empty-state { padding: 26px 10px; color: var(--muted); text-align: center; }
.timeline { position: relative; display: grid; gap: 0; padding-left: 16px; }
.timeline::before { position: absolute; inset: 8px auto 8px 5px; width: 1px; content: ""; background: var(--line-strong); }
.timeline-item { position: relative; padding: 0 0 18px 14px; }
.timeline-item::before { position: absolute; left: -15px; top: 6px; width: 9px; height: 9px; content: ""; border: 2px solid #fff; border-radius: 50%; background: var(--navy-2); box-shadow: 0 0 0 1px var(--navy-2); }
.timeline-item header { display: flex; align-items: center; gap: 8px; }
.timeline-item h3 { margin: 0; font-size: 13px; }
.timeline-item time { color: var(--muted); font-size: 12px; }
.timeline-item p { margin: 5px 0 0; }
.timeline-next { color: var(--green-dark); }

.data-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.data-card { min-height: 190px; }
.data-card .button { margin-top: 15px; }
.sync-card { grid-column: 1 / -1; min-height: 0; }
.sync-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.sync-card-header p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.sync-metrics { display: grid; grid-template-columns: minmax(180px, 1.5fr) repeat(4, minmax(88px, 1fr)); gap: 9px; margin: 16px 0 0; }
.sync-metrics div { min-width: 0; padding: 10px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fafbfd; }
.sync-metrics dt { color: var(--muted); font-size: 12px; }
.sync-metrics dd { margin: 3px 0 0; overflow: hidden; color: var(--navy); font-size: 17px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.sync-actions { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.sync-actions .button { flex: 0 0 auto; margin-top: 0; }
.sync-actions .button:disabled { cursor: not-allowed; opacity: .55; }
.sync-message { margin: 0; color: var(--muted); font-size: 12px; }
.sync-message.is-error { color: var(--red); }
.sync-safety { margin: 12px 0 0 !important; padding-top: 10px; color: var(--green-dark) !important; border-top: 1px solid #e2ece7; }
.plain-list { margin: 12px 0 0; padding-left: 20px; color: var(--muted); }
.plain-list li { margin-bottom: 6px; }
.result-text { color: var(--green-dark) !important; }
.status-list { display: grid; gap: 8px; margin: 14px 0 0; }
.status-list div { display: flex; justify-content: space-between; padding-bottom: 7px; border-bottom: 1px solid #edf0f3; }
.status-list dt { color: var(--muted); }
.status-list dd { margin: 0; font-weight: 700; }

.drawer-backdrop { position: fixed; inset: 0; z-index: 45; display: none; background: rgba(12, 25, 40, .42); }
.drawer-backdrop.is-open { display: block; }
.detail-drawer { position: fixed; inset: 0 0 0 auto; z-index: 50; width: min(720px, 94vw); transform: translateX(102%); border-left: 1px solid var(--line); background: #fff; box-shadow: var(--shadow); transition: transform .22s ease; }
.detail-drawer.is-open { transform: translateX(0); }
.drawer-header { display: flex; align-items: start; justify-content: space-between; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.drawer-header h2 { margin: 2px 0 0; color: var(--navy); font-size: 20px; }
.eyebrow { color: var(--green-dark); font-size: 11px; font-weight: 800; letter-spacing: .08em; }
.drawer-content { height: calc(100vh - 78px); overflow: auto; padding: 20px 22px 40px; }
.drawer-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.detail-block { min-width: 0; padding: 13px; border: 1px solid var(--line); border-radius: 9px; }
.detail-block.full { grid-column: 1 / -1; }
.detail-block h3 { margin: 0 0 9px; color: var(--navy); font-size: 14px; }
.detail-warning { border-color: #edd69c; background: var(--amber-soft); }
.detail-list { display: grid; gap: 7px; margin: 0; }
.detail-list div { display: grid; grid-template-columns: 90px 1fr; gap: 8px; }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; overflow-wrap: anywhere; }
.mini-card { padding: 10px; border: 1px solid #e4e9ee; border-radius: 8px; }
.mini-card + .mini-card { margin-top: 8px; }
.mini-card header { display: flex; justify-content: space-between; gap: 8px; }
.mini-card p { margin: 5px 0 0; color: var(--muted); }

.modal { width: min(720px, 94vw); max-height: 90vh; padding: 0; border: 0; border-radius: 13px; box-shadow: 0 22px 70px rgba(15,39,65,.28); }
.modal::backdrop { background: rgba(12,25,40,.48); }
.modal-header { display: flex; align-items: start; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 2px 0 0; color: var(--navy); font-size: 19px; }
.modal-body { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; max-height: 65vh; overflow: auto; padding: 18px 20px; }
.form-field { display: grid; gap: 5px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { color: #465565; font-size: 12px; font-weight: 700; }
.form-field .help { color: var(--muted); font-size: 11px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; padding: 14px 20px; border-top: 1px solid var(--line); }

.toast-region { position: fixed; z-index: 80; right: 20px; bottom: 20px; display: grid; gap: 8px; }
.toast { max-width: 360px; padding: 11px 14px; color: #fff; border-radius: 9px; background: var(--navy); box-shadow: var(--shadow); }
.toast.is-error { background: #9f2828; }

/* Authentication and MFA */
.auth-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 30px;
  background:
    radial-gradient(circle at 14% 18%, rgba(69,128,180,.22), transparent 34%),
    linear-gradient(135deg, #102b4a 0%, #17365d 54%, #244c79 100%);
}
.auth-shell {
  display: grid;
  width: min(930px, 100%);
  grid-template-columns: minmax(0, 1fr) minmax(360px, .86fr);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 30px 90px rgba(4,18,34,.36);
}
.auth-brand {
  min-height: 570px;
  padding: 58px 50px;
  color: #fff;
  background:
    linear-gradient(rgba(17,50,84,.86), rgba(16,43,74,.97)),
    linear-gradient(145deg, #244c79, #102b4a);
}
.auth-brand-mark {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border-radius: 14px;
  color: var(--navy);
  background: #fff;
  font-size: 30px;
  font-weight: 900;
}
.auth-kicker { margin: 28px 0 5px; color: #bcd3e8; font-size: 12px; font-weight: 800; letter-spacing: .12em; }
.auth-brand h1 { margin: 0; font-size: clamp(28px, 4vw, 40px); line-height: 1.15; }
.auth-brand > p:not(.auth-kicker) { max-width: 430px; margin: 15px 0 0; color: #d8e7f4; }
.auth-assurance { display: grid; gap: 12px; margin: 48px 0 0; padding: 0; list-style: none; color: #d8e7f4; }
.auth-assurance li { position: relative; padding-left: 25px; }
.auth-assurance li::before { position: absolute; left: 0; top: 1px; content: "✓"; color: #8ee0b2; font-weight: 900; }
.auth-card { align-self: center; padding: 46px 42px; }
.auth-card h2 { margin: 5px 0 0; color: var(--navy); font-size: 25px; }
.auth-intro { margin: 8px 0 22px; color: var(--muted); }
.auth-form { display: grid; gap: 8px; }
.auth-form label { margin-top: 7px; color: #465565; font-size: 12px; font-weight: 700; }
.auth-form input { min-height: 45px; }
.auth-submit { width: 100%; min-height: 44px; margin-top: 13px; }
.auth-footnote, .auth-support { color: var(--muted); font-size: 11px; }
.auth-footnote { margin: 15px 0 0; }
.auth-support { margin: 28px 0 0; padding-top: 14px; border-top: 1px solid var(--line); }
.recovery-entry { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.recovery-entry summary { color: var(--navy-2); cursor: pointer; font-size: 12px; font-weight: 700; }
.recovery-entry[open] summary { margin-bottom: 8px; }
.form-error, .auth-messages p {
  margin: 0 0 14px;
  padding: 10px 12px;
  color: #8f2525;
  border: 1px solid #f0bcbc;
  border-radius: 8px;
  background: var(--red-soft);
  font-size: 12px;
}
.auth-messages .success { color: var(--green-dark); border-color: #bce1cc; background: var(--green-soft); }
.otp-input { text-align: center; font-family: Consolas, monospace; font-size: 22px; font-weight: 800; letter-spacing: .18em; }
.mfa-setup-grid { display: grid; grid-template-columns: 150px 1fr; align-items: center; gap: 18px; margin: 18px 0; }
.mfa-qr { display: block; width: 150px; height: 150px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.manual-secret-label { margin: 0 0 6px; color: var(--muted); font-size: 11px; }
.manual-secret { display: block; overflow-wrap: anywhere; padding: 9px; color: var(--navy); border-radius: 7px; background: var(--navy-3); font-size: 12px; }
.secret-warning { margin: 10px 0 0; color: #8b5b0f; font-size: 11px; }
.recovery-codes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 18px 0; }
.recovery-codes code { padding: 9px; text-align: center; border: 1px solid var(--line); border-radius: 7px; background: #f8fafc; font-size: 13px; }
.confirm-check { display: flex; align-items: flex-start; gap: 8px; margin-top: 18px; color: #465565; font-size: 12px; }
.confirm-check input { min-height: 0; margin-top: 3px; }

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .global-search input { width: 220px; }
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-102%); transition: transform .2s ease; }
  .sidebar.is-open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .menu-button { display: block; }
  .topbar { padding: 13px 18px; }
  .view { padding: 18px; }
  .connection-banner { margin-inline: 18px; }
  .global-search { display: none; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .panel-span-2 { grid-column: auto; }
  .task-row { grid-template-columns: 88px 1fr 90px; }
  .task-row > :nth-child(3), .task-row > :nth-child(4) { display: none; }
  .daily-flow { grid-template-columns: repeat(3, 1fr); }
  .sync-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .auth-page { padding: 18px; }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-brand { min-height: 0; padding: 32px; }
  .auth-brand h1 { font-size: 28px; }
  .auth-assurance { margin-top: 24px; }
  .auth-card { padding: 34px 32px; }
}

@media (max-width: 640px) {
  .topbar-actions .button { display: none; }
  .current-user-chip { min-width: 0; padding-inline: 8px; }
  .current-user-chip span { max-width: 92px; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .notice { display: block; }
  .notice-safe > span { display: block; margin-top: 8px; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .filters { display: grid; grid-template-columns: 1fr 1fr; }
  .filters input, .filters select, .wide-filter select { width: 100%; min-width: 0; }
  .data-grid, .detail-grid { grid-template-columns: 1fr; }
  .sync-card { grid-column: auto; }
  .sync-metrics { grid-template-columns: 1fr 1fr; }
  .sync-actions { align-items: stretch; flex-direction: column; }
  .sync-actions .button { width: 100%; }
  .detail-block.full { grid-column: auto; }
  .detail-drawer { width: 100vw; }
  .daily-flow { grid-template-columns: 1fr 1fr; }
  .modal {
    width: 100vw;
    max-width: none;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
  }
  .modal > form { display: flex; height: 100%; flex-direction: column; }
  .modal-body { min-height: 0; max-height: none; flex: 1 1 auto; }
  .modal-actions { padding-bottom: max(14px, env(safe-area-inset-bottom)); }
  .modal-body { grid-template-columns: 1fr; }
  .form-field.full { grid-column: auto; }
  .auth-page { display: block; padding: 0; background: #fff; }
  .auth-shell { min-height: 100vh; border: 0; border-radius: 0; box-shadow: none; }
  .auth-brand { padding: 27px 24px; }
  .auth-brand-mark { width: 42px; height: 42px; border-radius: 11px; font-size: 24px; }
  .auth-kicker { margin-top: 18px; }
  .auth-brand > p:not(.auth-kicker), .auth-assurance { display: none; }
  .auth-card { padding: 32px 24px; }
  .mfa-setup-grid { grid-template-columns: 1fr; }
  .mfa-qr { margin: 0 auto; }
  .recovery-codes { grid-template-columns: 1fr; }
}
