:root {
  --ink: #17201e;
  --muted: #68716c;
  --paper: #f3f2ed;
  --surface: #fffefa;
  --surface-2: #eeeee8;
  --line: #dcded7;
  --line-strong: #c8ccc3;
  --forest: #173d36;
  --green: #246b5c;
  --green-soft: #e1eee9;
  --orange: #c85f32;
  --orange-soft: #f7e7de;
  --blue: #315e78;
  --blue-soft: #e3edf2;
  --red: #a54035;
  --red-soft: #f7e5e2;
  --yellow-soft: #f7efcf;
  --shadow: 0 16px 48px rgba(23, 32, 30, 0.12);
  --radius: 6px;
  --sidebar: 232px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: 26px; line-height: 1.2; letter-spacing: 0; }
h2 { margin-bottom: 4px; font-size: 19px; letter-spacing: 0; }
h3 { margin-bottom: 4px; font-size: 15px; letter-spacing: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.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;
}

.boot-screen, .auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(23, 61, 54, 0.08), transparent 48%),
    var(--paper);
}
.boot-screen { align-content: center; gap: 20px; }
.brand-mark {
  display: inline-grid; place-items: center; width: 58px; height: 58px;
  border-radius: 4px; background: var(--forest); color: white;
  font: 700 18px/1 "Segoe UI", sans-serif; letter-spacing: 0.08em;
}
.loading-line {
  width: 120px; height: 2px; overflow: hidden; background: var(--line);
}
.loading-line::after {
  content: ""; display: block; width: 45%; height: 100%; background: var(--green);
  animation: loading 1s ease-in-out infinite alternate;
}
@keyframes loading { from { transform: translateX(-20%); } to { transform: translateX(145%); } }

.auth-card {
  width: min(920px, 100%);
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(340px, 1.1fr);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.auth-aside {
  min-height: 520px;
  padding: 42px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--forest);
  color: #f4f5f0;
  position: relative;
  overflow: hidden;
}
.auth-aside::after {
  content: ""; position: absolute; right: -90px; bottom: -110px;
  width: 310px; height: 310px; border: 1px solid rgba(255,255,255,.15);
  transform: rotate(24deg);
}
.auth-aside .brand-mark { background: #f0eee6; color: var(--forest); }
.auth-aside h1 { max-width: 330px; font-size: 34px; margin-top: 60px; }
.auth-aside p { max-width: 300px; color: #cbd9d4; }
.auth-form { padding: 52px 48px; align-self: center; }
.auth-form h2 { font-size: 25px; margin-bottom: 8px; }
.auth-form > p { margin-bottom: 30px; color: var(--muted); }
.auth-form .stack { gap: 18px; }
.auth-form .btn { width: 100%; margin-top: 6px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar) 1fr; }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 24px 16px;
  display: flex; flex-direction: column; background: var(--forest); color: white;
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 0 10px 28px; }
.sidebar-brand .brand-mark { width: 40px; height: 40px; background: #f3f0e7; color: var(--forest); font-size: 14px; }
.sidebar-brand strong { display: block; font-size: 14px; }
.sidebar-brand span { display: block; color: #aac0b9; font-size: 11px; }
.nav { display: grid; gap: 4px; }
.nav-btn {
  width: 100%; min-height: 42px; padding: 0 12px; border: 0; border-radius: 4px;
  background: transparent; color: #c7d4cf; text-align: left;
  display: flex; align-items: center; gap: 11px;
}
.nav-btn:hover { background: rgba(255,255,255,.08); color: white; }
.nav-btn.active { background: #f2efe6; color: var(--forest); font-weight: 700; }
.nav-glyph {
  display: inline-grid; place-items: center; width: 22px; height: 22px;
  border: 1px solid currentColor; border-radius: 3px; font-size: 10px; font-weight: 700;
}
.sidebar-foot { margin-top: auto; padding: 18px 10px 2px; border-top: 1px solid rgba(255,255,255,.12); }
.user-line { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
  flex: 0 0 32px; width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; background: var(--orange-soft); color: var(--orange);
  font-weight: 700;
}
.user-line strong { display: block; font-size: 13px; }
.user-line span { display: block; color: #aac0b9; font-size: 11px; }
.logout-btn { margin-top: 14px; padding: 0; border: 0; background: none; color: #b9cbc5; font-size: 12px; }
.logout-btn:hover { color: white; }

.main-area { min-width: 0; }
.topbar {
  min-height: 66px; padding: 0 34px; display: flex; align-items: center;
  justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line);
  background: rgba(243, 242, 237, .92); position: sticky; top: 0; z-index: 10;
  backdrop-filter: blur(10px);
}
.topbar-title { font-size: 13px; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.mobile-brand { display: none; }
.content { width: min(1440px, 100%); margin: 0 auto; padding: 30px 34px 60px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-head p { margin-bottom: 0; color: var(--muted); }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.section { margin-top: 24px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.section-head h2, .section-head h3 { margin: 0; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.metric {
  min-height: 126px; padding: 18px; display: flex; flex-direction: column;
  justify-content: space-between; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius);
}
.metric-label { color: var(--muted); font-size: 12px; }
.metric-value { font-size: 30px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.metric-note { color: var(--muted); font-size: 11px; }
.metric.accent { border-top: 3px solid var(--orange); }
.metric.primary { background: var(--forest); color: white; border-color: var(--forest); }
.metric.primary .metric-label, .metric.primary .metric-note { color: #b8cac4; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr); gap: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel-head { padding: 16px 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.panel-head h2, .panel-head h3 { margin: 0; }
.panel-body { padding: 18px; }
.panel-body.flush { padding: 0; }

.list { display: grid; }
.list-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 58px; padding: 12px 18px; border-bottom: 1px solid var(--line);
}
.list-row:last-child { border-bottom: 0; }
.list-main { min-width: 0; }
.list-main strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-meta { color: var(--muted); font-size: 12px; }
.empty { padding: 38px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; margin-bottom: 4px; color: var(--ink); }

.btn {
  min-height: 38px; padding: 0 14px; display: inline-flex; align-items: center;
  justify-content: center; gap: 7px; border: 1px solid var(--line-strong);
  border-radius: 4px; background: var(--surface); color: var(--ink); font-weight: 600;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: #9ca69f; background: #f8f8f3; }
.btn.primary { background: var(--green); border-color: var(--green); color: white; }
.btn.primary:hover { background: var(--forest); border-color: var(--forest); }
.btn.danger { border-color: #e0beb9; color: var(--red); background: var(--surface); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { min-height: 30px; padding: 0 10px; font-size: 12px; }
.btn.icon { width: 34px; padding: 0; font-size: 18px; }
.btn:disabled { cursor: not-allowed; opacity: .55; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

.field { display: grid; gap: 6px; min-width: 0; }
.field > label { color: #3f4944; font-size: 12px; font-weight: 600; }
.input, .select, .textarea {
  width: 100%; min-height: 40px; border: 1px solid var(--line-strong); border-radius: 4px;
  background: white; padding: 9px 11px; outline: none;
}
.textarea { min-height: 96px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(36,107,92,.12); }
.stack { display: grid; gap: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.form-grid .span-2 { grid-column: span 2; }
.searchbar { display: flex; gap: 8px; width: min(460px, 100%); }
.searchbar .input { flex: 1; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.segmented { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface-2); }
.segmented button { min-height: 30px; padding: 0 11px; border: 0; border-radius: 3px; background: transparent; color: var(--muted); font-size: 12px; }
.segmented button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); font-weight: 700; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; background: var(--surface); }
.table th {
  padding: 10px 14px; color: var(--muted); text-align: left; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #faf9f4; }
.table .primary-cell { font-weight: 700; }
.table .sub-cell { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.table .actions { text-align: right; white-space: nowrap; }
.status { display: inline-flex; align-items: center; gap: 5px; min-height: 24px; padding: 0 8px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--surface-2); }
.status::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.status.new { color: var(--blue); background: var(--blue-soft); }
.status.contacting { color: var(--orange); background: var(--orange-soft); }
.status.qualified { color: #806717; background: var(--yellow-soft); }
.status.won { color: var(--green); background: var(--green-soft); }
.status.lost { color: var(--red); background: var(--red-soft); }
.status.neutral { color: var(--muted); background: var(--surface-2); }

.lookup-hero { max-width: 860px; margin: 0 auto 30px; padding: 30px; display: grid; grid-template-columns: 0.8fr 1.2fr; gap: 32px; align-items: center; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.lookup-hero h1 { font-size: 28px; }
.lookup-hero p { margin: 0; color: var(--muted); }
.lookup-form { display: grid; gap: 10px; }
.lookup-form-row { display: flex; gap: 8px; }
.lookup-form .input { min-height: 46px; font-size: 15px; }
.lookup-empty { max-width: 860px; margin: 0 auto; padding: 42px 24px; text-align: center; border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--muted); }
.lookup-results { max-width: 980px; margin: 0 auto; display: grid; gap: 10px; }
.lookup-card { padding: 18px; display: grid; grid-template-columns: 1fr auto; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.lookup-card h3 { margin-bottom: 5px; }
.lookup-card .facts { display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: 12px; }
.lookup-owner { min-width: 160px; padding-left: 18px; border-left: 1px solid var(--line); }
.lookup-owner strong { display: block; margin-bottom: 7px; }
.ownership-warning { padding: 10px 12px; border-left: 3px solid var(--orange); background: var(--orange-soft); color: #75412e; font-size: 12px; }

.admin-tabs { display: flex; gap: 3px; padding: 4px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface-2); width: fit-content; margin-bottom: 18px; }
.admin-tabs button { min-height: 34px; padding: 0 14px; border: 0; border-radius: 3px; background: transparent; color: var(--muted); }
.admin-tabs button.active { background: var(--surface); color: var(--ink); font-weight: 700; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.import-box { padding: 26px; border: 1px dashed var(--line-strong); border-radius: var(--radius); background: #faf9f4; }
.import-box input[type=file] { width: 100%; padding: 12px; border: 1px solid var(--line); background: white; border-radius: 4px; }
.import-result { margin-top: 14px; padding: 14px; background: var(--green-soft); border-left: 3px solid var(--green); color: #204c42; }
.user-card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.user-card { padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.user-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.user-card-head .avatar { width: 38px; height: 38px; flex-basis: 38px; }
.user-card-actions { display: flex; gap: 7px; flex-wrap: wrap; padding-top: 12px; border-top: 1px solid var(--line); }

.drawer-layer { position: fixed; inset: 0; z-index: 50; display: flex; justify-content: flex-end; background: rgba(16,24,22,.35); }
.drawer {
  width: min(580px, 100%); height: 100%; display: flex; flex-direction: column;
  background: var(--paper); box-shadow: var(--shadow); animation: slideIn .2s ease-out;
}
@keyframes slideIn { from { transform: translateX(24px); opacity: .5; } to { transform: translateX(0); opacity: 1; } }
.drawer-head { min-height: 78px; padding: 18px 22px; display: flex; align-items: center; justify-content: space-between; gap: 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin-bottom: 2px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px 22px 50px; }
.drawer-foot { padding: 13px 22px; display: flex; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--line); background: var(--surface); }
.detail-header { margin-bottom: 16px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.detail-top { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 18px; }
.detail-item span { display: block; color: var(--muted); font-size: 11px; }
.detail-item strong { display: block; overflow-wrap: anywhere; font-size: 13px; }
.tabs { display: flex; gap: 20px; border-bottom: 1px solid var(--line); margin: 18px 0 14px; }
.tabs button { min-height: 38px; padding: 0; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font-weight: 600; }
.tabs button.active { color: var(--ink); border-bottom-color: var(--green); }
.timeline { display: grid; gap: 10px; }
.timeline-item { padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.timeline-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 7px; }
.timeline-head strong { font-size: 13px; }
.timeline-notes { white-space: pre-wrap; overflow-wrap: anywhere; }
.timeline-meta { margin-top: 8px; color: var(--muted); font-size: 11px; }
.inline-form { margin-bottom: 16px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.deal-row { padding: 13px 0; border-bottom: 1px solid var(--line); }
.deal-row:last-child { border-bottom: 0; }
.deal-row-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.deal-amount { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.commission-preview { min-height: 45px; padding: 10px 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--green-soft); border-radius: 4px; }
.commission-preview strong { color: var(--forest); }

.modal-layer { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 18px; background: rgba(16,24,22,.42); }
.modal { width: min(560px, 100%); max-height: min(90vh, 760px); overflow-y: auto; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); }
.modal.wide { width: min(760px, 100%); }
.modal-head { padding: 18px 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--line); }
.toast-region { position: fixed; top: 18px; right: 18px; z-index: 100; display: grid; gap: 8px; width: min(360px, calc(100vw - 36px)); }
.toast { padding: 12px 14px; border-left: 3px solid var(--green); background: var(--forest); color: white; box-shadow: var(--shadow); border-radius: 3px; animation: toastIn .18s ease-out; }
.toast.error { border-left-color: #ff9d7e; background: #6f2e27; }
@keyframes toastIn { from { transform: translateY(-5px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.skeleton { min-height: 14px; border-radius: 3px; background: linear-gradient(90deg, var(--surface-2), #f8f7f2, var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.notice { padding: 12px 14px; border: 1px solid var(--line); border-left: 3px solid var(--blue); background: var(--blue-soft); color: #294f64; font-size: 12px; }
.filters-panel { background: var(--surface); }
.filter-row { display: grid; grid-template-columns: repeat(4, minmax(140px, 1fr)) auto; gap: 12px; align-items: end; }
.filter-row .btn { min-height: 40px; }
.insight-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.insight-grid .panel { min-width: 0; }
.link-button { padding: 0; border: 0; background: none; color: var(--green); font-weight: 700; text-align: left; }
.link-button:hover { text-decoration: underline; }
.grade { display: inline-flex; min-height: 24px; padding: 0 8px; align-items: center; border-radius: 999px; background: var(--surface-2); font-size: 11px; font-weight: 700; white-space: nowrap; }
.grade-A { color: #1d5d50; background: var(--green-soft); }
.grade-B { color: #315e78; background: var(--blue-soft); }
.grade-C { color: #806717; background: var(--yellow-soft); }
.grade-D { color: var(--red); background: var(--red-soft); }
.grade-none { color: var(--muted); }
.choice-group { display: flex; flex-wrap: wrap; gap: 6px; }
.choice-option { position: relative; cursor: pointer; }
.choice-option input { position: absolute; opacity: 0; pointer-events: none; }
.choice-option span { display: inline-flex; min-height: 34px; padding: 6px 10px; align-items: center; border: 1px solid var(--line-strong); border-radius: 4px; background: white; color: var(--muted); font-size: 12px; }
.choice-option input:checked + span { border-color: var(--green); background: var(--green-soft); color: var(--forest); font-weight: 700; box-shadow: 0 0 0 2px rgba(36,107,92,.08); }
.choice-option input:focus-visible + span { outline: 2px solid var(--green); outline-offset: 2px; }
.product-choices { display: flex; flex-wrap: wrap; gap: 6px; }
.product-chip { cursor: pointer; }
.product-chip input { position: absolute; opacity: 0; pointer-events: none; }
.product-chip span { display: inline-flex; min-height: 32px; padding: 6px 10px; align-items: center; gap: 5px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: 12px; }
.product-chip input:checked + span { color: white; background: var(--green); border-color: var(--green); }
.form-hint { color: var(--muted); font-size: 11px; }
.structured-summary { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.mini-tag { display: inline-flex; min-height: 22px; padding: 0 7px; align-items: center; border: 1px solid var(--line); border-radius: 3px; background: var(--surface-2); color: #48514d; font-size: 11px; }
.signal-good { border-left: 3px solid var(--green); }
.signal-warn { border-left: 3px solid var(--red); }
.signal-neutral { border-left: 3px solid var(--blue); }

@media (max-width: 1100px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
  .user-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-row .btn { grid-column: span 2; }
}
@media (max-width: 800px) {
  body { padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
  .app-shell { display: block; }
  .sidebar { position: fixed; inset: auto 0 0; z-index: 30; width: 100%; height: calc(62px + env(safe-area-inset-bottom)); padding: 5px 8px env(safe-area-inset-bottom); display: block; border-top: 1px solid rgba(255,255,255,.16); }
  .sidebar-brand, .sidebar-foot { display: none; }
  .nav { height: 57px; display: flex; justify-content: space-around; gap: 0; }
  .nav-btn { width: auto; min-width: 54px; min-height: 52px; padding: 4px 8px; flex-direction: column; justify-content: center; gap: 2px; font-size: 10px; text-align: center; }
  .nav-glyph { width: 19px; height: 19px; font-size: 9px; }
  .nav-btn.active { background: rgba(255,255,255,.12); color: white; }
  .topbar { min-height: 58px; padding: 0 16px; }
  .mobile-brand { display: flex; align-items: center; gap: 9px; font-weight: 700; }
  .mobile-brand .brand-mark { width: 30px; height: 30px; font-size: 10px; }
  .topbar-title { display: none; }
  .content { padding: 22px 16px 36px; }
  .page-head { margin-bottom: 18px; }
  .page-head h1 { font-size: 23px; }
  .page-actions { width: 100%; }
  .page-actions .btn.primary { flex: 1; }
  .lookup-hero { grid-template-columns: 1fr; gap: 20px; padding: 20px; margin-bottom: 18px; }
  .lookup-card { grid-template-columns: 1fr; }
  .lookup-owner { padding: 12px 0 0; border-left: 0; border-top: 1px solid var(--line); }
  .drawer-layer { align-items: flex-end; }
  .drawer { height: calc(100% - 24px); width: 100%; border-radius: 8px 8px 0 0; }
  .drawer-head { padding: 14px 16px; }
  .drawer-body { padding: 15px 16px 40px; }
  .drawer-foot { padding: 10px 16px; }
  .drawer-foot .btn { flex: 1; }
  .metric { min-height: 112px; padding: 14px; }
  .metric-value { font-size: 24px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .auth-card { grid-template-columns: 1fr; }
  .auth-aside { min-height: 220px; padding: 26px; }
  .auth-aside h1 { margin-top: 30px; font-size: 27px; }
  .auth-aside p { margin-bottom: 0; }
  .auth-form { padding: 30px 24px; }
  .user-card-grid { grid-template-columns: 1fr; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .table td { padding: 4px 0; border: 0; display: flex; align-items: center; justify-content: space-between; gap: 14px; text-align: right; }
  .table td::before { content: attr(data-label); color: var(--muted); font-size: 11px; text-align: left; }
  .table td:first-child { font-size: 15px; }
  .table td.actions { padding-top: 8px; text-align: right; }
  .table td.actions::before { content: ""; }
  .table .sub-cell { text-align: right; }
  .insight-grid { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .metrics { gap: 8px; }
  .metric { min-height: 104px; }
  .metric-value { font-size: 21px; }
  .topbar-actions .btn span { display: none; }
  .topbar-actions .btn { width: 36px; padding: 0; }
  .lookup-form-row { flex-direction: column; }
  .lookup-form .btn { width: 100%; }
  .toolbar .searchbar { width: 100%; }
  .segmented { width: 100%; overflow-x: auto; }
  .segmented button { flex: 1; white-space: nowrap; }
  .detail-grid { grid-template-columns: 1fr; }
  .modal-layer { padding: 0; align-items: flex-end; }
  .modal { max-height: 94vh; border-radius: 8px 8px 0 0; }
  .filter-row { grid-template-columns: 1fr; }
  .filter-row .btn { grid-column: auto; }
}
