/* ═══════════════ GioSamba — 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: grid; grid-template-columns: 248px 1fr; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--sidebar); color: var(--sidebar-fg); padding: 18px 12px;
}
.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: 8px 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; justify-content: space-between; gap: 16px;
  padding: 16px 32px; background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.page-title { font-size: 1.35rem; font-weight: 700; }
.content { padding: 24px 32px 48px; 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: 12px; 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;
}
.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; }
.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; }
.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%; 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; }
legend { color: var(--muted); font-size: .85rem; font-weight: 600; padding: 0 6px; }
form.inline { display: inline; }

/* ── Tabelas ── */
.table-wrap { overflow-x: auto; }
.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, .alert { display: flex; align-items: center; gap: 8px; margin: 0; padding: 10px 12px; border-radius: var(--radius-sm); width: 100%; }
.error, .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(100vh - 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; }
.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: 65vh; 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: 520px; 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;
}

/* ── Responsivo ── */
@media (max-width: 900px) {
  .has-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 6px; padding: 10px 12px; }
  .brand { padding: 4px 8px; }
  .nav { flex-direction: row; overflow-x: auto; flex: 1 1 100%; order: 3; }
  .nav-label { display: none; }
  .nav-item span { white-space: nowrap; }
  .sidebar-foot { border: 0; padding: 0; margin-left: auto; }
  .me-text { display: none; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
}

/* ── 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; }
.crumbs a { display: inline-flex; align-items: center; padding: 2px 6px; 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; 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; }
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: auto; }
.perm-grid th, .perm-grid td { text-align: center; padding: 8px 18px; }
.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; 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(100vh - 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); }
