/* ============================================================================
   rag-v5 — design system "Console" (redesign 2026)
   Dois temas: claro (padrão) + escuro. Acento verde. Sidebar sempre escura no
   tema claro; tudo escuro no tema escuro. Portável p/ Flask (static/css/style.css).
   Fontes: Hanken Grotesk (UI) + JetBrains Mono (dados/labels).
   ============================================================================ */

/* ---------- TOKENS: tema CLARO (padrão) ---------- */
:root {
  /* surfaces (conteúdo) */
  --bg:            #eceef1;
  --surface:       #ffffff;
  --surface-2:     #f6f8fa;
  --surface-3:     #eef1f4;
  --inset:         #f1f3f5;
  --border:        #e3e7ec;
  --border-strong: #cfd6de;

  /* texto */
  --text:        #1c2632;
  --text-strong: #0b0f14;
  --text-muted:  #586271;
  --text-faint:  #98a2b0;

  /* sidebar (escura no claro) */
  --side-bg:      #0e1620;
  --side-bg-2:    #0b1118;
  --side-border:  rgba(255,255,255,.08);
  --side-text:    #d6deea;
  --side-muted:   rgba(214,222,234,.56);
  --side-faint:   rgba(214,222,234,.34);
  --side-hover:   rgba(255,255,255,.05);
  --side-accent:  #34d399;
  --side-active:  rgba(52,211,153,.14);

  /* acento (conteúdo) */
  --accent:        #0c9b62;
  --accent-hi:     #0a8957;
  --accent-soft:   rgba(12,155,98,.10);
  --accent-border: rgba(12,155,98,.30);
  --accent-ink:    #ffffff;

  /* semânticas */
  --green:   #0c9b62; --green-soft:  rgba(12,155,98,.12);
  --red:     #d92649; --red-soft:    rgba(217,38,73,.10);
  --yellow:  #b07a16; --yellow-soft: rgba(176,122,22,.12);
  --blue:    #2563eb; --blue-soft:   rgba(37,99,235,.10);
  --violet:  #7c3aed; --violet-soft: rgba(124,58,237,.10);

  --shadow-sm:  0 1px 2px rgba(16,24,40,.05);
  --shadow:     0 1px 2px rgba(16,24,40,.04), 0 2px 6px rgba(16,24,40,.06);
  --shadow-lg:  0 8px 28px rgba(16,24,40,.12);
  --shadow-pop: 0 12px 40px rgba(16,24,40,.18);

  /* tipografia */
  --font-ui:   'Hanken Grotesk', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  /* layout / forma (tweakáveis) */
  --sidebar-w: 250px;
  --topbar-h:  56px;
  --radius:    12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  /* densidade (tweakável) */
  --pad:     22px;
  --gap:     16px;
  --row-pad: 11px 16px;
  --maxw:    1500px;

  --ease: cubic-bezier(.2,.8,.2,1);
}

/* ---------- TOKENS: tema ESCURO ---------- */
[data-theme="dark"] {
  --bg:            #0b0d11;
  --surface:       #15181e;
  --surface-2:     #1b1f27;
  --surface-3:     #232834;
  --inset:         #0f1217;
  --border:        rgba(255,255,255,.08);
  --border-strong: rgba(255,255,255,.15);

  --text:        #e7eaee;
  --text-strong: #fbfcfd;
  --text-muted:  rgba(231,234,238,.58);
  --text-faint:  rgba(231,234,238,.32);

  --side-bg:     #0c0e12;
  --side-bg-2:   #090a0d;
  --side-border: rgba(255,255,255,.07);
  --side-text:   #d6deea;
  --side-muted:  rgba(214,222,234,.50);
  --side-faint:  rgba(214,222,234,.30);
  --side-hover:  rgba(255,255,255,.05);
  --side-accent: #34d399;
  --side-active: rgba(52,211,153,.14);

  --accent:        #34d399;
  --accent-hi:     #6ee7b7;
  --accent-soft:   rgba(52,211,153,.13);
  --accent-border: rgba(52,211,153,.34);
  --accent-ink:    #04140c;

  --green:  #34d399; --green-soft:  rgba(52,211,153,.14);
  --red:    #fb7185; --red-soft:    rgba(251,113,133,.14);
  --yellow: #fbbf24; --yellow-soft: rgba(251,191,36,.14);
  --blue:   #60a5fa; --blue-soft:   rgba(96,165,250,.14);
  --violet: #a78bfa; --violet-soft: rgba(167,139,250,.14);

  --shadow-sm:  0 1px 2px rgba(0,0,0,.4);
  --shadow:     0 1px 3px rgba(0,0,0,.45);
  --shadow-lg:  0 12px 36px rgba(0,0,0,.55);
  --shadow-pop: 0 16px 48px rgba(0,0,0,.6);
}

/* ---------- ACENTO tweakável ---------- */
[data-accent="blue"]   { --accent:#1d6ad6; --accent-hi:#175bc0; --accent-soft:rgba(29,106,214,.10); --accent-border:rgba(29,106,214,.30); --side-accent:#60a5fa; --side-active:rgba(96,165,250,.16); }
[data-theme="dark"][data-accent="blue"]   { --accent:#60a5fa; --accent-hi:#93c5fd; --accent-soft:rgba(96,165,250,.14); --accent-border:rgba(96,165,250,.34); --accent-ink:#03101f; }
[data-accent="violet"] { --accent:#7c3aed; --accent-hi:#6d28d9; --accent-soft:rgba(124,58,237,.10); --accent-border:rgba(124,58,237,.30); --side-accent:#a78bfa; --side-active:rgba(167,139,250,.16); }
[data-theme="dark"][data-accent="violet"] { --accent:#a78bfa; --accent-hi:#c4b5fd; --accent-soft:rgba(167,139,250,.14); --accent-border:rgba(167,139,250,.34); --accent-ink:#120726; }
[data-accent="amber"]  { --accent:#b5740b; --accent-hi:#9c6309; --accent-soft:rgba(181,116,11,.10); --accent-border:rgba(181,116,11,.30); --side-accent:#f59e0b; --side-active:rgba(245,158,11,.16); }
[data-theme="dark"][data-accent="amber"]  { --accent:#f59e0b; --accent-hi:#fbbf24; --accent-soft:rgba(245,158,11,.14); --accent-border:rgba(245,158,11,.34); --accent-ink:#180f01; }

/* ---------- DENSIDADE / RAIO tweakáveis ---------- */
[data-density="compact"] { --pad:14px; --gap:10px; --row-pad:7px 12px; }
[data-density="comfy"]   { --pad:28px; --gap:20px; --row-pad:14px 18px; }
[data-radius="sharp"]    { --radius:6px;  --radius-sm:4px;  --radius-lg:8px; }
[data-radius="round"]    { --radius:18px; --radius-sm:12px; --radius-lg:24px; }

/* ============================================================================
   RESET / BASE
   ============================================================================ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
.mono { font-family: var(--font-mono); }
.tabular { font-variant-numeric: tabular-nums; }
.spacer { flex: 1; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
::selection { background: var(--accent-soft); }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ============================================================================
   SHELL — sidebar / topbar / drawer / content
   ============================================================================ */
.app { min-height: 100vh; }

/* mobile topbar (escondida no desktop) */
.topbar { display: none; }

.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
  background: var(--side-bg);
  border-right: 1px solid var(--side-border);
  display: flex; flex-direction: column;
  z-index: 40;
}
.side-head { display: flex; align-items: center; gap: 9px; padding: 18px 20px 16px; }
.logo { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 17px; letter-spacing: -.02em; color: #fff; }
.logo .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--side-accent); box-shadow: 0 0 0 3px var(--side-active); }
.logo .v { color: var(--side-accent); }
.side-head .ver { margin-left: auto; font-family: var(--font-mono); font-size: 10.5px; color: var(--side-faint); padding: 2px 8px; border: 1px solid var(--side-border); border-radius: var(--radius-pill); }

.side-nav { flex: 1; overflow-y: auto; padding: 4px 12px 12px; }
.side-nav::-webkit-scrollbar { width: 8px; }
.side-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); }
.nav-label { font-family: var(--font-mono); font-size: 10px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--side-faint); margin: 16px 10px 7px; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 8px 11px;
  border-radius: var(--radius-sm); color: var(--side-muted);
  font-size: 13px; font-weight: 500; cursor: pointer; transition: background .14s, color .14s;
}
.nav-item svg { width: 17px; height: 17px; flex: none; opacity: .85; }
.nav-item .t { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item:hover { background: var(--side-hover); color: #fff; }
.nav-item.active { background: var(--side-active); color: var(--side-accent); }
.nav-item.active svg { opacity: 1; }
.nav-item .count { font-family: var(--font-mono); font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: var(--radius-pill); background: rgba(255,255,255,.07); color: var(--side-muted); }
.nav-item .count.live { background: var(--side-accent); color: #04140c; }
.nav-item .count.warn { background: var(--red-soft); color: var(--red); }

.side-foot { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--side-border); }
.side-foot .avatar { width: 32px; height: 32px; border-radius: var(--radius-sm); background: var(--side-accent); color: #04140c; display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none; }
.side-foot .who { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.side-foot .who b { font-size: 13px; color: #fff; font-weight: 600; }
.side-foot .who small { font-family: var(--font-mono); font-size: 10px; color: var(--side-faint); }
.side-foot .ico-btn { margin-left: auto; }
.ico-btn { display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--radius-sm); color: var(--side-muted); cursor: pointer; background: transparent; border: none; transition: background .14s, color .14s; }
.ico-btn:hover { background: var(--side-hover); color: #fff; }
.ico-btn svg { width: 17px; height: 17px; }
.ico-btn.danger:hover { background: var(--red-soft); color: var(--red); }

.backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 35; opacity: 0; transition: opacity .2s; }
.backdrop.show { display: block; opacity: 1; }

.content { margin-left: var(--sidebar-w); padding: var(--pad) calc(var(--pad) + 6px) 80px; max-width: calc(var(--maxw) + var(--sidebar-w)); }

/* ============================================================================
   PAGE HEADER
   ============================================================================ */
.page-head { display: flex; align-items: center; gap: 13px; flex-wrap: wrap; margin-bottom: 4px; }
.page-head h1 { font-size: 25px; font-weight: 700; letter-spacing: -.025em; color: var(--text-strong); margin: 0; white-space: nowrap; }
.page-head .sep { color: var(--text-faint); font-size: 18px; }
.page-head .sub { color: var(--text-muted); font-size: 15px; }
.page-sub { color: var(--text-muted); font-size: 14px; margin: 8px 0 calc(var(--gap) + 6px); max-width: 620px; }
.page-sub code { font-family: var(--font-mono); font-size: 12.5px; color: var(--accent); background: var(--accent-soft); padding: 1px 6px; border-radius: 5px; }
.section-label { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 600; color: var(--text-strong); margin: calc(var(--gap) + 8px) 0 var(--gap); }
.section-label small { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); font-weight: 500; }

/* ============================================================================
   BADGES / PILLS
   ============================================================================ */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  padding: 4px 10px; border-radius: var(--radius-pill); border: 1px solid transparent;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.no-dot::before { display: none; }
.badge-ok      { color: var(--green);  background: var(--green-soft);  border-color: transparent; }
.badge-err     { color: var(--red);    background: var(--red-soft); }
.badge-pending { color: var(--yellow); background: var(--yellow-soft); }
.badge-info    { color: var(--blue);   background: var(--blue-soft); }
.badge-accent  { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-border); }
.badge-muted   { color: var(--text-muted); background: var(--surface-3); }
.badge-live::before { animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 var(--accent-soft); } 70% { box-shadow: 0 0 0 6px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* ============================================================================
   BUTTONS
   ============================================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-ui); font-size: 13px; font-weight: 600;
  padding: 8px 15px; min-height: 38px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; transition: background .14s, border-color .14s, transform .08s; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hi); border-color: var(--accent-hi); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { filter: brightness(1.06); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { min-height: 30px; padding: 5px 11px; font-size: 12px; }
.btn-icon { padding: 0; width: 38px; min-height: 38px; }

/* ============================================================================
   CARDS / KPI
   ============================================================================ */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--gap); }
.cards.c6 { grid-template-columns: repeat(6, 1fr); }
.cards.c4 { grid-template-columns: repeat(4, 1fr); }
.cards.c3 { grid-template-columns: repeat(3, 1fr); }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px var(--pad); box-shadow: var(--shadow-sm); transition: border-color .14s, box-shadow .14s, transform .12s;
}
.card.link { cursor: pointer; position: relative; }
.card.link:hover { border-color: var(--accent-border); box-shadow: var(--shadow); transform: translateY(-1px); }
.card-label { font-family: var(--font-mono); font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); display: flex; align-items: center; gap: 7px; margin-bottom: 10px; }
.card-label .sw { width: 8px; height: 8px; border-radius: 50%; }
.card-value { font-size: 30px; font-weight: 700; letter-spacing: -.035em; color: var(--text-strong); font-variant-numeric: tabular-nums; line-height: 1.05; }
.card-value.green { color: var(--green); } .card-value.red { color: var(--red); } .card-value.blue { color: var(--blue); } .card-value.accent { color: var(--accent); } .card-value.yellow { color: var(--yellow); }
.card-trend { font-family: var(--font-mono); font-size: 11.5px; margin-top: 8px; color: var(--text-muted); }
.card-trend.up { color: var(--green); } .card-trend.down { color: var(--red); }
.card.shortcut .card-value { font-size: 15px; font-weight: 600; color: var(--text-strong); letter-spacing: -.01em; }
.card.shortcut .arrow { position: absolute; top: 18px; right: 18px; color: var(--text-faint); transition: transform .16s; }
.card.shortcut:hover .arrow { transform: translateX(3px); color: var(--accent); }

/* ============================================================================
   HERO STAT
   ============================================================================ */
.hero { display: grid; grid-template-columns: 1.6fr 1fr; gap: var(--gap); margin-bottom: var(--gap); }
.hero-main { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--pad); box-shadow: var(--shadow-sm); }
.hero-label { font-family: var(--font-mono); font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); display: flex; align-items: center; gap: 9px; margin-bottom: 14px; }
.hero-value { font-size: clamp(48px, 6vw, 72px); font-weight: 700; letter-spacing: -.045em; color: var(--text-strong); line-height: .95; font-variant-numeric: tabular-nums; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 10px 20px; margin-top: 22px; }
.hero-meta .m { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-muted); }
.hero-meta .m b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.hero-meta .sw { width: 8px; height: 8px; border-radius: 50%; }
.hero-side { display: flex; flex-direction: column; gap: var(--gap); }
.hero-mini { flex: 1; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px var(--pad); display: flex; flex-direction: column; justify-content: center; box-shadow: var(--shadow-sm); }
.hero-mini .l { font-family: var(--font-mono); font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 8px; }
.hero-mini .v { font-size: 30px; font-weight: 700; letter-spacing: -.035em; font-variant-numeric: tabular-nums; }

/* ============================================================================
   WORKERS STRIP
   ============================================================================ */
.workers-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--gap); margin-bottom: var(--gap); }
.worker-row { display: flex; align-items: center; gap: 11px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 15px 18px; cursor: pointer; box-shadow: var(--shadow-sm); transition: border-color .14s; }
.worker-row:hover { border-color: var(--border-strong); }
.worker-row.run { border-color: var(--accent-border); }
.worker-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-faint); flex: none; }
.worker-row.run .worker-dot { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); animation: pulse 2s infinite; }
.worker-name { font-weight: 600; font-size: 13.5px; color: var(--text); }
.worker-state { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); margin-left: auto; }
.worker-row.run .worker-state { color: var(--accent); }

/* ============================================================================
   PANEL + TABLE
   ============================================================================ */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); margin-bottom: var(--gap); overflow: hidden; }
.panel-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.panel-head h2 { font-size: 14.5px; font-weight: 600; color: var(--text-strong); margin: 0; white-space: nowrap; }
.panel-head .sub { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); }
.panel-body { padding: 18px; }
.panel-body.flush { padding: 0; }

.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl thead th { position: sticky; top: 0; font-family: var(--font-mono); font-size: 10.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-faint); text-align: left; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
table.tbl tbody td { padding: var(--row-pad); border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl td.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
table.tbl td.mono, table.tbl td .mono { font-family: var(--font-mono); }
table.tbl td.dim { color: var(--text-muted); }
table.tbl td.email { color: var(--text); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-copy { cursor: pointer; border-radius: 5px; transition: background .12s; }
.cell-copy:hover { background: var(--accent-soft); color: var(--accent); }
.cell-copy.flash { background: var(--green-soft); color: var(--green); }
td code, .code-pill { font-family: var(--font-mono); font-size: 12px; color: var(--blue); background: var(--blue-soft); padding: 2px 7px; border-radius: 5px; }
.totp-live { font-family: var(--font-mono); font-weight: 600; color: var(--green); background: var(--green-soft); padding: 2px 8px; border-radius: 5px; letter-spacing: .08em; }
.empty-row td { text-align: center; color: var(--text-faint); padding: 32px; font-style: italic; }

.kind-tag { font-family: var(--font-mono); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat-pill { font-family: var(--font-mono); font-size: 10.5px; font-weight: 600; padding: 2px 8px; border-radius: 5px; letter-spacing: .03em; display: inline-block; }

/* tabela vira cards no mobile */
@media (max-width: 720px) {
  table.tbl.responsive thead { display: none; }
  table.tbl.responsive, table.tbl.responsive tbody, table.tbl.responsive tr, table.tbl.responsive td { display: block; width: 100%; }
  table.tbl.responsive tr { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 10px; padding: 6px 4px; }
  table.tbl.responsive td { border: none; padding: 6px 14px; display: flex; justify-content: space-between; gap: 16px; text-align: right; }
  table.tbl.responsive td::before { content: attr(data-label); font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); text-align: left; }
  table.tbl.responsive td.email { max-width: none; }
}

/* ============================================================================
   CONTROLS / FILTERS / FORMS
   ============================================================================ */
.controls { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm); margin-bottom: var(--gap); }
.ctl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; align-items: end; }
.ctl-grid .actions { display: flex; gap: 10px; grid-column: 1 / -1; }
@media (min-width: 900px) { .ctl-grid .actions { grid-column: auto; justify-content: flex-end; } }
.field { display: flex; flex-direction: column; gap: 5px; }
.field-label { font-family: var(--font-mono); font-size: 10px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.field-hint { font-size: 11.5px; color: var(--text-faint); }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=search], select, textarea {
  font-family: var(--font-ui); font-size: 13.5px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 11px; min-height: 38px; outline: none; transition: border-color .14s, box-shadow .14s; width: 100%;
}
[data-theme="dark"] input, [data-theme="dark"] select, [data-theme="dark"] textarea { background: var(--inset); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder, textarea::placeholder { color: var(--text-faint); }
textarea { font-family: var(--font-mono); font-size: 12.5px; line-height: 1.6; resize: vertical; min-height: 90px; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; cursor: pointer; }
.input-prefix { display: flex; align-items: center; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); overflow: hidden; }
[data-theme="dark"] .input-prefix { background: var(--inset); }
.input-prefix:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-prefix .pfx { padding: 0 12px; font-family: var(--font-mono); font-size: 13px; color: var(--text-muted); border-right: 1px solid var(--border); align-self: stretch; display: flex; align-items: center; }
.input-prefix input { border: none; box-shadow: none !important; }
input[type=checkbox] { -webkit-appearance: none; appearance: none; width: 18px; height: 18px; min-height: 0; border: 1px solid var(--border-strong); border-radius: 5px; cursor: pointer; position: relative; flex: none; padding: 0; background: var(--surface); }
input[type=checkbox]:checked { background: var(--accent); border-color: var(--accent); }
input[type=checkbox]:checked::after { content: ''; position: absolute; left: 5px; top: 2px; width: 5px; height: 9px; border: solid var(--accent-ink); border-width: 0 2px 2px 0; transform: rotate(45deg); }
label.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; color: var(--text); }

.filter-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { font-family: var(--font-ui); font-size: 12.5px; font-weight: 500; padding: 6px 13px; border-radius: var(--radius-pill); border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); cursor: pointer; transition: all .14s; }
.pill:hover { border-color: var(--border-strong); color: var(--text); }
.pill.active { background: var(--accent-soft); border-color: var(--accent-border); color: var(--accent); }

/* segmented control */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.seg button { font-family: var(--font-ui); font-size: 12.5px; font-weight: 500; padding: 5px 13px; border: none; background: transparent; color: var(--text-muted); border-radius: calc(var(--radius-sm) - 2px); cursor: pointer; }
.seg button.active { background: var(--surface); color: var(--text-strong); box-shadow: var(--shadow-sm); font-weight: 600; }

/* ============================================================================
   LOG BOX / PROGRESS
   ============================================================================ */
.log-box { font-family: var(--font-mono); font-size: 12px; line-height: 1.7; background: var(--inset); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; max-height: 320px; overflow-y: auto; white-space: pre-wrap; word-break: break-word; }
.log-ok { color: var(--green); } .log-err { color: var(--red); } .log-info { color: var(--blue); } .log-sys { color: var(--text-faint); }
.progress { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .4s var(--ease); }

/* ============================================================================
   GRIDS / HELPERS
   ============================================================================ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.grid-1-2 { display: grid; grid-template-columns: 1fr 2fr; gap: var(--gap); }
.row-flex { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.note { background: var(--accent-soft); border: 1px solid var(--accent-border); border-radius: var(--radius-sm); padding: 12px 15px; color: var(--text); font-size: 13px; }

/* ============================================================================
   TOAST
   ============================================================================ */
.toast-host { position: fixed; top: 18px; right: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 90; }
.toast { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--text-faint); border-radius: var(--radius-sm); padding: 11px 16px; font-size: 13px; box-shadow: var(--shadow-lg); transform: translateX(120%); transition: transform .3s var(--ease); min-width: 220px; }
.toast.in { transform: translateX(0); }
.toast.ok { border-left-color: var(--green); } .toast.err { border-left-color: var(--red); }

/* ============================================================================
   TWEAKS PANEL (vanilla, design-time)
   ============================================================================ */
#tweaks { position: fixed; right: 18px; bottom: 18px; width: 268px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow-pop); z-index: 100; font-family: var(--font-ui); display: none; overflow: hidden; }
#tweaks.show { display: block; }
#tweaks .tw-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: move; }
#tweaks .tw-head b { font-size: 13px; color: var(--text-strong); }
#tweaks .tw-head .x { margin-left: auto; cursor: pointer; color: var(--text-faint); background: none; border: none; font-size: 16px; line-height: 1; }
#tweaks .tw-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 14px; }
#tweaks .tw-sec { font-family: var(--font-mono); font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-faint); }
#tweaks .tw-row { display: flex; flex-direction: column; gap: 6px; }
#tweaks .tw-row > span { font-size: 12px; color: var(--text-muted); }
#tweaks .tw-seg { display: flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
#tweaks .tw-seg button { flex: 1; font-size: 11.5px; font-weight: 500; padding: 5px 4px; border: none; background: transparent; color: var(--text-muted); border-radius: calc(var(--radius-sm) - 2px); cursor: pointer; text-transform: capitalize; }
#tweaks .tw-seg button.on { background: var(--surface); color: var(--text-strong); box-shadow: var(--shadow-sm); font-weight: 600; }
#tweaks .tw-swatches { display: flex; gap: 8px; }
#tweaks .tw-swatches button { width: 30px; height: 30px; border-radius: 8px; border: 2px solid transparent; cursor: pointer; }
#tweaks .tw-swatches button.on { border-color: var(--text-strong); }

/* ============================================================================
   ME-CARD (sidebar funcionário)
   ============================================================================ */
.me-card { margin: 6px 12px 10px; padding: 13px; background: rgba(52,211,153,.10); border: 1px solid rgba(52,211,153,.22); border-radius: var(--radius-sm); }
.me-card .me-top { display: flex; align-items: center; gap: 10px; }
.me-card .me-avatar { width: 36px; height: 36px; border-radius: var(--radius-sm); background: var(--side-accent); color: #04140c; display: grid; place-items: center; font-weight: 700; font-size: 15px; flex: none; }
.me-card .me-name { font-size: 13.5px; font-weight: 600; color: #fff; }
.me-card .me-role { font-family: var(--font-mono); font-size: 10px; color: var(--side-muted); }
.me-card .me-stats { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; padding-top: 11px; border-top: 1px solid rgba(255,255,255,.08); }
.me-card .me-stats > div { display: flex; justify-content: space-between; align-items: baseline; }
.me-card .me-l { font-size: 11.5px; color: var(--side-muted); }
.me-card .me-v { font-family: var(--font-mono); font-size: 13px; font-weight: 600; color: #fff; }
.me-card .me-v.accent { color: var(--side-accent); }

/* prize / egg / rank grids */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--gap); }
.prize { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; box-shadow: var(--shadow-sm); }
.prize .pm { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prize .pn { font-weight: 600; font-size: 13.5px; margin: 5px 0 2px; }
.prize .pr { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-faint); }
.rank-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; box-shadow: var(--shadow-sm); border-left: 3px solid var(--border-strong); }
.rank-card.rare { border-left-color: var(--yellow); }
.rank-card .rk { font-family: var(--font-mono); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-faint); }
.rank-card .rn { font-weight: 600; font-size: 13px; margin: 4px 0; }
.rank-card .rc { font-family: var(--font-mono); font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.rank-card .rp { font-size: 11px; color: var(--text-muted); }
.chip-cat { font-family: var(--font-ui); font-size: 12.5px; font-weight: 500; padding: 6px 13px; border-radius: var(--radius-pill); border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); cursor: pointer; }
.chip-cat.active { background: var(--accent-soft); border-color: var(--accent-border); color: var(--accent); }

/* stack bar */
.stack { display: flex; height: 14px; border-radius: var(--radius-pill); overflow: hidden; }
.stack > i { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 14px; }
.legend .lg { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-muted); }
.legend .sw { width: 9px; height: 9px; border-radius: 3px; }

/* dropzone */
.dropzone { border: 1.5px dashed var(--border-strong); border-radius: var(--radius-sm); padding: 22px; text-align: center; color: var(--text-muted); cursor: pointer; transition: border-color .14s, background .14s; }
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone .dz-ic { color: var(--text-faint); margin-bottom: 8px; }
.dropzone .dz-hint { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); margin-top: 4px; }

/* action tiles (admin) */
.action-tile { display: flex; flex-direction: column; gap: 4px; text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; cursor: pointer; transition: border-color .14s; box-shadow: var(--shadow-sm); }
.action-tile:hover { border-color: var(--border-strong); }
.action-tile.danger:hover { border-color: var(--red); background: var(--red-soft); }
.action-tile .at-title { font-weight: 600; font-size: 13.5px; color: var(--text-strong); }
.action-tile .at-desc { font-size: 12px; color: var(--text-muted); }
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.danger-zone { border-color: var(--red-soft); }
.danger-zone .panel-head { border-bottom-color: var(--red-soft); }
.pool-row { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.pool-row:last-child { border-bottom: none; }
.pool-row .pv { font-family: var(--font-mono); font-weight: 600; font-variant-numeric: tabular-nums; }

/* worker cards (distributed) */
.wk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--gap); }
.wk-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; box-shadow: var(--shadow-sm); }
.wk-card.run { border-color: var(--accent-border); }
.wk-card .wk-top { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.wk-card .wk-name { font-weight: 600; font-size: 13.5px; }
.wk-card .wk-host { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.wk-card .wk-log { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); margin: 8px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wk-card .wk-acts { display: flex; gap: 6px; }

/* ring */
.ring-wrap { display: flex; align-items: center; gap: 16px; }
.ring { width: 92px; height: 92px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 9; }
.ring-pct { font-family: var(--font-mono); font-size: 19px; font-weight: 700; }

/* pay list (staff pagamentos) */
.pay-row { display: grid; grid-template-columns: 100px 1fr 120px 40px; gap: 14px; align-items: center; padding: var(--row-pad); border-bottom: 1px solid var(--border); cursor: pointer; font-size: 13px; }
.pay-row:hover { background: var(--surface-2); }
.pay-detail { display: none; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 14px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.pay-detail.open { display: grid; }
.pay-detail .pd-l { font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); }
.pay-detail .pd-v { font-size: 13px; margin-top: 3px; }

/* ============================================================================
   RESPONSIVO
   ============================================================================ */
@media (max-width: 1080px) { .hero { grid-template-columns: 1fr; } .workers-strip { grid-template-columns: repeat(2, 1fr); } .cards.c6 { grid-template-columns: repeat(3, 1fr); } .cards.c4 { grid-template-columns: repeat(2, 1fr); } .grid-1-2, .grid-2 { grid-template-columns: 1fr; } }

@media (max-width: 860px) {
  .topbar { display: flex; align-items: center; gap: 12px; position: sticky; top: 0; height: var(--topbar-h); padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--border); z-index: 30; }
  .topbar .logo { color: var(--text-strong); font-size: 16px; }
  .topbar .logo .dot { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
  .topbar .logo .v { color: var(--accent); }
  .sidebar { transform: translateX(-100%); transition: transform .26s var(--ease); width: 280px; }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-pop); }
  .content { margin-left: 0; padding: 16px 16px 80px; }
  .cards.c6, .cards.c4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  .workers-strip, .cards.c6, .cards.c4, .cards.c3 { grid-template-columns: 1fr 1fr; }
  .page-head h1 { font-size: 21px; }
  #tweaks { right: 12px; left: 12px; width: auto; bottom: 12px; }
}
