:root {
  --bg: #0e0e14;
  --bg-2: #15151e;
  --panel: #1b1b26;
  --panel-2: #232331;
  --line: #2c2c3c;
  --text: #e7e7ef;
  --muted: #9a9ab0;
  --brand: #7c5cff;
  --brand-2: #22d3ee;
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 10px;
  --shadow: 0 10px 30px -10px rgba(0, 0, 0, .6);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.15; letter-spacing: -.02em; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }

/* ---------- botones ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45em; padding: .6em 1.1em; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); text-decoration: none; cursor: pointer; font-weight: 600; white-space: nowrap; transition: background .15s, border-color .15s, transform .1s; }
.btn:hover { background: #2c2c3e; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: #6a48ff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--panel-2); }
.btn-danger { color: var(--danger); }
.btn-lg { padding: .85em 1.6em; font-size: 15px; border-radius: 10px; }
.btn-sm { padding: .35em .7em; font-size: 12px; }
.btn-icon { padding: .45em; width: 32px; height: 32px; }

/* ---------- formularios ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label, .label { font-size: 12px; font-weight: 600; color: var(--muted); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.input, .field input[type=text], .field input[type=email], .field input[type=password], .field input[type=url], .field input[type=number], .field select, .field textarea {
  width: 100%; background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: .6em .75em; outline: none; transition: border-color .15s;
}
.field textarea { resize: vertical; min-height: 70px; }
.field textarea.code { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12px; min-height: 140px; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand); }
.field input[type=range] { width: 100%; accent-color: var(--brand); }
.field input[type=color] { width: 36px; height: 30px; border: 1px solid var(--line); border-radius: 6px; background: none; padding: 2px; cursor: pointer; }
.color-row { display: flex; gap: 8px; align-items: center; }
.color-row input[type=text] { flex: 1; font-family: ui-monospace, monospace; font-size: 12px; }
.check { display: flex; gap: 8px; align-items: center; cursor: pointer; font-weight: 500; color: var(--text); font-size: 13px; margin-bottom: 14px; }
.check input { accent-color: var(--brand); width: 16px; height: 16px; }
.err { color: var(--danger); font-size: 13px; min-height: 1em; }

/* ---------- topbar ---------- */
.topbar { display: flex; align-items: center; gap: 16px; padding: 14px 24px; border-bottom: 1px solid var(--line); background: rgba(14, 14, 20, .8); backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 20; }
.topbar .spacer { flex: 1; }
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; text-decoration: none; letter-spacing: -.02em; }
.logo-img { width: 26px; height: 26px; border-radius: 7px; display: block; }
.logo-mark { width: 26px; height: 26px; border-radius: 7px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); display: grid; place-items: center; color: #fff; font-size: 14px; font-weight: 900; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.pill-pro { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #1a1205; border: 0; }
.pill-ok { color: var(--ok); border-color: rgba(52, 211, 153, .3); background: rgba(52, 211, 153, .08); }
.pill-warn { color: var(--warn); border-color: rgba(251, 191, 36, .3); background: rgba(251, 191, 36, .08); }

/* ---------- contenedores ---------- */
.container { max-width: 1100px; margin: 0 auto; padding: 32px 24px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; }
.grid { display: grid; gap: 18px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { font-size: 26px; }

/* ---------- modal + toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(5, 5, 10, .7); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 100; padding: 16px; animation: fade .15s; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; width: min(440px, 100%); padding: 26px; box-shadow: var(--shadow); max-height: 90vh; overflow: auto; }
.modal h2 { font-size: 20px; margin-bottom: 6px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: #24243a; border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); animation: up .2s; font-weight: 500; }
.toast.error { border-color: rgba(248, 113, 113, .5); color: #fecaca; }
@keyframes fade { from { opacity: 0 } }
@keyframes up { from { opacity: 0; transform: translateY(8px) } }

.env-banner { background: repeating-linear-gradient(45deg, #b45309 0 14px, #92400e 14px 28px); color: #fff; text-align: center; font: 600 12px/1.4 system-ui, sans-serif; padding: 6px 12px; }
.env-banner a { color: #fff; }
.notice { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 10px; border: 1px solid rgba(251, 191, 36, .35); background: rgba(251, 191, 36, .07); margin-bottom: 20px; flex-wrap: wrap; }

/* ---------- auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(60% 50% at 50% 0%, rgba(124, 92, 255, .25), transparent), var(--bg); }
.auth-card { width: min(400px, 100%); }
.auth-card h1 { font-size: 24px; margin: 18px 0 6px; }

/* ---------- dashboard ---------- */
.sites { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.site-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; transition: border-color .15s; }
.site-card:hover { border-color: #3d3d55; }
.site-thumb { height: 170px; position: relative; overflow: hidden; background: var(--bg-2); border-bottom: 1px solid var(--line); display: block; }
.site-thumb iframe { width: 400%; height: 400%; transform: scale(.25); transform-origin: 0 0; border: 0; pointer-events: none; }
.site-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.site-body h3 { font-size: 15px; }
.site-url { font-size: 12px; color: var(--muted); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-url:hover { color: var(--text); }
.site-meta { display: flex; gap: 12px; font-size: 12px; color: var(--muted); margin-top: auto; padding-top: 8px; }
.site-actions { display: flex; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--line); }
.site-new { border: 2px dashed var(--line); border-radius: 14px; display: grid; place-items: center; min-height: 290px; text-decoration: none; color: var(--muted); font-weight: 600; transition: border-color .15s, color .15s; }
.site-new:hover { border-color: var(--brand); color: var(--text); }
.menu { position: relative; }
.menu-list { position: absolute; right: 0; bottom: calc(100% + 6px); background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 6px; min-width: 170px; box-shadow: var(--shadow); z-index: 10; }
.menu-list button, .menu-list a { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 6px; background: none; border: 0; cursor: pointer; text-decoration: none; font-size: 13px; }
.menu-list button:hover, .menu-list a:hover { background: #33334a; }

/* ---------- templates ---------- */
.tabs { display: flex; gap: 4px; justify-content: center; border-bottom: 1px solid var(--line); margin-bottom: 36px; flex-wrap: wrap; }
.tabs button { background: none; border: 0; padding: 12px 18px; cursor: pointer; color: var(--muted); font-size: 15px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--text); border-color: var(--brand); }
.templates { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 24px; }
.tpl { border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: var(--panel); cursor: pointer; text-decoration: none; display: block; transition: transform .15s, border-color .15s; }
.tpl:hover { transform: translateY(-3px); border-color: var(--brand); }
.tpl-thumb { height: 220px; overflow: hidden; position: relative; background: var(--bg-2); }
.tpl-thumb iframe { width: 357.15%; height: 357.15%; transform: scale(.28); transform-origin: 0 0; border: 0; pointer-events: none; }
.tpl-name { padding: 12px 16px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.tpl-blank { display: grid; place-items: center; height: 100%; color: var(--muted); font-size: 18px; background: repeating-linear-gradient(45deg, transparent 0 14px, rgba(255, 255, 255, .02) 14px 28px); }

/* ---------- tablas ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: 12px; color: var(--muted); font-weight: 600; }
.table td { white-space: pre-wrap; word-break: break-word; }

@media (max-width: 640px) {
  .topbar { padding: 12px 16px; gap: 10px; }
  .container { padding: 24px 16px; }
  .templates { grid-template-columns: 1fr; }
}
