/* ============================================================
   Zeladoria — estilos únicos da aplicação.
   Tokens e componentes derivados de zeladoria-design-system.html.
   Nenhuma página tem CSS próprio: tudo usa estas classes.
   ============================================================ */

:root {
  /* Cores */
  --primary: #1D4ED8;
  --primary-dark: #1E40AF;
  --primary-soft: #EFF6FF;
  --primary-line: #BFDBFE;
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --text: #0F172A;
  --muted: #475569;
  --subtle: #64748B;
  --border: #CBD5E1;
  --line: #E2E8F0;
  --line-soft: #F1F5F9;
  --success: #15803D;
  --success-soft: #F0FDF4;
  --success-text: #166534;
  --warning: #B45309;
  --warning-soft: #FFFBEB;
  --warning-line: #FDE68A;
  --warning-text: #92400E;
  --danger: #B91C1C;
  --danger-soft: #FEF2F2;
  --danger-text: #991B1B;

  /* Forma e medida */
  --radius-field: 8px;
  --radius-card: 12px;
  --control-h: 48px;
  --sidebar-w: 248px;
  --bottomnav-h: 64px;
  --gutter: 16px;

  /* Espaçamento (escala de 4 px) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.55 var(--font); overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 28px; letter-spacing: -.8px; line-height: 1.2; }
h2 { font-size: 20px; letter-spacing: -.4px; line-height: 1.3; }
h3 { font-size: 16px; line-height: 1.35; }
p { color: var(--muted); }
small, .small { font-size: 13px; color: var(--muted); }
a { color: var(--primary); }
img, svg { max-width: 100%; }
[hidden] { display: none !important; }

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--primary); outline-offset: 3px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.pular {
  position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--primary); color: #fff;
  padding: 10px 14px; border-radius: var(--radius-field); text-decoration: none;
}
.pular:focus { top: 12px; }

/* ---------- Ícones ---------- */
.icon { width: 20px; height: 20px; stroke: currentColor; stroke-width: 1.7; fill: none;
  stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* ---------- Estrutura do app ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: var(--surface);
  border-right: 1px solid var(--line); padding: 24px 16px; display: flex; flex-direction: column;
  z-index: 10; overflow-y: auto;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 0 8px 24px; font-size: 18px; font-weight: 750;
  color: var(--text); text-decoration: none; }
.brand-mark { background: var(--primary); color: #fff; width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center; flex-shrink: 0; }
.nav { display: grid; gap: 4px; }
.nav-label { font-size: 11px; font-weight: 750; letter-spacing: 1.4px; text-transform: uppercase;
  color: var(--subtle); padding: 18px 14px 6px; }
.nav a, .nav button {
  display: flex; gap: 12px; align-items: center; text-align: left; background: none; border: 0;
  color: var(--muted); padding: 10px 14px; min-height: var(--control-h); border-radius: var(--radius-field);
  font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer; width: 100%;
}
.nav a:hover, .nav button:hover { background: var(--line-soft); }
.nav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding: 16px 8px 0; font-size: 13px; }
.sidebar-foot b { display: block; color: var(--text); overflow-wrap: anywhere; }

.main { margin-left: var(--sidebar-w); min-height: 100vh; min-width: 0; }
.topbar {
  min-height: 64px; border-bottom: 1px solid var(--line); display: flex; align-items: center;
  justify-content: space-between; gap: 12px; padding: 0 32px; background: var(--surface);
}
.topbar-title { font-size: 14px; color: var(--subtle); }
.topbar-title b { color: var(--text); }
.topbar-brand { display: none; font-weight: 750; font-size: 16px; color: var(--text); text-decoration: none;
  align-items: center; gap: 10px; }
.topbar-brand .brand-mark { width: 32px; height: 32px; border-radius: 8px; }
.content { max-width: 1200px; margin: 0 auto; padding: 32px 32px 64px; }
.content-narrow { max-width: 720px; }

.bottomnav { display: none; }

/* ---------- Cabeçalho de página ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px;
  margin-bottom: 24px; flex-wrap: wrap; }
.page-head p { margin-top: 6px; font-size: 15px; max-width: 640px; }
.kicker { color: var(--primary); font-size: 12px; font-weight: 750; letter-spacing: 1.4px;
  text-transform: uppercase; margin-bottom: 8px; }
.back { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font-size: 14px;
  font-weight: 600; text-decoration: none; margin-bottom: 8px; }

.section { margin-top: 32px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.section-head p { font-size: 14px; margin-top: 2px; }

/* ---------- Grade e cards ---------- */
.grid { display: grid; gap: 16px; }
.cols2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); padding: 24px; min-width: 0; }
.card-link { display: block; color: inherit; text-decoration: none; }
.card-link:hover { border-color: var(--primary-line); }
.label { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--subtle); margin-bottom: 12px; font-weight: 650; }

.metric { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; color: inherit; text-decoration: none; }
.metric .value { font-size: 30px; letter-spacing: -1px; font-weight: 750; margin-top: 8px; line-height: 1.2; color: var(--text); }
.metric p { font-size: 14px; }
.iconbox { background: var(--primary-soft); color: var(--primary); padding: 10px; border-radius: 9px; display: grid; place-items: center; }
.iconbox.warn { background: var(--warning-soft); color: var(--warning); }

/* ---------- Pílulas de status (sempre com texto) ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 6px; padding: 4px 9px;
  font-size: 12px; font-weight: 650; white-space: nowrap; line-height: 1.4; }
.pill.blue { background: var(--primary-soft); color: var(--primary-dark); }
.pill.green { background: var(--success-soft); color: var(--success-text); }
.pill.amber { background: var(--warning-soft); color: var(--warning-text); }
.pill.gray { background: var(--line-soft); color: var(--muted); }
.pill.red { background: var(--danger-soft); color: var(--danger-text); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.stack > * + * { margin-top: 12px; }

/* ---------- Botões ---------- */
.btn {
  border: 1px solid transparent; border-radius: var(--radius-field); min-height: var(--control-h);
  padding: 10px 18px; font-size: 15px; font-weight: 650; display: inline-flex; align-items: center;
  justify-content: center; gap: 8px; background: var(--primary); color: #fff; text-decoration: none;
  cursor: pointer; line-height: 1.2; text-align: center;
}
.btn:hover { background: var(--primary-dark); }
.btn.secondary { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn.secondary:hover { background: var(--bg); }
.btn.ghost { background: transparent; color: var(--primary); }
.btn.ghost:hover { background: var(--primary-soft); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #991B1B; }
.btn.small { min-height: 40px; font-size: 14px; padding: 8px 12px; }
.btn.block { width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn[aria-busy="true"] { cursor: progress; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 24px; }
.actions.end { justify-content: flex-end; }

/* ---------- Formulários ---------- */
.field { display: grid; gap: 6px; font-size: 14px; font-weight: 650; margin-bottom: 16px; min-width: 0; }
.field .opt { font-weight: 400; color: var(--subtle); }
.field input, .field select, .field textarea, .input {
  border: 1px solid var(--border); border-radius: var(--radius-field); min-height: var(--control-h);
  padding: 11px 13px; background: var(--surface); color: var(--text); width: 100%; font-size: 16px; font-weight: 400;
}
.field textarea { min-height: 110px; resize: vertical; }
.field small { font-weight: 400; font-size: 13px; }
.field [aria-invalid="true"] { border-color: var(--danger); }
.field-error { color: var(--danger) !important; }
.checkline { display: flex; gap: 10px; align-items: center; min-height: 44px; font-size: 15px; cursor: pointer; }
.checkline input { width: 20px; height: 20px; accent-color: var(--primary); }
.checklist { display: grid; gap: 2px; border: 1px solid var(--border); border-radius: var(--radius-field);
  padding: 6px 12px; max-height: 280px; overflow-y: auto; background: var(--surface); }
fieldset { border: 0; padding: 0; margin: 0 0 16px; min-width: 0; }
legend { font-size: 14px; font-weight: 650; margin-bottom: 6px; padding: 0; }
.form-grid { display: grid; gap: 0 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }

.segmented { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.segmented label { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--control-h);
  border: 1px solid var(--border); border-radius: var(--radius-field); background: var(--surface);
  font-size: 15px; font-weight: 600; cursor: pointer; padding: 8px; text-align: center; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented input:checked + span { color: var(--primary); }
.segmented label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.segmented label:has(input:focus-visible) { outline: 3px solid var(--primary); outline-offset: 2px; }

/* ---------- Avisos e estados ---------- */
.notice { border: 1px solid var(--primary-line); background: var(--primary-soft); border-radius: 9px;
  padding: 14px 16px; color: var(--primary-dark); font-size: 14px; }
.notice.warning { background: var(--warning-soft); border-color: var(--warning-line); color: var(--warning-text); }
.notice.error { background: var(--danger-soft); border-color: #FECACA; color: var(--danger-text); }
.notice.success { background: var(--success-soft); border-color: #BBF7D0; color: var(--success-text); }
.notice + .notice { margin-top: 12px; }
.empty { padding: 32px 16px; text-align: center; color: var(--subtle); font-size: 15px; }
.empty .icon { width: 28px; height: 28px; margin-bottom: 8px; color: var(--border); }
.loading { padding: 32px 16px; text-align: center; color: var(--subtle); font-size: 15px; }
.loading::before { content: ""; display: block; width: 24px; height: 24px; margin: 0 auto 10px;
  border: 3px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: giro .9s linear infinite; }
@keyframes giro { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .loading::before { animation: none; } }

/* ---------- Busca, abas, filtros ---------- */
.toolbar { display: flex; gap: 12px; margin-bottom: 16px; align-items: center; flex-wrap: wrap; }
.toolbar .input { max-width: 420px; flex: 1 1 220px; }
.toolbar select.input { flex: 0 1 220px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tab { border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--muted);
  padding: 10px 14px; min-height: var(--control-h); font-size: 14px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.tab[aria-selected="true"], .tab[aria-pressed="true"] { background: var(--primary-soft); color: var(--primary); border-color: var(--primary-line); }
.tab .count { font-size: 12px; background: var(--line-soft); border-radius: 10px; padding: 0 7px; color: var(--muted); }

/* ---------- Listas (tarefas, movimentações, usuários) ---------- */
.list { padding: 8px 24px; }
.item { display: flex; gap: 16px; padding: 18px 0; border-bottom: 1px solid var(--line); align-items: flex-start;
  color: inherit; text-decoration: none; }
.item:last-child { border-bottom: 0; }
a.item:hover h3 { color: var(--primary); }
.item-icon { width: 40px; height: 40px; border-radius: 9px; background: var(--line-soft); color: var(--muted);
  display: grid; place-items: center; flex-shrink: 0; }
.item-body { flex: 1; min-width: 0; }
.item h3 { font-size: 16px; margin: 8px 0 4px; overflow-wrap: anywhere; }
.item p { font-size: 14px; overflow-wrap: anywhere; }
.meta { font-size: 13px; color: var(--subtle); margin-top: 8px; display: flex; gap: 6px 16px; flex-wrap: wrap; }
.meta .late { color: var(--danger); font-weight: 650; }
.item-go { color: var(--primary); min-width: 32px; display: grid; place-items: center; align-self: center; }
.item-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

.spec { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.spec:last-child { border: 0; }
.spec span { color: var(--subtle); }
.spec b { text-align: right; overflow-wrap: anywhere; }
.prose { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); font-size: 15px; }

.timeline { border-left: 2px solid #DBEAFE; margin: 8px 0 0 8px; padding-left: 20px; }
.timeline li { list-style: none; margin-bottom: 16px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -27px; top: 6px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--surface); border: 2px solid var(--primary); }
.timeline .when { font-size: 13px; color: var(--subtle); }
.timeline p { font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); }
ol.timeline { padding-inline-start: 20px; }

/* ---------- Estoque ---------- */
.stockgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.stockcard { display: flex; flex-direction: column; }
.stockcard h3 { margin-top: 14px; overflow-wrap: anywhere; }
.stockcard p { font-size: 13px; margin-top: 2px; }
.qty { font-size: 30px; font-weight: 750; margin-top: 14px; line-height: 1.2; }
.qty span { font-size: 14px; font-weight: 400; color: var(--subtle); }
.stockbottom { border-top: 1px solid var(--line); margin-top: auto; padding-top: 14px; display: flex;
  justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.stockcard .qty + .small { margin-bottom: 16px; }
.balance { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--bg);
  border: 1px solid var(--line); padding: 16px; border-radius: var(--radius-field); margin: 8px 0 16px; flex-wrap: wrap; }
.balance small { display: block; }
.balance b { font-size: 22px; }
.balance .neg { color: var(--danger); }

/* ---------- Tabela (apenas telas largas e dados de apoio) ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--subtle);
  font-weight: 650; padding: 10px 12px; border-bottom: 1px solid var(--line); }
table.data td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data td.num, table.data th.num { text-align: right; white-space: nowrap; }

/* ---------- Diálogo ---------- */
dialog { border: 1px solid var(--line); border-radius: 16px; padding: 24px; max-width: 520px;
  width: calc(100% - 32px); color: var(--text); box-shadow: 0 24px 80px #0F172A33; max-height: calc(100dvh - 32px); }
dialog::backdrop { background: #0F172A70; }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 8px; }
.dialog-head h2 { margin-top: 2px; }
dialog p.desc { font-size: 15px; margin-bottom: 16px; }
.close { border: 0; background: var(--line-soft); border-radius: var(--radius-field); min-width: 44px; min-height: 44px;
  display: grid; place-items: center; cursor: pointer; color: var(--text); }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 28px; left: calc(50% + var(--sidebar-w) / 2); transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 14px 20px; border-radius: 10px; z-index: 100; max-width: min(520px, 90vw);
  font-size: 15px; box-shadow: 0 8px 30px #0F172A30; }
.toast.erro { background: var(--danger); }

/* ---------- Telas de acesso (login, solicitação, situação) ---------- */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth-side { background: var(--surface); border-right: 1px solid var(--line); padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-side h1 { font-size: 32px; margin-top: 48px; max-width: 420px; }
.auth-side p { margin-top: 12px; max-width: 420px; }
.auth-points { display: grid; gap: 12px; margin-top: 32px; max-width: 420px; padding: 0; }
.auth-points li { list-style: none; display: flex; gap: 12px; align-items: flex-start; color: var(--muted); font-size: 15px; }
.auth-points .icon { color: var(--primary); margin-top: 2px; }
.auth-main { display: grid; place-items: center; padding: 32px 24px; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card h2 { font-size: 26px; letter-spacing: -.6px; }
.auth-card h2 + p { margin: 6px 0 24px; }
.auth-foot { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); font-size: 15px; color: var(--muted); }
.auth-mobile-brand { display: none; }
.pw { position: relative; }
.pw input { padding-right: 96px; }
.pw button { position: absolute; right: 4px; top: 4px; bottom: 4px; border: 0; background: none; color: var(--primary);
  font-size: 14px; font-weight: 650; padding: 0 12px; border-radius: 6px; cursor: pointer; }

/* ============================================================
   Responsivo
   ============================================================ */
@media (max-width: 1100px) {
  :root { --sidebar-w: 220px; }
  .content { padding: 28px 24px 56px; }
  .topbar { padding: 0 24px; }
  .stockgrid, .cols3, .cols4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .auth-mobile-brand { display: flex; margin-bottom: 32px; }
}

@media (max-width: 760px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .topbar { min-height: 56px; padding: 0 var(--gutter); position: sticky; top: 0; z-index: 15; }
  .topbar-title { display: none; }
  .topbar-brand { display: inline-flex; }
  .content { padding: 20px var(--gutter) calc(var(--bottomnav-h) + 32px + env(safe-area-inset-bottom)); }
  h1 { font-size: 24px; }
  .page-head { margin-bottom: 20px; }
  .page-head > .btn, .page-head > div > .btn { width: 100%; }
  .page-head > div { width: 100%; }
  .cols2, .cols3, .stockgrid, .form-grid { grid-template-columns: 1fr; }
  .cols4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .cols4 .card { padding: 16px; }
  .metric .value { font-size: 26px; }
  .metric .iconbox { display: none; }
  .card { padding: 18px; }
  .list { padding: 4px 16px; }
  .item { gap: 10px; }
  .item-icon { display: none; }
  .toolbar .input, .toolbar select.input { max-width: none; flex: 1 1 100%; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; margin-left: calc(-1 * var(--gutter)); margin-right: calc(-1 * var(--gutter));
    padding: 0 var(--gutter) 4px; scrollbar-width: none; }
  .tab { flex-shrink: 0; }
  .actions .btn { flex: 1 1 100%; }
  .bottomnav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--line);
    padding: 6px 4px max(6px, env(safe-area-inset-bottom)); z-index: 20; justify-content: space-around;
  }
  .bottomnav a { flex: 1; display: grid; justify-items: center; align-content: center; gap: 2px; color: var(--subtle);
    font-size: 12px; font-weight: 600; min-height: 52px; padding: 4px; text-decoration: none; border-radius: 8px; }
  .bottomnav a[aria-current="page"] { color: var(--primary); }
  .toast { left: 50%; bottom: calc(var(--bottomnav-h) + 20px + env(safe-area-inset-bottom)); width: calc(100% - 32px); text-align: center; }
  dialog { padding: 20px; }
  table.data { font-size: 13px; }
  .hide-mobile { display: none !important; }
}
@media (min-width: 761px) { .only-mobile { display: none !important; } }
.auth-full { grid-column: 1 / -1; }
.mb { margin-bottom: 16px; }
.mt { margin-top: 16px; }
.meta .icon { width: 16px; height: 16px; vertical-align: -3px; }
.btn-reset { background: none; border: 0; width: 100%; text-align: left; font: inherit; cursor: pointer; color: inherit; }
.btn.danger-text { color: var(--danger); }
.btn.danger-text:hover { background: var(--danger-soft); }
