:root {
  --brand-primary: #0878d1;
  --brand-secondary: #075ea7;
  --brand-accent: #12a59b;
  --ink: #102a3a;
  --muted: #6b7f8d;
  --line: rgba(15, 78, 116, .13);
  --surface: rgba(255, 255, 255, .96);
  --surface-soft: #f6fbfe;
  --accent: #0878d1;
  --accent-dark: #075ea7;
  --accent-soft: #e4f3ff;
  --success: #0b946f;
  --success-soft: #dcf8ee;
  --danger: #c74350;
  --danger-soft: #ffe8eb;
  --warning: #a96d00;
  --warning-soft: #fff3d7;
  --info: #246b94;
  --info-soft: #e5f4ff;
  --state-created: #1769c2;
  --state-created-soft: #e5f2ff;
  --state-process: #a96d00;
  --state-process-soft: #fff3d7;
  --state-route: #6d43c5;
  --state-route-soft: #f0eaff;
  --state-delivered: #087d5e;
  --state-delivered-soft: #dcf8ee;
  --state-cancelled: #c74350;
  --state-cancelled-soft: #ffe8eb;
  --state-returned: #b45309;
  --state-returned-soft: #fff0df;
  --state-custom: #526572;
  --state-custom-soft: #edf1f3;
  --shadow: 0 16px 44px rgba(21, 76, 108, .1);
  --sidebar-width: 270px;
  --header-height: 78px;
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #eef8ff;
  line-height: 1.45;
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.app-background {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(circle at 92% 2%, rgba(35, 178, 255, .18), transparent 29rem),
    radial-gradient(circle at 25% 100%, rgba(20, 190, 156, .12), transparent 30rem),
    linear-gradient(135deg, #edf8ff 0%, #f6fbfd 50%, #edf8ff 100%);
}

.surface {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.sidebar {
  position: fixed;
  inset: 14px auto 14px 14px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-width);
  min-height: calc(100vh - 28px);
  padding: 18px;
  border-radius: 26px;
  color: #f7fbff;
  border-bottom: 4px solid var(--brand-accent);
  background: var(--brand-primary);
  box-shadow: 0 26px 70px rgba(5, 86, 149, .28);
  overflow: hidden;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}
.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 15px;
  color: #fff;
  background: var(--brand-accent);
  font-weight: 900;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35);
}
.brand-logo {
  display: block;
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  object-fit: contain;
  background: rgba(255, 255, 255, .94);
}
.public-layout-brand { margin-bottom: 18px; }
.site-settings-form { margin-top: 22px; }
.site-image-preview { display: grid; grid-template-columns: 72px minmax(0, 1fr); align-items: center; gap: 10px; margin-top: 8px; color: var(--muted); font-size: .78rem; }
.site-image-preview img { width: 72px; height: 54px; border: 1px solid var(--line); border-radius: 10px; object-fit: contain; background: var(--surface-soft); }
.site-image-preview.compact img { width: 42px; height: 42px; }
.site-image-preview.social img { width: 110px; height: 58px; object-fit: cover; }
.brand strong { display: block; font-size: 1.03rem; }
.brand small, .sidebar-user small, .public-tracking-link small { display: block; color: rgba(255,255,255,.66); font-size: .78rem; }
.sidebar-collapse { width: 100%; margin-top: 15px; min-height: 38px; color: #fff; background: rgba(255,255,255,.1); box-shadow: none; }
.side-nav {
  display: grid;
  gap: 5px;
  margin-top: 26px;
  overflow-y: auto;
  scrollbar-width: thin;
  padding-right: 2px;
}
.side-nav a, .public-tracking-link {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 14px;
  color: rgba(255,255,255,.91);
  text-decoration: none;
  transition: background .16s ease, transform .16s ease;
}
.side-nav a span, .public-tracking-link > span { display: grid; place-items: center; font-size: 1.08rem; }
.side-nav a b, .public-tracking-link b { font-size: .92rem; }
.side-nav a:hover, .side-nav a.active { background: rgba(255,255,255,.15); transform: translateX(2px); }
.sidebar-footer { display: grid; gap: 9px; margin-top: auto; padding-top: 16px; }
.sidebar-user {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 11px;
  border-radius: 15px;
  background: rgba(255,255,255,.1);
}
.sidebar-user > a { color: #fff; text-decoration: none; font-size: 1.1rem; }
.logout-button { grid-column: 1 / -1; display: inline-flex; align-items: center; justify-content: center; gap: 7px; width: 100%; padding: 8px 10px; border-radius: 10px; color: #fff; background: rgba(205,58,58,.34); }
.logout-button b { font-size: .76rem; }
.avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: #0878d1;
  background: #fff;
  font-weight: 900;
}
.avatar.large { width: 48px; height: 48px; }
.public-tracking-link {
  grid-template-columns: 28px 1fr;
  background: rgba(255,255,255,.08);
}
.public-tracking-link small { grid-column: 2; margin-top: -9px; }
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 70;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 14px;
  border: 0;
  color: #fff;
  background: var(--accent);
  box-shadow: var(--shadow);
  cursor: pointer;
}
.sidebar-backdrop { display: none; }
[data-tooltip] { position: relative; }
.sidebar-collapsed { --sidebar-width: 82px; }
.sidebar-collapsed .sidebar { padding-inline: 12px; }
.sidebar-collapsed .brand { justify-content: center; }
.sidebar-collapsed .brand > span:last-child,
.sidebar-collapsed .sidebar b,
.sidebar-collapsed .sidebar small,
.sidebar-collapsed .sidebar-user > div { display: none; }
.sidebar-collapsed .sidebar-collapse,
.sidebar-collapsed .side-nav a,
.sidebar-collapsed .public-tracking-link { display: grid; grid-template-columns: 1fr; place-items: center; padding-inline: 8px; }
.sidebar-collapsed .sidebar-user { grid-template-columns: 1fr; justify-items: center; padding-inline: 6px; }
.sidebar-collapsed [data-tooltip]::after,
.sidebar-collapsed [data-tooltip]::before { position: absolute; z-index: 90; pointer-events: none; opacity: 0; transition: opacity .15s ease, transform .15s ease; }
.sidebar-collapsed [data-tooltip]::after { content: attr(data-tooltip); top: 50%; left: calc(100% + 13px); width: max-content; max-width: 210px; padding: 8px 11px; border-radius: 9px; color: #fff; background: #123247; box-shadow: 0 10px 30px rgba(4,31,48,.22); font-size: .78rem; font-weight: 800; transform: translate(4px,-50%); }
.sidebar-collapsed [data-tooltip]::before { content: ''; top: 50%; left: calc(100% + 7px); border: 6px solid transparent; border-right-color: #123247; transform: translateY(-50%); }
.sidebar-collapsed [data-tooltip]:hover::after,
.sidebar-collapsed [data-tooltip]:hover::before,
.sidebar-collapsed [data-tooltip]:focus-visible::after,
.sidebar-collapsed [data-tooltip]:focus-visible::before { opacity: 1; }
@media (min-width: 821px) {
  .sidebar [data-tooltip]::after,
  .sidebar [data-tooltip]::before { display: none!important; }
}
.desktop-tooltip { position: fixed; z-index: 120; max-width: 230px; padding: 9px 12px; border-radius: 10px; color: #fff; background: #123247; box-shadow: 0 12px 34px rgba(4,31,48,.28); font-size: .8rem; font-weight: 800; line-height: 1.25; pointer-events: none; }
.desktop-tooltip[hidden] { display: none; }

.app-shell {
  min-height: 100vh;
  margin-left: calc(var(--sidebar-width) + 28px);
  width: calc(100% - var(--sidebar-width) - 28px);
}
.app-header {
  position: fixed;
  inset: 0 0 auto calc(var(--sidebar-width) + 28px);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: var(--header-height);
  padding: 14px 24px;
  border-bottom: 1px solid rgba(15, 78, 116, .08);
  background: rgba(238, 248, 255, .94);
  box-shadow: 0 8px 24px rgba(21, 76, 108, .07);
  backdrop-filter: blur(18px);
}
.scanner-search {
  display: grid;
  grid-template-columns: auto minmax(220px, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: min(780px, 100%);
  padding: 7px 8px 7px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(28, 87, 119, .08);
}
.scanner-search > span { color: var(--accent); font-size: 1.25rem; }
.scanner-search input { border: 0; background: transparent; padding: 8px 2px; }
.scanner-search button { padding: 10px 15px; border-radius: 12px; }
.header-user { margin-left: auto; text-align: right; white-space: nowrap; }
.header-user small { display: block; color: var(--muted); }
.client-header-title { min-width: 0; }
.client-header-title small, .client-header-title strong { display: block; }
.client-header-title small { color: var(--muted); }
.app-main {
  width: 100%;
  max-width: none;
  padding: 22px 24px 64px;
}
.has-app-header .app-main {
  padding-top: calc(var(--header-height) + 22px);
}
.public-main {
  position: relative;
  width: min(1020px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 64px;
}
.public-shell { display: grid; gap: 18px; }
.public-brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; width: fit-content; }
.public-brand small { display: block; color: var(--muted); }

h1, h2, h3, p { overflow-wrap: anywhere; }
h1, h2, h3 { letter-spacing: -.025em; }
.hero, .panel, .form-grid, .form-card, .tracking-result, .timeline, .auth-card, .public-hero, .internal-search, .preview-card, .label-editor-form {
  border-radius: 24px;
}
.hero { padding: clamp(24px, 4vw, 44px); }
.hero h1, .page-title h1, .form-head h1, .auth-card h1, .public-hero h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 1.02;
}
.hero p:not(.eyebrow), .page-title p:not(.eyebrow), .form-head p, .public-hero p:not(.eyebrow) { color: var(--muted); }
.dashboard-hero {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  overflow: hidden;
}
.dashboard-hero::after {
  content: "";
  position: absolute;
  right: -90px;
  top: -120px;
  width: 330px;
  height: 330px;
  border-radius: 50%;
  background: linear-gradient(135deg, #20d3f5, #1688f0);
  opacity: .13;
  pointer-events: none;
}
.dashboard-hero > * { position: relative; z-index: 1; }
.dashboard-hero p:not(.eyebrow) { max-width: 740px; margin: 14px 0 0; }
.eyebrow {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: .76rem;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.page-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin: 4px 0 20px;
}
.page-title h1 { font-size: clamp(2.2rem, 4vw, 3.8rem); }
.page-title p { margin: 8px 0 0; max-width: 850px; }

.primary, button, .secondary, .danger-button, .success-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 0;
  border-radius: 14px;
  padding: 10px 15px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition: transform .14s ease, box-shadow .14s ease, opacity .14s ease;
}
.primary, button:not(.secondary):not(.danger-button):not(.success-button):not(.link-button):not(.switch) {
  border-bottom: 3px solid var(--brand-accent);
  color: #fff;
  background: var(--brand-primary);
  box-shadow: 0 8px 20px rgba(8, 120, 209, .18);
}
.primary:hover, button:hover, .secondary:hover, .danger-button:hover, .success-button:hover { transform: translateY(-1px); }
.secondary {
  color: var(--accent-dark);
  background: var(--accent-soft);
  box-shadow: none;
}
.danger-button { color: var(--danger); background: var(--danger-soft); box-shadow: none; }
.success-button { color: #11633e; background: #daf5e7; box-shadow: none; }
[data-theme="dark"] .success-button { color: #9ce2bd; background: rgba(24,137,84,.24); }
.link-button { min-height: 0; padding: 0; color: var(--accent); background: transparent; box-shadow: none; border-radius: 0; }
.button-row { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
.person-lookup { position: relative; display: grid; gap: 12px; padding: 16px; border-radius: 18px; background: var(--surface-soft); }
.person-lookup-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.person-lookup-head strong, .person-lookup-head small { display: block; }
.person-lookup-head small { margin-top: 3px; color: var(--muted); font-weight: 600; }
.person-lookup-head > span { flex: 0 0 auto; padding: 5px 9px; border-radius: 999px; color: var(--success); background: var(--success-soft); font-size: .72rem; font-weight: 900; }
.person-lookup-grid { display: grid; grid-template-columns: minmax(150px, .65fr) minmax(260px, 1fr) minmax(280px, 1.35fr); gap: 12px; }
.input-action { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; }
.input-action button { min-height: 46px; }
.person-lookup-status { min-height: 20px; color: var(--muted); font-size: .82rem; font-weight: 700; }
.person-lookup-status.is-success { color: var(--success); }
.person-lookup-status.is-danger { color: var(--danger); }
.person-suggestions { display: grid; gap: 7px; width: 100%; max-height: 290px; padding: 8px; overflow-y: auto; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); box-shadow: 0 12px 30px rgba(21,76,108,.09); }
.person-suggestions[hidden] { display: none; }
.person-suggestions .person-suggestion { display: grid; grid-template-columns: 42px minmax(0,1fr) auto; align-items: center; gap: 11px; width: 100%; min-height: 62px; padding: 9px 11px; border: 1px solid transparent; color: var(--ink); background: transparent; box-shadow: none; text-align: left; }
.person-suggestions .person-suggestion:hover,
.person-suggestions .person-suggestion:focus-visible { border-color: rgba(8,120,209,.18); background: var(--accent-soft); transform: none; }
.person-suggestion-avatar { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; color: #fff; background: linear-gradient(135deg,var(--accent),#16aa9c); font-weight: 900; }
.person-suggestion-copy { min-width: 0; }
.person-suggestions strong, .person-suggestions small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-suggestions strong { font-size: .9rem; }
.person-suggestions small { margin-top: 3px; color: var(--muted); font-weight: 650; }
.person-suggestion-action { padding: 6px 9px; border-radius: 999px; color: var(--accent-dark); background: rgba(8,120,209,.09); font-size: .72rem; font-weight: 900; }
.stack-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.stack-actions form { display: inline-flex; }

.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 16px 0;
}
.quick-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 13px;
  padding: 16px;
  border-radius: 19px;
  color: var(--ink);
  text-decoration: none;
  transition: transform .16s ease, box-shadow .16s ease;
}
.quick-card:hover { transform: translateY(-2px); box-shadow: 0 18px 48px rgba(23,84,122,.15); }
.quick-card small { display: block; margin-top: 3px; color: var(--muted); }
.quick-card > b { color: #9aacb8; font-size: 1.7rem; }
.quick-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 15px; font-size: 1.25rem; }
.quick-icon.blue { color: #0878d1; background: #e4f3ff; }
.quick-icon.green { color: #09966f; background: #ddf8ef; }
.quick-icon.orange { color: #d77716; background: #fff0dc; }
.metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}
.metrics.compact { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metric { position: relative; min-height: 104px; padding: 17px; border-radius: 19px; }
.metric > .status-dot { position: absolute; top: 18px; right: 18px; }
.metric span, .metric small { color: var(--muted); }
.metric small { display: block; margin-top: 4px; }
.metric strong { display: block; margin-top: 10px; font-size: 2rem; }
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #f1b932; }
.status-dot.success { background: #0bb889; }
.status-dot.danger { background: #ed6470; }
.status-dot.info { background: #1688f0; }
.status-dot.warning { background: #f1b932; }
.status-dot.state-created, .event.state-created > span { background: var(--state-created); }
.status-dot.state-process, .event.state-process > span { background: var(--state-process); }
.status-dot.state-route, .event.state-route > span { background: var(--state-route); }
.status-dot.state-delivered, .event.state-delivered > span { background: var(--state-delivered); }
.status-dot.state-cancelled, .event.state-cancelled > span { background: var(--state-cancelled); }
.status-dot.state-returned, .event.state-returned > span { background: var(--state-returned); }
.status-dot.state-custom, .event.state-custom > span { background: var(--state-custom); }

.panel { padding: 22px; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 17px;
}
.section-head h2, .section-head p { margin: 0; }
.section-head p { margin-top: 4px; color: var(--muted); }
.export-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 180px 150px 150px 120px auto auto;
  gap: 10px;
  margin-bottom: 17px;
}
input, select, textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid rgba(15, 78, 116, .16);
  border-radius: 13px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(8,120,209,.12); }
input[readonly] { color: #60727d; background: #f0f5f8; }
textarea { resize: vertical; }
select[multiple] { padding: 8px; min-height: 145px; }
label { display: grid; align-content: start; gap: 6px; color: #526c7c; font-size: .89rem; font-weight: 700; }
label small { color: var(--muted); font-weight: 500; }
.field-note { margin: 0; color: var(--muted); }

.table-wrap { width: 100%; overflow-x: auto; border-radius: 16px; border: 1px solid rgba(15,78,116,.08); }
table { width: 100%; min-width: 900px; border-collapse: collapse; }
th, td { padding: 13px 14px; text-align: left; vertical-align: middle; border-bottom: 1px solid rgba(15,78,116,.07); }
th { color: #5e7482; background: #f4f9fc; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
td small { display: block; margin-top: 3px; color: var(--muted); }
tbody tr:hover { background: #f5fbff; }
.actions { align-items: center; flex-wrap: wrap; gap: 7px; }
td.actions { vertical-align: middle; }
.actions a, .actions button { align-items: center; justify-content: center; gap: 6px;
  min-height: 30px; padding: 6px 11px; border-radius: 10px;
  color: var(--accent-dark); background: var(--accent-soft);
  text-decoration: none; font-size: .82rem; font-weight: 800; line-height: 1; white-space: nowrap;
  transition: color .14s ease, background .14s ease, transform .14s ease;
}
.actions a:hover, .actions button:hover { color: #fff; background: var(--accent); transform: translateY(-1px); }
.actions .invoice-action { color: #11633e; background: #daf5e7; }
[data-theme="dark"] .actions .invoice-action { color: #9ce2bd; background: rgba(24,137,84,.24); }
.actions .invoice-action:hover { color: #fff; background: #0c8a58; }
.empty { padding: 28px; color: var(--muted); text-align: center; }
.mobile-cards { display: none; }

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
}
.pagination-info { flex: 1 1 100%; margin: 0; color: var(--muted); text-align: center; font-size: .82rem; }
.pagination-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; }
.page-link {
  display: inline-grid;
  place-items: center;
  min-width: 36px;
  min-height: 36px;
  padding: 0 11px;
  border: 1px solid rgba(15, 78, 116, .14);
  border-radius: 10px;
  color: var(--accent-dark);
  background: var(--surface);
  text-decoration: none;
  font-size: .85rem;
  font-weight: 800;
  line-height: 1;
  transition: background .14s ease, color .14s ease, border-color .14s ease;
}
.page-link:hover { background: var(--accent-soft); }
.page-link.active { color: #fff; background: var(--accent); border-color: var(--accent); }
.page-link.disabled { opacity: .45; pointer-events: none; }
.page-ellipsis { display: inline-grid; place-items: center; min-width: 26px; color: var(--muted); }
[data-theme="dark"] .page-link { border-color: rgba(255, 255, 255, .14); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: fit-content;
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--warning);
  background: var(--warning-soft);
  font-size: .76rem;
  font-weight: 900;
  white-space: nowrap;
}
.pill.success { color: var(--success); background: var(--success-soft); }
.pill.danger { color: var(--danger); background: var(--danger-soft); }
.pill.info { color: var(--info); background: var(--info-soft); }
.pill.muted-pill, .muted-pill { color: #6c7a84; background: #edf1f3; }
.pill.state-created, .state-select.state-created { color: var(--state-created); background: var(--state-created-soft); }
.pill.state-process, .state-select.state-process { color: var(--state-process); background: var(--state-process-soft); }
.pill.state-route, .state-select.state-route { color: var(--state-route); background: var(--state-route-soft); }
.pill.state-delivered, .state-select.state-delivered { color: var(--state-delivered); background: var(--state-delivered-soft); }
.pill.state-cancelled, .state-select.state-cancelled { color: var(--state-cancelled); background: var(--state-cancelled-soft); }
.pill.state-returned, .state-select.state-returned { color: var(--state-returned); background: var(--state-returned-soft); }
.pill.state-custom, .state-select.state-custom { color: var(--state-custom); background: var(--state-custom-soft); }
.state-select { border-color: currentColor; font-weight: 800; }
option.state-created { color: var(--state-created); background: var(--state-created-soft); }
option.state-process { color: var(--state-process); background: var(--state-process-soft); }
option.state-route { color: var(--state-route); background: var(--state-route-soft); }
option.state-delivered { color: var(--state-delivered); background: var(--state-delivered-soft); }
option.state-cancelled { color: var(--state-cancelled); background: var(--state-cancelled-soft); }
option.state-returned { color: var(--state-returned); background: var(--state-returned-soft); }
option.state-custom { color: var(--state-custom); background: var(--state-custom-soft); }
.alert {
  margin: 0 0 16px;
  padding: 13px 15px;
  border-radius: 15px;
  border: 1px solid transparent;
  font-weight: 700;
}
.alert.success { color: var(--success); background: var(--success-soft); border-color: rgba(11,148,111,.18); }
.alert.danger { color: var(--danger); background: var(--danger-soft); border-color: rgba(199,67,80,.18); }
.alert.info { color: var(--info); background: var(--info-soft); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px;
  padding: 22px;
}
.form-head { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.form-head h1 { font-size: clamp(2rem, 4vw, 3.3rem); }
.form-head p { margin: 6px 0 0; }
.sticky-form-head { position: sticky; top: calc(var(--header-height) + 10px); z-index: 10; padding: 14px; margin: -6px; border: 1px solid rgba(15,78,116,.08); border-radius: 18px; background: rgba(255,255,255,.94); backdrop-filter: blur(12px); }
fieldset {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  min-width: 0;
  margin: 0;
  padding: 18px;
  border: 1px solid rgba(15,78,116,.1);
  border-radius: 20px;
  background: var(--surface-soft);
}
.guide-form fieldset { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.guide-form .person-lookup-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.guide-form .person-name-field { grid-column: 1 / -1; }
.guide-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.guide-form .form-head,
.guide-step-service,
.guide-step-sender,
.guide-form .mobile-submit { grid-column: 1 / -1; }
.guide-step-recipient { grid-column: 1; grid-row: 3; }
.guide-step-package { grid-column: 2; grid-row: 3; align-self: start; }
.guide-live-summary { display: grid; gap: 16px; margin-top: 8px; padding: clamp(18px,2vw,26px); border-radius: 20px; color: var(--ink); background: linear-gradient(145deg,var(--surface),var(--accent-soft)); box-shadow: 0 14px 36px rgba(21,76,108,.08); }
.guide-summary-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.guide-summary-head h2 { margin: 0; font-size: 1.3rem; }
.guide-summary-number { display: grid; gap: 4px; padding: 15px 17px; border-radius: 15px; background: rgba(255,255,255,.72); }
.guide-summary-number small { color: var(--muted); }
.guide-summary-number strong { color: var(--accent-dark); font-size: 1.12rem; overflow-wrap: anywhere; }
.guide-summary-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.guide-summary-grid section { display: grid; align-content: start; gap: 6px; min-width: 0; padding: 15px; border-radius: 15px; background: rgba(255,255,255,.66); }
.guide-summary-grid h3 { margin: 0 0 2px; color: var(--accent-dark); font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; }
.guide-summary-grid strong, .guide-summary-grid span { overflow-wrap: anywhere; }
.guide-summary-grid span { color: var(--muted); font-size: .82rem; }
.guide-summary-grid .is-empty { color: var(--muted); font-weight: 500; }
.guide-summary-total { color: var(--accent)!important; font-size: 1.35rem; }
[data-theme="dark"] .guide-live-summary { background: linear-gradient(145deg,var(--surface),rgba(8,120,209,.16)); }
[data-theme="dark"] .guide-summary-number,
[data-theme="dark"] .guide-summary-grid section { background: rgba(255,255,255,.055); }
.quote-coverage { margin-top: auto; overflow: hidden; border: 1px solid rgba(15,78,116,.09); border-radius: 14px; background: var(--surface-soft); }
.quote-coverage summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 46px; padding: 10px 13px; color: var(--accent-dark); font-size: .86rem; font-weight: 900; cursor: pointer; list-style: none; }
.quote-coverage summary::-webkit-details-marker { display: none; }
.quote-coverage summary::after { content: '⌄'; flex: 0 0 auto; font-size: 1rem; transition: transform .16s ease; }
.quote-coverage[open] summary::after { transform: rotate(180deg); }
.quote-coverage summary small { margin-left: auto; color: var(--muted); font-size: .72rem; font-weight: 700; }
.quote-coverage-body { max-height: 260px; padding: 0 13px 13px; overflow-y: auto; border-top: 1px solid rgba(15,78,116,.07); }
.quote-coverage p { margin: 11px 0 0; color: var(--muted); font-size: .84rem; }
.coverage-cantons { display: grid; gap: 9px; margin-top: 11px; }
.coverage-canton { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.coverage-canton strong { width: 100%; font-size: .83rem; }
legend { padding: 0 8px; color: var(--ink); font-size: 1.02rem; font-weight: 900; }
legend span { display: inline-grid; place-items: center; width: 29px; height: 29px; margin-right: 7px; border-radius: 9px; color: #fff; background: var(--accent); font-size: .82rem; }
.wide { grid-column: 1 / -1; }
.invoice-toggle { display: flex; align-items: center; gap: 10px; font-weight: 800; }
.invoice-toggle input { width: 20px; height: 20px; }
.invoice-fields { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.invoice-fields[hidden] { display: none; }
.invoice-lookup .person-lookup-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.invoice-lookup .person-name-field { grid-column: 1 / -1; }
.sender-summary {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  border-radius: 19px;
}
.sender-summary h2, .sender-summary p { margin: 0; }
.sender-summary p:not(.eyebrow) { color: var(--muted); }
.quote-inline { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 15px; border-radius: 15px; color: var(--muted); background: #edf8ff; }
.quote-inline strong { color: var(--accent); font-size: 1.4rem; }
.mobile-submit { display: none; grid-column: 1 / -1; }
.cost-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

.split-grid {
  display: grid;
  grid-template-columns: minmax(300px, 390px) minmax(0, 1fr);
  gap: 16px;
}
.split-grid.narrow-left { grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); }
.form-card { display: grid; align-content: start; gap: 14px; padding: 21px; }
.password-form { width: min(100%, 560px); }
.form-card h2, .form-card p { margin: 0; }
.form-card > div:first-child p:not(.eyebrow) { margin-top: 5px; color: var(--muted); }
.card-list { display: grid; gap: 10px; }
.list-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px;
  border: 1px solid rgba(15,78,116,.09);
  border-radius: 16px;
  background: #fbfdfe;
}
.list-card small { display: block; margin-top: 3px; color: var(--muted); }
.title-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.user-main { display: flex; align-items: center; gap: 12px; }
.user-main .pill { margin-top: 7px; }
.preview-number { padding: 14px; border-radius: 14px; background: #edf8ff; }
.preview-number small { display: block; color: var(--muted); }
.preview-number strong { display: block; margin-top: 5px; color: var(--accent); overflow-wrap: anywhere; }
.info-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
.info-grid article { padding: 17px; border-radius: 16px; background: #f4f9fc; }
.info-grid p { margin: 6px 0 0; color: var(--muted); }

.tabs {
  display: flex;
  gap: 7px;
  margin-bottom: 16px;
  padding: 8px;
  overflow-x: auto;
  border-radius: 18px;
  scrollbar-width: thin;
}
.tabs a { flex: 0 0 auto; padding: 9px 13px; border-radius: 11px; color: var(--ink); text-decoration: none; font-size: .88rem; font-weight: 800; white-space: nowrap; }
.tabs a.active { color: #fff; background: var(--accent); }

.tariff-layout { grid-template-columns: minmax(430px, 650px) minmax(0, 1fr); }
.tariff-admin-form { max-height: calc(100vh - var(--header-height) - 34px); overflow-y: auto; }
.scope-builder {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: 16px;
  background: #edf8ff;
}
.scope-builder h3, .scope-builder p { margin: 0; }
.scope-builder p, .scope-builder small { color: var(--muted); }
.scope-builder-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.scope-builder-tools { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.scope-builder-tools button { padding: 7px 10px; font-size: .8rem; }
.scope-province-list { display: grid; gap: 10px; }
.scope-province-card {
  overflow: hidden;
  border: 1px solid rgba(15, 78, 116, .11);
  border-radius: 14px;
  background: #fff;
}
.scope-province-card > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 13px;
  color: var(--accent-dark);
  background: #e8f5ff;
  cursor: pointer;
  list-style: none;
  font-weight: 850;
}
.scope-province-card > summary::-webkit-details-marker { display: none; }
.scope-province-card > summary::after { content: '＋'; font-size: 1rem; }
.scope-province-card[open] > summary::after { content: '−'; }
.scope-province-card > summary small { color: var(--muted); font-weight: 700; }
.scope-province-body { display: grid; gap: 9px; padding: 10px; }
.scope-whole-province {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: 10px;
  background: #f3f9fc;
  font-weight: 800;
}
.scope-whole-province input,
.scope-table input { width: 17px; height: 17px; margin: 0; accent-color: var(--accent); }
.scope-table-wrap { width: 100%; overflow-x: auto; border-radius: 11px; }
.scope-table { width: 100%; min-width: 560px; border-collapse: separate; border-spacing: 0; }
.scope-table th, .scope-table td { padding: 9px 10px; border-bottom: 1px solid rgba(15,78,116,.07); vertical-align: top; }
.scope-table th { position: static; color: #5e7482; background: #f4f9fc; font-size: .72rem; }
.scope-table tbody tr:last-child td { border-bottom: 0; }
.scope-canton-choice { display: flex; align-items: flex-start; gap: 8px; min-width: 145px; }
.scope-canton-choice span { display: grid; }
.scope-canton-choice small { margin-top: 1px; font-size: .72rem; }
.scope-district-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 10px; }
.scope-district-choice { display: flex; align-items: flex-start; gap: 7px; min-width: 0; font-size: .78rem; }
.scope-district-choice span { min-width: 0; overflow-wrap: anywhere; }
.scope-district-choice small { display: inline; margin: 0 0 0 3px; font-size: .68rem; }
.scope-province-card.is-covered .scope-whole-province { color: #087552; background: var(--success-soft); }
.scope-canton-row.is-covered > td { background: rgba(220,248,238,.38); }
.scope-builder input:disabled + span { opacity: .58; }
.scope-builder .scope-availability.is-active { color: var(--success); }
.scope-builder .scope-availability.is-inactive { color: var(--danger); }
.scope-builder .scope-availability strong,
.scope-builder .scope-availability small { color: inherit; }
[data-theme="dark"] .scope-builder { --ink: #e6edf3; --muted: #a7b8c7; --line: rgba(230,237,243,.18); --surface: #182632; --surface-soft: #20313e; --accent-soft: #213c50; --accent-dark: #9ed5ff; --success: #9ce2bd; --success-soft: #123c32; --danger: #ffabb4; color: var(--ink); background: var(--surface-soft); }
[data-theme="dark"] .scope-builder .scope-province-card { border-color: var(--line); background: var(--surface); }
[data-theme="dark"] .scope-builder .scope-province-card > summary { background: var(--accent-soft); }
[data-theme="dark"] .scope-builder .scope-whole-province,
[data-theme="dark"] .scope-builder .scope-table th { color: var(--muted); background: var(--surface-soft); }
[data-theme="dark"] .scope-builder .scope-table th,
[data-theme="dark"] .scope-builder .scope-table td { border-color: var(--line); }
[data-theme="dark"] .scope-builder .scope-province-card.is-covered .scope-whole-province,
[data-theme="dark"] .scope-builder .scope-canton-row.is-covered > td { background: var(--success-soft); }
.tariff-card { align-items: flex-start; }
.tariff-card > div:first-child { min-width: 0; flex: 1 1 auto; }
.tariff-card p { margin: 7px 0; color: #415f70; }
.scope-text { max-width: 700px; }
.assigned-scope {
  margin-top: 10px;
  overflow: hidden;
  border: 1px solid rgba(15,78,116,.10);
  border-radius: 12px;
  background: #fbfdff;
}
.assigned-scope > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 45px;
  padding: 9px 11px;
  color: #526d7d;
  background: #f4f9fc;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.assigned-scope > summary::-webkit-details-marker { display: none; }
.assigned-scope > summary::after {
  content: '⌄';
  flex: 0 0 auto;
  color: var(--accent-dark);
  font-size: 1.05rem;
  font-weight: 900;
  line-height: 1;
  transition: transform .16s ease;
}
.assigned-scope[open] > summary::after { transform: rotate(180deg); }
.assigned-scope-heading { display: grid; min-width: 0; gap: 1px; }
.assigned-scope-heading strong { font-size: .78rem; text-transform: uppercase; letter-spacing: .035em; }
.assigned-scope-heading small { overflow: hidden; color: var(--muted); font-size: .74rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.assigned-scope-action { margin-left: auto; color: var(--accent-dark); font-size: .75rem; font-weight: 850; white-space: nowrap; }
.assigned-scope-collapse { display: none; }
.assigned-scope[open] .assigned-scope-expand { display: none; }
.assigned-scope[open] .assigned-scope-collapse { display: inline; }
.assigned-scope-body { display: grid; gap: 7px; padding: 9px 10px 10px; border-top: 1px solid rgba(15,78,116,.07); }
.assigned-scope-table { width: 100%; min-width: 0; border-collapse: separate; border-spacing: 0; border: 1px solid rgba(15,78,116,.09); border-radius: 10px; overflow: hidden; font-size: .76rem; }
.assigned-scope-table caption { padding: 7px 9px; color: var(--accent-dark); background: #eaf6ff; font-weight: 850; text-align: left; }
.assigned-scope-table th, .assigned-scope-table td { padding: 6px 8px; border-bottom: 1px solid rgba(15,78,116,.06); vertical-align: top; }
.assigned-scope-table th { width: 34%; color: #415f70; background: #f7fbfd; font-size: .72rem; text-transform: none; letter-spacing: 0; }
.assigned-scope-table tr:last-child th, .assigned-scope-table tr:last-child td { border-bottom: 0; }
.scope-chip { display: inline-block; margin: 1px 3px 1px 0; padding: 2px 6px; border-radius: 999px; color: #31586f; background: #edf6fb; font-size: .7rem; }
.specificity { color: var(--muted); font-size: .78rem; }

.switch { position: relative; width: 44px; min-height: 25px; padding: 0; border-radius: 999px; background: #c9d4da; box-shadow: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 19px; height: 19px; border-radius: 50%; background: #fff; transition: transform .15s ease; }
.switch.on { background: var(--success); }
.switch.on::after { transform: translateX(19px); }
.location-tools .button-row { justify-content: flex-end; }
.location-filter { grid-template-columns: minmax(240px, 1fr) auto auto; }
.location-tree { display: grid; gap: 10px; }
.location-node { border: 1px solid rgba(15,78,116,.1); border-radius: 16px; background: #fbfdfe; overflow: hidden; }
.location-node > summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 15px; cursor: pointer; list-style: none; }
.location-node > summary::-webkit-details-marker { display: none; }
.location-node > summary span:first-child { display: flex; align-items: baseline; gap: 8px; }
.location-node > summary small { color: var(--muted); }
.province-node > summary { color: var(--accent-dark); background: #eaf6ff; }
.canton-node { margin: 0 12px 12px; }
.canton-node > summary { background: #f3f9fc; }
.location-editor { display: flex; flex-wrap: wrap; gap: 8px; padding: 11px 14px; border-top: 1px solid rgba(15,78,116,.08); background: #fff; }
.inline-edit { display: grid; grid-template-columns: minmax(190px, 1fr) auto; gap: 8px; flex: 1 1 380px; }
.district-list { display: grid; }
.district-row { display: grid; grid-template-columns: minmax(300px, 1fr) auto auto auto; align-items: center; gap: 8px; padding: 10px 13px; border-top: 1px solid rgba(15,78,116,.07); }
.district-edit { display: grid; grid-template-columns: minmax(180px, 1fr) 100px auto; gap: 8px; }
.status-text { font-size: .76rem; font-weight: 900; }
.status-text.on { color: var(--success); }
.status-text.off { color: var(--danger); }

.location-manager { display: grid; gap: 16px; min-width: 0; color: var(--ink); }
.location-manager .location-metrics { margin: 0; }
.location-manager .location-panel { min-width: 0; }
.location-manager .location-tools p { max-width: 680px; }
.location-manager .location-filter { align-items: end; }
.location-manager .location-filter label { min-width: 0; }
.location-manager .location-help { margin: 0 0 16px; color: var(--muted); font-size: .85rem; }
.location-manager .location-node { border-color: var(--line); background: var(--surface); }
.location-manager .province-node > summary { color: var(--ink); background: var(--accent-soft); }
.location-manager .canton-node > summary { background: var(--surface-soft); }
.location-manager .location-node > summary { min-height: 64px; }
.location-manager .location-node > summary > span:first-child { display: grid; gap: 3px; min-width: 0; }
.location-manager .location-node > summary [data-location-child-count] { display: inline; }
.location-manager .location-node > summary strong,
.location-manager .district-heading strong { overflow-wrap: anywhere; }
.location-manager .location-node > summary::after { content: ''; width: 8px; height: 8px; flex: 0 0 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); }
.location-manager .location-node[open] > summary::after { transform: rotate(225deg); }
.location-manager .location-node > summary .status-text { margin-left: auto; white-space: nowrap; }
.location-manager .location-node > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }
.location-manager .canton-list { padding-top: 12px; }
.location-manager .location-editor { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; border-color: var(--line); background: var(--surface); }
.location-manager .location-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.location-manager .location-actions form { margin: 0; }
.location-manager .location-actions button,
.location-manager .location-edit-form button { font-size: .85rem; }
.location-manager .location-edit-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(120px, .3fr); align-items: end; gap: 12px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft); }
.location-manager .location-edit-form label { min-width: 0; color: var(--muted); }
.location-manager .location-edit-form input { min-width: 0; width: 100%; color: var(--ink); border-color: var(--line); background: var(--surface); }
.location-manager .location-edit-heading,
.location-manager .location-edit-form .button-row { grid-column: 1 / -1; }
.location-manager .location-edit-heading small { display: block; margin-top: 3px; color: var(--muted); font-weight: 400; }
.location-manager .district-row { display: block; padding: 14px; border-color: var(--line); }
.location-manager .district-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.location-manager .district-heading > div { min-width: 0; }
.location-manager .district-heading small { display: block; margin-top: 4px; color: var(--muted); overflow-wrap: anywhere; }
.location-manager .district-row .location-editor { padding: 10px 0 0; border: 0; }
.location-manager .location-feedback { position: sticky; top: calc(var(--header-height) + 8px); z-index: 5; margin: 0 0 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; color: var(--success); background: var(--success-soft); overflow-wrap: anywhere; }
.location-manager .location-feedback.is-error { color: var(--danger); background: var(--danger-soft); }
.location-manager [hidden] { display: none; }
.location-manager button:disabled,
.location-manager input:disabled { opacity: .6; cursor: wait; }
[data-theme="dark"] .location-manager { --ink: #e6edf3; --muted: #a7b8c7; --line: rgba(230,237,243,.18); --surface: #182632; --surface-soft: #20313e; --accent-soft: #213c50; --accent-dark: #9ed5ff; --success: #9ce2bd; --success-soft: #123c32; --danger: #ffabb4; --danger-soft: #441f25; }
@media (max-width: 820px) {
  .location-manager .location-tools { flex-direction: column; align-items: stretch; }
  .location-manager .location-tools .button-row { justify-content: flex-start; }
  .location-manager .location-edit-form { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .location-manager .location-filter { grid-template-columns: minmax(0, 1fr); }
  .location-manager .location-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .location-manager .location-actions > [data-location-edit-open] { grid-column: 1 / -1; }
  .location-manager .location-actions button { width: 100%; padding-inline: 8px; }
  .location-manager .canton-node { margin-inline: 6px; }
  .location-manager .location-node > summary { padding-inline: 10px; }
  .location-manager .district-row { padding-inline: 10px; }
  .location-manager .district-heading { flex-wrap: wrap; }
  .location-manager .location-edit-form { padding: 12px; }
}

.quote-layout { display: grid; grid-template-columns: minmax(310px, 390px) minmax(0, 1fr); gap: 16px; }
.quote-filters { position: sticky; top: calc(var(--header-height) + 12px); max-height: calc(100vh - var(--header-height) - 26px); overflow-y: auto; }
.quote-results { min-width: 0; }
.quote-result { display: grid; place-items: center; align-content: center; min-height: 430px; padding: 38px; text-align: center; }
.quote-result h2 { margin-bottom: 0; }
.quote-result p { color: var(--muted); }
.quote-icon { display: grid; place-items: center; width: 78px; height: 78px; border-radius: 23px; color: var(--accent); background: var(--accent-soft); font-size: 2.2rem; font-weight: 900; }
.quote-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.quote-card { display: grid; gap: 17px; padding: 20px; border-radius: 20px; }
.quote-card-head { display: flex; justify-content: space-between; gap: 14px; }
.quote-card h3 { margin: 0; font-size: 1.35rem; }
.quote-card small { color: var(--muted); }
.price-breakdown { display: grid; gap: 7px; margin: 0; }
.price-breakdown div { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; border-bottom: 1px dashed rgba(15,78,116,.12); }
.price-breakdown dt { color: var(--muted); }
.price-breakdown dd { margin: 0; font-weight: 800; }
.price-breakdown .total { margin-top: 4px; border: 0; font-size: 1.15rem; }
.price-breakdown .total dd { color: var(--accent); }

.internal-search, .public-search {
  display: grid;
  grid-template-columns: auto minmax(0,1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
}
.internal-search > span { color: var(--accent); font-size: 1.4rem; }
.public-hero { padding: clamp(24px, 5vw, 46px); text-align: center; }
.public-hero .public-search { width: min(650px, 100%); margin: 20px auto 0; }
.tracking-result { padding: 22px; }
.tracking-result-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.tracking-result-head h2 { margin: 0; font-size: clamp(1.8rem, 4vw, 3rem); }
.tracking-result-head p { margin: 6px 0 0; color: var(--muted); }
.state-decision-dialog {
  width: min(520px, calc(100vw - 28px));
  margin: auto;
  padding: clamp(22px, 4vw, 34px);
  border: 1px solid var(--line);
  border-radius: 24px;
  color: var(--ink);
  text-align: center;
}
.state-decision-dialog::backdrop { background: rgba(8, 28, 41, .62); backdrop-filter: blur(4px); }
.state-decision-dialog h2 { margin: 4px 0 8px; font-size: clamp(1.8rem, 5vw, 2.7rem); }
.state-decision-dialog p { margin: 7px 0; }
.state-decision-icon { display: grid; place-items: center; width: 54px; height: 54px; margin: 0 auto 14px; border-radius: 50%; color: var(--success); background: var(--success-soft); font-size: 1.6rem; font-weight: 900; }
.state-decision-copy { color: var(--muted); line-height: 1.55; }
.state-decision-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 22px; }
.state-decision-actions form { display: contents; }
.state-decision-actions > *, .state-decision-actions form > button { width: 100%; }
.state-decision-dialog .pill { vertical-align: middle; }
.state-button.state-created { background: var(--state-created); }
.state-button.state-process { background: var(--state-process); }
.state-button.state-route { background: var(--state-route); }
.state-button.state-delivered { background: var(--state-delivered); }
.state-button.state-cancelled { background: var(--state-cancelled); }
.state-button.state-returned { background: var(--state-returned); }
.state-button.state-custom { background: var(--state-custom); }
.tracking-summary { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; margin: 18px 0; }
.tracking-summary article { padding: 13px; border-radius: 14px; background: #f3f9fc; }
.tracking-summary small { display: block; color: var(--muted); }
.tracking-summary strong { display: block; margin-top: 5px; }
.address { padding: 12px 14px; border-radius: 13px; background: #f5fafc; color: #486575; }
.address a { color: var(--accent); font-weight: 800; }
.timeline { margin-top: 16px; padding: 22px; }
.event { position: relative; display: grid; grid-template-columns: 20px 1fr; gap: 12px; padding: 0 0 21px; }
.event:last-child { padding-bottom: 0; }
.event > span { position: relative; width: 13px; height: 13px; margin-top: 5px; border: 3px solid #fff; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px rgba(8,120,209,.2); }
.event:not(:last-child) > span::after { content: ""; position: absolute; top: 12px; left: 3px; width: 2px; height: calc(100% + 17px); background: #d7e8f2; }
.event strong { display: block; }
.event small { display: block; color: var(--muted); }
.event p { margin: 4px 0 0; }
.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; align-items: start; gap: 16px; }
.detail-layout .timeline { margin-bottom: 0; }
.tracking-update { position: sticky; top: calc(var(--header-height) + 12px); }

.editor-layout { display: grid; grid-template-columns: minmax(380px, 520px) minmax(0, 1fr); gap: 16px; align-items: start; }
.label-editor-form { display: grid; gap: 10px; padding: 16px; max-height: calc(100vh - 105px); overflow-y: auto; }
.label-editor-form details { border: 1px solid rgba(15,78,116,.1); border-radius: 15px; background: #fbfdfe; }
.label-editor-form summary { padding: 13px 15px; cursor: pointer; font-weight: 900; }
.editor-section { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 11px; padding: 0 14px 14px; }
.toggle-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
.check-row { display: flex; align-items: center; gap: 9px; min-height: 38px; padding: 9px 10px; border-radius: 11px; background: #f0f7fb; }
.check-row input { width: 18px; height: 18px; }
.editor-actions { display: flex; gap: 9px; position: sticky; bottom: 0; padding: 11px 0 2px; background: linear-gradient(transparent, #fff 28%); }
.preview-card { position: sticky; top: calc(var(--header-height) + 12px); padding: 18px; }
.preview-frame { display: grid; place-items: center; min-height: 720px; padding: 18px; border-radius: 17px; overflow: auto; background: #dde8ee; }
.preview-frame iframe { width: 100%; min-height: 680px; border: 0; border-radius: 12px; background: #edf4f7; }

.login-wrap { display: grid; place-items: center; min-height: calc(100vh - 60px); padding: 20px; }
.auth-card { display: grid; gap: 14px; width: min(460px, 100%); padding: 30px; }
.auth-card h1 { font-size: clamp(2.2rem, 7vw, 3.7rem); }
.auth-foot { margin: 0; color: var(--muted); text-align: center; }
.auth-foot a { color: var(--accent); font-weight: 800; }

@media (max-width: 1280px) {
  .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  fieldset { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .quote-cards { grid-template-columns: 1fr; }
  .tracking-summary { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 1040px) {
  :root { --sidebar-width: 250px; }
  .app-main { padding-inline: 18px; }
  .app-header { padding-inline: 18px; }
  .header-user { display: none; }
  .split-grid, .tariff-layout, .quote-layout, .editor-layout, .detail-layout { grid-template-columns: 1fr; }
  .form-card, .quote-filters, .preview-card, .tracking-update { position: static; max-height: none; }
  .tariff-admin-form, .label-editor-form { max-height: none; }
  .preview-frame { min-height: 640px; }
  .quick-actions { grid-template-columns: 1fr; }
  fieldset { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .person-lookup-grid { grid-template-columns: 1fr 1fr; }
  .person-name-field { grid-column: 1 / -1; }
  .scope-builder-head { align-items: stretch; flex-direction: column; }
  .scope-builder-tools { justify-content: flex-start; }
}

@media (max-width: 820px) {
  :root { --header-height: 76px; }
  .sidebar-toggle { display: grid; place-items: center; }
  .sidebar {
    inset: 8px auto 8px 8px;
    width: min(300px, calc(100vw - 24px));
    min-height: calc(100vh - 16px);
    transform: translateX(calc(-100% - 24px));
    transition: transform .2s ease;
  }
  .sidebar-collapse { display: none; }
  .sidebar-collapsed { --sidebar-width: 250px; }
  .sidebar-collapsed .sidebar { padding: 18px; }
  .sidebar-collapsed .brand { justify-content: flex-start; }
  .sidebar-collapsed .brand > span:last-child,
  .sidebar-collapsed .sidebar b,
  .sidebar-collapsed .sidebar small,
  .sidebar-collapsed .sidebar-user > div { display: block; }
  .sidebar-collapsed .side-nav a { display: grid; grid-template-columns: 28px 1fr; place-items: initial; padding-inline: 13px; }
  .sidebar-collapsed .public-tracking-link { display: grid; grid-template-columns: 28px 1fr; place-items: initial; padding-inline: 13px; }
  .sidebar-collapsed .sidebar-user { grid-template-columns: 38px minmax(0, 1fr); justify-items: initial; padding: 11px; }
  .sidebar [data-tooltip]::after { position: absolute; z-index: 90; content: attr(data-tooltip); top: calc(100% + 6px); left: 50%; width: max-content; max-width: 210px; padding: 8px 11px; border-radius: 9px; color: #fff; background: #123247; box-shadow: 0 10px 30px rgba(4,31,48,.22); font-size: .78rem; font-weight: 800; opacity: 0; pointer-events: none; transform: translateX(-50%); }
  .sidebar [data-tooltip].tooltip-visible::after { opacity: 1; }
  .sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 45; background: rgba(4,31,48,.42); backdrop-filter: blur(2px); }
  .sidebar-open .sidebar-backdrop { display: block; }
  .app-shell { margin-left: 0; width: 100%; }
  .app-header {
    position: fixed;
    inset: 0 0 auto 0;
    min-height: var(--header-height);
    padding: 10px 12px 10px 66px;
    background: rgba(238, 248, 255, .96);
    border-bottom: 1px solid rgba(15, 78, 116, .08);
  }
  .client-header-title { min-width: 0; }
  .client-header-title small, .client-header-title strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .scanner-search { width: 100%; }
  .app-main { padding: 12px 14px 50px; }
  .has-app-header .app-main { padding-top: calc(var(--header-height) + 12px); }
  .public-main { width: min(100% - 24px, 1020px); padding-top: 18px; }
  .dashboard-hero { align-items: flex-start; flex-direction: column; }
  .dashboard-hero .primary { width: 100%; }
  .metrics, .metrics.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar { grid-template-columns: 1fr 1fr; }
  .toolbar input:first-of-type { grid-column: 1 / -1; }
  .desktop-table { display: none; }
  .mobile-cards { display: grid; gap: 11px; }
  .guide-card { padding: 15px; border: 1px solid var(--line); border-radius: 17px; background: #fbfdfe; }
  .guide-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
  .guide-card-head small { display: block; color: var(--muted); }
  .guide-card h3 { margin: 13px 0 3px; }
  .guide-card p { margin: 0; color: var(--muted); }
  .guide-client { display: block; margin: 2px 0 0; color: var(--muted); font-weight: 700; }
  .card-meta { display: flex; justify-content: space-between; gap: 10px; margin: 13px 0; }
  .sticky-form-head { position: static; }
  .form-head { align-items: flex-start; flex-direction: column; }
  .form-head > button { display: none; }
  .mobile-submit { display: block; }
  .mobile-submit button { width: 100%; }
  .tracking-result-head { flex-direction: column; }
  .tracking-summary { grid-template-columns: 1fr 1fr; }
  .district-row { grid-template-columns: 1fr auto; }
  .district-edit { grid-column: 1 / -1; }
  .district-row .status-text { justify-self: end; }
  .location-editor { display: grid; grid-template-columns: 1fr 1fr; }
  .inline-edit { grid-column: 1 / -1; }
  .editor-section { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .app-header { padding: 9px 8px 9px 60px; }
  .scanner-search { grid-template-columns: auto minmax(0, 1fr) auto; gap: 6px; padding-left: 9px; border-radius: 15px; }
  .scanner-search input { min-width: 0; font-size: .84rem; }
  .scanner-search button { width: auto; padding: 9px 10px; font-size: .8rem; }
  .app-main { padding-inline: 10px; }
  .hero, .panel, .form-grid, .tracking-result, .timeline, .public-hero, .preview-card { border-radius: 19px; }
  .hero { padding: 22px; }
  .page-title { margin-top: 10px; }
  .metrics, .metrics.compact { grid-template-columns: 1fr 1fr; }
  .metric { min-height: 90px; padding: 14px; }
  .metric strong { font-size: 1.65rem; }
  .panel, .tracking-result, .timeline { padding: 15px; }
  .toolbar { grid-template-columns: 1fr; }
  .toolbar input:first-of-type { grid-column: auto; }
  .form-grid { display: grid; grid-template-columns: 1fr; padding: 14px; }
  fieldset { grid-column: 1; grid-template-columns: 1fr; padding: 14px; }
  .guide-form fieldset, .guide-form .person-lookup-grid { grid-template-columns: 1fr; }
  .guide-form { grid-template-columns: 1fr; }
  .guide-form .form-head,
  .guide-step-service,
  .guide-step-recipient,
  .guide-step-package,
  .guide-step-sender,
  .guide-form .mobile-submit { grid-column: 1; grid-row: auto; }
  .guide-form .person-name-field { grid-column: auto; }
  .guide-summary-grid { grid-template-columns: 1fr; }
  .person-suggestions .person-suggestion { grid-template-columns: 38px minmax(0,1fr); padding: 8px; }
  .person-suggestion-avatar { width: 38px; height: 38px; border-radius: 11px; }
  .person-suggestion-action { display: none; }
  .person-lookup-grid { grid-template-columns: 1fr; }
  .person-name-field { grid-column: auto; }
  .person-lookup-head { flex-direction: column; }
  .wide { grid-column: auto; }
  .invoice-fields { grid-template-columns: 1fr; }
  .invoice-lookup .person-lookup-grid { grid-template-columns: 1fr; }
  .sender-summary { grid-column: 1; align-items: flex-start; flex-direction: column; }
  .cost-grid { grid-template-columns: 1fr; }
  .split-grid { gap: 12px; }
  .form-card { padding: 16px; }
  .list-card, .tariff-card, .user-card { align-items: stretch; flex-direction: column; }
  .scope-province-body { padding: 7px; }
  .scope-table { min-width: 480px; }
  .scope-district-grid { grid-template-columns: 1fr; }
  .assigned-scope-table th { width: 40%; }
  .stack-actions { justify-content: flex-start; }
  .stack-actions > *, .stack-actions form, .stack-actions button, .stack-actions a { flex: 1 1 auto; }
  .quote-card { padding: 16px; }
  .tracking-summary { grid-template-columns: 1fr; }
  .state-decision-actions { grid-template-columns: 1fr; }
  .internal-search, .public-search { grid-template-columns: 1fr; }
  .internal-search > span { display: none; }
  .public-hero { text-align: left; }
  .location-tools { align-items: stretch; flex-direction: column; }
  .location-tools .button-row { justify-content: flex-start; }
  .location-filter { grid-template-columns: 1fr; }
  .location-editor { grid-template-columns: 1fr; }
  .inline-edit, .district-edit { grid-template-columns: 1fr; }
  .district-row { grid-template-columns: 1fr; }
  .district-row .status-text { justify-self: start; }
  .toggle-grid { grid-template-columns: 1fr; }
  .preview-frame { min-height: 540px; padding: 8px; }
  .preview-frame iframe { min-height: 520px; }
  .auth-card { padding: 22px; }
  .button-row > .primary, .button-row > .secondary, .button-row > button { flex: 1 1 auto; }
}

.report-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr)) auto auto auto;
  align-items: end;
  gap: 12px;
  margin-bottom: 22px;
  padding: 18px;
  border-radius: 20px;
}
.report-check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 9px 11px;
  border-radius: 12px;
  background: var(--surface-soft);
}
.report-check input { width: 18px; height: 18px; }
.report-currency { margin-bottom: 24px; }
.report-currency .section-head { margin-bottom: 12px; }
.report-metrics { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.report-metrics .metric strong {
  overflow-wrap: anywhere;
  font-size: clamp(1.35rem, 2.2vw, 2.25rem);
}
.report-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr);
  align-items: start;
  gap: 16px;
}
.report-grid > .panel:first-child { grid-row: span 2; }
.report-table-wrap { overflow-x: auto; }
.report-table { min-width: 540px; }
.report-ranking { display: grid; }
.report-ranking article {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.report-ranking article:last-child { border-bottom: 0; }
.report-ranking article div { min-width: 0; }
.report-ranking strong, .report-ranking small { display: block; }
.report-ranking small { margin-top: 3px; color: var(--muted); }
.report-ranking b { flex: 0 0 auto; color: var(--accent-dark); }
.report-empty { text-align: center; }
.report-export {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 22px;
  padding: 13px 16px;
  border-radius: 16px;
}
.report-export-label { color: var(--muted); font-weight: 800; margin-right: 6px; }

@media (max-width: 1280px) {
  .report-filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .report-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1040px) {
  .report-grid { grid-template-columns: 1fr; }
  .report-grid > .panel:first-child { grid-row: auto; }
}

@media (max-width: 820px) {
  .report-filters { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
  .report-filters, .report-metrics { grid-template-columns: 1fr; }
  .report-filters > button, .report-filters > .secondary { width: 100%; }
  .report-ranking article { align-items: flex-start; flex-direction: column; }
}

.scanner-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 9px; width: min(880px, 100%); }
.scanner-actions .scanner-search { width: 100%; }
.bulk-search-button { min-height: 44px; white-space: nowrap; }
.bulk-search-dialog { width: min(1120px, calc(100vw - 28px)); max-height: calc(100vh - 28px); margin: auto; padding: clamp(18px, 3vw, 28px); border: 1px solid var(--line); border-radius: 24px; color: var(--ink); overflow: auto; }
.bulk-search-dialog::backdrop { background: rgba(8,28,41,.68); backdrop-filter: blur(4px); }
.bulk-dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.bulk-dialog-head h2 { margin: 3px 0 6px; font-size: clamp(1.65rem, 4vw, 2.4rem); }
.bulk-dialog-head p { margin: 0; color: var(--muted); }
.bulk-dialog-x { flex: 0 0 auto; width: 42px; height: 42px; padding: 0; font-size: 1.7rem; line-height: 1; }
.bulk-session-controls { display: grid; grid-template-columns: minmax(170px, 230px) minmax(180px, 230px) minmax(190px, 1fr); align-items: end; gap: 12px; margin: 20px 0 12px; }
.bulk-counter { min-height: 67px; padding: 11px 15px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-soft); }
.bulk-counter small, .bulk-counter strong { display: block; }
.bulk-counter small { color: var(--muted); }
.bulk-counter strong { margin-top: 4px; font-size: 1.25rem; }
.bulk-scanner { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface-soft); }
.bulk-scanner > span { color: var(--accent); font-size: 1.4rem; }
.bulk-alert { margin: 12px 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; color: var(--muted); background: var(--surface-soft); font-weight: 800; }
.bulk-alert.green { border-color: #86d9be; color: #087d5e; background: #dcf8ee; }
.bulk-alert.red { border-color: #ffb7bf; color: #b53643; background: #ffe8eb; }
.bulk-alert.yellow { border-color: #ead08c; color: #755000; background: #fff6d8; }
.bulk-alert.orange { border-color: #f3bd83; color: #9a4707; background: #fff0df; }
.bulk-table-wrap { max-height: min(48vh, 520px); border: 1px solid var(--line); border-radius: 15px; overflow: auto; }
.bulk-table { min-width: 760px; }
.bulk-table th { position: sticky; top: 0; z-index: 1; background: var(--surface-soft); }
.bulk-table td { vertical-align: middle; }
.bulk-table td strong, .bulk-table td small { display: block; }
.bulk-table td small { max-width: 420px; margin-top: 3px; color: var(--muted); overflow-wrap: anywhere; }
.bulk-table select { min-width: 190px; }
.bulk-dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
[data-theme="dark"] .bulk-search-dialog { color: var(--ink); background: var(--surface); }
[data-theme="dark"] .bulk-alert.green { color: #8ce8ca; background: #123c32; }
[data-theme="dark"] .bulk-alert.red { color: #ffabb4; background: #441f25; }
[data-theme="dark"] .bulk-alert.yellow { color: #ffe198; background: #453817; }
[data-theme="dark"] .bulk-alert.orange { color: #ffc48b; background: #472a16; }

@media (max-width: 1040px) {
  .scanner-actions { width: 100%; }
  .bulk-session-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bulk-counter { grid-column: 1 / -1; }
}

@media (max-width: 820px) {
  .scanner-actions { grid-template-columns: minmax(0,1fr) auto; gap: 6px; }
  .bulk-search-button { padding-inline: 10px; font-size: .78rem; }
  .bulk-search-dialog { width: calc(100vw - 16px); max-height: calc(100vh - 16px); padding: 16px; border-radius: 18px; }
}

@media (max-width: 560px) {
  .scanner-actions { grid-template-columns: 1fr; }
  .bulk-search-button { width: 100%; }
  .bulk-session-controls, .bulk-scanner { grid-template-columns: 1fr; }
  .bulk-scanner > span { display: none; }
  .bulk-dialog-actions { display: grid; grid-template-columns: 1fr; }
  .bulk-dialog-actions button { width: 100%; }
}

.invoice-action { color: #11633e; background: #daf5e7; }
[data-theme="dark"] .invoice-action { color: #9ce2bd; background: rgba(24,137,84,.24); }

.invoice-detail-dialog { width: min(760px, calc(100vw - 28px)); max-height: calc(100vh - 28px); margin: auto; padding: clamp(18px, 3vw, 28px); border: 1px solid var(--line); border-radius: 24px; color: var(--ink); overflow: auto; }
.invoice-detail-dialog::backdrop { background: rgba(8,28,41,.68); backdrop-filter: blur(4px); }
.invoice-detail-section { margin-top: 20px; }
.invoice-detail-section h3 { margin: 0 0 10px; color: var(--muted); font-size: .84rem; text-transform: uppercase; letter-spacing: .05em; }
.invoice-copy-list { display: grid; gap: 8px; }
.invoice-copy-item { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-soft); }
.invoice-copy-text { min-width: 0; }
.invoice-copy-label { display: block; color: var(--muted); font-size: .76rem; font-weight: 700; }
.invoice-copy-text b { display: block; margin-top: 3px; font-size: .95rem; overflow-wrap: anywhere; }
.invoice-copy-btn { flex: 0 0 auto; min-height: 32px; padding: 6px 12px; }
[data-theme="dark"] .invoice-detail-dialog { color: var(--ink); background: var(--surface); }

@media (max-width: 820px) {
  .invoice-detail-dialog { width: calc(100vw - 16px); max-height: calc(100vh - 16px); padding: 16px; border-radius: 18px; }
}

@media (max-width: 560px) {
  .invoice-copy-item { flex-direction: column; align-items: stretch; }
  .invoice-copy-btn { width: 100%; }
}
