:root {
  --bg: #f4f6f3;
  --surface: #ffffff;
  --surface-muted: #f8faf8;
  --text: #17231c;
  --text-soft: #46574d;
  --muted: #75837b;
  --line: #dde5df;
  --line-strong: #c9d5cd;
  --brand: #1f6b47;
  --brand-dark: #163d2b;
  --brand-hover: #18583b;
  --brand-soft: #e8f3ec;
  --amber: #8a5b16;
  --amber-soft: #fff5df;
  --red: #9d3535;
  --red-soft: #fdeaea;
  --blue: #315f8f;
  --blue-soft: #eaf2fa;
  --shadow-sm: 0 1px 2px rgba(22, 61, 43, 0.04);
  --shadow-md: 0 8px 28px rgba(22, 61, 43, 0.08);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --sidebar-width: 232px;
  --topbar-height: 64px;
  --mobile-nav-height: 66px;
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-hover); }
button, a { -webkit-tap-highlight-color: transparent; }

.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;
}
.skip-link {
  position: fixed;
  left: 12px;
  top: -60px;
  z-index: 100;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}
.skip-link:focus { top: 12px; }

.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(--brand-dark);
  color: #fff;
}
.sidebar__brand {
  display: flex;
  min-height: var(--topbar-height);
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.sidebar__brand a { display: flex; align-items: center; gap: 11px; color: #fff; }
.sidebar__brand strong { display: block; font-size: 17px; letter-spacing: 0.02em; }
.sidebar__brand small {
  display: block;
  max-width: 140px;
  margin-top: 1px;
  overflow: hidden;
  color: #b9ccbf;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  font-weight: 750;
}
.sidebar__nav { flex: 1; overflow-y: auto; padding: 18px 12px; }
.nav-section-label {
  margin: 0 10px 8px;
  color: #8eaa99;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
}
.nav-section-label--tools { margin-top: 24px; }
.nav-item {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
  padding: 0 12px;
  border-radius: 10px;
  color: #dbe8df;
  font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.nav-item.active { background: #fff; color: var(--brand-dark); box-shadow: var(--shadow-sm); }
.nav-item--secondary { color: #b9ccbf; font-size: 14px; }
.nav-icon {
  position: relative;
  display: inline-block;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}
.nav-icon::before {
  position: absolute;
  inset: 2px;
  border: 1.7px solid currentColor;
  border-radius: 4px;
  content: "";
}
.nav-icon--home::after {
  position: absolute;
  left: 5px;
  top: 5px;
  width: 8px;
  height: 8px;
  border-left: 1.7px solid currentColor;
  border-top: 1.7px solid currentColor;
  content: "";
  transform: rotate(45deg);
}
.nav-icon--visit::after, .nav-icon--customer::after {
  position: absolute;
  left: 6px;
  top: 4px;
  width: 6px;
  height: 6px;
  border: 1.7px solid currentColor;
  border-radius: 50%;
  content: "";
}
.nav-icon--order::after {
  position: absolute;
  left: 5px;
  top: 6px;
  width: 8px;
  border-top: 1.7px solid currentColor;
  border-bottom: 1.7px solid currentColor;
  content: "";
  height: 4px;
}
.nav-icon--service::after, .nav-icon--followup::after {
  position: absolute;
  left: 5px;
  top: 8px;
  width: 8px;
  border-top: 1.7px solid currentColor;
  content: "";
}
.nav-icon--tool::before { border-radius: 50%; }
.sidebar__footer {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 76px;
  padding: 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.account-avatar {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  place-items: center;
  border-radius: 50%;
  background: #d9eadf;
  color: var(--brand-dark);
  font-weight: 750;
}
.account-copy { min-width: 0; flex: 1; }
.account-copy strong, .account-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-copy strong { font-size: 14px; }
.account-copy small { color: #9fb6a7; font-size: 12px; }
.icon-button {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 8px;
  color: #c5d6ca;
}
.icon-button:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }

.app-workspace { min-height: 100vh; margin-left: var(--sidebar-width); }
.app-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  height: var(--topbar-height);
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
}
.menu-button {
  display: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.topbar-context strong, .topbar-context span { display: block; }
.topbar-context strong { font-size: 15px; }
.topbar-context span { color: var(--muted); font-size: 12px; }
.topbar-account { display: flex; align-items: center; gap: 9px; color: var(--text); }
.topbar-account__button {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
}
.global-search { position: relative; width: min(420px, 42vw); margin-left: auto; }
.global-search input { width: 100%; min-height: 38px; padding-left: 14px; background: var(--surface-muted); }
.global-search__results { position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 50; }
.search-results-card { overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-md); }
.search-result { display: flex; min-height: 58px; align-items: center; gap: 11px; padding: 9px 12px; border-bottom: 1px solid var(--line); color: var(--text); }
.search-result:last-child { border-bottom: 0; }
.search-result:hover { background: var(--surface-muted); }
.search-result__avatar { display: grid; width: 34px; height: 34px; flex: 0 0 34px; place-items: center; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-weight: 750; }
.search-result__copy { min-width: 0; flex: 1; }
.search-result__copy strong, .search-result__copy small { display: block; }
.search-result__copy small { color: var(--muted); }
.search-result--empty { justify-content: space-between; color: var(--muted); }
.topbar-account strong, .topbar-account small { display: block; text-align: left; }
.topbar-account strong { max-width: 150px; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.topbar-account small { color: var(--muted); font-size: 11px; }
.account-avatar--small { width: 32px; height: 32px; flex-basis: 32px; font-size: 13px; }
.sidebar-backdrop { display: none; }
.mobile-nav { display: none; }
.container { width: min(100%, 1240px); margin: 0 auto; padding: 30px 28px 44px; }
.public-container { width: min(100%, 1180px); margin: 0 auto; padding: 28px 20px; }
.global-notice {
  margin: 12px 28px 0;
  padding: 10px 14px;
  border: 1px solid #efcaca;
  border-radius: var(--radius-sm);
  background: var(--red-soft);
  color: var(--red);
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}
h1 { margin: 0; font-size: clamp(24px, 3vw, 30px); line-height: 1.25; letter-spacing: -0.025em; }
h2 { margin: 0 0 14px; font-size: 17px; line-height: 1.35; }
h2 span { color: var(--muted); font-weight: 500; }
.muted { margin: 5px 0 0; color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.card {
  margin-bottom: 18px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.grid > .card { margin-bottom: 0; }
.row {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 0;
  border-top: 1px solid var(--line);
}
.row small, .timeline span { display: block; color: var(--muted); }
.empty { padding: 24px 10px; color: var(--muted); text-align: center; }
.empty-state { padding: 44px 20px; color: var(--text-soft); text-align: center; }
.empty-state__icon {
  display: grid;
  width: 44px;
  height: 44px;
  margin: 0 auto 12px;
  place-items: center;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 20px;
}
.empty-state strong { display: block; color: var(--text); font-size: 17px; }
.empty-state p { max-width: 520px; margin: 6px auto 18px; color: var(--muted); }
.module-placeholder { min-height: 330px; }

.button, button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.button:hover, button:hover { border-color: #aebeb3; color: var(--text); }
.button.danger, button.danger { border-color: #d9a6a1; color: #a33128; background: #fff7f6; }
.button.danger:hover, button.danger:hover { border-color: #b9473e; color: #84241d; background: #ffefed; }
.button:active, button:active { transform: translateY(1px); }
.primary { border-color: var(--brand); background: var(--brand); color: #fff; }
.primary:hover { border-color: var(--brand-hover); background: var(--brand-hover); color: #fff; }
.permission-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(12, 28, 20, 0.36);
  backdrop-filter: blur(2px);
}
.permission-dialog {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 22px 60px rgba(12, 28, 20, 0.22);
  text-align: center;
}
.permission-dialog__icon {
  display: grid;
  width: 48px;
  height: 48px;
  margin: 0 auto 14px;
  place-items: center;
  border-radius: 50%;
  background: #fff1dc;
  color: #9a5b00;
  font-size: 24px;
  font-weight: 800;
}
.permission-dialog h1 { margin: 0; font-size: 22px; }
.permission-dialog p { margin: 10px 0 22px; color: var(--muted); }
.permission-dialog .button { min-width: 120px; }
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; }
.toolbar input { flex: 1; }
.toolbar input, .toolbar select, input, select, textarea {
  max-width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  outline: none;
  background: var(--surface);
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(31, 107, 71, 0.12);
}
textarea { min-height: 96px; resize: vertical; }
.search-field { position: relative; display: block; flex: 1; }
.search-field input { width: 100%; padding-left: 38px; }
.search-field__icon { position: absolute; left: 13px; top: 8px; z-index: 1; color: var(--muted); font-size: 19px; }
.form-card { max-width: 720px; }
.form-card label { display: block; margin-bottom: 5px; font-weight: 650; }
.form-card input, .form-card select, .form-card textarea { width: 100%; }
.form-card input[type="radio"], .form-card input[type="checkbox"] { width: auto; }
.form-card #id_product_types { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; margin: 8px 0 16px; }
.form-card #id_product_types label { display: flex; min-height: 40px; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-muted); cursor: pointer; }
.form-card .short-text-input { width: 12em; }
.form-card .helptext { color: var(--muted); font-size: 13px; }
.form-card ul.errorlist { padding-left: 20px; color: var(--red); }
.form-field { margin-bottom: 18px; }
.form-field--choices > div { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.form-field--choices > div > div label { display: flex; align-items: center; gap: 7px; min-height: 42px; margin: 0; padding: 8px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; }
.form-field--choices > div > div:has(input:checked) label { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.page-head .actions { margin-top: 0; }
.inline { display: inline; }

.table-card { overflow-x: auto; padding: 0; }
.table-card h2 { padding: 20px 20px 0; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 16px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { background: var(--surface-muted); color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: 0.02em; }
tbody tr:hover { background: #fbfcfb; }
tbody tr:last-child td { border-bottom: 0; }
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #eef2ef;
  color: #536259;
  font-size: 12px;
  font-weight: 650;
}
.badge.complete, .badge.completed, .badge--complete, .badge--completed { background: var(--brand-soft); color: var(--brand); }
.badge.needs_info, .badge.pending, .badge--needs_info, .badge--pending { background: var(--amber-soft); color: var(--amber); }
.badge.processing, .badge--processing { background: var(--blue-soft); color: var(--blue); }
.badge.cancelled, .badge--cancelled { background: var(--red-soft); color: var(--red); }
.soft-tip { margin: -8px 0 18px; padding: 12px 15px; border-radius: 10px; background: var(--amber-soft); color: var(--amber); }
.timeline { margin-left: 5px; padding: 0 0 17px 16px; border-left: 2px solid #cfe0d5; }
.timeline-entry { position: relative; display: flex; align-items: flex-start; gap: 14px; min-height: 68px; margin-left: 7px; padding: 4px 0 18px 22px; border-left: 2px solid #d6e3da; }
.timeline-entry:last-child { border-left-color: transparent; }
.timeline-entry__dot { position: absolute; left: -7px; top: 7px; width: 12px; height: 12px; border: 3px solid var(--surface); border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 1px #bcd2c4; }
.timeline-entry__body { min-width: 0; flex: 1; }
.timeline-entry__body p { margin: 4px 0 0; color: var(--muted); }
.timeline-entry time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric { padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.metric span { display: block; color: var(--muted); }
.metric strong { display: block; margin-top: 5px; font-size: 24px; line-height: 1.25; }
.metric.accent { background: var(--brand-dark); color: #fff; }
.metric.accent span { color: #bdd1c5; }
.analytics-scope { margin: 9px 0 0; color: var(--text); font-size: 13px; font-weight: 650; }
.analytics-filter {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 26px;
  padding: 14px;
}
.analytics-filter label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; }
.analytics-filter select, .analytics-filter input { min-width: 142px; }
.period-tabs { display: flex; align-items: center; gap: 5px; margin-right: auto; }
.period-tabs button { min-height: 40px; border-color: transparent; background: transparent; }
.period-tabs button.active { background: var(--brand-soft); color: var(--brand-dark); }
.analytics-section { margin-bottom: 26px; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.section-heading h2 { margin-bottom: 2px; }
.section-heading p { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.analytics-metrics { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.analytics-metrics--six { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.analytics-metrics--three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.analytics-metrics .metric { min-height: 142px; }
.analytics-metrics .metric small {
  display: block;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.analytics-metrics .metric.accent small { color: #bdd1c5; }
.metric.warning { border-color: #ead9b5; background: var(--amber-soft); }
.metric.warning strong { color: var(--amber); }
.analytics-detail-grid .card { align-self: start; }
.analytics-row > span { min-width: 0; }
.analytics-row strong { text-align: right; white-space: nowrap; }
.analytics-match-alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: -8px 0 26px;
  border-color: #ead9b5;
  background: var(--amber-soft);
  color: var(--text);
}
.analytics-match-alert strong { color: var(--amber); white-space: nowrap; }
.issue { display: flex; gap: 15px; padding: 12px; border-top: 1px solid var(--line); }
.issue.blocking strong { color: var(--red); }
.login-card {
  max-width: 420px;
  margin: 8vh auto;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}
.login-card input { width: 100%; }
.login-card button { width: 100%; }
.message {
  margin-bottom: 15px;
  padding: 12px 16px;
  border: 1px solid #cfe1d5;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand-dark);
}
.message.error { border-color: #efcaca; background: var(--red-soft); color: var(--red); }
.skeleton-stack { display: grid; gap: 10px; padding: 8px 0; }
.skeleton {
  display: block;
  width: 100%;
  height: 13px;
  border-radius: 7px;
  background: linear-gradient(90deg, #edf1ee 25%, #f8faf8 50%, #edf1ee 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
}
.skeleton--title { width: 44%; height: 18px; }
.skeleton--short { width: 68%; }
@keyframes shimmer { to { background-position: -200% 0; } }
.htmx-progress {
  position: fixed;
  left: var(--sidebar-width);
  right: 0;
  top: 0;
  z-index: 80;
  height: 3px;
  opacity: 0;
  background: linear-gradient(90deg, var(--brand), #80b996);
  transform: scaleX(0);
  transform-origin: left;
  transition: opacity 0.15s ease, transform 0.2s ease;
}
.htmx-request.htmx-progress, .htmx-request .htmx-progress { opacity: 1; transform: scaleX(0.8); }

@media (max-width: 980px) {
  .sidebar {
    width: min(82vw, 280px);
    box-shadow: var(--shadow-md);
    transform: translateX(-105%);
    transition: transform 0.2s ease;
  }
  .sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 25;
    border: 0;
    border-radius: 0;
    background: rgba(12, 28, 19, 0.42);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }
  .sidebar-open .sidebar-backdrop { display: block; opacity: 1; pointer-events: auto; }
  .app-workspace { margin-left: 0; }
  .menu-button { display: inline-grid; place-items: center; }
  .htmx-progress { left: 0; }
}

@media (max-width: 760px) {
  body.has-app-shell { padding-bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom)); }
  .app-topbar { height: 58px; padding: 0 14px; }
  .topbar-account__button > span:last-child { display: none; }
  .global-search { display: none; }
  .container { padding: 20px 14px 30px; }
  .public-container { padding: 18px 14px; }
  .global-notice { margin: 10px 14px 0; }
  .page-head { align-items: flex-start; gap: 14px; margin-bottom: 18px; }
  .page-head > .button { min-height: 42px; white-space: nowrap; }
  h1 { font-size: 23px; }
  .grid { grid-template-columns: 1fr; gap: 14px; }
  .card { margin-bottom: 14px; padding: 16px; border-radius: 14px; }
  .toolbar { flex-wrap: wrap; }
  .toolbar input, .toolbar .search-field { min-width: 100%; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .metric { padding: 14px; }
  .metric strong { font-size: 20px; }
  .analytics-filter { align-items: stretch; flex-direction: column; }
  .period-tabs { width: 100%; margin-right: 0; }
  .period-tabs button { flex: 1; padding-inline: 8px; }
  .analytics-filter select, .analytics-filter input { width: 100%; }
  .analytics-metrics, .analytics-metrics--six, .analytics-metrics--three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .analytics-metrics .metric { min-height: 132px; }
  th, td { padding: 12px 13px; }
  .mobile-nav {
    position: fixed;
    inset: auto 0 0;
    z-index: 24;
    display: flex;
    min-height: var(--mobile-nav-height);
    padding: 5px 6px calc(5px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 -5px 18px rgba(22, 61, 43, 0.06);
    backdrop-filter: blur(12px);
  }
  .mobile-nav a {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border-radius: 9px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 650;
  }
  .mobile-nav a.active { background: var(--brand-soft); color: var(--brand); }
  .mobile-nav .nav-icon { width: 17px; height: 17px; transform: scale(0.9); }
  .empty-state { padding: 34px 10px; }
  .form-card #id_product_types { grid-template-columns: 1fr; }
  .timeline-entry { flex-wrap: wrap; gap: 4px 10px; }
  .timeline-entry time { width: 100%; order: -1; }
}

@media (max-width: 430px) {
  .page-head { flex-direction: column; }
  .page-head > .button { width: 100%; }
  .actions { width: 100%; }
  .actions .button, .actions button { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}

.metric-card { display:flex; flex-direction:column; gap:6px; padding:18px; border:1px solid var(--line); border-radius:var(--radius); background:var(--surface); color:var(--text); text-decoration:none; }
.metric-card strong { font-size:27px; }
.metric-card small,.quick-action span { color:var(--muted); }
.trend-heading { display:flex; align-items:flex-start; justify-content:space-between; gap:20px; }
.trend-heading h2 { margin-bottom:3px; }
.trend-heading p { margin:0; color:var(--muted); font-size:13px; }
.trend-summary { display:flex; align-items:flex-end; flex-direction:column; gap:3px; color:var(--muted); font-size:12px; }
.trend-summary strong { color:var(--brand-dark); font-size:17px; }
.trend-chart { width:100%; margin-top:12px; overflow-x:auto; }
.trend-line-chart { display:block; width:100%; min-width:620px; height:auto; overflow:visible; }
.trend-grid line { stroke:var(--line); stroke-width:1; stroke-dasharray:4 5; vector-effect:non-scaling-stroke; }
.trend-area { fill:var(--brand-soft); opacity:.72; }
.trend-line { fill:none; stroke:var(--brand); stroke-width:3; stroke-linecap:round; stroke-linejoin:round; vector-effect:non-scaling-stroke; }
.trend-point circle { fill:var(--surface); stroke:var(--brand); stroke-width:3; vector-effect:non-scaling-stroke; }
.trend-point.is-current circle { fill:var(--brand); }
.trend-point text { text-anchor:middle; }
.trend-value { fill:var(--text); font-size:12px; font-weight:700; }
.trend-date { fill:var(--muted); font-size:12px; }
.quick-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:14px; margin:18px 0; }
.quick-action { display:flex; flex-direction:column; gap:7px; color:var(--text); text-decoration:none; }
.business-list { display:grid; gap:12px; }
.business-card { display:grid; grid-template-columns:1fr auto; align-items:start; gap:10px; }
.business-card small { display:block; margin-top:5px; color:var(--muted); }
.business-card p,.business-card .actions { grid-column:1/-1; margin:0; }
.visit-history { display:grid; gap:28px; }
.visit-day { min-width:0; }
.visit-day__header { display:flex; align-items:baseline; justify-content:space-between; gap:16px; margin-bottom:12px; padding-bottom:10px; border-bottom:1px solid var(--line); }
.visit-day__header h2 { display:flex; flex-wrap:wrap; align-items:center; gap:8px; margin:0; font-size:18px; }
.visit-day__header h2 span { font-size:13px; }
.visit-day__header h2 em { padding:2px 8px; border-radius:999px; background:var(--brand-soft); color:var(--brand); font-size:12px; font-style:normal; font-weight:700; }
.visit-day__header > span { color:var(--muted); font-size:13px; white-space:nowrap; }
.visit-day__list { padding-left:14px; border-left:3px solid #dbe9df; }
.visit-day__list .business-card { padding-bottom:14px; border-bottom:1px dashed var(--line); }
.visit-day__list .business-card:last-child { padding-bottom:0; border-bottom:0; }
.business-card--selectable { position:relative; }
.business-card--selectable:has(.batch-checkbox:not([hidden])) { grid-template-columns:auto 1fr auto; }
.business-card--selectable:has(.batch-checkbox:not([hidden])) p,
.business-card--selectable:has(.batch-checkbox:not([hidden])) .actions { grid-column:2/-1; }
.business-card.is-selected { border-color:var(--brand); background:var(--brand-soft); }
.batch-checkbox { display:flex; align-items:center; padding-top:2px; cursor:pointer; }
.batch-checkbox[hidden] { display:none; }
.batch-checkbox input,.batch-select-all input { width:17px; height:17px; min-height:0; accent-color:var(--brand); cursor:pointer; }
.batch-toolbar { position:sticky; top:calc(var(--topbar-height) + 10px); z-index:10; display:flex; align-items:center; gap:16px; margin-bottom:12px; padding:12px 16px; border:1px solid #bcd6c5; border-radius:var(--radius); background:var(--surface); box-shadow:var(--shadow-md); }
.batch-toolbar[hidden] { display:none; }
.batch-select-all { display:flex; align-items:center; gap:7px; font-weight:650; cursor:pointer; }
.batch-toolbar > span { margin-left:auto; color:var(--muted); }
.batch-toolbar button:disabled { cursor:not-allowed; opacity:.5; }
.followup-date-filter { display:flex; flex-wrap:wrap; align-items:flex-end; gap:10px; margin-bottom:16px; padding:14px 16px; border:1px solid var(--line); border-radius:var(--radius); background:var(--surface); }
.followup-date-filter label { display:grid; gap:4px; color:var(--muted); font-size:12px; font-weight:650; }
.followup-date-filter input { min-height:40px; color:var(--text); }
.followup-date-filter > span { padding-bottom:9px; color:var(--muted); }
.followup-date-filter small { width:100%; color:var(--muted); }
.confirm-dialog { width:min(440px,calc(100% - 32px)); padding:24px; border:0; border-radius:var(--radius-lg); color:var(--text); box-shadow:0 24px 80px rgba(22,61,43,.24); }
.confirm-dialog::backdrop { background:rgba(12,26,18,.5); }
.confirm-dialog p { margin:0; color:var(--text-soft); }
.confirm-dialog .actions { justify-content:flex-end; }
.followup-stage { color:var(--brand-dark); font-weight:700; }
.script-library-dialog { width:min(860px,calc(100% - 32px)); max-height:min(82vh,760px); overflow:auto; padding:0; border:0; border-radius:var(--radius-lg); color:var(--text); box-shadow:0 24px 80px rgba(22,61,43,.24); }
.script-library-dialog::backdrop { background:rgba(12,26,18,.5); }
.script-library__head { position:sticky; top:0; z-index:1; display:flex; align-items:flex-start; justify-content:space-between; gap:20px; padding:22px 24px; border-bottom:1px solid var(--line); background:var(--surface); }
.script-library__head h2,.script-library__head p { margin:0; }
.script-library__head p { margin-top:5px; color:var(--muted); }
.script-library__groups { display:grid; gap:22px; padding:24px; }
.script-library__group h3 { margin:0 0 10px; color:var(--brand-dark); }
.script-library__items { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
.script-library__item { display:grid; align-content:start; gap:9px; padding:15px; border:1px solid var(--line); border-radius:12px; background:var(--surface-soft); }
.script-library__item p { min-height:3.4em; margin:0; color:var(--text-soft); line-height:1.7; }
.script-library__item button { justify-self:start; }
.pagination { display:flex; align-items:center; justify-content:space-between; gap:16px; margin-top:18px; color:var(--muted); }
.pagination__links { display:flex; flex-wrap:wrap; align-items:center; justify-content:flex-end; gap:7px; }
.pagination__page { display:grid; width:38px; height:38px; place-items:center; border:1px solid var(--line); border-radius:9px; background:var(--surface); color:var(--text-soft); font-weight:650; }
.pagination__page.active { border-color:var(--brand); background:var(--brand); color:#fff; }
.pagination__ellipsis { padding:0 3px; color:var(--muted); }
.pagination-summary { margin:18px 0 0; color:var(--muted); text-align:right; }
.visit-board { display:flex; align-items:center; gap:12px; margin-bottom:18px; padding:13px 16px; border:1px solid #cfe1d5; border-radius:var(--radius); background:var(--brand-soft); color:var(--text-soft); }
.visit-board__label { flex:0 0 auto; padding:3px 9px; border-radius:999px; background:var(--brand); color:#fff; font-size:12px; font-weight:700; }
.visit-board p { margin:0; }
.visit-board strong { color:var(--brand-dark); font-size:17px; }
.visit-footer-actions { display:flex; justify-content:flex-start; margin-top:-2px; }
.subnav { display:flex; flex-wrap:wrap; gap:8px; margin-bottom:16px; }
.subnav a { padding:9px 14px; border-radius:999px; background:var(--surface); color:var(--muted); text-decoration:none; border:1px solid var(--line); }
.subnav a.active { color:var(--brand); border-color:var(--brand); background:var(--brand-soft); }
.choice-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:16px; }
.choice-card { display:flex; min-height:150px; flex-direction:column; justify-content:center; gap:10px; color:var(--text); text-decoration:none; }
.choice-card strong { font-size:22px; }
.choice-card span { color:var(--muted); line-height:1.7; }
.choice-card--success { border-color:var(--brand); background:var(--brand-soft); }
.optional-customer { padding:14px; margin-bottom:18px; border:1px dashed var(--line); border-radius:12px; background:var(--surface-soft); }
.optional-customer > input { width:100%; margin-top:9px; }
.customer-search-options { display:grid; gap:8px; margin-top:10px; }
.customer-search-option { display:flex; align-items:center; gap:10px; padding:10px; border:1px solid var(--line); border-radius:10px; background:var(--surface); cursor:pointer; }
.customer-search-option small { display:block; color:var(--muted); }
@media (max-width: 900px) { .quick-grid { grid-template-columns:repeat(2,minmax(0,1fr)); } .choice-grid { grid-template-columns:1fr; } }
@media (max-width: 560px) {
  .quick-grid { gap:9px; }
  .metric-card { padding:14px; }
  .metric-card strong { font-size:22px; }
  .trend-heading { flex-direction:column; gap:8px; }
  .trend-summary { align-items:flex-start; }
  .business-card { grid-template-columns:1fr; }
  .visit-history { gap:24px; }
  .visit-day__header { align-items:flex-start; }
  .visit-day__list { padding-left:10px; }
  .business-card--selectable:has(.batch-checkbox:not([hidden])) { grid-template-columns:auto 1fr; }
  .business-card--selectable:has(.batch-checkbox:not([hidden])) .status-badge { grid-column:2; }
  .batch-toolbar { align-items:stretch; flex-wrap:wrap; }
  .batch-toolbar > span { margin-left:0; }
  .batch-toolbar button { width:100%; }
  .followup-date-filter > label { width:calc(50% - 16px); }
  .followup-date-filter input { width:100%; }
  .pagination { align-items:flex-start; flex-direction:column; }
  .pagination__links { justify-content:flex-start; }
  .visit-board { align-items:flex-start; }
  .script-library-dialog { width:calc(100% - 20px); max-height:88vh; }
  .script-library__head { padding:17px; }
  .script-library__groups { padding:17px; }
  .script-library__items { grid-template-columns:1fr; }
}
