/* LMFM theme — "Arovehic Dispatch Desk" design system (compact, professional).
   Shared by every page. Look only: no IDs or behaviour live here. */

:root {
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f4f6fb;
  --ring: 0 0 0 3px rgba(37, 99, 235, .15);
  --shadow-card: 0 1px 2px rgba(15, 23, 42, .04), 0 6px 18px rgba(15, 23, 42, .04);
  --shadow-menu: 0 12px 32px rgba(15, 23, 42, .14);
}

html { font-size: 14px; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  padding-bottom: 112px;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-weight: 500; font-size: 12.5px; }

/* Visibility helpers. JS toggles "hidden"; it must always win over component display rules. */
.hidden, .hidden-view { display: none !important; }

@keyframes lm-fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255, 255, 255, .9);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid #e2e8f0;
}
.topbar-in {
  max-width: 1152px; margin: 0 auto; height: 56px; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand > div:last-child { min-width: 0; }
.brand-logo {
  width: 36px; height: 36px; border-radius: 12px; flex: none; overflow: hidden;
  background: #fff; border: 1px solid var(--line);
  display: grid; place-items: center;
  box-shadow: 0 2px 6px rgba(15, 23, 42, .08);
}
.brand-logo img { width: 100%; height: 100%; object-fit: contain; padding: 2px; }
.brand-logo svg { width: 19px; height: 19px; }
.brand-name { font-size: 15px; font-weight: 700; line-height: 1.15; letter-spacing: -.01em; }
.brand-sub { font-size: 11.5px; font-weight: 500; color: #64748b; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: 8px; min-width: 0; flex-shrink: 1; }
@media (max-width: 639px) {
  .topbar-right .pill { max-width: 46vw; overflow: hidden; text-overflow: ellipsis; display: inline-block; }
  .topbar-right .pill::before { display: inline-block; margin-right: 6px; vertical-align: 1px; }
}
.date-pill {
  background: #f1f5f9; color: #475569; border-radius: 9999px;
  font-size: 14px; padding: 4px 12px; white-space: nowrap;
}
@media (max-width: 639px) { .date-pill { display: none; } }

/* ---------- Page ---------- */
.page { max-width: 1152px; margin: 0 auto; padding: 24px; animation: lm-fade .18s ease-out; }
.page > * + * { margin-top: 16px; }
@media (max-width: 639px) {
  .topbar-in, .page { padding-left: 16px; padding-right: 16px; }
}
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head-left { display: flex; align-items: center; gap: 10px; min-width: 0; flex-wrap: wrap; }
.page-head-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page-title { font-size: 20px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }

.count-pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600; border-radius: 9999px; padding: 3px 10px;
  background: #fef3c7; color: #92400e; white-space: nowrap;
}
.count-pill:empty { display: none; }
.cp-completed { background: #d1fae5; color: #065f46; }
.cp-returning { background: #ffedd5; color: #9a3412; }
.cp-in_transit { background: #dbeafe; color: #1e40af; }
.cp-risk { background: #fee2e2; color: #991b1b; }
.cp-brand { background: #e0ecff; color: var(--brand-dark); }

/* ---------- Back button + breadcrumb ---------- */
.back-btn {
  width: 38px; height: 38px; border-radius: 11px; flex: none; display: grid; place-items: center;
  background: #fff; border: 1px solid var(--line); color: #475569; box-shadow: var(--shadow-card);
  transition: border-color .15s, color .15s, box-shadow .15s, background-color .15s;
}
.back-btn svg { width: 17px; height: 17px; transition: transform .15s; }
.back-btn:hover { border-color: #c7d7fe; color: var(--brand); background: #f8fbff; }
.back-btn:hover svg { transform: translateX(-3px); }
.back-btn:active { transform: translateY(1px); }
.back-btn:focus-visible { outline: none; box-shadow: var(--ring); border-color: var(--brand); }
.title-stack { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.crumb {
  display: inline-flex; align-items: center; gap: 2px; align-self: flex-start;
  font-size: 11.5px; font-weight: 600; color: var(--muted); line-height: 1.2; transition: color .15s;
}
.crumb svg { width: 13px; height: 13px; transition: transform .15s; }
.crumb:hover { color: var(--brand); }
.crumb:hover svg { transform: translateX(-2px); }
.back-btn:hover + .title-stack .crumb { color: var(--brand); }
/* Breadcrumb on its own (no title under it): bigger, centred next to the back button */
.title-stack:has(> .crumb:only-child) { justify-content: center; }
.title-stack > .crumb:only-child { font-size: 15px; font-weight: 600; color: #334155; gap: 3px; }
.title-stack > .crumb:only-child svg { display: none; }
.title-stack > .crumb:only-child:hover, .back-btn:hover + .title-stack > .crumb:only-child { color: var(--brand); }

/* ---------- Cards ---------- */
.card { background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-card); }
.card-body { padding: 20px 24px; }
.card-foot {
  border-top: 1px solid #f1f5f9; background: rgba(248, 250, 252, .6);
  padding: 14px 24px; border-radius: 0 0 14px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.toolbar { padding: 14px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
/* Three-column toolbar (COD list): Filter | centred amount | dates */
.toolbar-3 { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.toolbar-3 > :first-child { justify-self: start; }
@media (max-width: 639px) { .toolbar-3 { grid-template-columns: 1fr; } .toolbar-3 > .text-right { text-align: left; } }
.toolbar-3 > .seg { justify-self: center; }
@media (max-width: 639px) { .toolbar-3 > .seg { justify-self: start; } }
/* Centre block of the 3-column toolbar (count / amount) keeps its original sizes */
.toolbar-3 > .text-center .text-xs { font-size: 12px; line-height: 16px; }
.toolbar-3 > .text-center .text-2xl { font-size: 24px; line-height: 32px; }
@media (max-width: 639px) { .toolbar-3 > .text-center { text-align: left; } }
@media (max-width: 639px) { .card-body { padding: 18px 16px; } .toolbar { padding: 12px 16px; } }

.kpi-label, .label {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted);
}
.label { display: block; margin-bottom: 6px; }
.kpi-value { font-size: 22px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.meta { font-size: 12.5px; color: var(--muted); }
.meta b, .meta strong { color: #334155; font-weight: 600; }
.section-title { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: 16px; }

/* ---------- Form fields ---------- */
.input {
  height: 40px; border-radius: 9px; border: 1px solid #cbd5e1; background: #fff;
  font-size: 14px; padding: 0 12px; color: var(--ink); width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: #94a3b8; }
.input:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.input-36 { height: 36px; }
select.input {
  -webkit-appearance: none; appearance: none; cursor: pointer; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' 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 11px center; background-size: 14px;
}
.search { position: relative; }
.search > svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: #94a3b8; pointer-events: none; }
.search > .input { padding-left: 36px; }
.search-w { width: 280px; }
@media (max-width: 639px) { .search-w { width: 100%; } .page-head-right { width: 100%; } .page-head-right .search { flex: 1 1 100%; } }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; color: #475569; font-weight: 500; cursor: pointer; white-space: nowrap; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 40px; padding: 0 16px; border-radius: 9px; border: 1px solid transparent;
  font-size: 14px; font-weight: 600; white-space: nowrap; cursor: pointer;
  transition: background-color .15s, border-color .15s, box-shadow .15s, color .15s;
}
.btn svg { width: 15px; height: 15px; flex: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn-36 { height: 36px; padding: 0 13px; }
.btn-34 { height: 34px; padding: 0 12px; font-size: 13px; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(37, 99, 235, .25); }
.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:disabled { background: #bfd3fb; box-shadow: none; cursor: not-allowed; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-danger:disabled { background: #f6b7b7; }
.btn-outline-danger { background: #fff; color: #dc2626; border-color: #fecaca; }
.btn-outline-danger:hover { background: #fef2f2; }
.btn-ghost { background: #fff; color: #334155; border-color: var(--line); }
.btn-ghost:hover { background: #f8fafc; border-color: #cbd5e1; }
.btn-ghost .ico-brand { color: var(--brand); }
.btn .chev { width: 14px; height: 14px; color: #94a3b8; transition: transform .15s; }
.btn-link { font-size: 13px; font-weight: 600; color: var(--brand); display: inline-flex; align-items: center; gap: 4px; }
.btn-link:hover { color: var(--brand-dark); }
.btn-link svg { width: 14px; height: 14px; }

/* An open menu's button: brand border + ring, chevron flipped (no JS needed) */
.menu-wrap { position: relative; }
.menu-wrap:has(> .menu:not(.hidden)) > .btn { border-color: var(--brand); box-shadow: var(--ring); }
.menu-wrap:has(> .menu:not(.hidden)) > .btn .chev { transform: rotate(180deg); }

/* ---------- Status pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; font-weight: 500; border-radius: 9999px; padding: 4px 11px; white-space: nowrap;
}
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 9999px; background: currentColor; flex: none; opacity: .9; }
.pill:empty { display: none; }
.pill-ok { background: #ecfdf5; color: #047857; }
.pill-error { background: #fef2f2; color: #b91c1c; }
.pill-warn { background: #fffbeb; color: #b45309; }
.pill-info { background: #f1f5f9; color: #475569; }
/* Long messages: same colours, box shape so the text can wrap */
.note {
  display: flex; align-items: flex-start; gap: 9px;
  font-size: 13px; font-weight: 500; line-height: 1.45; border-radius: 10px; padding: 9px 12px;
}
.note::before { content: ""; width: 8px; height: 8px; border-radius: 9999px; background: currentColor; flex: none; margin-top: 5px; }
.note:empty { display: none; }
.note-info { background: #f1f5f9; color: #475569; }
.note-warn { background: #fffbeb; color: #b45309; }
.note-error { background: #fef2f2; color: #b91c1c; }

/* ---------- Segmented control (courier tabs, time range) ---------- */
.seg { display: inline-flex; background: #eef1f6; border-radius: 10px; padding: 3px; gap: 2px; }
.seg-btn {
  height: 32px; padding: 0 14px; border-radius: 8px; font-size: 13.5px; font-weight: 600; color: #64748b;
  transition: background-color .15s, color .15s, box-shadow .15s; white-space: nowrap;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.is-active { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(15, 23, 42, .08), 0 1px 0 rgba(15, 23, 42, .04); }
.seg-full { display: grid; grid-template-columns: repeat(5, 1fr); width: 100%; }
.seg-full .seg-btn { padding: 0 6px; font-size: 12.5px; height: 30px; }
@media (max-width: 639px) { .seg-scroll { overflow-x: auto; max-width: 100%; } }

/* ---------- Menus / popovers ---------- */
.menu {
  position: absolute; z-index: 40; background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 5px; box-shadow: var(--shadow-menu); animation: lm-fade .18s ease-out;
}
.menu-below-right { right: 0; top: calc(100% + 6px); }
.menu-below-left { left: 0; top: calc(100% + 6px); }
.menu-above-right { right: 0; bottom: calc(100% + 8px); }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 8px 10px; border-radius: 9px; transition: background-color .15s;
}
.menu-item:hover, .menu-item:focus-visible { background: #f1f5f9; outline: none; }
.menu-ico { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; flex: none; background: #eff6ff; color: var(--brand); }
.menu-ico svg { width: 16px; height: 16px; }
.menu-label { display: block; font-size: 14px; font-weight: 600; color: var(--ink); line-height: 1.25; }
.menu-hint { display: block; font-size: 12.5px; color: var(--muted); line-height: 1.3; margin-top: 1px; }
.menu-note { font-size: 12px; color: #94a3b8; padding: 6px 10px 4px; border-top: 1px solid #f1f5f9; margin-top: 4px; }
.popover { padding: 16px; width: 360px; max-width: calc(100vw - 32px); }

/* ---------- Tables ---------- */
.table-card { overflow: hidden; }
.table-scroll { overflow: auto; max-height: calc(100vh - 340px); min-height: 220px; }
.tbl { min-width: 100%; font-size: 13.5px; border-collapse: separate; border-spacing: 0; }
.tbl thead th {
  position: sticky; top: 0; z-index: 1; background: #f8fafc; text-align: left; white-space: nowrap;
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted);
  padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: bottom;
}
.tbl tbody td { padding: 12px; border-top: 1px solid #f1f5f9; color: #334155; vertical-align: top; }
.tbl tbody tr:first-child td { border-top: 0; }
.tbl tbody tr:hover td { background: #fafcff; }
.tbl td.nowrap { white-space: nowrap; }
.tbl td.wrap { min-width: 12rem; }
.tbl td.wide { min-width: 16rem; }
.tbl .strong { font-weight: 700; color: var(--ink); }
.tbl td.muted { color: var(--muted); }
.tbl tr.state-row td, .tbl tr.state-row:hover td { background: #fff; }

.chip { display: inline-flex; align-items: center; border-radius: 6px; font-size: 12px; font-weight: 600; padding: 2px 8px; white-space: nowrap; }
.chip-month { background: #eef2ff; color: #4338ca; }
.chip-completed { background: #ecfdf5; color: #047857; }
.chip-returning { background: #fff7ed; color: #c2410c; }
.chip-in_transit { background: #eff6ff; color: #1d4ed8; }
.chip-risk { background: #fef2f2; color: #b91c1c; }
.chip-missing { background: #fffbeb; color: #b45309; }
.chip-plain { background: #f1f5f9; color: #475569; }

/* Empty / loading / error state inside a table */
.empty { padding: 40px 16px; text-align: center; position: sticky; left: 0; max-width: calc(100vw - 34px); }
@media (min-width: 1200px) { .empty { max-width: 1102px; } }
.empty-ico { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; margin: 0 auto 12px; background: #ecfdf5; color: #059669; }
.empty-ico svg { width: 26px; height: 26px; }
.empty-ico.is-error { background: #fef2f2; color: #dc2626; }
.empty-title { font-size: 14.5px; font-weight: 700; color: var(--ink); }
.empty-sub { font-size: 13px; color: var(--muted); margin-top: 3px; }
.loading { padding: 36px 16px; text-align: center; color: var(--muted); font-size: 13.5px; }
.table-foot { font-size: 14px; color: #64748b; padding: 0 2px; }

/* ---------- Category rows (Home / COD) ---------- */
.cat-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 14px; border-radius: 11px; border: 1px solid var(--line); background: #fff;
  transition: background-color .15s, border-color .15s, box-shadow .15s;
}
.cat-row:hover { background: #fafcff; border-color: #c7d7fe; box-shadow: 0 2px 8px rgba(37, 99, 235, .06); }
.cat-row .dot { width: 10px; height: 10px; border-radius: 9999px; flex: none; }
.cat-name { font-size: 14px; font-weight: 600; color: var(--ink); line-height: 1.25; }
.cat-sub { font-size: 12.5px; color: var(--muted); }
.cat-pct { font-size: 14px; font-weight: 700; }
.cat-row .arrow { width: 15px; height: 15px; color: #94a3b8; }
.donut-center-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.donut-center-value { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.donut-center-sub { font-size: 12px; color: #94a3b8; }

/* ---------- Exception filter tiles ---------- */
.xtile {
  display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 8px 0 12px;
  border-radius: 9px; border: 1px solid var(--line); background: #fff;
  font-size: 13px; font-weight: 600; color: #334155;
  transition: background-color .15s, border-color .15s, color .15s;
}
.xtile:hover { background: #f8fafc; border-color: #cbd5e1; }
.xtile-n { background: #f1f5f9; color: #475569; border-radius: 9999px; font-size: 11.5px; font-weight: 700; padding: 1px 8px; }
.xtile.is-active { background: #eff6ff; border-color: var(--brand); color: var(--brand-dark); }
.xtile.is-active .xtile-n { background: var(--brand); color: #fff; }

/* ---------- Floating bottom navigation ---------- */
.bnav { position: fixed; left: 0; right: 0; bottom: 18px; z-index: 40; display: flex; justify-content: center; pointer-events: none; }
.bnav-in {
  position: relative; pointer-events: auto; display: flex; align-items: center; gap: 2px;
  background: rgba(255, 255, 255, .96); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: 14px; padding: 5px; box-shadow: 0 10px 28px rgba(15, 23, 42, .14);
}
.bnav-item {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 18px; border-radius: 10px;
  font-size: 13.5px; font-weight: 600; color: #475569; transition: background-color .15s, color .15s;
}
.bnav-item svg { width: 16px; height: 16px; }
.bnav-item:hover { background: #f1f5f9; color: var(--ink); }
.bnav-item.is-active { background: #eff6ff; color: var(--brand-dark); }
.bnav-item .chev { width: 14px; height: 14px; transition: transform .15s; }
.bnav-in:has(> .menu:not(.hidden)) > #more-btn .chev { transform: rotate(180deg); }
.bnav-in:has(> .menu:not(.hidden)) > #more-btn { background: #f1f5f9; color: var(--ink); }
.bnav .menu { width: 250px; }
@media (max-width: 420px) { .bnav-item { padding: 8px 12px; } }
