:root {
  --bg: #f3f6fa;
  --bg-strong: #e9eef5;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --surface-tint: #edf4ff;
  --line: #d9e2ee;
  --line-strong: #c8d3e1;
  --text: #172033;
  --muted: #657187;
  --soft: #8b97aa;
  --accent: #245fcf;
  --accent-strong: #1b4fb4;
  --accent-soft: #eaf1ff;
  --accent-warm: #c56f22;
  --accent2: #d44f67;
  --accent2-soft: #fff0f3;
  --ok: #12836d;
  --ok-soft: #e8f7f2;
  --warn: #b96506;
  --shadow: 0 18px 45px rgba(29, 45, 73, .08);
  --shadow-soft: 0 8px 22px rgba(29, 45, 73, .06);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    linear-gradient(180deg, rgba(255,255,255,.64), rgba(255,255,255,0) 240px),
    linear-gradient(135deg, #f5f8fc 0%, #edf3f8 54%, #f8f3ed 100%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Microsoft YaHei UI", "PingFang SC", "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }

.app-main { min-height: calc(100vh - 68px); }
.topbar {
  display: flex;
  align-items: center;
  gap: 22px;
  height: 68px;
  padding: 0 26px;
  background: rgba(255, 255, 255, .88);
  border-bottom: 1px solid rgba(217, 226, 238, .92);
  box-shadow: 0 1px 0 rgba(255,255,255,.7) inset, 0 12px 28px rgba(27,45,74,.05);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(16px);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
  min-width: 196px;
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #245fcf 0%, #12836d 100%);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  box-shadow: 0 9px 20px rgba(36, 95, 207, .22);
  flex: 0 0 auto;
}
.brand-copy { display: flex; flex-direction: column; gap: 1px; }
.brand-copy strong { font-size: 15px; line-height: 1.1; }
.brand-copy small { color: var(--muted); font-size: 12px; }
.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
}
.nav-links a {
  color: var(--muted);
  padding: 8px 13px;
  border-radius: 8px;
  font-weight: 650;
  transition: background .16s ease, color .16s ease;
}
.nav-links a:hover { background: var(--surface-soft); color: var(--text); }
.nav-links a.active { background: var(--accent-soft); color: var(--accent); }
.spacer { flex: 1; }
.user-area { display: inline-flex; align-items: center; gap: 10px; }
.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}
.user-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--ok);
  box-shadow: 0 0 0 4px var(--ok-soft);
}
.logout {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  padding: 7px 10px;
  border-radius: 8px;
}
.logout:hover { background: var(--surface-soft); color: var(--text); }

.wrap {
  width: min(1280px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 24px 0 56px;
}
.page-layout, .content-stack, .col {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.grid { display: grid; gap: 16px; }
.row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.panel {
  background: rgba(255, 255, 255, .94);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow-soft);
}

h1, h2, h3, p { margin-top: 0; }
h1 {
  margin-bottom: 8px;
  font-size: 28px;
  line-height: 1.18;
  letter-spacing: 0;
}
h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.25;
  color: var(--text);
  font-weight: 750;
}
.muted { color: var(--muted); }
.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
}
.page-desc {
  margin: 0;
  color: var(--muted);
  max-width: 640px;
}
.compact-head h1 { font-size: 24px; }
.panel-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}
.panel-title-row { align-items: center; }
.panel-title p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

input[type=text], input[type=password], textarea, select {
  min-height: 38px;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 8px 11px;
  font-size: 14px;
  outline: none;
  font-family: inherit;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
input[type=text]:hover, input[type=password]:hover, textarea:hover, select:hover {
  border-color: #b7c4d6;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(36, 95, 207, .12);
}
textarea {
  width: 100%;
  resize: vertical;
  min-height: 140px;
  font-family: ui-monospace, Consolas, "SFMono-Regular", monospace;
  font-size: 13px;
  line-height: 1.55;
}
select {
  min-width: 104px;
  cursor: pointer;
}
label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.field span { color: var(--muted); font-size: 12px; font-weight: 800; }
.field input, .field select { width: 100%; }
.input-wide { width: min(300px, 100%); }

button, .btn {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  border-radius: 7px;
  padding: 8px 15px;
  font-size: 14px;
  font-weight: 750;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
  transition: transform .14s ease, background .14s ease, border-color .14s ease, box-shadow .14s ease;
}
button:hover, .btn:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: #fff;
  box-shadow: 0 8px 18px rgba(36, 95, 207, .18);
}
button:active, .btn:active { transform: translateY(1px); }
button.ghost, .btn.ghost {
  background: #fff;
  color: var(--text);
  border-color: var(--line-strong);
}
button.ghost:hover, .btn.ghost:hover {
  background: var(--surface-soft);
  border-color: #b8c5d7;
  box-shadow: none;
}
button.danger {
  background: var(--accent2);
  border-color: var(--accent2);
}
button.danger:hover {
  background: #be4057;
  border-color: #be4057;
  box-shadow: 0 8px 18px rgba(212, 79, 103, .18);
}
button.ok {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
}
button.ok:hover {
  background: #0e715f;
  border-color: #0e715f;
  box-shadow: 0 8px 18px rgba(18, 131, 109, .16);
}
button.sm, .btn.sm {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 13px;
}
label.btn { cursor: pointer; }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.badge:empty { display: none; }
.badge.soft { background: var(--surface-soft); color: var(--muted); border: 1px solid var(--line); }
.hit {
  color: var(--warn);
  font-weight: 800;
}
.safe {
  color: var(--ok);
  font-weight: 800;
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(310px, .65fr);
  gap: 22px;
  align-items: stretch;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255,255,255,.98) 0%, rgba(239,246,255,.96) 58%, rgba(255,247,238,.94) 100%);
  box-shadow: var(--shadow);
}
.hero-copy { align-self: center; }
.hero-copy h1 { font-size: 32px; margin-bottom: 10px; }
.hero-desc {
  max-width: 620px;
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 15px;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.hero-stats {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-content: center;
}
.stat-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid rgba(200, 211, 225, .8);
  border-radius: 8px;
  background: rgba(255,255,255,.7);
}
.stat-value {
  color: var(--text);
  font-size: 26px;
  font-weight: 850;
  line-height: 1;
}
.stat-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.tool-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.tool-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 14px;
  align-items: start;
  min-height: 190px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.95);
  color: var(--text);
  box-shadow: var(--shadow-soft);
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.tool-card:hover {
  transform: translateY(-2px);
  border-color: #b7c4d6;
  box-shadow: var(--shadow);
}
.card-icon {
  grid-row: span 4;
  width: 46px;
  height: 46px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 850;
  font-size: 18px;
}
.card-icon.accent {
  background: var(--ok-soft);
  color: var(--ok);
}
.card-kicker {
  color: var(--soft);
  font-size: 12px;
  font-weight: 800;
}
.card-title {
  color: var(--text);
  font-size: 19px;
  font-weight: 820;
}
.card-desc {
  color: var(--muted);
  max-width: 540px;
}
.card-link {
  color: var(--accent);
  font-weight: 800;
  align-self: end;
}
.notice-panel {
  margin-top: 16px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.72);
}
.notice-panel p { margin: 0; }

.unified-workbench {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.workspace-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-margin-top: 88px;
}
.workspace-section + .workspace-section {
  margin-top: 16px;
  padding-top: 18px;
  border-top: 1px solid rgba(217, 226, 238, .9);
}

.query-bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}
.query-main {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}
.query-result {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  color: var(--muted);
}
.workspace-grid {
  display: grid;
  gap: 16px;
  align-items: start;
}
.customers-grid {
  --customer-workspace-height: clamp(560px, calc(100vh - 330px), 680px);
  grid-template-columns: minmax(360px, 420px) minmax(0, 1fr);
  align-items: stretch;
}
.side-panel, .records-panel, .input-panel, .search-panel, .result-panel, .file-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.customer-list-panel {
  height: var(--customer-workspace-height);
  min-width: 0;
  min-height: 0;
}
.customers-grid > .content-stack {
  display: grid;
  grid-template-rows: minmax(220px, .46fr) minmax(280px, .54fr);
  gap: 16px;
  height: var(--customer-workspace-height);
  min-height: 0;
}
.records-panel, .input-panel {
  min-height: 0;
  overflow: hidden;
}
.customer-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
  margin-bottom: 10px;
}
.inline-form {
  display: grid;
  grid-template-columns: minmax(80px, .8fr) minmax(120px, 1fr) auto;
  gap: 8px;
  margin-bottom: 12px;
}
.action-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.action-row.compact { margin-top: 0; }
.filter-grid {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(150px, 1.1fr) minmax(130px, 1fr) minmax(110px, .8fr) auto;
  gap: 10px;
  align-items: end;
  margin-top: 14px;
}
.brand-row {
  display: grid;
  grid-template-columns: minmax(180px, 260px) auto minmax(220px, 1fr);
  align-items: end;
  gap: 10px;
  margin-top: 12px;
}
.helper-text { display: block; margin: 12px 0; }

pre.output {
  min-height: 280px;
  background: #111827;
  color: #e5edf8;
  border: 1px solid #223047;
  border-radius: 8px;
  padding: 14px;
  overflow: auto;
  max-height: 60vh;
  white-space: pre;
  font-family: ui-monospace, Consolas, "SFMono-Regular", monospace;
  font-size: 12.5px;
  line-height: 1.55;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
th, td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  vertical-align: middle;
}
th {
  color: var(--muted);
  font-weight: 800;
  position: sticky;
  top: 0;
  background: var(--surface-soft);
  z-index: 1;
}
tbody tr:last-child td { border-bottom: none; }
tr.clickable:hover { background: #f4f7fb; cursor: pointer; }
tr.sel { background: var(--accent-soft); }
td:last-child {
  white-space: nowrap;
  text-align: right;
}
.empty-row td,
.empty-row td:last-child {
  height: 84px;
  text-align: center;
  color: var(--soft);
  background: #fff;
}
.empty-row span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 82px;
  min-height: 28px;
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.tbl-scroll {
  max-height: 56vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.table-tall { max-height: 62vh; }
.table-mid { max-height: 42vh; }
.customer-list-scroll {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
  max-height: none;
  overflow-y: scroll;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #9fb0c7 #eef3f8;
}
.customer-list-scroll::-webkit-scrollbar { width: 10px; }
.customer-list-scroll::-webkit-scrollbar-track { background: #eef3f8; border-radius: 999px; }
.customer-list-scroll::-webkit-scrollbar-thumb {
  background: #9fb0c7;
  border: 2px solid #eef3f8;
  border-radius: 999px;
}
.customer-list-scroll::-webkit-scrollbar-thumb:hover { background: #7f90a8; }
.records-panel .table-mid {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
}
.records-panel .table-mid {
  border-bottom-right-radius: 0;
  border-bottom-left-radius: 0;
}
.records-actions {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: stretch;
  gap: 8px;
  margin-top: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  background: #fff;
}
.records-actions button {
  width: 100%;
  justify-content: center;
}
.input-panel .panel-title { flex: 0 0 auto; }
#add_text {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
  max-height: none;
  resize: none;
  overflow: auto;
  overscroll-behavior: contain;
}
.input-panel .action-row { flex: 0 0 auto; }

.tabs {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: fit-content;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.76);
}
.tabs button {
  min-height: 34px;
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  box-shadow: none;
}
.tabs button:hover {
  background: var(--surface-soft);
  border-color: transparent;
  color: var(--text);
  box-shadow: none;
}
.tabs button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  background: #172033;
  color: #fff;
  border: 1px solid rgba(255,255,255,.12);
  padding: 11px 18px;
  border-radius: 8px;
  z-index: 200;
  opacity: 0;
  transition: opacity .2s ease, bottom .2s ease;
  pointer-events: none;
  max-width: 80vw;
  box-shadow: var(--shadow);
}
.toast.show { opacity: 1; bottom: 36px; }
.toast.ok { border-color: rgba(18, 131, 109, .8); }
.toast.err { border-color: rgba(212, 79, 103, .85); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 180;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: rgba(15, 23, 42, .42);
  backdrop-filter: blur(10px);
}
.modal-backdrop[hidden] { display: none; }
.data-modal {
  width: min(920px, calc(100vw - 40px));
  max-height: min(760px, calc(100vh - 44px));
  overflow: hidden;
  border: 1px solid #20304a;
  border-radius: 8px;
  background: #f8fafc;
  box-shadow: 0 30px 80px rgba(15, 23, 42, .28);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  color: #fff;
  background: linear-gradient(135deg, #111827, #1f3b66);
}
.modal-head .eyebrow {
  margin-bottom: 6px;
  color: #86efac;
}
.modal-head h2 {
  color: #fff;
  font-size: 20px;
}
.icon-btn {
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 8px;
  border-color: rgba(255,255,255,.18);
  background: rgba(255,255,255,.1);
  color: #fff;
  font-size: 22px;
  line-height: 1;
}
.icon-btn:hover {
  background: rgba(255,255,255,.18);
  border-color: rgba(255,255,255,.28);
  box-shadow: none;
}
.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 16px 18px 0;
}
.metric-card {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.metric-card strong {
  display: block;
  margin-top: 6px;
  color: var(--text);
  font-size: 28px;
  line-height: 1;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 16px 18px 18px;
}
.stats-block {
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}
.stats-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #f4f7fb;
}
.stats-block-head h3 {
  margin: 0;
  font-size: 14px;
}
.stats-block-head span {
  color: var(--soft);
  font-size: 11px;
  font-weight: 800;
}
.data-table-wrap {
  max-height: 340px;
  overflow: auto;
}
.data-table th, .data-table td {
  padding: 9px 12px;
}
.data-table .num {
  width: 86px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}
.ratio-cell {
  position: relative;
  height: 22px;
  min-width: 120px;
  overflow: hidden;
  border-radius: 999px;
  background: #eef3f8;
}
.ratio-cell span {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #245fcf, #12836d);
}
.ratio-cell b {
  position: relative;
  z-index: 1;
  display: block;
  padding: 2px 8px;
  color: #172033;
  font-size: 12px;
  line-height: 18px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

body.page-login {
  background:
    linear-gradient(135deg, #eef4fb 0%, #f8fafc 50%, #f6efe8 100%);
}
body.page-login .app-main { min-height: 100vh; }
.login-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 520px) 380px;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 32px;
}
.login-aside {
  min-height: 420px;
  border-radius: 8px;
  padding: 30px;
  background:
    linear-gradient(145deg, rgba(23, 32, 51, .96) 0%, rgba(36, 95, 207, .86) 56%, rgba(18, 131, 109, .86) 100%);
  box-shadow: var(--shadow);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}
.login-mark {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255,255,255,.25);
  background: rgba(255,255,255,.12);
  font-weight: 850;
  font-size: 20px;
}
.login-lines {
  display: grid;
  gap: 12px;
  max-width: 360px;
}
.login-lines span {
  display: block;
  height: 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.2);
}
.login-lines span:nth-child(1) { width: 92%; }
.login-lines span:nth-child(2) { width: 70%; }
.login-lines span:nth-child(3) { width: 82%; }
.login-box {
  width: 100%;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.96);
  box-shadow: var(--shadow);
}
.login-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}
.login-heading h1 {
  margin: 0 0 2px;
  font-size: 22px;
}
.login-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.login-tip {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--accent-soft);
}
.login-box input {
  width: 100%;
  margin-bottom: 12px;
}
.login-box button { width: 100%; }
.err {
  margin-bottom: 12px;
  padding: 9px 11px;
  color: #ad3348;
  background: var(--accent2-soft);
  border: 1px solid #ffd0d8;
  border-radius: 8px;
  font-size: 13px;
}

.cost-country {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  background: var(--surface);
}
.cost-country h3 {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--accent);
}
.cost-tbl td, .cost-tbl th { padding: 4px 8px; }

@media (max-width: 980px) {
  .topbar {
    height: auto;
    min-height: 68px;
    align-items: flex-start;
    flex-wrap: wrap;
    padding: 12px 18px;
    gap: 12px;
  }
  .brand { min-width: 0; }
  .nav-links { order: 3; width: 100%; overflow-x: auto; padding-bottom: 2px; }
  .user-area { margin-left: auto; }
  .app-main { min-height: calc(100vh - 112px); }
  .hero-panel, .customers-grid, .tool-grid {
    grid-template-columns: 1fr;
  }
  .customer-list-panel, .customers-grid > .content-stack {
    height: auto;
  }
  .customers-grid > .content-stack {
    display: flex;
    flex-direction: column;
  }
  .filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .filter-grid button { justify-self: start; }
  .brand-row { grid-template-columns: 1fr auto; }
  .brand-row .muted { grid-column: 1 / -1; }
  .login-wrap {
    grid-template-columns: minmax(280px, 420px);
  }
  .login-aside { display: none; }
}

@media (max-width: 640px) {
  .wrap {
    width: min(100vw - 24px, 1280px);
    padding: 16px 0 36px;
  }
  .page-head, .query-bar, .panel-title-row {
    align-items: stretch;
    flex-direction: column;
  }
  h1 { font-size: 24px; }
  .hero-panel { padding: 20px; }
  .hero-copy h1 { font-size: 26px; }
  .query-main, .action-row, .row {
    align-items: stretch;
  }
  .query-main > *, .action-row > button, .action-row > .btn {
    width: 100%;
  }
  .filter-grid, .inline-form, .brand-row {
    grid-template-columns: 1fr;
  }
  .customer-search {
    grid-template-columns: 1fr;
  }
  .records-actions {
    grid-template-columns: 1fr;
  }
  .customer-list-scroll {
    height: 320px;
    flex: 0 0 auto;
  }
  #add_text {
    height: 180px;
    flex: 0 0 auto;
  }
  .tabs { width: 100%; }
  .tabs button { flex: 1; }
  .metric-grid, .stats-grid {
    grid-template-columns: 1fr;
  }
  .user-pill { max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
  .login-wrap { padding: 18px; }
  .login-box { padding: 22px; }
}
