/* Depósito — interface inspirada no macOS (Ajustes do Sistema / Finder) */
:root {
  --bg: #F5F5F7; --surface: #FFFFFF; --surface-2: #FAFAFC; --sidebar: rgba(236,236,240,.72);
  --text: #1D1D1F; --muted: #6E6E73; --faint: #A1A1A6; --line: rgba(0,0,0,.08); --line-strong: rgba(0,0,0,.14);
  --accent: #F9A01B; --accent-press: #E58E0A; --accent-soft: rgba(249,160,27,.16); --accent-ink: #A85B00; --on-accent: #26201A; --brand: #26201A;
  --ok: #248A3D; --ok-soft: rgba(52,199,89,.16); --warn: #B25000; --warn-soft: rgba(255,159,10,.18);
  --err: #D70015; --err-soft: rgba(255,59,48,.13); --gray-soft: rgba(120,120,128,.14);
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  --shadow-lg: 0 12px 48px rgba(0,0,0,.18);
  --r: 14px; --r-sm: 10px; --field: rgba(120,120,128,.10);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #1C1C1E; --surface: #2C2C2E; --surface-2: #323234; --sidebar: rgba(36,36,38,.74);
  --text: #F5F5F7; --muted: #A1A1A6; --faint: #6E6E73; --line: rgba(255,255,255,.09); --line-strong: rgba(255,255,255,.18);
  --accent: #FFAA2B; --accent-press: #FFBC57; --accent-soft: rgba(255,170,43,.2); --accent-ink: #FFB84D; --on-accent: #26201A; --brand: #000;
  --ok: #30D158; --ok-soft: rgba(48,209,88,.18); --warn: #FF9F0A; --warn-soft: rgba(255,159,10,.18);
  --err: #FF453A; --err-soft: rgba(255,69,58,.18); --gray-soft: rgba(120,120,128,.26);
  --shadow: 0 1px 2px rgba(0,0,0,.3); --shadow-lg: 0 12px 48px rgba(0,0,0,.6); --field: rgba(120,120,128,.22);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", system-ui, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-ink); text-decoration: none; }
h1 { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin: 0; }
h2 { font-size: 17px; font-weight: 600; margin: 0 0 12px; letter-spacing: -.01em; }
h3 { font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 0 8px; text-transform: uppercase; letter-spacing: .04em; }
p { margin: 0 0 10px; }
svg.lucide { width: 18px; height: 18px; stroke-width: 1.9; flex: none; }
.muted { color: var(--muted); } .small { font-size: 13px; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.tnum { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 1px; border-radius: 8px; }

/* ---------- Estrutura ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100dvh; padding: 18px 12px; display: flex; flex-direction: column; gap: 2px;
  background: var(--sidebar); backdrop-filter: saturate(180%) blur(24px); -webkit-backdrop-filter: saturate(180%) blur(24px);
  border-right: 1px solid var(--line); overflow-y: auto; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 16px; font-weight: 700; font-size: 16px; letter-spacing: -.01em; color: var(--text); }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(160deg, #FDB913, #F28C1A); display: grid; place-items: center; color: #fff; box-shadow: 0 2px 6px rgba(249,160,27,.4); }
.brand-mark svg { fill: currentColor; }
.nav-label { font-size: 11px; font-weight: 600; color: var(--faint); padding: 14px 10px 4px; text-transform: uppercase; letter-spacing: .05em; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--text); font-size: 14px; font-weight: 500; transition: background .15s; }
.nav-item .ico { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; background: var(--gray-soft); color: var(--muted); transition: .15s; }
.nav-item .ico svg { width: 15px; height: 15px; }
.nav-item:hover { background: var(--gray-soft); }
.nav-item.active { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.nav-item.active .ico { background: rgba(38,32,26,.14); color: var(--on-accent); }
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
.userbox { display: flex; align-items: center; gap: 10px; padding: 8px 10px; }
.userbox b { display: block; font-size: 13px; line-height: 1.2; } .userbox span { font-size: 12px; color: var(--muted); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 28px; min-height: 54px;
  background: color-mix(in srgb, var(--bg) 78%, transparent); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
}
.topbar .title { font-weight: 600; font-size: 15px; }
.topbar .spacer { flex: 1; }
.search { position: relative; flex: 0 1 300px; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted); }
.search input { padding-left: 32px; height: 34px; border-radius: 9px; }
.content { padding: 28px; max-width: 1240px; width: 100%; margin: 0 auto; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.tabbar { display: none; }

/* ---------- Cartões ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 20px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 12px; }
.kpi { display: flex; flex-direction: column; gap: 10px; }
.kpi .ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); }
.kpi .ico.ok { background: var(--ok-soft); color: var(--ok); } .kpi .ico.warn { background: var(--warn-soft); color: var(--warn); } .kpi .ico.gray { background: var(--gray-soft); color: var(--muted); }
.kpi b { font-size: 30px; font-weight: 700; letter-spacing: -.03em; line-height: 1; }
.kpi span { color: var(--muted); font-size: 13px; }

/* Lista agrupada estilo Ajustes */
.list { list-style: none; margin: 0; padding: 0; }
.list > li, .list > a { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--line); color: var(--text); }
.list > :first-child { border-top: 0; }
.list > a:hover { background: var(--surface-2); }
.list .grow { flex: 1; min-width: 0; } .list .grow b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .grow span { font-size: 13px; color: var(--muted); }
.bar { height: 6px; border-radius: 3px; background: var(--gray-soft); overflow: hidden; margin-top: 6px; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 30px; height: 30px; color: var(--faint); margin-bottom: 8px; }

/* ---------- Tabelas ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .12s; } tbody tr:hover { background: var(--surface-2); }
tr[data-href] { cursor: pointer; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 9px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); font: inherit; font-size: 14px; font-weight: 500;
  cursor: pointer; transition: transform .1s, background .15s, box-shadow .15s; box-shadow: 0 1px 1px rgba(0,0,0,.04); white-space: nowrap;
}
.btn:hover { background: var(--surface-2); } .btn:active { transform: scale(.97); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--on-accent); font-weight: 600; box-shadow: 0 1px 3px rgba(249,160,27,.4); }
.btn.primary:hover { background: var(--accent-press); }
.btn.danger { color: var(--err); } .btn.ghost { border-color: transparent; background: transparent; box-shadow: none; color: var(--accent-ink); }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.lg { height: 48px; padding: 0 20px; font-size: 16px; border-radius: 12px; } .btn.block { width: 100%; }
.btn.icon { width: 36px; padding: 0; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ---------- Formulários ---------- */
label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
label .req { color: var(--err); }
input, select, textarea {
  width: 100%; height: 40px; padding: 0 12px; border-radius: var(--r-sm); border: 1px solid transparent; background: var(--field);
  color: var(--text); font: inherit; transition: box-shadow .15s, background .15s, border-color .15s; appearance: none; -webkit-appearance: none;
}
textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238E8E93' stroke-width='3' 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 12px center; padding-right: 32px; }
input:focus, select:focus, textarea:focus { outline: none; background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; padding: 0; appearance: auto; -webkit-appearance: auto; accent-color: var(--accent); }
input[type=file] { height: auto; padding: 9px 12px; }
.field { margin-bottom: 16px; } .hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 16px; } .form-grid .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 400; font-size: 14px; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; align-items: end; }
.filters .field { margin: 0; }
.filter-box { padding: 0; margin-bottom: 16px; }
.filter-box summary { display: flex; align-items: center; gap: 8px; padding: 12px 16px; cursor: pointer; font-weight: 500; font-size: 14px; list-style: none; }
.filter-box summary::-webkit-details-marker { display: none; }
.filter-box .filters { padding: 4px 16px 16px; }

/* Segmented control */
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--field); border-radius: 10px; padding: 3px; gap: 2px; }
.segmented label { margin: 0; text-align: center; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 14px; transition: .15s; position: relative; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.12); font-weight: 600; }

/* ---------- Badges / avisos ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; background: var(--gray-soft); color: var(--muted); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.entregue, .badge.ok, .badge.inserido, .badge.atualizado { background: var(--ok-soft); color: var(--ok); }
.badge.agendada, .badge.warn, .badge.ignorado { background: var(--warn-soft); color: var(--warn); }
.badge.cancelada, .badge.err, .badge.erro { background: var(--err-soft); color: var(--err); }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; margin-bottom: 16px; font-size: 14px; background: var(--accent-soft); color: var(--text); }
.alert.success { background: var(--ok-soft); } .alert.success svg { color: var(--ok); }
.alert.error { background: var(--err-soft); } .alert.error svg { color: var(--err); }
.alert.warn { background: var(--warn-soft); } .alert.warn svg { color: var(--warn); }
.alert ul { margin: 0; padding-left: 18px; }

/* ---------- Avatar / fotos ---------- */
.avatar { width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(160deg, #B0B4BD, #7E838E); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 14px; flex: none; object-fit: cover; overflow: hidden; }
.avatar.sm { width: 30px; height: 30px; font-size: 12px; } .avatar.lg { width: 72px; height: 72px; font-size: 24px; } .avatar.xl { width: 104px; height: 104px; font-size: 34px; }
img.avatar { display: block; }
.thumb { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: var(--gray-soft); display: grid; place-items: center; color: var(--faint); flex: none; }
.thumb.lg { width: 96px; height: 96px; border-radius: 14px; }
.photo-pick { display: flex; align-items: center; gap: 14px; }
.photo-pick .preview { width: 84px; height: 84px; border-radius: 16px; background: var(--field); display: grid; place-items: center; color: var(--faint); overflow: hidden; flex: none; border: 1px dashed var(--line-strong); }
.photo-pick .preview.round { border-radius: 50%; }
.photo-pick .preview img { width: 100%; height: 100%; object-fit: cover; }
.photo-pick input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }

/* ---------- Modal ---------- */
dialog { border: 0; padding: 0; border-radius: 18px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); }
dialog::backdrop { background: rgba(0,0,0,.32); backdrop-filter: blur(4px); }
dialog[open] { animation: pop .2s cubic-bezier(.2,.9,.3,1.2); }
@keyframes pop { from { opacity: 0; transform: scale(.96); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-head h2 { margin: 0; } .modal-body { padding: 20px; } .modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- Assistente (retirada) ---------- */
.steps { display: flex; gap: 6px; margin-bottom: 20px; }
.steps li { flex: 1; list-style: none; text-align: center; font-size: 12px; font-weight: 600; color: var(--faint); padding-top: 10px; border-top: 3px solid var(--gray-soft); transition: .2s; }
.steps { padding: 0; margin-top: 0; }
.steps li.on { color: var(--accent-ink); border-color: var(--accent); } .steps li.done { color: var(--text); border-color: var(--accent); }
.step { display: none; } .step.on { display: block; animation: fade .25s ease; }
.wizard-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 20px; }
.results { margin-top: 8px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; max-height: 320px; overflow-y: auto; }
.results:empty { display: none; }
.results button { display: flex; width: 100%; align-items: center; gap: 12px; padding: 10px 14px; border: 0; border-top: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.results button:first-child { border-top: 0; } .results button:hover { background: var(--accent-soft); }
.results .none { padding: 14px; color: var(--muted); font-size: 14px; }
.picked { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 14px; background: var(--accent-soft); margin-top: 12px; }
.item-card { border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; gap: 12px; align-items: flex-start; background: var(--surface-2); }
.item-card .grow { flex: 1; min-width: 0; }
.dl { display: grid; grid-template-columns: 150px 1fr; gap: 8px 16px; font-size: 14px; margin: 0; }
.dl dt { color: var(--muted); } .dl dd { margin: 0; }

/* ---------- Gráfico ---------- */
.chart { display: flex; align-items: flex-end; gap: 4px; height: 170px; padding-top: 10px; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; height: 100%; min-width: 0; }
.chart .col i { width: 100%; max-width: 26px; border-radius: 5px 5px 2px 2px; background: var(--accent); min-height: 2px; transition: height .5s cubic-bezier(.2,.8,.2,1); opacity: .9; }
.chart .col:hover i { opacity: 1; }
.chart .col span { font-size: 10px; color: var(--faint); white-space: nowrap; }

/* ---------- Login ---------- */
.guest { min-height: 100dvh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 50% -10%, var(--accent-soft), transparent), var(--bg); }
.guest .card { width: min(400px, 100%); padding: 32px; border-radius: 20px; }
.guest .brand-mark { width: 56px; height: 56px; border-radius: 15px; margin: 0 auto 16px; } .guest .brand-mark svg { width: 28px; height: 28px; }
.guest h1 { text-align: center; font-size: 22px; } .guest .sub { text-align: center; color: var(--muted); margin: 6px 0 24px; }

.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }

/* ---------- Mobile ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 280px; transform: translateX(-100%); transition: transform .28s cubic-bezier(.2,.8,.2,1); background: var(--surface); padding-top: max(18px, env(safe-area-inset-top)); }
  body.menu-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  body.menu-open::after { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 25; }
  .topbar { padding: 8px 16px; } .topbar .search { display: none; }
  .content { padding: 18px 16px 96px; }
  h1 { font-size: 24px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .grid > * { grid-column: auto !important; } .g4.kpis { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .dl { grid-template-columns: 1fr; gap: 2px; } .dl dd { margin-bottom: 10px; }
  input, select { height: 46px; font-size: 16px; } textarea { font-size: 16px; }
  .btn { height: 44px; } .btn.lg { height: 52px; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; z-index: 22;
    background: color-mix(in srgb, var(--surface) 86%, transparent); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar a, .tabbar button { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10px; font-weight: 500; color: var(--muted); background: none; border: 0; padding: 4px 0; font-family: inherit; }
  .tabbar svg { width: 22px; height: 22px; }
  .tabbar .active { color: var(--accent-ink); }
  .tabbar .fab span { width: 46px; height: 46px; margin-top: -18px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; box-shadow: 0 4px 14px rgba(249,160,27,.5); }
  .hide-m { display: none !important; }
  dialog { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 18px 18px 0 0; }
}
@media (min-width: 901px) { .only-m { display: none !important; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media print { .sidebar, .topbar, .tabbar, .no-print { display: none !important; } .shell { display: block; } .content { padding: 0; } .card { box-shadow: none; } }
