/* ═══════════════ GioSMB — design system ═══════════════ */
:root {
  --bg: #f4f5f9;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --fg: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --ok: #16a34a;
  --ok-soft: #f0fdf4;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --sidebar: #0f172a;
  --sidebar-fg: #cbd5e1;
  --sidebar-muted: #64748b;
  --sidebar-active: #1e293b;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgb(16 24 40 / .05), 0 1px 3px rgb(16 24 40 / .06);
  --shadow-lg: 0 20px 40px -12px rgb(16 24 40 / .25);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f17; --surface: #121826; --surface-2: #161d2d; --fg: #e5e7eb; --muted: #94a3b8;
    --line: #232c3d; --line-strong: #334155; --primary: #6366f1; --primary-hover: #818cf8;
    --primary-soft: #1e1b4b; --danger: #f87171; --danger-soft: #2a1215; --ok: #4ade80; --ok-soft: #0f2418;
    --warn: #fbbf24; --warn-soft: #2a1f08; --sidebar: #070a10; --sidebar-active: #131a28;
    --shadow: 0 1px 2px rgb(0 0 0 / .4); --shadow-lg: 0 20px 40px -12px rgb(0 0 0 / .6);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); min-height: 100vh; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: var(--mono); font-size: .9em; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h2 { font-size: 1rem; font-weight: 600; }
h3 { font-size: .95rem; font-weight: 600; margin: 18px 0 8px; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ── Shell ── */
.has-shell { display: block; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 50; width: min(280px, 85vw); height: 100dvh;
  display: flex; flex-direction: column; background: var(--sidebar); color: var(--sidebar-fg);
  padding: 18px 12px calc(12px + env(safe-area-inset-bottom)); transform: translateX(-100%);
  transition: transform .22s ease; box-shadow: var(--shadow-lg);
}
.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }
.nav-toggle:checked ~ .sidebar { transform: none; }
.nav-backdrop { display: none; }
.nav-toggle:checked ~ .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 40; background: rgb(15 23 42 / .5); backdrop-filter: blur(2px); }
.menu-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; margin-left: -8px; border-radius: var(--radius-sm); cursor: pointer; color: var(--fg); flex-shrink: 0; }
.menu-btn:hover { background: var(--surface-2); }
.menu-btn svg { width: 22px; height: 22px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; font-size: 1.1rem; }
.brand:hover { text-decoration: none; }
.brand-text strong { color: #a5b4fc; font-weight: 700; }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; box-shadow: 0 6px 16px -6px #6366f1;
}
.brand-mark.lg { width: 52px; height: 52px; border-radius: 14px; }
.brand-mark.lg svg { width: 28px; height: 28px; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--sidebar-muted); padding: 14px 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: var(--radius-sm);
  color: var(--sidebar-fg); font-weight: 500; transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--sidebar-active); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--sidebar-active); color: #fff; box-shadow: inset 3px 0 0 #818cf8; }
.nav-item.active svg { color: #a5b4fc; }
.sidebar-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 8px 0; border-top: 1px solid #1e293b; }
.me { display: flex; align-items: center; gap: 10px; min-width: 0; }
.me-text { display: flex; flex-direction: column; min-width: 0; }
.me-text strong { color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.me-text small { color: var(--sidebar-muted); }
.avatar {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: #312e81; color: #c7d2fe; font-weight: 700;
}
.icon-btn { background: transparent; border: 0; color: var(--sidebar-fg); padding: 8px; border-radius: var(--radius-sm); cursor: pointer; }
.icon-btn:hover { background: var(--sidebar-active); color: #fff; }

.main-wrap { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 16px; padding-top: calc(8px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.page-title { font-size: 1.1rem; font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.content { padding: 16px 12px calc(40px + env(safe-area-inset-bottom)); max-width: 1400px; width: 100%; }
.job-status { font-size: .88rem; }
.job-status:not(:empty) { padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }

/* ── Blocos ── */
.page-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.lead { margin: 0; color: var(--muted); }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head h2 .muted { font-weight: 400; margin-left: 6px; }
.link-more { font-size: .88rem; font-weight: 500; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }
.grid-2 .card { margin-bottom: 20px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat {
  display: flex; align-items: center; gap: 14px; padding: 18px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); color: var(--fg); transition: transform .15s, box-shadow .15s; min-width: 0;
}
a.stat:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0; }
.stat-icon svg { width: 22px; height: 22px; }
.tone-indigo { background: #eef2ff; color: #4f46e5; }
.tone-amber { background: #fffbeb; color: #d97706; }
.tone-sky { background: #f0f9ff; color: #0284c7; }
.tone-violet { background: #f5f3ff; color: #7c3aed; }
@media (prefers-color-scheme: dark) {
  .tone-indigo { background: #1e1b4b; color: #a5b4fc; } .tone-amber { background: #2a1f08; color: #fbbf24; }
  .tone-sky { background: #0c2536; color: #7dd3fc; } .tone-violet { background: #241a3d; color: #c4b5fd; }
}
.stat-body { display: flex; flex-direction: column; min-width: 0; }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.stat-value small { font-size: .9rem; color: var(--muted); font-weight: 500; }
.stat-label { color: var(--muted); font-size: .85rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 10px 20px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }
.health { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.health li { display: flex; align-items: center; gap: 10px; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.dot-ok { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }
.dot-warn { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); }
.dot-danger { background: var(--danger); box-shadow: 0 0 0 4px var(--danger-soft); }

/* ── Botões e campos ── */
button, select, input, textarea { font: inherit; color: inherit; }
button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px;
  border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--radius-sm);
  font-weight: 500; cursor: pointer; transition: background .15s, border-color .15s, box-shadow .15s;
}
button:hover { background: var(--surface-2); }
button:disabled { opacity: .55; cursor: not-allowed; }
button svg { width: 16px; height: 16px; }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 1px 2px rgb(79 70 229 / .3); }
button.primary:hover { background: var(--primary-hover); }
button.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
button.danger:hover { background: var(--danger-soft); }
button.small { padding: 4px 10px; font-size: .85rem; }
button.block { width: 100%; padding: 10px; }
button.link { border: 0; background: none; color: var(--primary); padding: 0; font-weight: 500; }
button.link:hover { text-decoration: underline; background: none; }
button.icon { border: 0; background: none; font-size: 1.1rem; padding: 4px 8px; color: var(--muted); }
button.htmx-request { opacity: .7; cursor: progress; }
input:not([type=checkbox]):not([type=radio]), select, textarea {
  width: 100%; max-width: 100%; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); }
.grid select { width: auto; min-width: 150px; padding: 5px 8px; }
label { font-weight: 500; font-size: .9rem; }
.check { display: inline-flex; gap: 8px; align-items: center; font-weight: 400; margin: 4px 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack > label, .cols label { display: flex; flex-direction: column; gap: 6px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 18px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 14px 14px; margin: 0; min-width: 0; }
legend { color: var(--muted); font-size: .85rem; font-weight: 600; padding: 0 6px; }
form.inline { display: inline; }

/* ── Tabelas ── */
.table-wrap { overflow-x: auto; max-width: 100%; }
.grid { width: 100%; border-collapse: collapse; }
.grid th, .grid td { padding: 11px 16px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line); }
.grid th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
.grid tbody tr { transition: background .1s; }
.grid tbody tr:hover { background: var(--surface-2); }
.grid tbody tr:last-child td { border-bottom: 0; }
.card:not(.flush) .grid { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.grid .tag { margin-right: 3px; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.truncate { max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.right .small + .small, td.right button + button { margin-left: 4px; }
.empty, td.muted[colspan] { text-align: center; color: var(--muted); padding: 36px 16px; }

/* ── Badges, tags, alertas ── */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px;
  font-size: .78rem; font-weight: 600; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.synced { color: var(--ok); background: var(--ok-soft); }
.badge.pending { color: var(--warn); background: var(--warn-soft); }
.badge.drift, .badge.error { color: var(--danger); background: var(--danger-soft); }
.tag { display: inline-block; font-size: .72rem; font-weight: 600; padding: 1px 7px; border-radius: 6px; background: var(--primary-soft); color: var(--primary); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.ok { color: var(--ok); }
.err { color: var(--danger); }
.error:not(.badge), .alert { display: flex; align-items: center; gap: 8px; margin: 0; padding: 10px 12px; border-radius: var(--radius-sm); width: 100%; }
.error:not(.badge), .alert-danger { color: var(--danger); background: var(--danger-soft); border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent); }

/* ── Modal ── */
dialog.modal {
  width: min(760px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); overflow: auto;
  border: 1px solid var(--line); border-radius: 16px; padding: 22px 24px; background: var(--surface); color: var(--fg);
  box-shadow: var(--shadow-lg); animation: pop .18s ease-out;
}
dialog.modal.wide { width: min(1000px, calc(100vw - 32px)); }
dialog.modal.narrow { width: min(460px, calc(100vw - 32px)); }
dialog::backdrop { background: rgb(15 23 42 / .55); backdrop-filter: blur(3px); animation: fade .18s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes fade { from { opacity: 0; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.modal-head h2 { font-size: 1.1rem; min-width: 0; overflow-wrap: anywhere; }
.modal-head code { word-break: break-all; }
.inherited { margin: 0 0 12px; }
.inherited ul { margin: 6px 0; padding-left: 20px; }
.row-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.row-form select { width: auto; }
pre.conf { max-height: 65dvh; overflow: auto; background: var(--surface-2); border: 1px solid var(--line); padding: 14px; border-radius: var(--radius-sm); font-size: .82rem; }
pre.json { white-space: pre-wrap; word-break: break-all; background: var(--surface-2); padding: 8px; border-radius: 6px; max-width: 100%; font-size: .8rem; }
.filters { border: 0; margin: 0 0 14px; padding: 0; }
.filters label { display: flex; gap: 8px; align-items: center; }

/* ── Login ── */
.no-shell { display: grid; place-items: center; background: radial-gradient(1200px 600px at 10% -10%, #c7d2fe 0, transparent 60%), radial-gradient(900px 500px at 110% 110%, #ddd6fe 0, transparent 55%), var(--bg); }
@media (prefers-color-scheme: dark) { .no-shell { background: radial-gradient(1200px 600px at 10% -10%, #1e1b4b 0, transparent 60%), var(--bg); } }
.login { width: min(400px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 32px; }
.login-brand { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; margin-bottom: 24px; }
.login-brand h1 { font-size: 1.6rem; font-weight: 700; }
.login-brand h1 strong { color: var(--primary); }
.login-brand p { margin: 0; }
.login-foot { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 18px 0 0; }
.login-foot svg { width: 14px; height: 14px; }

/* ── Toasts ── */
#toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 1000; }
.toast {
  background: #111827; color: #f9fafb; padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow-lg);
  max-width: 380px; border-left: 4px solid #818cf8; animation: pop .2s ease-out;
}

/* ── Explorador de arquivos ── */
.files-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; font-family: var(--mono); font-size: .9rem; min-width: 0; overflow-wrap: anywhere; }
.crumbs a { display: inline-flex; align-items: center; min-height: 36px; padding: 4px 8px; border-radius: 6px; color: var(--fg); }
.crumbs a:hover { background: var(--surface-2); text-decoration: none; }
.crumbs .sep { color: var(--muted); }
.goto { display: flex; gap: 6px; min-width: min(420px, 100%); }
.goto input { font-family: var(--mono); font-size: .85rem; }
.files-note { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--ok-soft); }
#files-panel > .alert { margin: 12px 16px; width: auto; }
.alert-warn { color: var(--warn); background: var(--warn-soft); }
.fname { display: inline-flex; align-items: center; gap: 8px; color: var(--fg); font-weight: 500; overflow-wrap: anywhere; }
a.fname:hover { color: var(--primary); text-decoration: none; }
.ico-dir { color: #d97706; fill: color-mix(in srgb, #f59e0b 25%, transparent); }
.ico-file { color: var(--muted); }
.files code { font-size: .82rem; }
.acl { color: var(--primary); font-weight: 700; margin-left: 2px; }
.files-note.ro { background: var(--surface-2); color: var(--muted); }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.perm-grid { width: 100%; max-width: 460px; }
.perm-grid th, .perm-grid td { text-align: center; padding: 8px 6px; }
.perm-grid th[scope=row] { text-align: left; text-transform: none; font-size: .9rem; color: var(--fg); background: transparent; }

/* ── Editor de texto ── */
a.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--fg); font-weight: 500; }
a.btn:hover { background: var(--surface-2); text-decoration: none; }
a.btn.small { padding: 4px 10px; font-size: .85rem; }
.editor { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.editor-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.editor-text {
  width: 100%; min-height: calc(100dvh - 260px); border: 0 !important; border-radius: 0 !important; box-shadow: none !important;
  padding: 14px 16px !important; font-family: var(--mono); font-size: 13.5px; line-height: 1.55; tab-size: 4;
  resize: vertical; background: var(--surface); white-space: pre; overflow: auto;
}
.editor-text.wrap { white-space: pre-wrap; }
.editor-status { display: inline-flex; align-items: center; gap: 6px; font-size: .88rem; }
.editor-status svg { width: 16px; height: 16px; }
.editor-dirty::after { content: " ●"; color: var(--warn); }

/* ── Terminal ── */
.term-card { background: #0b0f17; border-color: #1e293b; }
.term-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; background: #111827; color: #cbd5e1; border-bottom: 1px solid #1e293b; }
.term-bar svg { width: 16px; height: 16px; vertical-align: -3px; }
.term-bar code { color: #a5b4fc; }
.term { height: calc(100dvh - 250px); min-height: 360px; padding: 8px 10px; }
.term-lock { max-width: 440px; margin: 40px auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.term-lock form { width: 100%; }
.lock-ico { width: 40px; height: 40px; color: var(--primary); }

/* ── Fluxo simplificado ── */
.step { display: flex; gap: 14px; align-items: flex-start; }
.step-n { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 700; flex-shrink: 0; margin-top: 2px; }
.step-body { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.step-body > label { display: flex; flex-direction: column; gap: 6px; }
.step-title { margin: 4px 0 0; font-weight: 600; }
.picker { border: 1px solid var(--line); border-radius: var(--radius-sm); max-height: 320px; overflow: auto; }
.picker-head { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--surface-2); padding: 6px 12px; font-weight: 600; position: sticky; top: 0; z-index: 1; }
.picker-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; border-top: 1px solid var(--line); }
.picker-row span { display: inline-flex; align-items: center; gap: 8px; min-width: 0; overflow-wrap: anywhere; }
.picker-row svg { width: 16px; height: 16px; color: var(--muted); }
.level-select { width: auto !important; min-width: 170px; }
.advanced summary { cursor: pointer; color: var(--muted); font-weight: 500; min-height: 36px; display: flex; align-items: center; }
.advanced .checks { margin-top: 10px; }
.share-hero { display: flex; gap: 18px; align-items: flex-start; }
.share-hero > div { min-width: 0; flex: 1; }
.share-hero h2 { font-size: 1.25rem; display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 6px; }
.share-hero .kv { margin-top: 10px; }
.tree-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.radio-card { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; font-weight: 400; }
.radio-card:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.radio-card input { margin-top: 3px; accent-color: var(--primary); }
.sub-form:has(input[value=inherit]:checked) .sub-picker { opacity: .45; pointer-events: none; }


/* ═══════════════ Mobile first: celular é a base; telas maiores ampliam ═══════════════ */

/* Toque: alvos ≥ 44px, fonte 16px em campos (evita zoom automático no iOS) */
button, a.btn { min-height: 44px; }
button.small, a.btn.small { min-height: 40px; padding: 6px 12px; }
button.link { min-height: 32px; display: inline-flex; align-items: center; }
button.icon, .icon-btn { min-width: 44px; min-height: 44px; display: inline-grid; place-items: center; padding: 8px; }
input:not([type=checkbox]):not([type=radio]), select, textarea { font-size: 16px; min-height: 44px; }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; flex-shrink: 0; }
.check { min-height: 40px; }

/* Blocos empilhados no celular */
.page-actions { flex-direction: column; align-items: stretch; gap: 12px; }
.page-actions .actions { justify-content: flex-start; }
.page-actions .actions > button, .page-actions > button, .page-actions .actions > a.btn, .page-actions > a.btn { flex: 1 1 auto; }
.card { padding: 16px; border-radius: 12px; margin-bottom: 14px; }
.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat { flex-direction: column; align-items: flex-start; gap: 10px; padding: 14px; }
.stat-value { font-size: 1.4rem; }
.grid-2 { grid-template-columns: 1fr; gap: 0; }
.kv { grid-template-columns: 1fr; gap: 2px; }
.kv dd { margin-bottom: 10px; word-break: break-all; }
.share-hero { flex-direction: column; gap: 12px; }
.cols { grid-template-columns: 1fr; }
.actions.right { justify-content: stretch; }
.actions.right > button, .actions.right > form, .actions.right > a.btn { flex: 1; }

/* Tabelas viram cartões no celular (rótulos vêm de data-label) */
.grid:not(.perm-grid) thead { display: none; }
.grid:not(.perm-grid), .grid:not(.perm-grid) tbody { display: block; }
.grid:not(.perm-grid) tr { display: block; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.grid:not(.perm-grid) tbody tr:last-child { border-bottom: 0; }
/* rótulo flutua à esquerda; o conteúdo da célula (vários elementos) fica junto à direita */
.grid:not(.perm-grid) td { display: block; padding: 5px 0; border: 0; text-align: right; min-width: 0; overflow-wrap: anywhere; }
.grid:not(.perm-grid) td::after { content: ""; display: block; clear: both; }
.grid:not(.perm-grid) td[data-label]::before { content: attr(data-label); float: left; margin-right: 12px; color: var(--muted); font-size: .8rem; font-weight: 500; line-height: 1.9; }
.grid:not(.perm-grid) td[data-label=""]::before { content: none; }
.grid:not(.perm-grid) td:first-child { font-size: 1rem; text-align: left; padding-bottom: 8px; }
.grid:not(.perm-grid) td:first-child::before { content: none; }
.grid:not(.perm-grid) td[colspan] { text-align: center; }
.grid:not(.perm-grid) td .audit-details { text-align: left; margin-top: 6px; clear: both; }
.grid:not(.perm-grid) td.right, .grid:not(.perm-grid) td.row-actions { display: flex; justify-content: flex-start; flex-wrap: wrap; gap: 6px; text-align: left; padding-top: 10px; }
.grid:not(.perm-grid) td.right > *, .grid:not(.perm-grid) td.row-actions > * { flex: 1 1 auto; }
.grid:not(.perm-grid) td.right::before, .grid:not(.perm-grid) td.row-actions::before { content: none; }
.grid:not(.perm-grid) td.truncate { max-width: none; white-space: normal; }
.grid:not(.perm-grid) td code { word-break: break-all; }
.grid select { min-width: 0; max-width: 60vw; }
.card:not(.flush) .grid { border: 0; }
.table-wrap { overflow: visible; }
.row-actions { flex-wrap: wrap; justify-content: flex-start; }
.row-actions form.inline { display: contents; }

/* Modais como folha de baixo para cima */
dialog.modal, dialog.modal.wide, dialog.modal.narrow {
  width: 100vw; max-width: 100vw; max-height: 92dvh; margin: auto 0 0; border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); animation: sheet .22s ease-out;
}
@keyframes sheet { from { transform: translateY(40px); opacity: 0; } }
.modal-head { position: sticky; top: -18px; background: var(--surface); margin: -4px 0 12px; padding: 8px 0; border-bottom: 1px solid var(--line); z-index: 2; }
.picker { max-height: 45dvh; }
.picker-row { flex-wrap: wrap; }
.level-select { min-width: 0 !important; flex: 1 1 160px; }
.row-form { flex-direction: column; align-items: stretch; }
.row-form select, .row-form > * { width: 100%; }
#toasts { left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); }
.toast { max-width: none; }

/* Explorador, editor e terminal */
.files-bar { flex-direction: column; align-items: stretch; }
.goto { min-width: 0; width: 100%; }
.files-bar .actions { flex-wrap: wrap; width: 100%; }
.files-bar .actions > button { flex: 1 1 auto; }
.editor-bar { flex-direction: column; align-items: stretch; }
.editor-bar .actions { justify-content: space-between; width: 100%; }
.editor-text { font-size: 13px; min-height: 60dvh; padding: 10px !important; }
.term { height: calc(100dvh - 210px); min-height: 280px; padding: 4px; }
.term-bar { flex-direction: column; align-items: flex-start; }
.term-lock { margin: 12px auto; }
.login { padding: 24px 18px; }

/* ── Segurança / componentes compactos (declarados antes das media queries de ampliação) ── */
.inline-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: end; margin-top: .75rem; }
.inline-form label { display: flex; flex-direction: column; gap: .25rem; font-size: .875rem; }
.howto dt { font-weight: 600; margin-top: .75rem; }
.howto dd { margin: .25rem 0 0; overflow-wrap: anywhere; }
.version-line { margin-top: .75rem; }

.jail-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); }
.jail { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.jail.hot { border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.jail-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.jail-head code { font-size: .9rem; font-weight: 600; overflow-wrap: anywhere; }
.jail-desc { margin: -6px 0 0; color: var(--muted); font-size: .8rem; }
.jail .stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 0; }
.jail .stat, .stats.four .stat {
  flex-direction: column; align-items: flex-start; gap: 2px;
  background: var(--surface-2, color-mix(in srgb, var(--fg) 4%, transparent));
  border: 0; box-shadow: none; border-radius: 8px; padding: 10px 12px;
}
.stat b { display: block; font-size: 1.25rem; line-height: 1.2; }
.stat small { color: var(--muted); font-size: .75rem; }
.ip-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ip-list li { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: space-between; }
.ip-list code { overflow-wrap: anywhere; font-size: .85rem; }
.ip-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.chip { display: inline-flex; align-items: center; gap: 4px; min-height: 36px; padding: 4px 6px 4px 12px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: .82rem; }
.chip code { color: inherit; background: none; }
.chip button { border: 0; background: none; color: inherit; cursor: pointer; padding: 0 6px; font-size: 1.1rem; line-height: 1; min-width: 32px; min-height: 32px; display: inline-grid; place-items: center; border-radius: 50%; }
.form-cards { display: grid; gap: 12px; grid-template-columns: 1fr; margin-top: 14px; }
@media (min-width: 900px) { .form-cards { grid-template-columns: 1fr 1fr; } }
.form-card { border: 1px dashed var(--line); border-radius: var(--radius-sm); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.form-card h3 { margin: 0; font-size: .95rem; }
.form-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: stretch; }
.form-row > input, .form-row > select { flex: 1 1 160px; min-width: 0; }
.form-row > button { flex: 0 0 auto; }
.section-title { margin: 18px 0 8px; font-size: .95rem; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.section-title small { font-weight: 400; }
.tips li + li { margin-top: 6px; }
@media (max-width: 639px) { .grid:not(.perm-grid) td[data-label]:empty { display: none; } }

/* ── Auditoria ── */
.audit-filters { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr)); margin-bottom: 14px; }
.audit-filters label { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; color: var(--muted); min-width: 0; }
.audit-filters .grow { grid-column: span 2; }
@media (max-width: 639px) { .audit-filters .grow { grid-column: 1 / -1; } }
.audit-grid .path { display: inline-block; max-width: 340px; overflow-wrap: anywhere; }
.audit-grid tr.row-fail td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.audit-details dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 8px 0; font-size: .8rem; }
.audit-details dt { color: var(--muted); }
.audit-details dd { margin: 0; overflow-wrap: anywhere; }
.audit-details pre.json { max-width: 100%; white-space: pre-wrap; overflow-wrap: anywhere; }
.tag.src-http { background: color-mix(in srgb, var(--fg) 8%, transparent); color: var(--muted); }
.tag.src-worker { background: var(--warn-soft); color: var(--warn); }
.tag.src-smb { background: var(--ok-soft); color: var(--ok); }
.mode-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; font-size: .88rem; }
.pick-cols { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .pick-cols { grid-template-columns: 1fr 1fr; } }
.pick-cols fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 12px; max-height: 260px; overflow: auto; display: flex; flex-direction: column; gap: 4px; }
.stack label.check, label.check { display: flex; flex-direction: row; align-items: center; justify-content: flex-start; gap: 8px; text-align: left; }
label.check input { width: auto; margin: 0; }

/* ── Dispositivos ── */
.disk-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 1100px) { .disk-grid { grid-template-columns: 1fr 1fr; } }
.disk .card-head h2 { display: flex; align-items: center; gap: 8px; }
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
.part { border-top: 1px solid var(--line); padding: 12px 0; display: flex; flex-direction: column; gap: 6px; }
.part:first-of-type { border-top: 0; }
.part-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; flex-wrap: wrap; }
.part-head small { display: block; }
.part-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.part-actions .form-row { flex: 1 1 280px; }
progress.usage { appearance: none; width: 100%; height: 8px; border: 0; border-radius: 99px; overflow: hidden; background: color-mix(in srgb, var(--fg) 10%, transparent); color: var(--primary); }
progress.usage::-webkit-progress-bar { background: color-mix(in srgb, var(--fg) 10%, transparent); }
progress.usage::-webkit-progress-value { background: var(--primary); }
progress.usage::-moz-progress-bar { background: var(--primary); }
progress.usage.warn::-webkit-progress-value { background: var(--warn); }
progress.usage.warn::-moz-progress-bar { background: var(--warn); }
progress.usage.crit::-webkit-progress-value { background: var(--danger); }
progress.usage.crit::-moz-progress-bar { background: var(--danger); }

/* ── Checklist de segurança ── */
.posture-grid { display: grid; gap: 14px; grid-template-columns: 1fr; margin-bottom: 14px; }
@media (min-width: 1100px) { .posture-grid { grid-template-columns: 3fr 2fr; } }
.posture-grid > .card { margin: 0; }
ul.checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
ul.checks li { display: flex; gap: 10px; align-items: flex-start; }
.check-ico { flex: 0 0 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: .75rem; font-weight: 700; }
.check-ok .check-ico { background: var(--ok-soft); color: var(--ok); }
.check-warn .check-ico { background: var(--warn-soft); color: var(--warn); }
.check-crit .check-ico { background: var(--danger-soft); color: var(--danger); }
.score { font-weight: 700; font-size: 1.1rem; padding: 2px 10px; border-radius: 99px; }
.score.good { background: var(--ok-soft); color: var(--ok); }
.score.mid { background: var(--warn-soft); color: var(--warn); }
.score.bad { background: var(--danger-soft); color: var(--danger); }
textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.part-actions .form-row label.check { flex-basis: 100%; }

/* ── Alertas ── */
.topbar .bell { margin-left: auto; position: relative; display: inline-grid; place-items: center; min-width: 44px; min-height: 44px; padding: 8px; border-radius: 10px; color: var(--muted); }
.topbar .bell svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; }
.topbar .bell.on { color: var(--warn); }
.topbar .bell.on.lvl-crit { color: var(--danger); }
.bell-count { position: absolute; top: 4px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; font-size: .7rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; color: #fff; background: var(--danger); }
.alert-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.alert-item { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; padding: 12px 0; border-top: 1px solid var(--line); }
.alert-item:first-child { border-top: 0; }
.alert-item .alert-text { flex: 1 1 200px; min-width: 0; overflow-wrap: anywhere; }
.alert-item.resolved, .alert-item.acked { opacity: .6; }
.cols-2 { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .cols-2 { grid-template-columns: 1fr 1fr; } }
.table-foot { padding: 8px 14px; margin: 0; }

/* ── Minha conta / 2FA ── */
.narrow-card { max-width: 640px; }
img.qr { display: block; max-width: 100%; height: auto; margin: 8px 0; border-radius: 8px; background: #fff; padding: 8px; }
code.secret { word-break: break-all; font-size: .95rem; }
.codes { list-style: none; padding: 0; margin: 10px 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.codes code { display: block; text-align: center; padding: 6px; border: 1px dashed var(--line); border-radius: 6px; font-size: .95rem; }
.steps { padding-left: 18px; }
.howto-tabs details { border-top: 1px solid var(--line); padding: 10px 0; }
.howto-tabs details:first-child { border-top: 0; }
.howto-tabs summary { cursor: pointer; font-weight: 600; min-height: 36px; display: flex; align-items: center; }
.howto-tabs ol { padding-left: 18px; margin: 8px 0; }
pre.cmd { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .82rem; padding: 8px 10px; border-radius: 6px; background: color-mix(in srgb, var(--fg) 6%, transparent); }
.stats.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 900px) { .stats.four { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.top-lists ol { padding-left: 18px; margin: 4px 0; }

/* ── Relatório de acessos ── */
.matrix-wrap { overflow: auto; max-height: 75dvh; -webkit-overflow-scrolling: touch; }
table.matrix { border-collapse: separate; border-spacing: 0; font-size: .85rem; min-width: 100%; }
.matrix th, .matrix td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; }
.matrix thead th { position: sticky; top: 0; background: var(--surface); z-index: 2; font-weight: 600; }
.matrix .sticky { position: sticky; left: 0; background: var(--surface); text-align: left; z-index: 1; border-right: 1px solid var(--line); }
.matrix thead .sticky { z-index: 3; }
.matrix tr.disabled { opacity: .55; }
.matrix td.lvl-write, .key.lvl-write { color: var(--ok); background: var(--ok-soft); font-weight: 700; }
.matrix td.lvl-read, .key.lvl-read { color: var(--primary); background: var(--primary-soft); font-weight: 700; }
.matrix td.lvl-deny, .key.lvl-deny { color: var(--danger); background: var(--danger-soft); font-weight: 700; }
.key { display: inline-block; padding: 0 6px; border-radius: 4px; }
label.inline { display: inline-flex; align-items: center; gap: 6px; }
label.inline input { width: 80px; }

/* ── Tablet (≥ 640px) ── */
@media (min-width: 640px) {
  .content { padding: 20px 20px 48px; }
  .stats:not(.four) { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
  .jail .stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  a.stat { flex-direction: row; align-items: center; }
  .cols { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
  .kv { grid-template-columns: max-content 1fr; gap: 10px 20px; }
  .kv dd { margin: 0; }
  .share-hero { flex-direction: row; }
  .page-actions { flex-direction: row; align-items: center; }
  .page-actions .actions > button, .page-actions > button, .page-actions .actions > a.btn, .page-actions > a.btn { flex: 0 0 auto; }
  .actions.right { justify-content: flex-end; }
  .actions.right > button, .actions.right > form, .actions.right > a.btn { flex: 0 0 auto; }
  .row-form { flex-direction: row; align-items: center; }
  .row-form select, .row-form > * { width: auto; }
  dialog.modal { width: min(760px, calc(100vw - 32px)); max-width: calc(100vw - 32px); max-height: calc(100dvh - 48px); margin: auto; border-radius: 16px; padding: 22px 24px; animation: pop .18s ease-out; }
  dialog.modal.wide { width: min(1000px, calc(100vw - 32px)); }
  dialog.modal.narrow { width: min(460px, calc(100vw - 32px)); }
  .modal-head { top: -22px; margin: -6px 0 16px; }
  #toasts { left: auto; right: 20px; bottom: 20px; }
  .toast { max-width: 380px; }
  .files-bar, .editor-bar { flex-direction: row; align-items: center; }
  .files-bar .actions, .editor-bar .actions { width: auto; }
  .files-bar .actions > button { flex: 0 0 auto; }
  .goto { width: auto; min-width: min(420px, 100%); }
  .term-bar { flex-direction: row; align-items: center; }
  .perm-grid { width: auto; }
  .perm-grid th, .perm-grid td { padding: 8px 18px; }
}

/* ── Desktop (≥ 1024px): tabelas reais, sidebar fixa ── */
@media (min-width: 1024px) {
  .has-shell { display: grid; grid-template-columns: 248px 1fr; }
  .sidebar { position: sticky; top: 0; height: 100dvh; width: auto; transform: none; box-shadow: none; }
  .nav-backdrop, .nav-toggle:checked ~ .nav-backdrop, .menu-btn { display: none; }
  .nav-item { padding: 8px 12px; }
  .topbar { padding: 16px 32px; gap: 16px; }
  .page-title { font-size: 1.35rem; }
  .content { padding: 24px 32px 48px; }
  .grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }
  .card { padding: 20px; margin-bottom: 20px; }

  .grid:not(.perm-grid) { display: table; }
  .grid:not(.perm-grid) thead { display: table-header-group; }
  .grid:not(.perm-grid) tbody { display: table-row-group; }
  .grid:not(.perm-grid) tr { display: table-row; padding: 0; border: 0; }
  .grid:not(.perm-grid) td { display: table-cell; padding: 11px 16px; border-bottom: 1px solid var(--line); text-align: left; }
  .grid:not(.perm-grid) td::before, .grid:not(.perm-grid) td::after { content: none !important; }
  .grid:not(.perm-grid) td:first-child { font-size: inherit; padding-bottom: 11px; }
  .grid:not(.perm-grid) td.right, .grid:not(.perm-grid) td.row-actions { display: table-cell; text-align: right; padding-top: 11px; }
  .grid:not(.perm-grid) td.row-actions > * + * { margin-left: 4px; }
  .grid:not(.perm-grid) td.row-actions form.inline { display: inline; }
  .grid:not(.perm-grid) tbody tr:last-child td { border-bottom: 0; }
  .grid:not(.perm-grid) td.truncate { max-width: 380px; white-space: nowrap; }
  .card:not(.flush) .grid { border: 1px solid var(--line); }
  .table-wrap { overflow-x: auto; }
  .row-actions { display: flex; justify-content: flex-end; flex-wrap: nowrap; }
  .grid select { max-width: none; }
  .picker { max-height: 320px; }
  .editor-text { font-size: 13.5px; min-height: calc(100dvh - 260px); padding: 14px 16px !important; }
  .term { height: calc(100dvh - 250px); min-height: 360px; padding: 8px 10px; }
  button, a.btn { min-height: 38px; }
  button.small, a.btn.small { min-height: 30px; padding: 4px 10px; }
  button.icon, .icon-btn { min-width: 34px; min-height: 34px; }
  .topbar .bell { min-width: 36px; min-height: 36px; padding: 6px; }
  input:not([type=checkbox]):not([type=radio]), select, textarea { font-size: 14.5px; min-height: 38px; }
  input[type=checkbox], input[type=radio] { width: 16px; height: 16px; }
  .check { min-height: 0; }
}
