/* Estilos compartilhados: painel público (/) e área administrativa (/admin).
   Um sistema só: cores, tamanhos de controle, cartões, tabelas e selos. */
:root {
  --bg: #f5f6f8; --card: #fff; --raised: #f9fafb; --hover: #f3f4f6;
  --text: #111827; --muted: #6b7280; --faint: #9ca3af;
  --line: #e5e7eb; --line-strong: #d1d5db;
  --accent: #2563eb; --accent-ink: #fff; --accent-soft: #eef3fe;
  --good: #047857; --good-soft: #e8f6ef; --warn: #b45309; --warn-soft: #fdf3e6;
  --danger: #be123c; --danger-soft: #fdecef; --chip: #f1f3f6;
  --series-1: #2a78d6; --series-2: #eb6834; --grid: #e7e7e4;
  --radius: 12px; --radius-sm: 8px; --ctl: 34px;
  --shadow: 0 1px 2px rgba(17, 24, 39, .04), 0 1px 1px rgba(17, 24, 39, .02);
  --shadow-pop: 0 10px 30px rgba(17, 24, 39, .14);
  color-scheme: light;
}
/* Tema: segue o sistema; o seletor (theme.js) força claro ou escuro com data-theme */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1013; --card: #16191e; --raised: #1b1f25; --hover: #20252c;
    --text: #e7e9ec; --muted: #9aa3ae; --faint: #6b7380;
    --line: #262b33; --line-strong: #353b45;
    --accent: #6ea2ff; --accent-ink: #0e1013; --accent-soft: #18233a;
    --good: #4ccf8f; --good-soft: #12261c; --warn: #f2b25e; --warn-soft: #2a2114;
    --danger: #f7809d; --danger-soft: #2c1520; --chip: #21262d;
    --series-1: #3987e5; --series-2: #d95926; --grid: #2e3138;
    --shadow: none; --shadow-pop: 0 10px 30px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1013; --card: #16191e; --raised: #1b1f25; --hover: #20252c;
  --text: #e7e9ec; --muted: #9aa3ae; --faint: #6b7380;
  --line: #262b33; --line-strong: #353b45;
  --accent: #6ea2ff; --accent-ink: #0e1013; --accent-soft: #18233a;
  --good: #4ccf8f; --good-soft: #12261c; --warn: #f2b25e; --warn-soft: #2a2114;
  --danger: #f7809d; --danger-soft: #2c1520; --chip: #21262d;
  --series-1: #3987e5; --series-2: #d95926; --grid: #2e3138;
  --shadow: none; --shadow-pop: 0 10px 30px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text);
       font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-underline-offset: 2px; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 14.5px; font-weight: 620; letter-spacing: -.005em; }
h3 { font-size: 13px; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; background: var(--chip);
       border-radius: 4px; padding: 1px 5px; }

/* ── Controles ───────────────────────────────────────────────────────────── */
input, select, button, textarea { font: inherit; color: inherit; }
input[type=search], input[type=text], input[type=password], input[type=url], input[type=number], select, textarea {
  background: var(--card); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 6px 10px; min-width: 0; min-height: var(--ctl); transition: border-color .12s, box-shadow .12s;
}
textarea { min-height: auto; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--ctl);
       border: 1px solid var(--line-strong); background: var(--card); border-radius: var(--radius-sm);
       padding: 6px 12px; cursor: pointer; text-decoration: none; color: var(--text); white-space: nowrap;
       font-weight: 500; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.btn.ghost { border-color: transparent; background: none; }
.btn.ghost:hover { background: var(--hover); }
.btn.link { border: 0; background: none; padding: 2px 0; min-height: 0; color: var(--accent); }
.btn.sm { min-height: 28px; padding: 3px 9px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: default; pointer-events: none; }
label.check { display: inline-flex; gap: 7px; align-items: center; cursor: pointer; }
/* Seletor de tema (theme.js) */
.theme-pick { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.theme-pick select { min-height: 30px; padding: 3px 8px; font-size: 12.5px; }

/* Blocos que abrem e fecham (importar, adicionar…) */
details > summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 6px;
                    color: var(--text); font-weight: 500; user-select: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: ""; width: 6px; height: 6px; border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform .15s; margin: 0 2px; }
details[open] > summary::before { transform: rotate(45deg); }

/* ── Estrutura ───────────────────────────────────────────────────────────── */
.topbar { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--card) 92%, transparent);
          backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--line); }
.topbar .inner { max-width: 1200px; margin: 0 auto; padding: 10px 16px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.topbar .brand { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.logo { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: var(--accent-ink);
        display: grid; place-items: center; font-weight: 800; font-size: 15px; flex: none;
        box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .12); }
main { max-width: 1200px; margin: 0 auto; padding: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.clip { overflow: hidden; }
.section { padding: 14px 16px; }
.section + .section { border-top: 1px solid var(--line); }

/* ── Status (bolinha + texto, nunca só cor) ──────────────────────────────── */
.pill { display: inline-flex; align-items: center; gap: 7px; border-radius: 999px; padding: 3px 10px;
        font-size: 12px; background: var(--chip); color: var(--muted); white-space: nowrap; max-width: 100%;
        overflow: hidden; text-overflow: ellipsis; }
.pill > span { overflow: hidden; text-overflow: ellipsis; }
.pill.fresh { cursor: pointer; font: inherit; color: var(--accent); border: 1px solid var(--accent); background: var(--accent-soft); }
.pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); display: inline-block; flex: none; }
.pill.ok { color: var(--good); background: var(--good-soft); }
.pill.ok i { background: var(--good); }
.pill.run { color: var(--accent); background: var(--accent-soft); }
.pill.run i { background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.pill.warn { color: var(--warn); background: var(--warn-soft); }
.pill.warn i { background: var(--warn); }
.pill.err { color: var(--danger); background: var(--danger-soft); }
.pill.err i { background: var(--danger); }
@keyframes pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .pill.run i { animation: none; } * { transition: none !important; } }

/* ── Selos ───────────────────────────────────────────────────────────────── */
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--chip); color: var(--text); border-radius: 6px;
        padding: 0 7px; font-size: 12px; line-height: 21px; white-space: nowrap; }
.chip.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 650; letter-spacing: .02em; }
.chip.good { color: var(--good); background: var(--good-soft); font-weight: 600; }
.chip.warn { color: var(--warn); background: var(--warn-soft); }
.chip.accent { color: var(--accent); background: var(--accent-soft); }
.chip.bad { color: var(--danger); background: var(--danger-soft); }
.chip button { border: 0; background: none; padding: 0 0 0 2px; cursor: pointer; color: inherit; font-size: 14px; line-height: 1; }

/* ── Tabelas ─────────────────────────────────────────────────────────────── */
table.grid { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.grid th { position: sticky; top: 0; z-index: 1; background: var(--raised); text-align: left; font-weight: 550;
                color: var(--muted); font-size: 11.5px; letter-spacing: .02em; text-transform: uppercase;
                padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.grid td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid tbody tr:hover td { background: var(--raised); }
table.grid tr:last-child td { border-bottom: 0; }
table.grid td.num, table.grid th.num { text-align: right; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.table-wrap.scroll { max-height: 560px; overflow: auto; overscroll-behavior: contain; }

.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--card);
         padding: 9px 16px; border-radius: 10px; font-size: 13px; z-index: 20; box-shadow: var(--shadow-pop); max-width: calc(100% - 32px); }
.toast[hidden] { display: none; }
