:root {
  --bg: #111214;
  --surface: #18191c;
  --surface-2: #212226;
  --border: #2c2d32;
  --text: #f1f4f2;
  --muted: #9ca6a1;
  --accent: #e5252a;
  --accent-soft: color-mix(in srgb, var(--accent) 16%, transparent);
  --danger: #ff8a3d;
  --danger-soft: rgba(255, 138, 61, 0.14);
  --ok: #3dd68c;
  --ok-soft: rgba(61, 214, 140, 0.14);
  --warn: #ffb224;
  --warn-soft: rgba(255, 178, 36, 0.14);
  --gray-soft: rgba(160, 160, 171, 0.14);
  --radius: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
h1 { font-size: 22px; font-weight: 600; margin: 0; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 12px; }
a { color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 12px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: #5a5a66; }
textarea { min-height: 72px; resize: vertical; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
label > input, label > select, label > textarea { color: var(--text); font-size: 15px; }
.help { font-size: 12px; color: var(--muted); }

.btn {
  border: 1px solid var(--border); background: var(--surface-2); border-radius: 8px; padding: 9px 16px;
  cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: #4a4a55; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .6; cursor: default; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 20px; }
.error { color: var(--danger); margin: 0; font-size: 14px; white-space: pre-line; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.brand-dot { width: 14px; height: 14px; border-radius: 4px; background: var(--accent); }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; display: grid; gap: 16px; }

/* Estrutura */
.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.sidebar {
  border-right: 1px solid var(--border); padding: 20px 14px; display: flex; flex-direction: column; gap: 24px;
  position: sticky; top: 0; height: 100vh;
}
.side-logo { display: grid; justify-items: start; gap: 6px; padding: 4px 10px; font-weight: 700; }
.side-logo img { width: 52px; height: 52px; object-fit: contain; }
.sidebar nav { display: grid; gap: 4px; }
.nav-group { margin: 0 0 6px; padding: 0 10px; color: var(--muted); font-size: 13px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 12px; text-decoration: none; padding: 10px 12px;
  border-radius: 8px; color: var(--text); font-size: 15px;
}
.sidebar nav a svg {
  width: 19px; height: 19px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.sidebar nav a:hover { background: var(--surface); }
.sidebar nav a.active { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.sidebar nav a.active svg { color: var(--accent); }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.dash-grid .list-item { cursor: pointer; }
.dash-grid .list-item:hover { outline: 1px solid var(--border); }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 14px; }
.content { padding: 28px; min-width: 0; }
.page { display: grid; gap: 20px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

.code-form { display: flex; gap: 8px; width: min(420px, 100%); }
.code-form input { text-transform: uppercase; letter-spacing: 1px; }
.code-form input::placeholder { text-transform: none; letter-spacing: 0; }

/* Números */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px;
  cursor: pointer; text-align: left;
}
.stat:hover { border-color: #4a4a55; }
.stat.selected { border-color: var(--accent); }
.stat b { display: block; font-size: 24px; font-weight: 600; }
.stat span { color: var(--muted); font-size: 13px; }

.toolbar input { max-width: 460px; }

/* Tabela */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; min-width: 720px; }
.table th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--border); }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 14px; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.code { font-family: ui-monospace, Consolas, monospace; letter-spacing: 1px; font-weight: 600; }
.empty { padding: 32px; text-align: center; color: var(--muted); margin: 0; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.active { background: var(--ok-soft); color: var(--ok); }
.badge.pending { background: var(--warn-soft); color: var(--warn); }
.badge.expired, .badge.blocked { background: var(--danger-soft); color: var(--danger); }

/* Gaveta de detalhes */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 10; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100%); background: var(--bg);
  border-left: 1px solid var(--border); z-index: 11; overflow-y: auto; padding: 24px; display: grid; gap: 18px; align-content: start;
}
.drawer-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.drawer-head .code { font-size: 24px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.row > label { flex: 1; min-width: 140px; }
.list { display: grid; gap: 8px; }
.list-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--surface-2); border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.list-item small { color: var(--muted); display: block; overflow-wrap: anywhere; }
.log { font-size: 13px; color: var(--muted); display: grid; gap: 4px; }
details summary { cursor: pointer; color: var(--muted); font-size: 14px; }

/* Aparência */
.appearance { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }
.form-grid { display: grid; gap: 16px; }
.color-field { display: flex; gap: 8px; align-items: center; }
.color-field input[type="color"] { width: 48px; height: 40px; padding: 2px; flex: none; }
.logo-field { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.logo-field img { max-height: 56px; max-width: 180px; background: #fff1; border-radius: 6px; padding: 4px; }
.preview-wrap { position: sticky; top: 24px; display: grid; gap: 8px; }
.phone { border-radius: 22px; border: 6px solid #2a2a33; overflow: hidden; height: 520px; display: grid; align-content: start; gap: 10px; padding-bottom: 12px; }
.phone-top { display: flex; align-items: center; gap: 8px; padding: 12px 12px 0; font-weight: 700; }
.phone-top img { height: 24px; max-width: 110px; object-fit: contain; }
.phone-notice { margin: 0 12px; padding: 8px 10px; border-radius: 8px; font-size: 12px; }
.phone-hero { margin: 0 12px; height: 170px; border-radius: 10px; background: linear-gradient(#ffffff10, #00000060); display: flex; align-items: end; justify-content: center; padding: 12px; }
.phone-btn { background: #fff; color: #111; font-size: 12px; font-weight: 700; padding: 6px 14px; border-radius: 6px; }
.phone-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 0 12px; }
.phone-row i { height: 84px; border-radius: 6px; }

.narrow { max-width: 420px; display: grid; gap: 14px; }
.dns-form { display: grid; grid-template-columns: 1fr 2fr; gap: 12px; align-items: end; }
.dns-form .row, .dns-form .error { grid-column: 1 / -1; }
.table td.actions { text-align: right; white-space: nowrap; }
@media (max-width: 800px) { .dns-form { grid-template-columns: 1fr; } }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--surface-2);
  border: 1px solid var(--border); padding: 10px 18px; border-radius: 10px; z-index: 20;
}

/* Celular */
@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px 16px; gap: 12px; border-right: 0; border-bottom: 1px solid var(--border); }
  .sidebar nav { display: flex; overflow-x: auto; order: 3; width: 100%; }
  .nav-group { display: none; }
  .side-logo { grid-auto-flow: column; align-items: center; }
  .side-logo img { width: 32px; height: 32px; }
  .sidebar-foot { margin: 0 0 0 auto; }
  .content { padding: 16px; }
  .appearance { grid-template-columns: 1fr; }
  .preview-wrap { position: static; }
  .kv { grid-template-columns: 110px 1fr; }
}
