/* Nexum Entregas — shared look for the panel, the portal and the courier app. */

:root {
  --bg: #eef2f6;
  --card: #ffffff;
  --card-2: #f6f8fb;
  --ink: #142030;
  --ink-2: #44546a;
  --muted: #7a889a;
  --line: #e2e8ef;
  --line-2: #d0d9e3;
  --brand: #0a8fc2;
  --brand-ink: #ffffff;
  --brand-soft: #e1f3fb;
  --night: #0c1724;
  --ok: #1f9d55;
  --ok-soft: #e2f5ea;
  --warn: #d97a00;
  --warn-soft: #fff1dc;
  --crit: #d93a3a;
  --crit-soft: #fde7e7;
  --info: #5b5fe0;
  --info-soft: #ecedff;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 2px 8px rgba(16, 24, 40, .06);
  --shadow-hi: 0 10px 30px rgba(16, 24, 40, .16);
  --radius: 12px;
  --sans: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a1018; --card: #121b26; --card-2: #0f1720; --ink: #e7eef5; --ink-2: #b2c0ce; --muted: #8394a6;
    --line: #1f2b38; --line-2: #2b3a4a; --brand: #3cc8f5; --brand-ink: #04202c; --brand-soft: #0d2a38;
    --ok: #3cc477; --ok-soft: #0f2a1b; --warn: #f2a43a; --warn-soft: #2d2210; --crit: #ff6b6b; --crit-soft: #331718;
    --info: #9296ff; --info-soft: #1d1f40;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-hi: 0 10px 30px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a1018; --card: #121b26; --card-2: #0f1720; --ink: #e7eef5; --ink-2: #b2c0ce; --muted: #8394a6;
  --line: #1f2b38; --line-2: #2b3a4a; --brand: #3cc8f5; --brand-ink: #04202c; --brand-soft: #0d2a38;
  --ok: #3cc477; --ok-soft: #0f2a1b; --warn: #f2a43a; --warn-soft: #2d2210; --crit: #ff6b6b; --crit-soft: #331718;
  --info: #9296ff; --info-soft: #1d1f40;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-hi: 0 10px 30px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 var(--sans); font-feature-settings: "tnum" 1; }
a { color: var(--brand); text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 14px; }
svg.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, Consolas, monospace; }
.right { text-align: right; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.nowrap { white-space: nowrap; }

/* ---- buttons and fields -------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 9px;
  border: 1px solid var(--line-2); background: var(--card); color: var(--ink); font: 600 13px var(--sans); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); color: var(--brand-ink); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--crit); }
.btn.danger:hover { border-color: var(--crit); }
.btn.ghost { border-color: transparent; background: none; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12px; }
.btn.lg { height: 48px; padding: 0 20px; font-size: 15px; border-radius: 12px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }

label.f { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
label.f.check { flex-direction: row; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; color: var(--ink); }
input, select, textarea { font: 14px var(--sans); color: var(--ink); background: var(--card); border: 1px solid var(--line-2); border-radius: 9px;
  padding: 8px 10px; min-height: 38px; width: 100%; }
input[type="checkbox"] { width: 18px; min-height: 18px; height: 18px; accent-color: var(--brand); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
textarea { resize: vertical; min-height: 64px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 640px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

/* ---- cards, tables, badges ----------------------------------------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card > .hd { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.card > .bd { padding: 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi { padding: 14px 16px; }
.kpi .lbl { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.kpi .val { font-size: 24px; font-weight: 700; margin-top: 4px; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted);
  padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--card-2); position: sticky; top: 0; z-index: 1; }
table.t td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--card-2); }
.tablewrap { overflow: auto; }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--card-2); color: var(--ink-2); border: 1px solid var(--line); }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.st-pendente { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.st-agendado, .st-em_preparo { background: var(--card-2); color: var(--ink-2); }
.st-aceito, .st-na_coleta { background: var(--info-soft); color: var(--info); border-color: transparent; }
.st-em_rota { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.st-entregue, .on { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.st-cancelado, .off { background: var(--card-2); color: var(--muted); }
.neg { color: var(--crit); } .pos { color: var(--ok); }

/* ---- modal and toast ------------------------------------------------ */
.modal-bg { position: fixed; inset: 0; background: rgba(8, 14, 22, .55); display: grid; place-items: center; z-index: 1000; padding: 16px; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--card); border-radius: 16px; box-shadow: var(--shadow-hi); }
.modal.wide { width: min(880px, 100%); }
.modal > .hd { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); z-index: 2; }
.modal > .bd { padding: 18px; }
.modal > .ft { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--card); }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 2000; }
.toast { background: var(--night); color: #fff; padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow-hi); max-width: 360px; font-size: 13px; }
.toast.err { background: var(--crit); }
@media (max-width: 640px) { #toasts { left: 16px; right: 16px; } .toast { max-width: none; } }

/* ---- timeline -------------------------------------------------------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 12px 22px; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 5px; width: 9px; height: 9px; border-radius: 50%; background: var(--brand); }
.timeline li::after { content: ""; position: absolute; left: 8px; top: 16px; bottom: 0; width: 1px; background: var(--line-2); }
.timeline li:last-child::after { display: none; }

/* ---- app shell (panel and portal) ---------------------------------- */
.shell { display: grid; grid-template-columns: 232px 1fr; height: 100vh; }
.side { background: var(--night); color: #c9d6e3; display: flex; flex-direction: column; padding: 16px 12px; gap: 4px; overflow: auto; }
.side .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: #fff; font-weight: 700; font-size: 16px; }
.side .brand small { display: block; font-weight: 500; font-size: 11px; color: #7f93a8; }
.side a.nav { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; color: #c9d6e3; font-weight: 500; }
.side a.nav:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.side a.nav.on { background: rgba(60, 200, 245, .14); color: #fff; }
.side a.nav.on svg { color: #3cc8f5; }
.side .spacer { flex: 1; }
.side .me { border-top: 1px solid rgba(255, 255, 255, .08); padding: 12px 8px 0; font-size: 12px; }
.side .me b { display: block; color: #fff; font-size: 13px; }
.side .me button { background: none; border: 0; color: #7f93a8; padding: 4px 0; cursor: pointer; font: 12px var(--sans); }
.side .me button:hover { color: #fff; }
.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; overflow: hidden; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 22px; background: var(--card); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.topbar .menu { display: none; }
.view { flex: 1; overflow: auto; padding: 20px 22px; }
.view.full { padding: 0; display: flex; overflow: hidden; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.live.ok::before { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 900; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: var(--shadow-hi); }
  .topbar .menu { display: inline-flex; }
  .topbar { padding: 12px 16px; }
  .view { padding: 16px; }
}

/* ---- address form -------------------------------------------------- */
.af { display: flex; flex-direction: column; gap: 10px; }
.af-search { position: relative; display: flex; gap: 8px; }
.af-search input { flex: 1; }
.af-sug { position: absolute; top: 42px; left: 0; right: 0; z-index: 1200; background: var(--card); border: 1px solid var(--line-2); border-radius: 10px;
  box-shadow: var(--shadow-hi); max-height: 340px; overflow: auto; padding: 4px 0; }
.af-sug .af-h { padding: 8px 12px 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.af-sug a { display: block; padding: 8px 12px; cursor: pointer; color: var(--ink); font-size: 13px; }
.af-sug a:hover { background: var(--brand-soft); }
.af-sug a small { display: block; color: var(--muted); font-size: 11px; }
.af-warn { color: var(--warn) !important; font-weight: 600; }
.af-grid { display: grid; grid-template-columns: 130px 1fr 110px; gap: 10px; }
.af-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 560px) { .af-grid { grid-template-columns: 1fr 100px; } .af-grid label:first-child { grid-column: 1 / -1; } .af-grid2 { grid-template-columns: 1fr; } }

/* ---- stops of an order --------------------------------------------- */
.stops { display: flex; flex-direction: column; gap: 8px; }
.stop { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--card-2); }
.stop .n { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font: 700 12px var(--sans); background: var(--ok); color: #fff; }
.stop.done { opacity: .7; } .stop.done .n { background: var(--muted); }

/* ---- chat ------------------------------------------------------------ */
.chat { display: flex; flex-direction: column; min-height: 0; }
.chat .msgs { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; background: var(--card-2); min-height: 200px; }
.chat .msgs .empty { margin: auto; }
.chat .msg { max-width: 78%; align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: 14px 14px 14px 4px; padding: 8px 12px; }
.chat .msg.mine { align-self: flex-end; background: var(--brand); border-color: var(--brand); color: var(--brand-ink); border-radius: 14px 14px 4px 14px; }
.chat .msg .who { font-size: 11px; font-weight: 700; color: var(--brand); margin-bottom: 2px; }
.chat .msg .txt { white-space: pre-wrap; word-break: break-word; }
.chat .msg img { display: block; max-width: 240px; max-height: 240px; border-radius: 8px; margin-top: 4px; }
.chat .msg .at { font-size: 10px; opacity: .7; text-align: right; margin-top: 2px; }
.chat .compose { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px; border-top: 1px solid var(--line); background: var(--card); }
.chat .compose textarea { min-height: 40px; max-height: 140px; resize: none; }
.chat .compose .iconbtn { cursor: pointer; align-self: center; }
.iconbtn { background: none; border: 0; color: var(--muted); padding: 5px; border-radius: 7px; cursor: pointer; display: inline-flex; }
.iconbtn:hover { background: var(--card-2); color: var(--ink); }
.dot-count { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--crit); color: #fff; font: 700 11px var(--sans); }

/* ---- maps ------------------------------------------------------------ */
.map { width: 100%; height: 100%; min-height: 260px; background: var(--card-2); }
.leaflet-container { font: 13px var(--sans); }
.pin { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35);
  color: #fff; font: 700 11px var(--sans); }
.pin.courier { background: #0a8fc2; }
.pin.courier.busy { background: #5b5fe0; }
.pin.courier.offline { background: #8a97a6; }
.pin.pickup { background: #d97a00; border-radius: 8px; }
.pin.drop { background: #1f9d55; border-radius: 8px; }
.pin.waiting { background: #d93a3a; border-radius: 8px; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(217, 58, 58, .25); } }
