/* cs-admin v2 — design tokens + mobile-first (spec 2026-07-11) */
:root {
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px; --sp-8: 64px;
  --radius-card: 12px;
  --radius-pill: 999px;
  --fs-sm: 14px; --fs-base: 16px; --fs-md: 18px; --fs-lg: 22px; --fs-xl: 28px;
  --bg: #f5f6f8;
  --card: #ffffff;
  --ink: #1c2733;
  --ink-soft: #4b5563;
  --line: #e4e8ee;
  --primary: #1c64f2;
  --primary-press: #1750c4;
  --success: #16a34a;
  --warn: #d97706;
  --error: #dc2626;
  --sirius: #7c3aed;
  --hubla: #ea580c;
  --header-bg: #101828;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .05);
  --touch: 44px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: var(--fs-base);
  line-height: 1.5;
  background: var(--bg);
  color: var(--ink);
}
h1 { font-size: var(--fs-lg); line-height: 1.25; margin: var(--sp-5) 0 var(--sp-3); }
h2 { margin: 0; }
a { color: var(--primary); }
code { font-size: 13px; word-break: break-all; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.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;
}
.muted { color: var(--ink-soft); font-size: var(--fs-sm); }
.error { color: var(--error); }
.wrap { max-width: 840px; margin: 0 auto; padding: 0 var(--sp-4) var(--sp-8); }
.page-hint { color: var(--ink-soft); font-size: var(--fs-sm); margin: 0 0 var(--sp-4); }

/* ── Header sticky + abas ─────────────────────────────── */
.site-header { position: sticky; top: 0; z-index: 30; background: var(--header-bg); color: #fff; }
.header-inner {
  max-width: 840px; margin: 0 auto; padding: var(--sp-2) var(--sp-4) 0;
  display: flex; flex-wrap: wrap; align-items: center;
}
.brand { color: #fff; font-weight: 700; font-size: var(--fs-md); text-decoration: none; padding: var(--sp-1) 0; order: 1; }
.logout-form { order: 2; margin-left: auto; display: flex; }
.logout-btn {
  background: none; border: 0; color: #94a3b8; cursor: pointer; border-radius: 8px;
  min-width: var(--touch); min-height: var(--touch);
  display: inline-flex; align-items: center; justify-content: center;
}
.logout-btn:hover { color: #fff; background: rgba(255, 255, 255, .1); }
.tabs { order: 3; width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); }
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--touch); padding: var(--sp-1);
  color: #cbd5e1; text-decoration: none; font-size: var(--fs-sm);
  border-bottom: 3px solid transparent;
}
.tab .ico { font-size: 18px; line-height: 1; }
.tab.active { color: #fff; font-weight: 600; border-bottom-color: var(--primary); }
.tab-label { display: inline-flex; align-items: center; gap: var(--sp-1); }

@media (min-width: 768px) {
  h1 { font-size: var(--fs-xl); }
  .header-inner { flex-wrap: nowrap; padding: 0 var(--sp-4); }
  .tabs { order: 2; width: auto; display: flex; margin-left: var(--sp-6); gap: var(--sp-1); }
  .tab { flex-direction: row; gap: var(--sp-2); padding: 0 var(--sp-3); border-bottom: 0; border-radius: 8px; min-height: 56px; }
  .tab.active { background: rgba(255, 255, 255, .12); border-bottom: 0; }
  .logout-form { order: 3; }
}

/* ── Badges (status/origem) ───────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px; border-radius: var(--radius-pill);
  font-size: var(--fs-sm); font-weight: 600;
  background: #e4e8ee; color: #374151; vertical-align: middle; white-space: nowrap;
}
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.muted { background: #e5e7eb; color: #374151; }
.badge.ok-soft, .badge.ok { background: #dcfce7; color: #166534; }
.badge.err-soft { background: #fee2e2; color: #991b1b; }
.badge.err { background: #b91c1c; color: #fff; }
.badge.sirius { background: #ede9fe; color: #5b21b6; }
.badge.hubla { background: #ffedd5; color: #9a3412; }
.badge.pend { background: #b91c1c; color: #fff; min-width: 22px; justify-content: center; padding: 2px 8px; }

/* ── Chips (turmas) ───────────────────────────────────── */
.chip-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin: var(--sp-2) 0; }
.chip {
  display: inline-flex; align-items: center; padding: 4px 12px;
  border-radius: var(--radius-pill); background: #eef1f5; border: 1px solid var(--line);
  font-size: var(--fs-sm); color: #374151;
}
.chip.err { background: #fee2e2; border-color: #fecaca; color: #991b1b; }

/* ── Chips de filtro (compras) ────────────────────────── */
.chips-row {
  display: flex; gap: var(--sp-2); overflow-x: auto;
  padding: var(--sp-1) 0 var(--sp-4); -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.chips-row::-webkit-scrollbar { display: none; }
.chip-link {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--touch); padding: 0 var(--sp-4);
  border-radius: var(--radius-pill); background: #fff; border: 1px solid var(--line);
  color: var(--ink); font-size: var(--fs-sm); font-weight: 600;
  text-decoration: none; white-space: nowrap; flex: none;
}
.chip-link.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ── Cards ────────────────────────────────────────────── */
.card-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-3); }
.card { background: var(--card); border-radius: var(--radius-card); box-shadow: var(--shadow); padding: var(--sp-4); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-2); }
.card-title { font-size: var(--fs-md); font-weight: 700; line-height: 1.3; }
.meta { color: var(--ink-soft); font-size: var(--fs-sm); margin: var(--sp-1) 0; }
.meta strong { color: var(--ink); }
.row-line { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); margin: var(--sp-2) 0; }
.card .btn-block { margin-top: var(--sp-3); }
.card-foot {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap;
  margin-top: var(--sp-3); padding-top: var(--sp-3); border-top: 1px solid var(--line);
}
@media (min-width: 768px) { .card { padding: var(--sp-5); } }

/* ── Botões ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: var(--touch); padding: var(--sp-2) var(--sp-4);
  border: 0; border-radius: var(--radius-card);
  background: var(--primary); color: #fff;
  font-size: var(--fs-base); font-weight: 600; font-family: inherit;
  text-decoration: none; text-align: center; cursor: pointer;
}
.btn:hover { background: var(--primary-press); }
.btn:active { transform: translateY(1px); }
.btn:disabled { background: #94a3b8; cursor: not-allowed; }
.btn:disabled:active { transform: none; }
.btn-block { display: flex; width: 100%; }
.edit-link, .pick-edit {
  font-weight: 600; min-height: var(--touch);
  display: inline-flex; align-items: center; padding: 0 var(--sp-2); flex: none;
}
.toolbar { margin: 0 0 var(--sp-4); }
.toolbar .btn { width: 100%; }
@media (min-width: 768px) { .toolbar .btn { width: auto; } }

/* ── Inputs / campos ──────────────────────────────────── */
.input {
  width: 100%; min-height: var(--touch); padding: var(--sp-2) var(--sp-3);
  border: 1.5px solid var(--line); border-radius: 10px;
  font-size: var(--fs-base); font-family: inherit; background: #fff; color: var(--ink);
}
.input:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: var(--primary); }
textarea.input { min-height: 88px; resize: vertical; }
.search { margin-bottom: var(--sp-3); }
.field { margin: var(--sp-4) 0 0; }
.field-label { display: block; font-weight: 600; margin-bottom: var(--sp-1); }
fieldset.field-group { border: 0; margin: 0; padding: 0; }
.field-legend { font-weight: 700; font-size: var(--fs-base); padding: 0; margin-bottom: var(--sp-3); }

/* ── Lista de turmas (checkboxes) ─────────────────────── */
.turma-list {
  display: flex; flex-direction: column;
  max-height: 55vh; overflow: auto;
  border: 1px solid var(--line); border-radius: 10px; padding: var(--sp-1);
}
.check-item {
  display: flex; align-items: center; gap: var(--sp-3);
  min-height: var(--touch); padding: var(--sp-2); border-radius: 10px; cursor: pointer;
}
.check-item:hover { background: #eef4ff; }
.check-item input { width: 22px; height: 22px; margin: 0; accent-color: var(--primary); flex: none; }
.check-name { flex: 1; min-width: 0; }
.check-id { color: var(--ink-soft); font-size: 12px; flex: none; }

/* ── Toggle (switch) ──────────────────────────────────── */
.toggle-row {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-4) 0; margin-top: var(--sp-2); border-top: 1px solid var(--line); cursor: pointer;
}
.toggle-text small { display: inline-block; margin-top: 2px; }
.switch { position: relative; width: 52px; height: 32px; flex: none; display: inline-block; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.switch .track {
  display: block; width: 52px; height: 32px; border-radius: var(--radius-pill);
  background: #cbd5e1; transition: background .15s ease; pointer-events: none;
}
.switch .track::after {
  content: ""; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .3);
  transition: transform .15s ease;
}
.switch input:checked + .track { background: var(--success); }
.switch input:checked + .track::after { transform: translateX(20px); }
.switch input:focus-visible + .track { outline: 2px solid var(--primary); outline-offset: 2px; }

/* switch-botão (toggle inline em /mapeamentos) */
.toggle-form { display: flex; align-items: center; gap: var(--sp-3); }
.switch-btn {
  position: relative; width: 52px; height: 32px; flex: none; padding: 0;
  border: 0; border-radius: var(--radius-pill); background: #cbd5e1;
  cursor: pointer; transition: background .15s ease;
}
.switch-btn::before { content: ""; position: absolute; inset: -8px; } /* área de toque ≥44px */
.switch-btn::after {
  content: ""; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .3);
  transition: transform .15s ease;
}
.switch-btn[aria-pressed="true"] { background: var(--success); }
.switch-btn[aria-pressed="true"]::after { transform: translateX(20px); }
.toggle-label { font-size: var(--fs-sm); }

/* ── Barra sticky de ação (rodapé) ────────────────────── */
.sticky-actions {
  position: sticky; bottom: 0; z-index: 20; background: var(--bg);
  margin-top: var(--sp-3);
  padding: var(--sp-2) 0 calc(var(--sp-3) + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 16px -14px rgba(16, 24, 40, .4);
}
.turma-counter { text-align: center; margin: 0 0 var(--sp-2); font-size: var(--fs-sm); font-weight: 600; color: var(--ink-soft); }

/* ── Banners / avisos ─────────────────────────────────── */
.banner { display: block; border-radius: var(--radius-card); padding: var(--sp-3) var(--sp-4); margin: var(--sp-4) 0 0; font-size: var(--fs-base); }
.banner-ok { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.banner-err { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* ── Estados vazios ───────────────────────────────────── */
.empty { text-align: center; padding: var(--sp-7) var(--sp-4); color: var(--ink-soft); }
.empty strong { color: var(--ink); }
.empty-emoji { font-size: 44px; margin-bottom: var(--sp-3); }
.empty-inline { color: var(--ink-soft); font-size: var(--fs-sm); text-align: center; padding: var(--sp-4); }

/* ── Detalhes técnicos / observações ──────────────────── */
details.tech { margin: var(--sp-2) 0 0; }
details.tech summary { padding: var(--sp-3) 0; cursor: pointer; color: var(--ink-soft); font-size: var(--fs-sm); }
.tech-body { color: var(--ink-soft); font-size: var(--fs-sm); margin: 0 0 var(--sp-2); }

/* ── Picker de produto (tela escolher, modo novo) ─────── */
.pick-card { display: flex; align-items: center; gap: var(--sp-3); text-decoration: none; color: var(--ink); }
a.pick-card:hover { box-shadow: 0 2px 10px rgba(16, 24, 40, .12); }
.pick-main { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.pick-count { flex: none; color: var(--ink-soft); font-size: var(--fs-sm); }
.pick-arrow { color: var(--primary); font-weight: 700; font-size: var(--fs-md); flex: none; }
.pick-card.is-mapped { opacity: .8; }

/* ── Login ────────────────────────────────────────────── */
body.login { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: var(--sp-4); }
.login-card { width: 100%; max-width: 380px; margin: 0 auto; }
.login-title { margin: 0 0 var(--sp-1); font-size: var(--fs-lg); }
.login-card .field-label { margin-top: var(--sp-4); }
.login-card .btn { margin-top: var(--sp-4); }
.login-card .banner { margin: var(--sp-3) 0 0; }
