/* CCTVControl — base compartida */
:root {
    --bg: #0a0a0a;
    --bg-alt: #111111;
    --surface: #161616;
    --surface-2: #1e1e1e;
    --border: #2a2a2a;
    --border-soft: #222;
    --accent: #f5c400;
    --accent-dark: #c9a000;
    --accent-text: #0a0a0a;
    --text: #f0f0f0;
    --text-muted: #888;
    --text-faint: #555;
    --danger: #e53e3e;
    --danger-soft: #2d1010;
    --success: #38a169;
    --success-soft: #0d2b1a;
    --warning: #f5c400;
    --warning-soft: #2a2000;
    --info: #4299e1;
    --info-soft: #0d1e30;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,.5);
    --shadow-md: 0 4px 16px rgba(0,0,0,.6);
    --font: system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-mono: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;

    /* aliases para compatibilidad con componentes */
    --brand: var(--accent);
    --brand-strong: var(--accent-dark);
    --muted: var(--text-muted);
    --line: var(--border);
    --line-strong: #333;
    --ink: var(--text);
    --ink-2: #c0c0c0;
    --mono: var(--font-mono);
    --graphite: #1a1a1a;
    --graphite-2: #202020;
    --brand-ink: var(--accent-text);
    --brand-soft: #2a2000;
    --green: var(--success);
    --green-soft: var(--success-soft);
    --red: var(--danger);
    --red-soft: var(--danger-soft);
    --amber: var(--warning);
    --amber-soft: var(--warning-soft);
    --radius-sm: 8px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; min-height: 100%; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -.02em; }
h1 { font-size: 30px; font-weight: 750; }
h2 { font-size: 21px; font-weight: 720; }
h3 { font-size: 17px; font-weight: 700; }
p { margin: 0; }
a { color: var(--text); text-decoration: none; }
a:hover { color: var(--accent); }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
strong { font-weight: 700; }
small { font-size: 12.5px; }

::selection { background: var(--accent); color: var(--accent-text); }

:focus-visible {
    outline: 3px solid rgba(245, 196, 0, .45);
    outline-offset: 2px;
}

/* ── Utilidades ────────────────────────────────── */
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.text-muted  { color: var(--text-muted); }
.text-faint  { color: var(--text-faint); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-accent { color: var(--accent); }
.muted   { color: var(--text-muted); }
.small   { font-size: 13px; }
.strong  { font-weight: 700; }
.nowrap  { white-space: nowrap; }
.num     { text-align: right; font-variant-numeric: tabular-nums; }
.mono    { font-family: var(--font-mono); }
.center  { text-align: center; }

/* Layout */
.stack   { display: flex; flex-direction: column; gap: 14px; }
.cluster { display: flex; flex-wrap: wrap; gap: 10px; }
.row     { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.split   { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.spacer  { flex: 1; }

/* Grillas */
.container { max-width: 1200px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }

/* ── Marca ──────────────────────────────────────── */
.brand {
    font-size: 21px;
    font-weight: 800;
    letter-spacing: -.035em;
    color: var(--text);
    display: inline-flex;
    align-items: baseline;
    gap: 0;
    text-decoration: none;
}
.brand span { color: var(--accent); font-weight: 900; }
.brand:hover { color: var(--text); }

/* ── Botones ────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-lg);
    background: transparent;
    color: var(--text);
    font-size: 14px;
    font-weight: 680;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    transition: background .16s ease, border-color .16s ease, transform .16s ease, box-shadow .16s ease;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-text);
    box-shadow: 0 6px 14px rgba(245, 196, 0, .22);
}
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: var(--accent-text); }

.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.btn-soft { background: var(--warning-soft); border-color: #3a2d00; color: var(--accent); }
.btn-soft:hover { background: #332500; color: var(--accent); }

.btn-danger { background: var(--danger-soft); border-color: #5a1a1a; color: var(--danger); }
.btn-danger:hover { background: #3d1414; color: var(--danger); }

.btn-link {
    min-height: 0; padding: 0; border: 0; background: none;
    color: var(--text-muted); font-weight: 650; text-decoration: underline;
    text-decoration-color: var(--border); text-underline-offset: 3px;
}
.btn-link:hover { color: var(--accent); }

.btn-sm  { min-height: 34px; padding: 0 12px; border-radius: 9px; font-size: 13px; }
.btn-sm svg { width: 15px; height: 15px; }
.btn-lg  { min-height: 50px; padding: 0 24px; border-radius: var(--radius-lg); font-size: 15px; }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-disabled { opacity: .45; pointer-events: none; }

/* ── Formularios ────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .label {
    font-size: 12px;
    font-weight: 750;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.input, .select, .textarea {
    width: 100%;
    min-height: 44px;
    padding: 10px 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--text);
    font-size: 14.5px;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.textarea { min-height: 96px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(245, 196, 0, .18);
}
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 13px center;
    padding-right: 38px;
}

.input-group { position: relative; }
.input-group .input { padding-left: 38px; }
.input-group > span {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-weight: 700;
    font-size: 14px;
    pointer-events: none;
}

.password-field { position: relative; }
.password-field .input { padding-right: 46px; }
.password-toggle {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
}
.password-toggle:hover { color: var(--text); background: rgba(255,255,255,.06); }
.password-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.password-toggle svg[hidden] { display: none; }

.field-hint  { color: var(--text-muted); font-size: 12.5px; }
.field-error { color: var(--danger); font-size: 12.5px; font-weight: 600; }
.form-row    { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.check { display: flex; align-items: flex-start; gap: 9px; font-size: 13.5px; color: var(--text); }
.check input { width: 17px; height: 17px; margin-top: 2px; accent-color: var(--accent); }

/* ── Tarjetas ───────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}
.card-header, .card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 22px 0;
}
.card-body { padding: 22px; }
.card-title { font-size: 16px; font-weight: 720; }
.card-sub { color: var(--text-muted); font-size: 13px; margin-top: 3px; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Badges ─────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 25px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 750;
    letter-spacing: .01em;
    white-space: nowrap;
    border: 1px solid transparent;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge.is-ok      { background: #0d2b1a; color: #4ade80; border-color: #1a4a2a; }
.badge.is-warning { background: #2a2000; color: var(--accent); border-color: #3a2d00; }
.badge.is-warn    { background: #2a2000; color: var(--accent); border-color: #3a2d00; }
.badge.is-danger  { background: #2d1010; color: #fc8181; border-color: #4a1a1a; }
.badge.is-neutral { background: #1a1a1a; color: var(--text-muted); border-color: #2a2a2a; }
.badge.is-info    { background: #0d1e30; color: #63b3ed; border-color: #1a3050; }
.badge.is-brand   { background: #2a2000; color: var(--accent); border-color: #3a2d00; }

/* ── Alertas ────────────────────────────────────── */
.alert {
    padding: 13px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 18px;
}
.alert-error { background: var(--danger-soft); border-color: #4a1a1a; color: #fc8181; }
.alert-ok    { background: var(--success-soft); border-color: #1a4a2a; color: #68d391; }
.alert-info  { background: var(--info-soft); border-color: #1a3050; color: #63b3ed; }
.alert-warn  { background: var(--warning-soft); border-color: #3a2d00; color: var(--accent); }

/* ── Tablas ─────────────────────────────────────── */
.table-wrap { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
    padding: 10px 12px;
    text-align: left;
    font-size: 11px;
    font-weight: 750;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table td { padding: 12px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .num { text-align: right; }

/* ── Avatar ─────────────────────────────────────── */
.avatar {
    width: 40px; height: 40px; border-radius: 50%;
    display: inline-grid; place-items: center; flex: none;
    background: var(--accent); color: var(--accent-text);
    font-size: 13px; font-weight: 800; letter-spacing: .02em;
    border: 1px solid var(--accent-dark);
}

/* ── Estado vacío ───────────────────────────────── */
.empty {
    padding: 42px 22px;
    text-align: center;
    color: var(--text-muted);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}
.empty strong { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }

/* ── Público ─────────────────────────────────────── */
.public-body { background: var(--bg); }
.public-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 16px clamp(18px, 4vw, 48px);
    background: rgba(10, 10, 10, .88);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(10px);
}
.public-nav { display: flex; align-items: center; gap: 18px; font-size: 14px; font-weight: 600; }
.public-nav > a:not(.btn) { color: var(--text-muted); }
.public-nav > a:not(.btn):hover { color: var(--accent); }
.public-main { min-height: calc(100vh - 160px); }
.public-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 26px 18px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 13px;
}
.public-footer strong { color: var(--text); }
.public-footer a { color: var(--text-muted); }
.public-footer a:hover { color: var(--accent); }

/* ── Auth ────────────────────────────────────────── */
.auth-wrap { max-width: 480px; margin: 0 auto; padding: 48px 18px 64px; }
.auth-card { padding: 30px; }
.auth-card h1 { font-size: 26px; margin-bottom: 6px; }
.auth-card .lead { color: var(--text-muted); margin-bottom: 24px; }
.auth-card .brand { margin-bottom: 22px; }
.auth-alt { margin-top: 22px; text-align: center; font-size: 14px; color: var(--text-muted); }
.auth-alt a { font-weight: 700; color: var(--text); text-decoration: underline; text-decoration-color: var(--border); }

/* ── Footer app ─────────────────────────────────── */
.app-footer {
    padding: 22px 28px 30px;
    color: var(--text-faint);
    font-size: 12.5px;
    text-align: center;
}
.app-footer span { margin: 0 6px; color: var(--border); }

/* ── Progreso ────────────────────────────────────── */
.progress { height: 7px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent-dark), var(--accent)); }

/* ── Responsive base ─────────────────────────────── */
@media (max-width: 760px) {
    h1 { font-size: 25px; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: auto; }
    .public-nav { gap: 10px; }
    .public-nav > a:not(.btn) { display: none; }
    .public-bar { padding: 12px 16px; }
    .auth-card { padding: 24px 20px; }
    .app-footer { text-align: left; }
    .btn { min-height: 44px; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

@media print {
    .public-bar, .public-footer, .app-sidebar, .mobile-bar, .app-footer, .no-print { display: none !important; }
    body { background: #fff; color: #000; }
    .card { box-shadow: none; border-color: #ddd; }
}
