/* ==========================================================================
   Transporter TMS — application styles
   ========================================================================== */

:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef1f5;
  --border: #e2e7ef;
  --border-strong: #cbd3df;

  --text: #101828;
  --text-2: #475467;
  --muted: #667085;

  --sidebar: #0c2336;
  --sidebar-2: #12324c;
  --sidebar-text: #b9c7d6;
  --accent: #f5a524;
  --accent-ink: #1d1300;

  --primary: #1f5fbf;
  --primary-hover: #194e9e;
  --primary-soft: #e8f0fc;

  --success: #157f3b;
  --success-soft: #e3f5ea;
  --warning: #93560a;
  --warning-soft: #fff1d6;
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --info: #1f5fbf;
  --info-soft: #e8f0fc;
  --neutral: #475467;
  --neutral-soft: #eef1f5;

  --cash: #0f6e56;
  --cash-soft: #dff3ec;
  --credit: #5a3fb0;
  --credit-soft: #efeafc;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .07);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, monospace;
  --sidebar-w: 248px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; color: var(--text); }
p { margin: 0; }
small { font-size: 12px; }
code, .mono { font-family: var(--mono); font-size: .92em; }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }

.icon { width: 18px; height: 18px; flex: none; }
.icon-sm { width: 15px; height: 15px; flex: none; }
.icon-lg { width: 22px; height: 22px; flex: none; }

/* ----- App shell -------------------------------------------------------- */

.app { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--sidebar);
  color: var(--sidebar-text);
  display: flex; flex-direction: column;
  z-index: 40;
  overflow-y: auto;
}

.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 20px 18px;
  color: #fff;
  text-decoration: none !important;
}
.brand-mark {
  display: grid; place-items: center;
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
}
.brand-mark .icon { width: 22px; height: 22px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 16px; letter-spacing: .2px; }
.brand-text small { color: var(--sidebar-text); font-size: 11.5px; }

.nav { padding: 6px 12px 16px; display: flex; flex-direction: column; gap: 2px; }
.nav-section {
  margin: 16px 10px 6px;
  font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: #7f95ab;
}
.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--sidebar-text);
  font-weight: 500;
  text-decoration: none !important;
  position: relative;
}
.nav-link:hover { background: var(--sidebar-2); color: #fff; }
.nav-link.is-active { background: var(--sidebar-2); color: #fff; }
.nav-link.is-active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--accent);
}
.nav-link .nav-count {
  margin-left: auto; font-size: 11px; font-weight: 600;
  background: rgba(255,255,255,.1); color: #fff; padding: 1px 7px; border-radius: 999px;
}
.nav-link.nav-demo { color: var(--accent); }
.nav-link.nav-demo:hover, .nav-link.nav-demo.is-active { color: #ffc861; }

.sidebar-foot {
  margin-top: auto;
  padding: 14px 20px 18px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: 12px;
}
.sidebar-foot strong { display: block; color: #fff; font-size: 12.5px; }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 16px;
  height: 60px; padding: 0 28px;
  background: rgba(255,255,255,.92);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}
.menu-toggle { display: none; }
.global-search {
  position: relative; flex: 1; max-width: 440px;
}
.global-search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; }
.global-search input {
  width: 100%; height: 36px; padding: 0 12px 0 34px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2);
  font: inherit; color: var(--text);
}
.global-search input:focus { outline: none; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px var(--primary-soft); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar {
  display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
  font-weight: 700; font-size: 12px;
}
.user-chip .who { display: flex; flex-direction: column; line-height: 1.2; }
.user-chip .who small { color: var(--muted); }

.content { padding: 24px 28px 48px; width: 100%; max-width: 1360px; }

/* ----- Page header ------------------------------------------------------ */

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin-bottom: 20px;
}
.page-head h1 { font-size: 22px; font-weight: 700; letter-spacing: -.2px; }
.page-head .sub { color: var(--text-2); margin-top: 4px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--primary); }
.eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--primary);
}

/* ----- Buttons ---------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px;
  border: 1px solid transparent; border-radius: 8px;
  font: inherit; font-weight: 600; font-size: 13.5px; line-height: 1;
  cursor: pointer; white-space: nowrap;
  text-decoration: none !important;
  transition: background .15s, border-color .15s, box-shadow .15s, color .15s;
}
.btn .icon { width: 16px; height: 16px; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--primary-soft); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-accent { background: var(--accent); color: var(--accent-ink); }
.btn-accent:hover { background: #e79810; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #106a31; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #962017; }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); border-color: #b3bdcb; }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: #f3c1bd; }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 15px; }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px;
  border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text-2); cursor: pointer;
}
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--primary); cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

/* ----- Cards ------------------------------------------------------------ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.card-head h2, .card-head h3 { font-size: 15px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.card-head .hint { color: var(--muted); font-size: 12.5px; font-weight: 400; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main-side { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
.grid-side-main { grid-template-columns: 340px minmax(0, 1fr); align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wrap { flex-wrap: wrap; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.sticky { position: sticky; top: 76px; }

/* ----- KPI tiles -------------------------------------------------------- */

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.kpi { padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.kpi-label { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-weight: 600; font-size: 13px; }
.kpi-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--surface-3); color: var(--text-2); }
.kpi-icon .icon { width: 16px; height: 16px; }
.kpi-icon.tone-cash { background: var(--cash-soft); color: var(--cash); }
.kpi-icon.tone-credit { background: var(--credit-soft); color: var(--credit); }
.kpi-icon.tone-info { background: var(--info-soft); color: var(--info); }
.kpi-icon.tone-warning { background: var(--warning-soft); color: var(--warning); }
.kpi-value { font-size: 26px; font-weight: 700; letter-spacing: -.4px; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi-value .cur { font-size: 14px; font-weight: 600; color: var(--muted); margin-right: 4px; letter-spacing: 0; }
.kpi-meta { color: var(--muted); font-size: 12.5px; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.kpi-meta .text-danger { font-weight: 600; }
.kpi.is-flash { animation: kpi-flash 1.6s ease-out 1; }
@keyframes kpi-flash { 0% { box-shadow: 0 0 0 0 rgba(21,127,59,.45); background: var(--success-soft); } 100% { box-shadow: var(--shadow); background: var(--surface); } }

/* ----- Pipeline --------------------------------------------------------- */

.pipeline { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.pipe-step {
  padding: 16px 18px; position: relative;
  border-right: 1px solid var(--border);
  text-decoration: none !important; color: inherit;
}
.pipe-step:last-child { border-right: 0; }
.pipe-step:hover { background: var(--surface-2); }
.pipe-step .n { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pipe-step .l { font-weight: 600; color: var(--text); }
.pipe-step .d { color: var(--muted); font-size: 12px; }
.pipe-step:not(:last-child)::after {
  content: ""; position: absolute; right: -7px; top: 50%; width: 12px; height: 12px;
  background: #fff; border-top: 1px solid var(--border); border-right: 1px solid var(--border);
  transform: translateY(-50%) rotate(45deg); z-index: 1;
}
.pipe-step:hover::after { background: var(--surface-2); }
.pipe-bar { height: 4px; border-radius: 4px; margin-bottom: 12px; background: var(--surface-3); }
.pipe-bar.s-loaded { background: #98a2b3; }
.pipe-bar.s-cleared { background: var(--info); }
.pipe-bar.s-in_transit { background: var(--accent); }
.pipe-bar.s-delivered { background: var(--success); }

/* ----- Lists / attention ------------------------------------------------ */

.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.list > li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 600; }
.list .meta { color: var(--muted); font-size: 12.5px; }
.list a.row-link { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 12px; width: 100%; }
.list a.row-link:hover .title { color: var(--primary); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--muted); }
.dot.tone-danger { background: var(--danger); } .dot.tone-warning { background: var(--accent); }
.dot.tone-info { background: var(--info); } .dot.tone-success { background: var(--success); }
.count-pill {
  min-width: 28px; height: 24px; padding: 0 8px; border-radius: 999px;
  display: inline-grid; place-items: center;
  background: var(--surface-3); font-weight: 700; font-size: 12.5px; font-variant-numeric: tabular-nums;
}

/* ----- Aging bars ------------------------------------------------------- */

.aging { display: flex; flex-direction: column; gap: 12px; padding: 16px 18px; }
.aging-row { display: grid; grid-template-columns: 88px minmax(0, 1fr) 128px; align-items: center; gap: 12px; }
.aging-row .lbl { color: var(--text-2); font-size: 13px; }
.aging-row .amt { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; font-size: 13px; }
.bar-track { height: 10px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; background: #2a78d6; min-width: 0; }
.bar-fill.b1 { background: #86b6ef; }
.bar-fill.b2 { background: #3987e5; }
.bar-fill.b3 { background: #1c5cab; }
.bar-fill.b4 { background: #0d366b; }

.meter { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 4px; background: var(--primary); }
.meter.is-warning > span { background: var(--accent); }
.meter.is-danger > span { background: var(--danger); }

/* ----- Tables ----------------------------------------------------------- */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); background: var(--surface-2);
  padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fafbfd; }
.table tfoot td { background: var(--surface-2); font-weight: 700; border-top: 1px solid var(--border); border-bottom: 0; }
.table .doc-no { font-weight: 650; font-family: var(--mono); font-size: 13px; }
.table .sub { color: var(--muted); font-size: 12.5px; }
.table-compact td, .table-compact th { padding: 8px 12px; }
.row-click { cursor: pointer; }
.route { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.route .icon { width: 14px; height: 14px; color: var(--muted); }

.empty {
  text-align: center; padding: 40px 20px; color: var(--muted);
}
.empty .icon { width: 36px; height: 36px; color: #98a2b3; margin-bottom: 10px; }
.empty h3 { font-size: 15px; color: var(--text); margin-bottom: 4px; }
.empty .btn { margin-top: 14px; }

/* ----- Badges ----------------------------------------------------------- */

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--neutral-soft); color: var(--neutral);
}
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-neutral { background: var(--neutral-soft); color: var(--neutral); }
.badge-muted { background: var(--surface-3); color: var(--muted); }
.badge-cash { background: var(--cash-soft); color: var(--cash); }
.badge-credit { background: var(--credit-soft); color: var(--credit); }
.badge-lg { height: 28px; padding: 0 12px; font-size: 13px; }

/* ----- Filters / tabs --------------------------------------------------- */

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.toolbar .search { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.toolbar .search .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted); }
.toolbar .search input { padding-left: 32px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--border); background: #fff; color: var(--text-2);
  font-weight: 600; font-size: 12.5px; text-decoration: none !important;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.is-active { background: var(--text); border-color: var(--text); color: #fff; }
.chip .n { font-weight: 700; opacity: .7; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); padding: 0 12px; overflow-x: auto; }
.tab {
  appearance: none; border: 0; background: none; cursor: pointer;
  padding: 12px 10px; margin-bottom: -1px;
  font: inherit; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--primary); border-bottom-color: var(--primary); }
.tab .n { font-weight: 700; color: var(--muted); margin-left: 4px; font-size: 12px; }
.tab-panel[hidden] { display: none; }

/* ----- Forms ------------------------------------------------------------ */

.form-section { padding: 18px; border-bottom: 1px solid var(--border); }
.form-section:last-child { border-bottom: 0; }
.form-section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.step-num {
  display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: 12px; flex: none;
}
.form-section-head h3 { font-size: 14.5px; font-weight: 650; }
.form-section-head p { color: var(--muted); font-size: 12.5px; }

.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.fields-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-weight: 600; font-size: 13px; color: var(--text); }
.field .req { color: var(--danger); margin-left: 2px; }
.field .help { color: var(--muted); font-size: 12px; }
.field-error { color: var(--danger); font-size: 12.5px; font-weight: 500; }

.input, .select, .textarea {
  width: 100%; height: 38px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: 8px;
  background: #fff; color: var(--text);
  font: inherit; font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 76px; padding: 9px 12px; resize: vertical; }
.select {
  appearance: none; padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.input.is-invalid, .select.is-invalid, .textarea.is-invalid, .is-invalid .combo-input { border-color: var(--danger); }
.input[readonly] { background: var(--surface-2); color: var(--text-2); }
.input-lg { height: 46px; font-size: 18px; font-weight: 600; }

.input-group { display: flex; }
.input-group .input { border-radius: 8px 0 0 8px; min-width: 0; }
.input-group .select { width: auto; border-radius: 0 8px 8px 0; border-left: 0; background-color: var(--surface-2); font-weight: 600; }
.input-group .addon {
  display: grid; place-items: center; padding: 0 12px;
  border: 1px solid var(--border-strong); border-right: 0; border-radius: 8px 0 0 8px;
  background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: 13px;
}
.input-group .addon + .input { border-radius: 0 8px 8px 0; }
.convert { font-size: 12px; color: var(--muted); min-height: 18px; }

.choice-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.choice {
  position: relative; display: flex; gap: 12px; align-items: flex-start;
  padding: 14px; border: 1px solid var(--border-strong); border-radius: 10px; cursor: pointer; background: #fff;
}
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice .choice-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--surface-3); color: var(--text-2); flex: none; }
.choice strong { display: block; font-size: 14px; }
.choice span.d { color: var(--muted); font-size: 12.5px; }
.choice:hover { border-color: #9fb0c6; }
.choice:has(input:checked) { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.choice:has(input:checked) .choice-icon { background: var(--primary); color: #fff; }
.choice:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }

.segmented { display: inline-flex; padding: 3px; gap: 3px; border-radius: 10px; background: var(--surface-3); flex-wrap: wrap; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 8px;
  font-weight: 600; font-size: 13px; color: var(--text-2); cursor: pointer;
}
.segmented input:checked + span { background: #fff; color: var(--text); box-shadow: var(--shadow); }
.segmented input:focus-visible + span { outline: 2px solid var(--primary); }

.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }

.form-actions {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 14px 18px; border-top: 1px solid var(--border); background: var(--surface-2);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* Combobox */
.combo { position: relative; }
.combo-native { position: absolute !important; opacity: 0; pointer-events: none; height: 0 !important; width: 0 !important; }
.combo-input {
  width: 100%; height: 42px; padding: 0 36px 0 38px;
  border: 1px solid var(--border-strong); border-radius: 8px; font: inherit; font-size: 14.5px; background: #fff;
}
.combo-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.combo .combo-search { position: absolute; left: 12px; top: 13px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.combo-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20;
  max-height: 280px; overflow-y: auto; margin: 0; padding: 4px; list-style: none;
  background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg);
}
.combo-option { display: flex; justify-content: space-between; gap: 12px; padding: 9px 10px; border-radius: 7px; cursor: pointer; }
.combo-option.is-active, .combo-option:hover { background: var(--primary-soft); }
.combo-option[aria-selected="true"] .combo-label { color: var(--primary); }
.combo-label { font-weight: 600; }
.combo-meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
.combo-empty { padding: 10px; color: var(--muted); }

/* ----- Alerts / flashes ------------------------------------------------- */

.flashes { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: 10px; border: 1px solid;
  font-weight: 500;
}
.alert .icon { margin-top: 1px; }
.alert .grow { flex: 1; }
.alert-success { background: var(--success-soft); border-color: #b5e2c5; color: #0e5a2a; }
.alert-error { background: var(--danger-soft); border-color: #f6c4bf; color: #8f1d14; }
.alert-info { background: var(--info-soft); border-color: #c3d6f5; color: #173f80; }
.alert-warning { background: var(--warning-soft); border-color: #f5d9a3; color: #6e4007; }
.alert .close { background: none; border: 0; cursor: pointer; color: inherit; opacity: .6; padding: 0; }
.alert .close:hover { opacity: 1; }

.callout {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px; border-radius: 10px; background: var(--surface-2); border: 1px dashed var(--border-strong);
  color: var(--text-2); font-size: 13px;
}
.callout .icon { color: var(--primary); margin-top: 1px; }
.callout strong { color: var(--text); }

/* ----- Detail lists ----------------------------------------------------- */

.dl { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 9px 14px; margin: 0; }
.dl dt { color: var(--muted); font-size: 13px; }
.dl dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }

.stat-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat-strip > div { padding: 16px 18px; border-right: 1px solid var(--border); }
.stat-strip > div:last-child { border-right: 0; }
.stat-strip .l { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.stat-strip .v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }

/* ----- Customer billing card (loading sheet) ---------------------------- */

.billing-card { padding: 16px 18px; }
.billing-card .name { font-size: 16px; font-weight: 700; }
.billing-card .dl { grid-template-columns: 110px minmax(0, 1fr); font-size: 13px; gap: 7px 12px; }
.billing-card .terms-note {
  margin-top: 14px; padding: 10px 12px; border-radius: 8px; font-size: 12.5px; font-weight: 500;
}
.terms-note.is-cash { background: var(--cash-soft); color: #0b5443; }
.terms-note.is-credit { background: var(--credit-soft); color: #45308a; }
.billing-empty { padding: 26px 18px; text-align: center; color: var(--muted); }
.billing-empty .icon { width: 28px; height: 28px; color: #98a2b3; margin-bottom: 6px; }
.is-populated { animation: populate .7s ease-out 1; }
@keyframes populate { from { background: #fff8e6; } to { background: transparent; } }

.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.checklist li { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; }
.checklist li .icon { width: 17px; height: 17px; color: #b7c0cc; }
.checklist li.is-done { color: var(--text); }
.checklist li.is-done .icon { color: var(--success); }
.checklist li.is-error { color: var(--danger); }
.checklist li.is-error .icon { color: var(--danger); }

.next-no {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px; border-radius: 10px; background: var(--sidebar); color: #fff;
}
.next-no small { color: var(--sidebar-text); display: block; font-size: 11.5px; }
.next-no .no { font-family: var(--mono); font-size: 17px; font-weight: 700; color: var(--accent); }

.quote-box { padding: 14px 18px; }
.quote-line { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; padding: 4px 0; color: var(--text-2); font-variant-numeric: tabular-nums; }
.quote-line.is-applied { color: var(--text); font-weight: 650; }
.quote-line.is-applied > span:first-child::before { content: "✓ "; color: var(--success); }
.quote-total { display: flex; justify-content: space-between; align-items: baseline; padding-top: 10px; margin-top: 6px; border-top: 1px dashed var(--border-strong); }
.quote-total .v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }

.warn-line { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; color: var(--warning); font-weight: 500; }

/* ----- Freight calculation (invoice create) ----------------------------- */

.calc-table { width: 100%; border-collapse: collapse; }
.calc-table th, .calc-table td { padding: 11px 14px; border-bottom: 1px solid var(--border); text-align: left; }
.calc-table th { font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); background: var(--surface-2); }
.calc-table td.num, .calc-table th.num { text-align: right; }
.calc-table tr.is-applied td { background: #f1f8f3; font-weight: 650; }
.calc-table tr.is-applied td:first-child { box-shadow: inset 3px 0 0 var(--success); }
.calc-formula { font-family: var(--mono); font-size: 12.5px; color: var(--text-2); }
.applied-tag { display: inline-flex; align-items: center; gap: 4px; color: var(--success); font-size: 12px; font-weight: 700; }

.totals { display: flex; flex-direction: column; gap: 8px; padding: 16px 18px; }
.totals .line { display: flex; justify-content: space-between; gap: 10px; font-variant-numeric: tabular-nums; }
.totals .line span:first-child { color: var(--text-2); }
.totals .grand { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 4px; font-size: 20px; font-weight: 700; }
.totals .grand span:first-child { color: var(--text); }

.extra-row { display: grid; grid-template-columns: minmax(0, 1fr) 170px 36px; gap: 8px; margin-bottom: 8px; }

/* ----- Status timeline -------------------------------------------------- */

.timeline { list-style: none; margin: 0; padding: 4px 0; }
.timeline li { position: relative; display: flex; gap: 12px; padding: 0 0 16px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; left: 11px; top: 24px; bottom: 0; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline .t-dot {
  width: 24px; height: 24px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--surface-3); color: #98a2b3; position: relative; z-index: 1;
}
.timeline .t-dot .icon { width: 13px; height: 13px; }
.timeline li.is-done .t-dot { background: var(--success); color: #fff; }
.timeline li.is-current .t-dot { background: var(--accent); color: var(--accent-ink); box-shadow: 0 0 0 4px #fdecc8; }
.timeline .t-title { font-weight: 600; }
.timeline .t-meta { color: var(--muted); font-size: 12.5px; }
.timeline li:not(.is-done):not(.is-current) .t-title { color: var(--muted); font-weight: 500; }

/* ----- Dialog ----------------------------------------------------------- */

dialog.modal {
  width: min(520px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: 14px;
  box-shadow: var(--shadow-lg); color: var(--text);
}
dialog.modal::backdrop { background: rgba(12, 35, 54, .5); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 16px; }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); }
.pay-summary { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.pay-summary .v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ----- Banners ---------------------------------------------------------- */

.banner {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px 18px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid;
}
.banner .grow { flex: 1; min-width: 220px; }
.banner strong { display: block; font-size: 14.5px; }
.banner.is-cash { background: var(--cash-soft); border-color: #aeddcd; color: #0b4f3f; }
.banner.is-credit { background: var(--credit-soft); border-color: #d5caf5; color: #3c2a7c; }
.banner.is-success { background: var(--success-soft); border-color: #b5e2c5; color: #0e5a2a; }
.banner.is-warning { background: var(--warning-soft); border-color: #f5d9a3; color: #6e4007; }
.banner-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: rgba(255,255,255,.7); flex: none; }

/* ----- Documents (loading sheet, invoice, receipt) ---------------------- */

.doc {
  background: #fff; color: #111;
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 36px 40px; font-size: 13px;
}
.doc-head { display: flex; justify-content: space-between; gap: 24px; padding-bottom: 20px; border-bottom: 3px solid var(--sidebar); }
.doc-company { display: flex; gap: 14px; }
.doc-logo { display: grid; place-items: center; width: 50px; height: 50px; border-radius: 12px; background: var(--sidebar); color: var(--accent); flex: none; }
.doc-logo .icon { width: 28px; height: 28px; }
.doc-company h2 { font-size: 19px; letter-spacing: -.2px; }
.doc-company .tag { color: #555; font-size: 12px; margin-bottom: 4px; }
.doc-company .info { color: #444; font-size: 12px; line-height: 1.55; }
.doc-title { text-align: right; }
.doc-title .kind { font-size: 11.5px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: #555; }
.doc-title .no { font-family: var(--mono); font-size: 24px; font-weight: 800; letter-spacing: .5px; color: #111; margin: 2px 0 6px; }
.doc-title .barcode { display: block; margin-left: auto; max-width: 100%; height: 40px; }
.doc-title .stamp { margin-top: 8px; }

.doc-meta { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; margin: 20px 0; border: 1px solid #d6dbe3; border-radius: 8px; }
.doc-meta > div { padding: 10px 12px; border-right: 1px solid #d6dbe3; }
.doc-meta > div:last-child { border-right: 0; }
.doc-meta .l { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #667085; }
.doc-meta .v { font-weight: 650; margin-top: 2px; }

.doc-parties { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.doc-box { border: 1px solid #d6dbe3; border-radius: 8px; padding: 12px 14px; }
.doc-box .l { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #667085; margin-bottom: 6px; }
.doc-box .name { font-weight: 700; font-size: 14px; }
.doc-box .lines { color: #333; line-height: 1.55; }

.doc-route { display: grid; grid-template-columns: minmax(0, 1fr) 60px minmax(0, 1fr); align-items: center; gap: 10px; margin-bottom: 18px; }
.doc-route .doc-box { height: 100%; }
.doc-route .arrow { display: grid; place-items: center; color: #98a2b3; }
.doc-route .arrow .icon { width: 28px; height: 28px; }
.doc-route .place { font-size: 17px; font-weight: 800; }

.doc-cargo { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.doc-cargo .doc-box .v { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.doc-cargo .doc-box .s { color: #667085; font-size: 12px; }

.doc-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.doc-table th { text-align: left; font-size: 10.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #fff; background: var(--sidebar); padding: 8px 10px; }
.doc-table th:first-child { border-radius: 6px 0 0 0; } .doc-table th:last-child { border-radius: 0 6px 0 0; }
.doc-table td { padding: 10px; border-bottom: 1px solid #e3e7ee; vertical-align: top; }
.doc-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.doc-totals { margin-left: auto; width: 300px; }
.doc-totals .line { display: flex; justify-content: space-between; padding: 6px 0; font-variant-numeric: tabular-nums; }
.doc-totals .grand { border-top: 2px solid #111; margin-top: 4px; padding-top: 10px; font-size: 17px; font-weight: 800; }
.doc-totals .due { color: var(--danger); font-weight: 700; }

.doc-notes { margin-top: 18px; padding: 12px 14px; background: #f7f8fa; border-radius: 8px; color: #333; font-size: 12px; line-height: 1.55; }
.doc-notes strong { color: #111; }

.doc-signs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; margin-top: 30px; }
.sign .line { border-bottom: 1px solid #333; height: 36px; }
.sign .l { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #555; margin-top: 6px; }
.sign .s { font-size: 11.5px; color: #667085; }

.doc-foot { margin-top: 26px; padding-top: 12px; border-top: 1px solid #e3e7ee; display: flex; justify-content: space-between; gap: 12px; color: #667085; font-size: 11px; }

.stamp-mark {
  display: inline-block; padding: 4px 12px; border: 2.5px solid; border-radius: 6px;
  font-weight: 900; font-size: 15px; letter-spacing: .14em; text-transform: uppercase; transform: rotate(-4deg);
}
.stamp-mark.is-paid { color: var(--success); }
.stamp-mark.is-unpaid, .stamp-mark.is-partial { color: var(--warning); }
.stamp-mark.is-overdue { color: var(--danger); }

.receipt-amount { margin: 22px 0; padding: 18px 20px; border-radius: 10px; background: #f3f8f5; border: 1px solid #cfe7d8; display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.receipt-amount .v { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; }
.receipt-amount .words { color: #333; font-style: italic; }

/* ----- Demo script ------------------------------------------------------ */

.demo-hero {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 22px 24px; border-radius: 14px; margin-bottom: 18px;
  background: linear-gradient(120deg, #0c2336 0%, #173d5d 100%); color: #dfe8f1;
}
.demo-hero h1 { color: #fff; font-size: 22px; }
.demo-hero p { color: #b9c7d6; margin-top: 4px; max-width: 640px; }
.demo-hero .grow { flex: 1; min-width: 260px; }
.progress-ring { display: flex; align-items: center; gap: 12px; }
.progress-ring .big { font-size: 34px; font-weight: 800; color: #fff; font-variant-numeric: tabular-nums; }
.progress-track { width: 180px; height: 8px; border-radius: 4px; background: rgba(255,255,255,.14); overflow: hidden; }
.progress-track span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }

.phase { margin-bottom: 18px; }
.phase-head { display: flex; align-items: baseline; gap: 10px; margin: 0 2px 10px; }
.phase-head .eyebrow { color: var(--muted); }
.phase-head h2 { font-size: 16px; }

.demo-step { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 16px; padding: 18px; align-items: start; }
.demo-step + .demo-step { border-top: 1px solid var(--border); }
.demo-step .n {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; background: var(--surface-3); color: var(--text-2);
}
.demo-step.is-done .n { background: var(--success); color: #fff; }
.demo-step.is-next .n { background: var(--accent); color: var(--accent-ink); box-shadow: 0 0 0 5px #fdecc8; }
.demo-step h3 { font-size: 15px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.demo-step .module { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.demo-step .say {
  margin-top: 10px; padding: 10px 12px; border-left: 3px solid var(--accent); background: #fffaf0;
  border-radius: 0 8px 8px 0; color: #5a4210; font-size: 13px;
}
.demo-step .say b { color: #3d2c06; }
.demo-step .result { margin-top: 8px; font-size: 12.5px; color: var(--success); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.demo-step .actions { display: flex; flex-direction: column; gap: 6px; align-items: stretch; min-width: 170px; }

/* ----- Auth ------------------------------------------------------------- */

.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.auth-side {
  background: linear-gradient(150deg, #0c2336 0%, #16405f 100%); color: #c8d5e2;
  padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
}
.auth-side h1 { color: #fff; font-size: 32px; letter-spacing: -.5px; max-width: 460px; }
.auth-side p { max-width: 460px; margin-top: 12px; font-size: 15px; }
.auth-flow { display: flex; flex-direction: column; gap: 14px; margin-top: 36px; max-width: 440px; }
.auth-flow div { display: flex; gap: 12px; align-items: flex-start; }
.auth-flow .i { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: rgba(245,165,36,.16); color: var(--accent); flex: none; }
.auth-flow strong { color: #fff; display: block; }
.auth-main { display: grid; place-items: center; padding: 32px 16px; background: var(--bg); }
.auth-card { width: min(400px, 100%); }
.auth-card h2 { font-size: 22px; margin-bottom: 4px; }
.demo-creds { margin-top: 16px; padding: 12px 14px; border-radius: 10px; background: #fffaf0; border: 1px solid #f5d9a3; font-size: 13px; color: #5a4210; }
.demo-creds code { background: #fff; padding: 1px 6px; border-radius: 4px; border: 1px solid #f0dcb4; }

/* ----- Pagination ------------------------------------------------------- */

.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--border); }
.pagination-info { margin-right: auto; color: var(--muted); font-size: 12.5px; }

/* ----- Print layout ----------------------------------------------------- */

.print-body { background: #e9edf2; }
.print-toolbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 20px; background: var(--sidebar); color: #fff;
}
.print-toolbar .title { font-weight: 600; }
.paper { width: 210mm; max-width: calc(100% - 32px); margin: 24px auto 48px; }
.paper .doc { border-radius: 4px; box-shadow: 0 4px 20px rgba(16,24,40,.12); }

@media print {
  @page { size: A4; margin: 12mm; }
  body, .print-body { background: #fff; }
  .no-print, .print-toolbar, .sidebar, .topbar, .flashes { display: none !important; }
  .paper { width: auto; max-width: none; margin: 0; }
  .doc, .paper .doc { border: 0; box-shadow: none; padding: 0; border-radius: 0; }
  .doc-table th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .doc-logo, .doc-head, .receipt-amount, .stamp-mark { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  a { color: inherit; }
}

/* ----- Responsive ------------------------------------------------------- */

@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main-side, .grid-side-main { grid-template-columns: minmax(0, 1fr); }
  .sticky { position: static; }
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  .sidebar.is-open { transform: none; }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-grid; }
  .topbar { padding: 0 16px; }
  .content { padding: 18px 16px 40px; }
  .user-chip .who { display: none; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .pipeline { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pipe-step:nth-child(2) { border-right: 0; }
  .pipe-step:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
  .pipe-step::after { display: none; }
  .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-strip > div:nth-child(2) { border-right: 0; }
  .stat-strip > div:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
  .auth-wrap { grid-template-columns: minmax(0, 1fr); }
  .auth-side { display: none; }
  .doc { padding: 20px; }
  .doc-head { flex-direction: column; }
  .doc-title { text-align: left; }
  .doc-title .barcode { margin-left: 0; }
  .doc-meta, .doc-cargo { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .doc-meta > div:nth-child(2) { border-right: 0; }
  .doc-meta > div:nth-child(-n+2) { border-bottom: 1px solid #d6dbe3; }
  .doc-parties, .doc-signs { grid-template-columns: minmax(0, 1fr); }
  .doc-route { grid-template-columns: minmax(0, 1fr); }
  .doc-route .arrow { transform: rotate(90deg); height: 30px; }
  .doc-totals { width: 100%; }
  .demo-step { grid-template-columns: 40px minmax(0, 1fr); }
  .demo-step .actions { grid-column: 2; min-width: 0; }
}

@media (max-width: 600px) {
  .kpis { grid-template-columns: minmax(0, 1fr); }
  .fields, .fields-3 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .choice-cards { grid-template-columns: minmax(0, 1fr); }
  .global-search { display: none; }
  .aging-row { grid-template-columns: 70px minmax(0, 1fr) 100px; }
  .extra-row { grid-template-columns: minmax(0, 1fr) 110px 36px; }
  .dl { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .dl dd { margin-bottom: 8px; }
}

/* ----- Users & roles ---------------------------------------------------- */

.user-link { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none !important; border-radius: 8px; padding: 2px 6px 2px 2px; }
.user-link:hover { background: var(--surface-3); }
.role-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.role-cards.is-invalid .choice { border-color: var(--danger); }
.role-matrix th.c, .role-matrix td.c { text-align: center; }
.role-matrix .yes { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--success-soft); color: var(--success); }
.role-matrix .no { color: #b7c0cc; }
.readonly-note { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 12.5px; }
@media (max-width: 600px) { .role-cards { grid-template-columns: minmax(0, 1fr); } }

/* ----- Vendor credit ---------------------------------------------------- */

.powered { font-size: 12px; color: var(--muted); }
.powered a { color: inherit; font-weight: 600; text-decoration: none; }
.powered a:hover { color: var(--primary); text-decoration: underline; }
.powered-sidebar { display: block; margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,.08); color: #7f95ab; font-size: 11.5px; }
.powered-sidebar a { color: var(--accent); }
.powered-sidebar a:hover { color: #ffc861; }
.powered-dark { color: #9fb2c5; font-size: inherit; }
.powered-dark a { color: var(--accent); }
.powered-dark a:hover { color: #ffc861; }
.auth-powered { display: none; margin-top: 18px; text-align: center; }
.doc-powered { margin-top: 10px; text-align: center; font-size: 10.5px; letter-spacing: .04em; color: #98a2b3; }
.doc-powered a { color: inherit; font-weight: 600; text-decoration: none; }
@media (max-width: 900px) { .auth-powered { display: block; } }
