:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-2: #f7f9fa;
  --border: #e2e7ec;
  --border-strong: #cfd6de;
  --text: #16202b;
  --muted: #5d6a79;
  --accent: #009639;
  --accent-hover: #007f30;
  --accent-soft: #e5f4eb;
  --on-accent: #ffffff;
  --danger: #d0352b;
  --danger-soft: #fdecea;
  --warn: #a86400;
  --warn-soft: #fff3df;
  --info: #1b6bd0;
  --info-soft: #e8f1fc;
  --code-bg: #0f1720;
  --code-text: #d5e1ec;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .07);
  --shadow-lg: 0 20px 50px rgba(16, 24, 40, .22);
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --surface: #151b23;
    --surface-2: #1a212b;
    --border: #28313c;
    --border-strong: #36414e;
    --text: #e6edf3;
    --muted: #8d9aaa;
    --accent: #2db459;
    --accent-hover: #3cc768;
    --accent-soft: #11301d;
    --on-accent: #04170a;
    --danger: #f0675d;
    --danger-soft: #3a1917;
    --warn: #e2a640;
    --warn-soft: #33250f;
    --info: #5ea3f4;
    --info-soft: #13263b;
    --code-bg: #0a0e13;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 17px; font-weight: 620; }
h3 { font-size: 15px; font-weight: 620; }
p { margin: 0; }
code { font-family: var(--mono); font-size: .92em; background: var(--surface-2); border: 1px solid var(--border); padding: 1px 5px; border-radius: 5px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.svg-icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------------------------------------------------------- layout */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 18px 12px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; }
.brand-mark { width: 34px; height: 34px; flex: none; }
.brand strong { display: block; font-size: 15px; }
.brand span { display: block; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--muted); font-weight: 520; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 8px; }
.main { min-width: 0; }
.content { max-width: 1120px; margin: 0 auto; padding: 28px 32px 60px; }
.dry-banner { background: var(--info-soft); color: var(--info); padding: 8px 32px; font-size: 13px; display: flex; gap: 8px; align-items: center; border-bottom: 1px solid var(--border); }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin-top: 4px; }

/* ---------------------------------------------------------------- cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.stat-label { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.stat-value { font-size: 28px; font-weight: 680; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 12.5px; color: var(--muted); }

.status-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.status-main { display: flex; align-items: center; gap: 14px; }
.pulse { width: 14px; height: 14px; border-radius: 50%; flex: none; position: relative; }
.pulse.on { background: var(--accent); box-shadow: 0 0 0 5px var(--accent-soft); }
.pulse.off { background: var(--danger); box-shadow: 0 0 0 5px var(--danger-soft); }

.pill { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 560; padding: 6px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; }
.dot.on { background: var(--accent); }
.dot.off { background: var(--danger); }
.dot.idle { background: var(--muted); }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 580; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.badge .svg-icon { width: 13px; height: 13px; }
.badge-ok { background: var(--accent-soft); color: var(--accent); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-muted { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }

/* ---------------------------------------------------------------- botões */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 560; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn .svg-icon { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.94); background: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-soft { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.btn-soft:hover { background: var(--accent-soft); filter: brightness(.97); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.icon-btn { width: 34px; height: 34px; display: inline-grid; place-items: center; border: 0; background: transparent; color: var(--muted); border-radius: 8px; cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }

.spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; flex: none; }
.spinner.lg { width: 34px; height: 34px; border-width: 3px; color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }
.boot-loading, .loading { display: grid; place-items: center; min-height: 200px; color: var(--muted); }
.boot-loading { min-height: 100vh; }

/* ---------------------------------------------------------------- formulários */
.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-weight: 560; font-size: 13.5px; }
.field small, .hint { color: var(--muted); font-size: 12.5px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
input[type=text], input[type=password], input[type=email], input[type=url], input[type=number], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 8px; padding: 8px 11px; min-height: 38px; transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.code, .code-input { font-family: var(--mono); font-size: 13px; line-height: 1.55; resize: vertical; tab-size: 4; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }

.switch-row { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; padding: 6px 0; }
.switch-row .switch-text { display: flex; flex-direction: column; }
.switch-row .switch-text b { font-weight: 560; }
.switch-row .switch-text small { color: var(--muted); font-size: 12.5px; }
.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex: none; margin-top: 1px; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .track { position: absolute; inset: 0; background: var(--border-strong); border-radius: 999px; transition: background .15s; cursor: pointer; }
.switch .track::after { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

.section { border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin: 0; background: var(--surface); }
.section > legend, .section > summary { font-weight: 620; padding: 0 6px; font-size: 14px; }
details.section > summary { cursor: pointer; padding: 0; }
details.section[open] > summary { margin-bottom: 12px; }
.section-body { display: flex; flex-direction: column; gap: 12px; }

.type-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.type-card { position: relative; border: 1.5px solid var(--border); border-radius: 10px; padding: 12px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; transition: border-color .12s, background .12s; }
.type-card input { position: absolute; opacity: 0; }
.type-card:hover { border-color: var(--border-strong); }
.type-card .tc-icon { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); margin-bottom: 4px; }
.type-card b { font-weight: 600; }
.type-card small { color: var(--muted); font-size: 12px; line-height: 1.4; }
.type-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.type-card:has(input:checked) .tc-icon { background: var(--accent); color: var(--on-accent); }
.type-card:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

.callout { display: flex; gap: 10px; padding: 12px 14px; border-radius: 10px; font-size: 13.5px; align-items: flex-start; }
.callout .svg-icon { margin-top: 1px; }
.callout-info { background: var(--info-soft); color: var(--info); }
.callout-warn { background: var(--warn-soft); color: var(--warn); }
.callout-danger { background: var(--danger-soft); color: var(--danger); }
.callout-ok { background: var(--accent-soft); color: var(--accent); }
.callout > div { color: var(--text); }
.callout b { color: inherit; }

pre.code-block, pre.log-view { margin: 0; background: var(--code-bg); color: var(--code-text); font: 12.5px/1.6 var(--mono); padding: 14px 16px; border-radius: 10px; overflow: auto; white-space: pre; }
pre.output { max-height: 280px; white-space: pre-wrap; word-break: break-word; }

/* ---------------------------------------------------------------- lista de sites */
.site-list { display: flex; flex-direction: column; gap: 10px; }
.site-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; align-items: center; gap: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 14px 18px; box-shadow: var(--shadow); }
.site-row.disabled { opacity: .62; }
.site-title { display: flex; align-items: center; gap: 8px; font-weight: 620; font-size: 15px; min-width: 0; }
.site-title a { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-sub { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; margin-top: 3px; min-width: 0; }
.site-sub .target { font-family: var(--mono); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: flex; gap: 2px; }

.empty { text-align: center; padding: 56px 20px; }
.empty .empty-icon { width: 56px; height: 56px; border-radius: 16px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin: 0 auto 14px; }
.empty .empty-icon .svg-icon { width: 26px; height: 26px; }
.empty p { color: var(--muted); max-width: 420px; margin: 6px auto 18px; }

/* ---------------------------------------------------------------- tabelas */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.meter { height: 6px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; width: 120px; margin-top: 5px; }
.meter > i { display: block; height: 100%; border-radius: 999px; }

.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; align-items: baseline; }
.activity li:last-child { border-bottom: 0; }
.activity time { color: var(--muted); font-size: 12px; margin-left: auto; white-space: nowrap; }

.steps { list-style: none; margin: 0; padding: 0; counter-reset: s; display: flex; flex-direction: column; gap: 14px; }
.steps li { display: flex; gap: 12px; counter-increment: s; }
.steps li::before { content: counter(s); width: 26px; height: 26px; border-radius: 50%; flex: none; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); font-weight: 650; font-size: 13px; }
.steps li.done::before { content: "✓"; background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.steps b { display: block; }

/* ---------------------------------------------------------------- logs */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar select, .toolbar input[type=text] { width: auto; min-width: 140px; }
.toolbar .grow { flex: 1; min-width: 180px; }
pre.log-view { height: calc(100vh - 230px); min-height: 320px; }
.log-view .l-err { color: #ff8f86; }
.log-view .l-warn { color: #f3c063; }
.log-view .l-dim { color: #7d8b99; }

/* ---------------------------------------------------------------- modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(8, 12, 18, .55); display: grid; place-items: center; padding: 20px; z-index: 50; animation: fade .12s ease-out; }
.modal { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); width: min(560px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; animation: pop .16s ease-out; }
.modal.sm { width: min(440px, 100%); }
.modal.lg { width: min(760px, 100%); }
.modal.xl { width: min(1180px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); gap: 12px; }
.modal-body { padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

.editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 420px); gap: 18px; align-items: start; }
.editor-main { display: flex; flex-direction: column; gap: 14px; }
.editor-preview { position: sticky; top: 0; display: flex; flex-direction: column; gap: 8px; }
.editor-preview pre { max-height: calc(100vh - 260px); min-height: 200px; font-size: 12px; }
.preview-head { display: flex; align-items: center; justify-content: space-between; font-weight: 600; font-size: 13px; color: var(--muted); }
.preview-error { color: #ff8f86; }

.wizard-hero { text-align: center; padding: 12px 0 4px; }
.wizard-hero .big-icon { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 14px; }
.wizard-hero .big-icon .svg-icon { width: 30px; height: 30px; }
.wizard-hero h3 { font-size: 18px; }
.wizard-hero p { color: var(--muted); margin-top: 6px; }
.check-list { display: flex; flex-direction: column; gap: 8px; }
.check-item { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 1px solid var(--border); border-radius: 10px; }
.check-item .ci-icon { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.check-item .ci-icon .svg-icon { width: 14px; height: 14px; stroke-width: 3; }
.check-item.ok .ci-icon { background: var(--accent-soft); color: var(--accent); }
.check-item.fail .ci-icon { background: var(--warn-soft); color: var(--warn); }
.check-item b { display: block; }

/* ---------------------------------------------------------------- auth */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 32px; }
.auth-card .brand-mark { width: 48px; height: 48px; margin-bottom: 16px; }
.auth-card h1 { margin-bottom: 6px; }
.auth-card .form { margin-top: 22px; }
.form-error { color: var(--danger); font-size: 13px; min-height: 18px; }

/* ---------------------------------------------------------------- toasts */
#toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: calc(100vw - 40px); }
.toast { display: flex; align-items: center; gap: 10px; background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-weight: 520; animation: pop .18s ease-out; max-width: 420px; }
.toast-ok .svg-icon { color: #4ade80; }
.toast-error { background: var(--danger); color: #fff; }
.toast.out { opacity: 0; transform: translateY(6px); transition: .25s; }

/* ---------------------------------------------------------------- responsivo */
@media (max-width: 1000px) {
  .editor-grid { grid-template-columns: 1fr; }
  .editor-preview { position: static; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: sticky; z-index: 10; height: auto; flex-direction: row; align-items: center; padding: 8px 12px; gap: 8px; border-right: 0; border-bottom: 1px solid var(--border); overflow-x: auto; }
  .brand { padding: 0; }
  .brand > div { display: none; }
  .nav { flex-direction: row; }
  .nav a span { display: none; }
  .sidebar-foot { flex-direction: row; margin: 0 0 0 auto; padding: 0; }
  .sidebar-foot .pill-label { display: none; }
  .content { padding: 20px 16px 48px; }
  .dry-banner { padding: 8px 16px; }
  .grid-2, .stats { grid-template-columns: 1fr; }
  .type-cards, .row { grid-template-columns: 1fr; }
  .site-row { grid-template-columns: minmax(0, 1fr) auto; }
  .site-row .site-https { grid-column: 1 / -1; order: 3; }
}
