/* =========================================================
   URL Manager - estilos (iOS-friendly)
   ========================================================= */

:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-2: #f1f5f9;
    --text: #1e293b;
    --muted: #64748b;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --danger: #ef4444;
    --success: #10b981;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04);
    --radius: 12px;
    --transition: 0.18s ease;

    /* Safe areas iPhone (notch / Dynamic Island / home indicator) */
    --safe-top:    env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left:   env(safe-area-inset-left, 0px);
    --safe-right:  env(safe-area-inset-right, 0px);
}

body.dark, html.dark {
    --bg: #0f172a;
    --surface: #1e293b;
    --surface-2: #273449;
    --text: #f1f5f9;
    --muted: #94a3b8;
    --border: #334155;
    --primary: #60a5fa;
    --primary-hover: #3b82f6;
    --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 4px 12px rgba(0,0,0,0.4);
    color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; overscroll-behavior-y: contain; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    min-height: 100dvh; /* dynamic viewport: cuenta bien con barra Safari */
    /* Suaviza scroll en iOS */
    -webkit-overflow-scrolling: touch;
}

/* Botones e inputs: nunca disparar zoom en iOS (font-size >= 16px) */
input, select, textarea, button {
    font-size: 16px;
    font-family: inherit;
}

/* ---------- Topbar ---------- */
.topbar {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.6rem 1rem;
    padding-top: calc(0.6rem + var(--safe-top));
    padding-left: calc(1rem + var(--safe-left));
    padding-right: calc(1rem + var(--safe-right));
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    position: sticky; top: 0; z-index: 50;
    /* Soporte fondo translúcido al hacer scroll */
    -webkit-backdrop-filter: saturate(180%) blur(10px);
    backdrop-filter: saturate(180%) blur(10px);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
}
.brand {
    font-weight: 700; font-size: 1.05rem; text-decoration: none; color: var(--text);
    flex-shrink: 0; display: flex; align-items: center; gap: 0.3rem;
}
.brand-text { display: none; } /* oculto en móvil; solo el icono */

.nav { display: flex; gap: 0.6rem; flex: 1; flex-wrap: nowrap; overflow-x: auto;
       scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
    color: var(--muted); text-decoration: none; font-weight: 500;
    padding: 0.5rem 0.7rem; border-radius: 8px;
    white-space: nowrap; font-size: 0.9rem;
    min-height: 44px; display: inline-flex; align-items: center; gap: 0.3rem;
}
.nav a:hover, .nav a:active { color: var(--primary); background: var(--surface-2); }

/* Botón de cambio de módulo en la navegación */
.nav .nav-switch {
    color: #fff;
    background: var(--primary);
    border: none;
    border-radius: 999px;
    padding: 0.5rem 0.85rem;
    margin-left: 0.4rem;
}
.nav .nav-switch:hover, .nav .nav-switch:active {
    color: #fff;
    background: var(--primary-dark, var(--primary));
    opacity: 0.92;
}

.topbar-right { display: flex; gap: 0.4rem; align-items: center; flex-shrink: 0; }

.icon-btn {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    width: 44px; height: 44px; /* Apple HIG mínimo */
    border-radius: 50%;
    cursor: pointer; font-size: 1.1rem;
    transition: var(--transition);
    display: flex; align-items: center; justify-content: center;
    user-select: none;
}
.icon-btn:hover, .icon-btn:active { background: var(--primary); color: #fff; }
.btn-icon { width: 44px; height: 44px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.nav-toggle { display: none; touch-action: manipulation; } /* solo en móvil */
.nav-toggle-close { display: none; }
.nav-toggle[aria-expanded="true"] .nav-toggle-open { display: none; }
.nav-toggle[aria-expanded="true"] .nav-toggle-close { display: inline-flex; }

/* ---------- Layout ---------- */
.container {
    max-width: 1300px; margin: 0 auto;
    padding: 1rem;
    padding-left: calc(1rem + var(--safe-left));
    padding-right: calc(1rem + var(--safe-right));
    padding-bottom: calc(2rem + var(--safe-bottom));
}
.hero {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1rem; flex-wrap: wrap; gap: 0.75rem;
}
.hero h1 { margin: 0 0 0.25rem; font-size: 1.5rem; }
.muted { color: var(--muted); font-size: 0.9rem; }

/* ---------- Botones (mínimo 44pt en touch) ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0.7rem 1.1rem;
    min-height: 44px;
    border-radius: 10px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text);
    cursor: pointer; text-decoration: none;
    font-size: 0.95rem; font-weight: 500;
    transition: var(--transition);
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation; /* evita el delay de 300ms en touch */
}
.btn:hover, .btn:active { background: var(--surface-2); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover, .btn-primary:active { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-outline { background: transparent; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover, .btn-danger:active { opacity: 0.92; }
.btn-block { display: flex; width: 100%; }
.btn-sm { padding: 0.5rem 0.8rem; font-size: 0.85rem; min-height: 38px; }

/* ---------- Alerts ---------- */
.alert {
    padding: 0.8rem 1rem; border-radius: 10px;
    margin-bottom: 1rem; border: 1px solid;
    font-size: 0.95rem;
}
.alert-success { background: #d1fae5; border-color: #6ee7b7; color: #064e3b; }
.alert-error   { background: #fee2e2; border-color: #fca5a5; color: #7f1d1d; }
body.dark .alert-success { background: #022c22; color: #6ee7b7; }
body.dark .alert-error   { background: #2d0a0a; color: #fca5a5; }

/* ---------- Forms ---------- */
.form-card {
    background: var(--surface);
    padding: 1.25rem; border-radius: var(--radius);
    box-shadow: var(--shadow); max-width: 600px;
    display: flex; flex-direction: column; gap: 1rem;
}
.form-card label {
    display: flex; flex-direction: column;
    gap: 0.4rem; font-weight: 500; font-size: 0.95rem;
}
.form-card input[type="text"],
.form-card input[type="email"],
.form-card input[type="password"],
.form-card input[type="url"],
.form-card input[type="number"],
.form-card input[type="datetime-local"],
.form-card input[type="color"],
.form-card textarea,
.form-card select,
.filters input[type="search"],
.filters select,
.auth-card input {
    padding: 0.75rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font-size: 16px; /* Evita zoom iOS */
    min-height: 44px;
    width: 100%;
    transition: var(--transition);
    -webkit-appearance: none;
    appearance: none;
}
/* Re-permitir flecha nativa en selects */
.form-card select, .filters select {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 18px;
    padding-right: 2.5rem;
}

.form-card input[type="color"] { height: 44px; padding: 0.3rem; }
.form-card input[type="datetime-local"] { -webkit-appearance: none; }
.form-card textarea { min-height: 90px; resize: vertical; }
.form-card input:focus, .form-card textarea:focus,
.form-card select:focus, .filters input[type="search"]:focus,
.filters select:focus, .auth-card input:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
.form-actions { display: flex; gap: 0.75rem; justify-content: flex-end; flex-wrap: wrap; margin-top: 0.5rem; }
.form-actions .btn { flex: 1; min-width: 130px; }

.check {
    flex-direction: row !important; align-items: center; gap: 0.6rem;
    padding: 0.5rem 0; min-height: 44px;
}
.check input[type="checkbox"] {
    width: 22px; height: 22px; margin: 0;
    accent-color: var(--primary);
}

/* ---------- Auth ---------- */
.auth-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; min-height: 100dvh; padding: 1rem;
    padding-top: calc(1rem + var(--safe-top));
    padding-bottom: calc(1rem + var(--safe-bottom));
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.auth-card {
    background: var(--surface); padding: 1.75rem;
    border-radius: var(--radius); box-shadow: var(--shadow);
    max-width: 380px; width: 100%;
}
.auth-card h1 { margin: 0 0 0.5rem; text-align: center; font-size: 1.6rem; }
.auth-card p  { text-align: center; margin-bottom: 1.5rem; }
.auth-card form { display: flex; flex-direction: column; gap: 1rem; }
.auth-card label { display: flex; flex-direction: column; gap: 0.4rem; font-weight: 500; }

/* ---------- Mostrar/ocultar contraseña ---------- */
.password-wrap {
    position: relative;
    display: flex; align-items: center;
}
.password-wrap input { padding-right: 3rem; }
.password-toggle {
    position: absolute; right: 0.25rem; top: 50%;
    transform: translateY(-50%);
    display: inline-flex; align-items: center; justify-content: center;
    width: 44px; height: 44px;
    background: transparent; border: none;
    color: var(--muted); cursor: pointer;
    border-radius: 8px;
    transition: var(--transition);
    -webkit-appearance: none; appearance: none;
}
.password-toggle:hover, .password-toggle:active { color: var(--primary); }
.password-toggle .icon-eye-off { display: none; }
.password-toggle[aria-pressed="true"] .icon-eye { display: none; }
.password-toggle[aria-pressed="true"] .icon-eye-off { display: inline-block; }

/* ---------- Filtros del dashboard ---------- */
.filters {
    display: grid; gap: 0.6rem;
    grid-template-columns: 1fr;
    margin-bottom: 1rem;
    background: var(--surface); padding: 0.85rem;
    border-radius: var(--radius); box-shadow: var(--shadow);
}
.result-count { color: var(--muted); margin-bottom: 0.75rem; font-size: 0.9rem; }

/* ---------- Tarjetas (1 col en iPhone, 2+ en pantallas anchas) ---------- */
.cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}
.card {
    background: var(--surface); border-radius: var(--radius);
    box-shadow: var(--shadow); display: flex; flex-direction: column;
    overflow: hidden; transition: var(--transition);
    border: 1px solid var(--border);
}
.card:active { transform: scale(0.99); }

.card-preview {
    background: var(--surface-2);
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-bottom: 3px solid var(--primary);
}
.card-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }

.card-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.85rem 1rem;
}
.card-head-actions { display: flex; gap: 0.2rem; }

.favicon { width: 36px; height: 36px; border-radius: 8px; background: #fff; padding: 4px; }

.fav-btn, .note-btn {
    background: transparent; border: none; cursor: pointer;
    color: var(--border); transition: var(--transition);
    width: 44px; height: 44px; /* Touch target */
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%;
}
.fav-btn { font-size: 1.4rem; }
.note-btn { font-size: 1.1rem; }
.fav-btn:active, .fav-btn.is-fav { color: #f59e0b; }
.note-btn:active, .note-btn.is-on { color: var(--primary); filter: saturate(2); }

.card-body { padding: 0.85rem 1rem; flex: 1; }
.card-title { margin: 0 0 0.5rem; font-size: 1.05rem; line-height: 1.3; }
.card-desc { font-size: 0.9rem; color: var(--muted); margin: 0.5rem 0 0; }
.card-foot { padding: 0 1rem 1rem; display: flex; flex-direction: column; gap: 0.4rem; }

.note-box {
    margin-top: 0.75rem;
    background: var(--surface-2);
    border-radius: 10px;
    padding: 0.6rem;
}
.note-text {
    width: 100%; min-height: 80px; resize: vertical;
    border: 1px solid var(--border); border-radius: 8px;
    background: var(--surface); color: var(--text);
    padding: 0.5rem; font-size: 16px; font-family: inherit;
    -webkit-appearance: none;
}
.note-status { display: block; margin-top: 0.3rem; font-size: 0.78rem; }

.badge {
    display: inline-block;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 500;
}
.badge-admin { background: var(--danger); }

.empty-state {
    text-align: center; padding: 2.5rem 1rem;
    color: var(--muted); background: var(--surface);
    border-radius: var(--radius);
}

/* ---------- Tablas (con scroll horizontal en iPhone) ---------- */
.table {
    width: 100%; background: var(--surface);
    border-radius: var(--radius); overflow: hidden;
    box-shadow: var(--shadow); border-collapse: collapse;
    margin-bottom: 1.5rem;
    font-size: 0.92rem;
}
.table th, .table td {
    padding: 0.7rem 0.85rem; text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table th { background: var(--surface-2); font-weight: 600; }
.table tr:last-child td { border-bottom: none; }
.actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* Wrapper para scroll horizontal en móvil */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -1rem 1.5rem;
    padding: 0 1rem;
}

/* ---------- Stats ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 2 columnas en iPhone */
    gap: 0.75rem; margin-bottom: 1.5rem;
}
.stat {
    background: var(--surface); padding: 1rem 0.75rem;
    border-radius: var(--radius); box-shadow: var(--shadow);
    text-align: center;
}
.stat span { font-size: 1.6rem; }
.stat h2 { margin: 0.25rem 0; font-size: 1.6rem; color: var(--primary); }
.stat p { margin: 0; color: var(--muted); font-size: 0.85rem; }

.panel {
    background: var(--surface); padding: 1.1rem;
    border-radius: var(--radius); box-shadow: var(--shadow);
    margin-bottom: 1.25rem;
}
.panel h2 { margin-top: 0; font-size: 1.2rem; }

.dot { display: inline-block; width: 14px; height: 14px;
       border-radius: 50%; margin-right: 0.4rem; vertical-align: middle; }
.cat-list { list-style: none; padding: 0; margin: 0; }
.cat-list li { padding: 0.6rem 0; border-bottom: 1px solid var(--border); }
.cat-list li:last-child { border-bottom: none; }

/* ---------- Pulse para favoritos ---------- */
@keyframes pop { 0% { transform: scale(1); } 50% { transform: scale(1.3); } 100% { transform: scale(1); } }
.fav-btn.is-fav { animation: pop 0.3s ease; }

/* ---------- Footer ---------- */
.footer {
    text-align: center;
    padding: 1rem;
    padding-bottom: calc(1rem + var(--safe-bottom));
    color: var(--muted); font-size: 0.85rem;
}

/* =========================================================
   Tablet (768px+)
   ========================================================= */
@media (min-width: 768px) {
    .brand-text { display: inline; }
    .brand { font-size: 1.2rem; }
    .container { padding: 1.5rem; }
    .hero h1 { font-size: 1.75rem; }
    .filters { grid-template-columns: 2fr 1fr 1fr auto; }
    .cards { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.25rem; }
    .stats-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
    .stat span { font-size: 2rem; }
    .stat h2 { font-size: 2rem; }
    .table th, .table td { padding: 0.75rem 1rem; }
    .table { font-size: 1rem; }
}

/* =========================================================
   Móvil pequeño (<768px) - colapsar menú
   ========================================================= */
@media (max-width: 767px) {
    .nav-toggle { display: flex; }
    .nav {
        display: none;
        position: absolute;
        top: 100%; left: 0; right: 0;
        background: var(--surface);
        flex-direction: column;
        padding: 0.5rem;
        padding-left: calc(0.5rem + var(--safe-left));
        padding-right: calc(0.5rem + var(--safe-right));
        gap: 0;
        box-shadow: 0 8px 20px rgba(0,0,0,0.12);
        border-bottom: 1px solid var(--border);
        max-height: calc(100vh - 60px);
        overflow-y: auto;
    }
    .nav.open { display: flex; }
    .nav a {
        padding: 0.85rem 1rem;
        border-radius: 0;
        border-bottom: 1px solid var(--border);
        font-size: 1rem;
        width: 100%;
    }
    .nav a:last-child { border-bottom: none; }
    .hero { flex-direction: column; align-items: stretch; }
    .hero > div + * { width: 100%; }
    .hero .btn { width: 100%; }
}

/* =========================================================
   Modo standalone (PWA instalada en iPhone)
   ========================================================= */
@media (display-mode: standalone) {
    /* En PWA instalada, el sticky bar respeta el notch totalmente */
    .topbar { position: sticky; }
}

/* Animación suave para teclado iOS apareciendo */
@supports (-webkit-touch-callout: none) {
    /* iOS Safari */
    .form-card { padding-bottom: 1.5rem; }
}

/* =========================================================
   Iconos SVG (lucide)
   ========================================================= */
.icon {
    display: inline-block;
    vertical-align: -2px;
    flex-shrink: 0;
}
.icon-lg { width: 48px; height: 48px; opacity: 0.4; margin-bottom: 0.5rem; }

/* Toggle sol/luna en el botón de tema */
#themeToggle .icon-sun { display: inline-block; }
#themeToggle .icon-moon { display: none; }
body.dark #themeToggle .icon-sun { display: none; }
body.dark #themeToggle .icon-moon { display: inline-block; }

.brand { display: inline-flex; align-items: center; gap: 0.5rem; }
.brand .icon { color: var(--primary); }

.nav a { display: inline-flex; align-items: center; gap: 0.35rem; }

.nav-with-badge { position: relative; }
.nav-badge {
    display: inline-flex; align-items: center; justify-content: center;
    background: #f59e0b; color: #fff;
    border-radius: 999px; padding: 0 0.5rem;
    font-size: 0.7rem; font-weight: 700;
    min-width: 18px; height: 18px;
    margin-left: 0.25rem;
}

.alert {
    display: flex; align-items: center; gap: 0.5rem;
}
.alert .icon { flex-shrink: 0; }

/* =========================================================
   Mejor checkbox de favoritos en filtros
   ========================================================= */
.toggle-fav {
    display: inline-flex; align-items: center;
    min-height: 44px;
    cursor: pointer;
    position: relative;
}
.toggle-fav input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-fav-slider {
    display: inline-flex; align-items: center; gap: 0.5rem;
    padding: 0.55rem 0.9rem;
    border-radius: 999px;
    background: var(--surface);
    border: 2px solid var(--border);
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
    user-select: none;
}
.toggle-fav-slider .icon { color: currentColor; }
.toggle-fav input:checked + .toggle-fav-slider {
    background: #fbbf24;
    border-color: #f59e0b;
    color: #78350f;
}
.toggle-fav input:checked + .toggle-fav-slider .icon { fill: #78350f; }
.toggle-fav:hover .toggle-fav-slider { border-color: var(--primary); color: var(--text); }

/* Search con icono dentro */
.search-wrap { position: relative; }
.search-wrap .search-icon {
    position: absolute;
    left: 0.85rem; top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
}
.search-wrap input[type="search"] {
    padding-left: 2.5rem !important;
}

/* =========================================================
   Cards con favoritos destacados
   ========================================================= */
.card.is-favorite {
    border-color: #fbbf24;
    box-shadow: 0 0 0 1px #fbbf24, var(--shadow);
}
.card.is-favorite::before {
    content: '';
    position: absolute;
    top: 8px; right: 8px;
    width: 8px; height: 8px;
    background: #f59e0b;
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(245,158,11,0.3);
    z-index: 1;
}
.card { position: relative; }

.favicon-wrap {
    width: 40px; height: 40px;
    background: #fff;
    border-radius: 8px;
    padding: 4px;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
body.dark .favicon-wrap { background: #f1f5f9; }
.favicon { width: 100%; height: 100%; object-fit: contain; }
.favicon-placeholder { color: var(--muted); display: none; }

.icon-action {
    background: transparent;
    border: none;
    cursor: pointer;
    width: 36px; height: 36px;
    border-radius: 8px;
    color: var(--muted);
    transition: var(--transition);
    display: inline-flex; align-items: center; justify-content: center;
}
.icon-action:hover, .icon-action:active { background: var(--surface-2); color: var(--text); }
.fav-btn.is-fav { color: #f59e0b; }
.fav-btn.is-fav .icon { fill: #f59e0b; }
.note-btn.is-on { color: var(--primary); }
.note-btn.is-on .icon { fill: var(--primary); fill-opacity: 0.2; }

.btn-small-action {
    padding: 0.45rem 0.8rem !important;
    min-height: 36px !important;
    font-size: 0.85rem !important;
    background: transparent !important;
}

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; }

/* =========================================================
   Lista profesional de URLs (admin)
   ========================================================= */
.url-list {
    display: flex; flex-direction: column; gap: 0.6rem;
}
.url-row {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--cat-color, var(--primary));
    border-radius: 12px;
    padding: 0.85rem 1rem;
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    gap: 0.85rem;
    align-items: center;
    transition: var(--transition);
    box-shadow: var(--shadow);
}
.url-row:hover { transform: translateX(2px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }

.url-row-icon {
    width: 40px; height: 40px;
    background: #fff;
    border-radius: 8px;
    padding: 4px;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    flex-shrink: 0;
}
body.dark .url-row-icon { background: #f1f5f9; }
.url-row-icon img { width: 100%; height: 100%; object-fit: contain; }

.url-row-main { min-width: 0; }
.url-row-title {
    font-weight: 600;
    color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    margin-bottom: 0.15rem;
}
.url-row-link {
    color: var(--primary);
    font-size: 0.85rem;
    text-decoration: none;
    display: block;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.url-row-link:hover { text-decoration: underline; }
.url-row-desc { font-size: 0.8rem; margin-top: 0.2rem; }

.url-row-meta {
    display: flex; flex-direction: column; align-items: flex-end; gap: 0.3rem;
    flex-shrink: 0;
    font-size: 0.8rem;
}
.url-row-stat {
    display: inline-flex; align-items: center; gap: 0.25rem;
    color: var(--text);
}

.url-row-actions { display: flex; gap: 0.3rem; flex-shrink: 0; }

/* Móvil: una columna */
@media (max-width: 767px) {
    .url-row {
        grid-template-columns: auto 1fr auto;
        grid-template-areas:
            "icon main actions"
            "meta meta meta";
        gap: 0.6rem 0.75rem;
    }
    .url-row-icon { grid-area: icon; }
    .url-row-main { grid-area: main; }
    .url-row-actions { grid-area: actions; }
    .url-row-meta {
        grid-area: meta;
        flex-direction: row;
        justify-content: flex-start;
        align-items: center;
        gap: 0.75rem;
        flex-wrap: wrap;
    }
    .hero-actions { width: 100%; display: flex; gap: 0.5rem; flex-wrap: wrap; }
    .hero-actions .btn { flex: 1; min-width: 110px; }
}
@media (min-width: 768px) {
    .hero-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
}

/* =========================================================
   Recordatorios mejorados
   ========================================================= */
.reminder-tabs {
    display: flex; gap: 0.4rem;
    margin-bottom: 1.25rem;
    background: var(--surface);
    padding: 0.4rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow-x: auto;
}
.reminder-tab {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.7rem 1.1rem;
    border-radius: 8px;
    text-decoration: none;
    color: var(--muted);
    font-weight: 500;
    font-size: 0.9rem;
    transition: var(--transition);
    white-space: nowrap;
    min-height: 44px;
}
.reminder-tab:hover { background: var(--surface-2); color: var(--text); }
.reminder-tab.active { background: var(--primary); color: #fff; }
.reminder-tab-count {
    background: rgba(255,255,255,0.25);
    color: inherit;
    border-radius: 999px;
    padding: 0.1rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 700;
}
.reminder-tab:not(.active) .reminder-tab-count {
    background: var(--surface-2);
    color: var(--text);
}

.reminder-group-title {
    display: flex; align-items: center; gap: 0.5rem;
    margin: 1.25rem 0 0.75rem;
    font-size: 1rem;
    font-weight: 600;
}

.reminder-list { display: flex; flex-direction: column; gap: 0.75rem; }
.reminder-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 1rem;
    align-items: center;
    box-shadow: var(--shadow);
    transition: var(--transition);
}
.reminder-card:hover { transform: translateY(-1px); }

.reminder-overdue { border-left: 4px solid #ef4444; background: linear-gradient(135deg, rgba(239,68,68,0.05), transparent); }
.reminder-upcoming { border-left: 4px solid #3b82f6; }
.reminder-done    { border-left: 4px solid #10b981; opacity: 0.7; }

.reminder-date {
    text-align: center;
    background: var(--surface-2);
    border-radius: 10px;
    padding: 0.6rem 0.85rem;
    min-width: 70px;
}
.reminder-day { font-size: 1.6rem; font-weight: 700; line-height: 1; color: var(--text); }
.reminder-month { font-size: 0.7rem; font-weight: 600; color: var(--muted); letter-spacing: 0.05em; margin-top: 0.15rem; }
.reminder-time { font-size: 0.85rem; color: var(--muted); margin-top: 0.4rem; font-variant-numeric: tabular-nums; }

.reminder-overdue .reminder-day { color: #ef4444; }
.reminder-upcoming .reminder-day { color: #3b82f6; }
.reminder-done .reminder-day { color: #10b981; }

.reminder-content { min-width: 0; }
.reminder-url {
    display: flex; align-items: center; gap: 0.4rem;
    margin-bottom: 0.3rem;
}
.favicon-mini { width: 18px; height: 18px; border-radius: 4px; background: #fff; padding: 2px; }
body.dark .favicon-mini { background: #f1f5f9; }
.reminder-message { margin: 0.2rem 0; font-size: 0.95rem; }
.reminder-meta {
    display: flex; gap: 0.85rem; flex-wrap: wrap;
    font-size: 0.75rem;
    margin-top: 0.4rem;
}
.reminder-meta span { display: inline-flex; align-items: center; gap: 0.25rem; }
.reminder-actions { display: flex; gap: 0.3rem; flex-shrink: 0; }

@media (max-width: 767px) {
    .reminder-card {
        grid-template-columns: auto 1fr;
        grid-template-areas:
            "date content"
            "actions actions";
    }
    .reminder-date { grid-area: date; }
    .reminder-content { grid-area: content; }
    .reminder-actions { grid-area: actions; justify-content: flex-end; padding-top: 0.5rem; border-top: 1px solid var(--border); margin-top: 0.25rem; }
}

/* Empty state mejor */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--muted);
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.empty-state .icon-lg { display: block; margin: 0 auto 1rem; }
.empty-state p { margin: 0 0 1rem; font-size: 1rem; }


/* =========================================================
   KPIs de estadísticas
   ========================================================= */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.85rem;
    margin-bottom: 1.5rem;
}
.kpi {
    display: flex; align-items: center; gap: 0.85rem;
    padding: 1.1rem;
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}
.kpi::before {
    content: ''; position: absolute;
    top: 0; left: 0; right: 0; height: 3px;
    background: var(--kpi-color, var(--primary));
}
.kpi-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    background: color-mix(in srgb, var(--kpi-color, var(--primary)) 15%, transparent);
    color: var(--kpi-color, var(--primary));
    flex-shrink: 0;
}
.kpi-content { min-width: 0; }
.kpi-value {
    font-size: 1.75rem; font-weight: 700; line-height: 1;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}
.kpi-label {
    font-size: 0.8rem; color: var(--muted);
    margin-top: 0.25rem;
}
.kpi-blue   { --kpi-color: #3b82f6; }
.kpi-green  { --kpi-color: #10b981; }
.kpi-amber  { --kpi-color: #f59e0b; }
.kpi-purple { --kpi-color: #8b5cf6; }
.kpi-pink   { --kpi-color: #ec4899; }
.kpi-red    { --kpi-color: #ef4444; }

/* =========================================================
   Paneles de estadísticas
   ========================================================= */
.stat-panel {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    border: 1px solid var(--border);
}
.stat-panel-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1rem; flex-wrap: wrap; gap: 0.5rem;
}
.stat-panel-header h2 {
    margin: 0; font-size: 1.05rem;
    display: flex; align-items: center; gap: 0.5rem;
}

.stats-two-col {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}
@media (min-width: 900px) {
    .stats-two-col { grid-template-columns: 1fr 1fr; }
    .stats-two-col .stat-panel { margin-bottom: 0; }
}

/* Bar chart de actividad */
.chart-bars {
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: 0.3rem;
    height: 160px;
    padding-top: 1.5rem;
}
.chart-bar-wrap {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    min-width: 0; height: 100%;
}
.chart-bar {
    width: 100%; max-width: 36px;
    background: linear-gradient(180deg, var(--primary), color-mix(in srgb, var(--primary) 70%, transparent));
    border-radius: 6px 6px 0 0;
    position: relative;
    min-height: 4px;
    transition: filter 0.2s;
    cursor: pointer;
}
.chart-bar:hover { filter: brightness(1.1); }
.chart-bar-value {
    position: absolute;
    top: -20px; left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}
.chart-bar-label {
    font-size: 0.65rem;
    color: var(--muted);
    margin-top: 0.4rem;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
@media (max-width: 600px) {
    .chart-bar-label { font-size: 0.55rem; }
    .chart-bar-value { font-size: 0.6rem; }
    .chart-bars { gap: 0.15rem; }
}

/* Ranking */
.rank-list { display: flex; flex-direction: column; gap: 0.75rem; }
.rank-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 0.85rem;
    align-items: center;
    padding: 0.5rem 0;
}
.rank-pos {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--surface-2);
    color: var(--muted);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}
.rank-1 { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #fff; }
.rank-2 { background: linear-gradient(135deg, #cbd5e1, #94a3b8); color: #fff; }
.rank-3 { background: linear-gradient(135deg, #d97706, #92400e); color: #fff; }
.rank-content { min-width: 0; }
.rank-title {
    font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    margin-bottom: 0.25rem;
}
.rank-bar {
    height: 6px;
    background: var(--surface-2);
    border-radius: 999px;
    overflow: hidden;
    margin-top: 0.35rem;
}
.rank-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), color-mix(in srgb, var(--primary) 60%, transparent));
    border-radius: 999px;
    transition: width 0.5s ease;
}
.rank-value {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
}

/* Categorías como barras */
.cat-stats { display: flex; flex-direction: column; gap: 1rem; }
.cat-stat-item { }
.cat-stat-head {
    display: flex; align-items: center; gap: 0.5rem;
    margin-bottom: 0.35rem;
    font-size: 0.9rem;
}
.cat-stat-name { font-weight: 500; flex: 1; }
.cat-stat-count { font-weight: 600; font-variant-numeric: tabular-nums; }
.cat-stat-bar {
    height: 10px;
    background: var(--surface-2);
    border-radius: 999px;
    overflow: hidden;
}
.cat-stat-bar-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.5s ease;
}

/* Usuarios activos */
.user-stats { display: flex; flex-direction: column; gap: 0.85rem; }
.user-stat-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 0.85rem;
    align-items: center;
}
.user-stat-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}
.user-stat-info { min-width: 0; }
.user-stat-name { font-weight: 600; margin-bottom: 0.15rem; }
.user-stat-count { font-weight: 600; font-size: 0.95rem; }

/* =========================================================
   Configuración con tabs
   ========================================================= */
.config-tabs {
    display: flex; gap: 0.3rem;
    margin-bottom: 1.5rem;
    background: var(--surface);
    padding: 0.35rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow-x: auto;
    border: 1px solid var(--border);
}
.config-tab {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.65rem 1rem;
    border-radius: 8px;
    background: transparent;
    border: none;
    color: var(--muted);
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    font-family: inherit;
    min-height: 44px;
}
.config-tab:hover { background: var(--surface-2); color: var(--text); }
.config-tab.active { background: var(--primary); color: #fff; }
.config-tab.active .icon { color: #fff; }

.config-pane { display: none; }
.config-pane.active { display: block; }

.config-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    display: flex; flex-direction: column; gap: 0.85rem;
}
.config-card h3 {
    margin: 0 0 0.5rem;
    display: flex; align-items: center; gap: 0.5rem;
    font-size: 1.05rem;
}
.config-card h4 {
    margin: 0.5rem 0;
    display: flex; align-items: center; gap: 0.4rem;
    font-size: 0.95rem;
}
.config-card label {
    display: flex; flex-direction: column; gap: 0.35rem;
    font-weight: 500; font-size: 0.95rem;
}
.config-card input[type="text"],
.config-card input[type="email"],
.config-card input[type="url"],
.config-card input[type="number"] {
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-size: 16px;
    min-height: 44px;
    -webkit-appearance: none;
}
.config-card .check {
    flex-direction: row; align-items: center; gap: 0.6rem;
}

/* Consentimiento obligatorio (Ley 21.719) */
.consent-card { max-width: 560px; }
.consent-list { margin: 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: 0.4rem; }
.consent-list a { display: flex; align-items: center; gap: 0.4rem; font-weight: 500; }
.consent-list small { font-weight: 400; color: var(--muted, #6b7280); }
.consent-actions { margin-top: 0.25rem; display: flex; gap: 0.6rem; flex-wrap: wrap; }

.config-save {
    position: sticky;
    bottom: 1rem;
    margin-top: 1.5rem;
    background: var(--surface);
    padding: 0.85rem;
    border-radius: 12px;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.08);
    z-index: 10;
    border: 1px solid var(--border);
    justify-content: flex-end;
}

/* Instalación PWA */
.install-help {
    background: var(--surface-2);
    padding: 1rem;
    border-radius: 10px;
    margin-top: 0.5rem;
}
.install-help ol, .install-help ul {
    margin: 0.5rem 0; padding-left: 1.2rem;
    line-height: 1.7;
}
.install-help-ol {
    padding-left: 1.2rem;
    line-height: 2;
}

.code-block {
    background: var(--surface-2);
    color: var(--text);
    padding: 0.85rem;
    border-radius: 8px;
    font-family: 'SFMono-Regular', Menlo, Consolas, monospace;
    font-size: 0.8rem;
    overflow-x: auto;
    white-space: pre;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
}
.copy-code {
    display: block;
    background: var(--surface-2);
    padding: 0.6rem;
    border-radius: 6px;
    font-family: 'SFMono-Regular', Menlo, monospace;
    font-size: 0.75rem;
    word-break: break-all;
    cursor: pointer;
    margin: 0.3rem 0;
    border: 1px solid var(--border);
    user-select: all;
    -webkit-user-select: all;
}
.copy-code:hover { background: var(--primary); color: #fff; }
.copy-code.copied { background: #10b981; color: #fff; }

/* Bookmarklet area */
.bookmarklet-area {
    display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center;
    background: var(--surface-2);
    padding: 1rem;
    border-radius: 10px;
    border: 2px dashed var(--border);
}
.bookmarklet-btn {
    display: inline-flex; align-items: center; gap: 0.5rem;
    padding: 0.7rem 1.2rem;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: #fff;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    cursor: grab;
    box-shadow: 0 4px 12px rgba(59,130,246,0.3);
    transition: transform 0.15s;
}
.bookmarklet-btn:active { cursor: grabbing; transform: scale(0.97); }
.bookmarklet-btn:hover { transform: translateY(-2px); }

/* Activity log */
.activity-log { display: flex; flex-direction: column; gap: 0.3rem; }
.activity-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 0.85rem;
    align-items: center;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    background: var(--surface-2);
    font-size: 0.85rem;
}
.activity-time {
    text-align: center;
    min-width: 50px;
}
.activity-date { font-weight: 600; font-size: 0.8rem; }
.activity-hour { font-size: 0.7rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.activity-action {
    display: flex; align-items: center; gap: 0.4rem;
    flex-wrap: wrap;
}
.activity-details { font-size: 0.75rem; margin-top: 0.2rem; word-break: break-all; }
.activity-ip {
    font-size: 0.7rem;
    font-family: monospace;
    font-variant-numeric: tabular-nums;
}

/* Animación reordenamiento */
.card { will-change: transform; }


/* =========================================================
   Legal / Privacidad
   ========================================================= */
.legal-doc {
    background: var(--surface);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    max-width: 800px;
    margin: 0 auto;
    line-height: 1.7;
}
.legal-doc h1 { font-size: 1.6rem; }
.legal-doc h2 { font-size: 1.15rem; margin-top: 1.5rem; color: var(--primary); }
.legal-doc h3 { font-size: 1rem; margin-top: 1rem; }
.legal-doc ul, .legal-doc ol { padding-left: 1.5rem; }
.legal-doc code { background: var(--surface-2); padding: 0.1rem 0.3rem; border-radius: 4px; font-size: 0.85rem; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.5rem 0;
}
.data-table th, .data-table td {
    padding: 0.6rem 0.8rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.data-table th { background: var(--surface-2); font-weight: 600; width: 30%; }

.danger-zone {
    border: 1px solid #ef4444;
    background: linear-gradient(135deg, rgba(239,68,68,0.05), transparent);
}

.footer-links {
    display: flex; gap: 0.5rem; align-items: center;
    justify-content: center; margin-bottom: 0.5rem;
    flex-wrap: wrap;
}
.footer-links a { color: var(--primary); text-decoration: none; font-size: 0.85rem; }
.footer-links a:hover { text-decoration: underline; }
.footer-sep { color: var(--muted); }

/* Medidor de fortaleza de contraseña */
.pwd-meter { margin-top: 0.35rem; }
.pwd-meter-bar {
    height: 4px; width: 0%;
    background: var(--border);
    border-radius: 2px;
    transition: width 0.3s, background 0.3s;
}
.pwd-meter-text {
    font-size: 0.75rem;
    margin-top: 0.25rem;
    font-weight: 600;
    height: 1em;
}


/* =========================================================
   Notificación de recordatorios (toast)
   ========================================================= */
.reminder-toast-container {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 1rem);
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    max-width: calc(100vw - 2rem);
    width: 360px;
    pointer-events: none;
}
.reminder-toast {
    pointer-events: auto;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-left: 4px solid #f59e0b;
    border-radius: 12px;
    padding: 0.9rem 1rem;
    box-shadow: 0 10px 30px rgba(0,0,0,.2), 0 4px 10px rgba(0,0,0,.1);
    opacity: 0;
    transform: translateX(40px);
    transition: opacity .25s ease, transform .25s ease;
}
.reminder-toast.show {
    opacity: 1;
    transform: translateX(0);
}
.reminder-toast.out {
    opacity: 0;
    transform: translateX(40px);
}
.reminder-toast.summary { border-left-color: #3b82f6; }

.reminder-toast .rt-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}
.reminder-toast .rt-emoji {
    font-size: 1.4rem;
    display: inline-flex;
    align-items: center;
    animation: rt-shake 1s ease 2;
}
@keyframes rt-shake {
    0%, 100% { transform: rotate(0); }
    20%, 60% { transform: rotate(-10deg); }
    40%, 80% { transform: rotate(10deg); }
}
.reminder-toast .rt-head strong {
    flex: 1;
    font-size: 0.95rem;
}
.reminder-toast .rt-close {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 0.3rem;
    border-radius: 6px;
}
.reminder-toast .rt-close:hover {
    background: var(--surface-2);
    color: var(--text);
}
.reminder-toast .rt-msg {
    font-size: 0.95rem;
    margin: 0.3rem 0;
    line-height: 1.4;
}
.reminder-toast .rt-summary-line {
    font-size: 1rem;
    font-weight: 600;
    margin: 0.3rem 0;
    color: #3b82f6;
}
.reminder-toast .rt-url {
    font-size: 0.85rem;
    color: var(--muted);
    margin: 0.3rem 0;
    word-break: break-word;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}
.reminder-toast .rt-time {
    font-size: 0.75rem;
    margin-top: 0.3rem;
}
.reminder-toast .rt-actions {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.7rem;
    flex-wrap: wrap;
}
.reminder-toast .rt-btn {
    flex: 1;
    min-width: 0;
    padding: 0.5rem 0.7rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
    font-size: 0.85rem;
    text-align: center;
    text-decoration: none;
    transition: background .15s;
    -webkit-tap-highlight-color: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
}
.reminder-toast .rt-btn:hover { background: var(--border); }
.reminder-toast .rt-btn:disabled { opacity: 0.5; cursor: wait; }
.reminder-toast .rt-btn-primary {
    background: #2563eb;
    color: white;
    border-color: #2563eb;
}
.reminder-toast .rt-btn-primary:hover { background: #1d4ed8; }

@media (max-width: 480px) {
    .reminder-toast-container {
        left: 1rem;
        right: 1rem;
        width: auto;
        max-width: none;
    }
}

/* Selector de sonidos en preferencias */
.sound-options {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 0.8rem;
}
.sound-option {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.9rem 1rem;
    border: 2px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.sound-option:hover { background: var(--surface-2); }
.sound-option.selected {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.08);
}
.sound-option input[type="radio"] {
    width: 20px; height: 20px;
    flex-shrink: 0;
    cursor: pointer;
}
.sound-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.sound-info strong { font-size: 0.95rem; }
.sound-info small { font-size: 0.8rem; margin-top: 0.15rem; }
.btn-sm {
    padding: 0.4rem 0.7rem;
    font-size: 0.85rem;
}
.sound-preview { flex-shrink: 0; }

/* =========================================================
   Vista agrupada por categoría
   ========================================================= */
.url-groups {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-top: 1rem;
}
.url-group {
    background: var(--surface);
    border-radius: 14px;
    border: 1px solid var(--border);
    overflow: hidden;
    contain: layout style;
}
.group-header {
    padding: 0;
    border-left: 4px solid;
    background: linear-gradient(90deg, color-mix(in srgb, currentColor 6%, transparent), transparent);
}
.group-toggle {
    width: 100%;
    background: none;
    border: none;
    padding: 0.9rem 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    cursor: pointer;
    color: var(--text);
    font-family: inherit;
    text-align: left;
    -webkit-tap-highlight-color: transparent;
}
.group-toggle:hover { background: var(--surface-2); }
.group-color-dot {
    width: 14px; height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
}
.group-title {
    flex: 1;
    font-size: 1.1rem;
    margin: 0;
    font-weight: 600;
}
.group-count {
    background: var(--surface-2);
    color: var(--muted);
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
}
.group-chevron {
    color: var(--muted);
    transition: transform 0.2s;
    font-size: 0.9rem;
}
.group-toggle[aria-expanded="false"] .group-chevron {
    transform: rotate(-90deg);
}
.group-body {
    padding: 1rem;
    transition: max-height 0.3s ease, opacity 0.2s, padding 0.2s;
    overflow: hidden;
}
.group-body.collapsed {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
}

/* =========================================================
   Quick-jump tabs (pills horizontales)
   ========================================================= */
.quick-jump {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 0.5rem 0.25rem 0.75rem;
    margin: 0.5rem 0 1rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}
.quick-jump::-webkit-scrollbar { height: 4px; }
.quick-jump::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}
.qj-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.9rem;
    background: var(--surface);
    border: 2px solid transparent;
    border-radius: 999px;
    text-decoration: none;
    color: var(--text);
    font-size: 0.88rem;
    white-space: nowrap;
    flex-shrink: 0;
    transition: transform 0.15s, background 0.15s;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.qj-pill:hover { background: var(--surface-2); transform: translateY(-1px); }
.qj-pill:active { transform: translateY(0); }
.qj-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.qj-count {
    background: var(--surface-2);
    color: var(--muted);
    padding: 0.05rem 0.45rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
}

/* =========================================================
   Drag & drop (handles, ghost, modo manual)
   ========================================================= */
.drag-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px; height: 32px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--muted);
    cursor: grab;
    touch-action: none;
    transition: background 0.15s, color 0.15s;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}
.drag-handle:hover { background: var(--border); color: var(--text); }
.drag-handle:active { cursor: grabbing; }

.card .drag-handle {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 5;
    backdrop-filter: blur(4px);
    background: rgba(255,255,255,0.85);
}
body.dark .card .drag-handle {
    background: rgba(15,23,42,0.85);
}

.drag-handle-row {
    margin-right: 0.5rem;
    flex-shrink: 0;
}

.card { position: relative; contain: layout style; }

/* Ghost / placeholder al arrastrar */
.card-ghost {
    opacity: 0.4;
    background: var(--surface-2);
    border: 2px dashed var(--primary, #3b82f6);
}
.card-chosen { transition: box-shadow 0.15s; }
.card-dragging {
    box-shadow: 0 12px 30px rgba(0,0,0,0.25);
    transform: rotate(1deg);
    z-index: 1000;
}

/* Banner del modo manual */
.manual-mode-banner {
    background: linear-gradient(135deg, rgba(59,130,246,0.12), rgba(139,92,246,0.08));
    border: 1px solid rgba(59,130,246,0.3);
    border-radius: 10px;
    padding: 0.7rem 1rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    color: var(--text);
    font-size: 0.9rem;
}
.manual-mode-banner span { display: inline-flex; align-items: center; gap: 0.4rem; }
.inline-grip {
    background: var(--surface-2);
    padding: 0 0.35rem;
    border-radius: 4px;
    font-family: monospace;
    color: var(--muted);
}
.btn-sm {
    padding: 0.35rem 0.7rem;
    font-size: 0.85rem;
}

/* Categoría row con handle */
.category-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Móvil: ajustes */
@media (max-width: 640px) {
    .group-toggle { padding: 0.7rem 0.85rem; }
    .group-title { font-size: 1rem; }
    .quick-jump { padding-left: 0; padding-right: 0; }
    .qj-pill { padding: 0.4rem 0.7rem; font-size: 0.82rem; }
    .card .drag-handle {
        width: 36px; height: 36px;  /* más fácil de tocar */
    }
}

/* =========================================================
   Sistema TV Cable
   ========================================================= */

/* Separador en la navegación */
.nav-sep {
    display: inline-flex; align-items: center; gap: 0.3rem;
    font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--muted); white-space: nowrap;
    padding: 0 0.35rem;
}

/* Grilla de campos */
.form-grid-3 {
    display: grid; gap: 0.6rem;
    grid-template-columns: repeat(3, 1fr);
}
@media (max-width: 640px) {
    .form-grid-3 { grid-template-columns: 1fr; }
}

/* Input con botón/ícono adjunto */
.input-with-scan {
    display: flex; gap: 0.4rem; align-items: stretch;
}
.input-with-scan > input { flex: 1; min-width: 0; }
.input-with-scan .btn { flex-shrink: 0; }
.input-icon-holder {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0 0.6rem; color: var(--muted);
}

/* Resumen de stock */
.stock-summary {
    display: flex; gap: 1rem; flex-wrap: wrap;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.9rem 1.1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}
.stock-summary-item {
    display: flex; align-items: center; gap: 0.6rem;
}
.stock-summary-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: 10px;
    background: rgba(16,185,129,0.12); color: var(--success);
}
.stock-summary-item strong { font-size: 1.25rem; display: block; line-height: 1.1; }
.stock-summary-item span { font-size: 0.8rem; color: var(--muted); }

/* Filas de decos en el formulario */
.deco-row {
    display: grid; gap: 0.4rem; align-items: center;
    grid-template-columns: 1fr 1fr auto auto auto;
    margin-bottom: 0.5rem;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2);
}
.deco-row input {
    min-height: 40px; padding: 0.5rem 0.65rem;
    border: 1px solid var(--border); border-radius: 8px;
    background: var(--surface); color: var(--text); font-size: 16px;
}
.deco-status {
    grid-column: 1 / -1;
    font-size: 0.78rem; font-weight: 500;
    min-height: 1rem;
}
.deco-status.ok   { color: var(--success); }
.deco-status.warn { color: var(--danger); }
@media (max-width: 640px) {
    .deco-row { grid-template-columns: 1fr; }
    .deco-row .btn { width: 100%; }
    .deco-row .deco-serial, .deco-row .deco-mac { grid-column: 1 / -1; }
}

/* Preview de fotos en el formulario */
.fotos-preview {
    display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem;
}
.foto-preview-item {
    position: relative; width: 84px; height: 84px;
    border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
    background: #000;
}
.foto-preview-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.foto-preview-remove {
    position: absolute; top: 3px; right: 3px;
    width: 22px; height: 22px; padding: 0; line-height: 1;
    border: none; border-radius: 50%;
    background: rgba(0,0,0,.65); color: #fff; cursor: pointer;
    font-size: 14px; display: flex; align-items: center; justify-content: center;
}
.fotos-toolbar { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.fotos-toolbar small { color: var(--muted); }
body.tvcable .foto-preview-item { border-color: var(--tvc-border-2); }

/* Estados deco */
.badge-stock   { background: #10b981; }
.badge-ocupado { background: #ef4444; }

/* Estado GPS */
.gps-status { font-weight: 500; font-size: 0.9rem; }
.gps-good { color: var(--success); }
.gps-warn { color: #d97706; }
.gps-bad  { color: var(--danger); }

/* Modales */
.modal-overlay {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.15s ease;
}
.modal-overlay[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 100%; max-width: 520px;
    max-height: 85vh; overflow-y: auto;
    padding: 1.1rem;
    display: flex; flex-direction: column; gap: 0.7rem;
}
.modal-head {
    display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
}
.modal-head h3 { margin: 0; }
.modal-results {
    display: flex; flex-direction: column; gap: 0.4rem;
    max-height: 40vh; overflow-y: auto;
}
.modal-result {
    text-align: left;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: 10px;
    padding: 0.65rem 0.85rem;
    cursor: pointer;
    transition: var(--transition);
}
.modal-result:hover, .modal-result:active { border-color: var(--primary); background: var(--surface-2); }
.modal-result.is-used { opacity: 0.5; cursor: not-allowed; }
.modal-close { margin-left: auto; }

/* Overlay de escaneo por cámara */
.scan-overlay {
    position: fixed; inset: 0; z-index: 1100;
    background: rgba(0,0,0,0.85);
    display: flex; align-items: center; justify-content: center;
    padding: 1rem;
}
.scan-box {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1rem;
    width: 100%; max-width: 480px;
    text-align: center;
}
.scan-box video {
    width: 100%; max-height: 55vh;
    border-radius: 10px;
    background: #000;
    object-fit: cover;
    margin: 0.5rem 0;
}
.scan-box .btn { margin-top: 0.5rem; }
.scan-status {
    font-size: .85rem; font-weight: 500;
    color: var(--muted, #6b7280);
    margin: 0 0 .25rem;
    min-height: 1.2em;
}

/* =========================================================
   SISTEMA TV CABLE
   Usa los mismos colores que el sistema URL Manager
   (tema claro/oscuro global) en lugar de una identidad propia.
   ========================================================= */
body.tvcable {
    --tvc-bg: var(--bg);
    --tvc-bg-2: var(--surface-2);
    --tvc-surface: var(--surface);
    --tvc-surface-2: var(--surface-2);
    --tvc-surface-3: var(--surface-2);
    --tvc-border: var(--border);
    --tvc-border-2: var(--border);
    --tvc-text: var(--text);
    --tvc-muted: var(--muted);
    --tvc-amber: var(--primary);
    --tvc-amber-deep: var(--primary-hover);
    --tvc-orange: var(--primary);
    --tvc-green: var(--success);
    --tvc-red: var(--danger);
    --tvc-blue: var(--primary);
}

/* Cabina superior */
body.tvcable .topbar {
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    border-bottom: 1px solid var(--tvc-border-2);
    box-shadow: 0 1px 0 rgba(59,130,246,.14);
    -webkit-backdrop-filter: saturate(160%) blur(14px);
    backdrop-filter: saturate(160%) blur(14px);
}
body.tvcable .tvc-brand-mark {
    display: inline-flex;
    color: var(--tvc-amber);
    filter: drop-shadow(0 0 7px rgba(59,130,246,.55));
}
body.tvcable .tvc-brand-sub {
    font-family: 'IBM Plex Mono', monospace;
    font-size: .58rem; font-weight: 600; letter-spacing: .26em;
    color: var(--tvc-amber); opacity: .8;
    border: 1px solid color-mix(in srgb, var(--tvc-amber) 45%, transparent);
    border-radius: 4px; padding: .14rem .42rem;
}
body.tvcable .brand .icon { color: var(--tvc-amber); }

body.tvcable .nav a { color: var(--tvc-muted); }
body.tvcable .nav a:hover, body.tvcable .nav a:active { color: var(--tvc-text); background: var(--tvc-surface-2); }
body.tvcable .nav .nav-switch {
    background: rgba(59,130,246,.16);
    color: var(--tvc-blue);
    border: 1px solid rgba(59,130,246,.4);
}
body.tvcable .nav .nav-switch:hover, body.tvcable .nav .nav-switch:active {
    background: rgba(59,130,246,.28);
    color: var(--tvc-blue);
}

/* Botones */
body.tvcable .btn { background: var(--tvc-surface-2); border-color: var(--tvc-border-2); color: var(--tvc-text); }
body.tvcable .btn:hover, body.tvcable .btn:active { background: var(--tvc-surface-3); }
body.tvcable .btn-primary {
    background: linear-gradient(135deg, var(--tvc-amber), var(--tvc-amber-deep));
    color: #fff; border-color: transparent; font-weight: 600;
    box-shadow: 0 6px 18px rgba(59,130,246,.28);
}
body.tvcable .btn-primary:hover, body.tvcable .btn-primary:active {
    background: linear-gradient(135deg, var(--primary-hover), var(--tvc-amber));
    color: #fff;
}
body.tvcable .btn-danger { background: linear-gradient(135deg, #f87171, #dc2626); color: #fff; border-color: transparent; }
body.tvcable .btn-danger:hover, body.tvcable .btn-danger:active { opacity: .92; }
body.tvcable .btn-outline { background: transparent; }

body.tvcable .icon-btn { background: var(--tvc-surface-2); border-color: var(--tvc-border-2); color: var(--tvc-text); }
body.tvcable .icon-btn:hover, body.tvcable .icon-btn:active { background: var(--tvc-amber); color: #fff; }

/* Alertas */
body.tvcable .alert { border-radius: 12px; border-width: 1px; }
body.tvcable .alert-success { background: rgba(52,211,153,.1); border-color: rgba(52,211,153,.35); color: var(--tvc-green); }
body.tvcable .alert-error   { background: rgba(248,113,113,.1); border-color: rgba(248,113,113,.4); color: var(--tvc-red); }

/* Héroes */
body.tvcable .hero h1,
body.tvcable .container > h1 {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700; text-transform: uppercase; letter-spacing: .015em;
    font-size: 1.85rem; line-height: 1.05;
}
body.tvcable .container > h1:not(.hero h1) { margin: .25rem 0 1.1rem; }
.tvc-eyebrow {
    display: inline-flex; align-items: center; gap: .55rem;
    font-family: 'IBM Plex Mono', monospace;
    font-size: .66rem; font-weight: 600; letter-spacing: .22em;
    text-transform: uppercase; color: var(--tvc-amber);
    margin: 0 0 .4rem;
}
.tvc-eyebrow::before { content: ''; width: 24px; height: 1px; background: linear-gradient(90deg, var(--tvc-amber), transparent); }

/* Títulos de sección */
body.tvcable .container > h2 {
    display: flex; align-items: center; gap: .55rem;
    font-family: 'Barlow Condensed', sans-serif; font-weight: 700;
    text-transform: uppercase; letter-spacing: .05em; font-size: 1.2rem;
    border-left: 3px solid var(--tvc-amber); padding-left: .7rem;
    margin: 1.9rem 0 .9rem; color: var(--tvc-text);
}
body.tvcable .container > h2 .icon { color: var(--tvc-amber); }

/* KPIs del panel */
.tvc-stats {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: .8rem; margin-bottom: 1.5rem;
}
.tvc-stat {
    position: relative; overflow: hidden;
    display: flex; align-items: center; gap: .9rem;
    padding: 1.05rem 1rem;
    background: linear-gradient(180deg, var(--tvc-surface), var(--tvc-bg-2));
    border: 1px solid var(--tvc-border-2); border-radius: 16px;
    box-shadow: var(--shadow);
}
.tvc-stat::after {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
    background: linear-gradient(90deg, var(--tvc-stat, var(--tvc-amber)), transparent 70%);
}
.tvc-stat-icon {
    width: 46px; height: 46px; border-radius: 12px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: color-mix(in srgb, var(--tvc-stat, var(--tvc-amber)) 14%, transparent);
    color: var(--tvc-stat, var(--tvc-amber));
    border: 1px solid color-mix(in srgb, var(--tvc-stat, var(--tvc-amber)) 30%, transparent);
}
.tvc-stat-value {
    font-family: 'Barlow Condensed', sans-serif; font-weight: 700;
    font-size: 2.1rem; line-height: 1; color: var(--tvc-text);
    font-variant-numeric: tabular-nums;
}
.tvc-stat-label { font-size: .74rem; color: var(--tvc-muted); letter-spacing: .04em; margin-top: .28rem; }
.tvc-stat--stock        { --tvc-stat: var(--tvc-green); }
.tvc-stat--ocupado      { --tvc-stat: var(--tvc-red); }
.tvc-stat--total        { --tvc-stat: var(--tvc-amber); }
.tvc-stat--clientes     { --tvc-stat: #60a5fa; }
.tvc-stat--instalaciones{ --tvc-stat: var(--tvc-orange); }

/* Módulos del panel */
.tvc-modules { display: grid; grid-template-columns: 1fr; gap: .8rem; }
.tvc-module {
    display: flex; align-items: center; gap: .95rem;
    padding: .95rem 1rem;
    background: linear-gradient(180deg, var(--tvc-surface), var(--tvc-bg-2));
    border: 1px solid var(--tvc-border-2); border-radius: 16px;
    text-decoration: none; color: var(--tvc-text);
    box-shadow: var(--shadow); position: relative; overflow: hidden;
    transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.tvc-module::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
    background: var(--tvc-mod, var(--tvc-amber)); opacity: .85;
}
.tvc-module:hover {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--tvc-mod, var(--tvc-amber)) 55%, var(--tvc-border-2));
    box-shadow: 0 12px 30px rgba(0,0,0,.4);
}
.tvc-module-icon {
    width: 48px; height: 48px; border-radius: 12px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: color-mix(in srgb, var(--tvc-mod, var(--tvc-amber)) 14%, transparent);
    color: var(--tvc-mod, var(--tvc-amber));
    border: 1px solid color-mix(in srgb, var(--tvc-mod, var(--tvc-amber)) 32%, transparent);
}
.tvc-module-main { flex: 1; min-width: 0; }
.tvc-module-title { display: block; font-weight: 600; font-size: .98rem; }
.tvc-module-desc { display: block; color: var(--tvc-muted); font-size: .8rem; margin-top: .2rem; }
.tvc-module-go { color: var(--tvc-muted); flex-shrink: 0; transition: transform .16s ease, color .16s ease; }
.tvc-module:hover .tvc-module-go { transform: translateX(3px); color: var(--tvc-mod, var(--tvc-amber)); }
.tvc-module--amber { --tvc-mod: var(--tvc-amber); }
.tvc-module--green { --tvc-mod: var(--tvc-green); }
.tvc-module--blue  { --tvc-mod: #60a5fa; }
.tvc-module--orange{ --tvc-mod: var(--tvc-orange); }
.tvc-module--gray  { --tvc-mod: var(--tvc-muted); }

/* Tarjetas y registros */
body.tvcable .card { border-color: var(--tvc-border-2); }
body.tvcable .url-row {
    background: linear-gradient(180deg, var(--tvc-surface), color-mix(in srgb, var(--tvc-surface) 90%, var(--tvc-bg)));
    border: 1px solid var(--tvc-border-2);
    border-left: 4px solid var(--cat-color, var(--tvc-amber));
    border-radius: 14px; box-shadow: var(--shadow);
}
body.tvcable .url-row:hover { transform: translateX(3px); box-shadow: 0 10px 26px rgba(0,0,0,.4); }
body.tvcable .url-row-title { font-weight: 600; color: var(--tvc-text); }
body.tvcable .url-row-link { color: var(--tvc-amber); }
body.tvcable .url-row-link.muted,
body.tvcable .url-row-stat,
body.tvcable .url-row-desc { color: var(--tvc-muted); }

/* Códigos / chips mono */
.tvc-code {
    display: inline-block;
    font-family: 'IBM Plex Mono', monospace; font-size: .76rem; letter-spacing: .04em;
    padding: .16rem .5rem; border-radius: 6px;
    background: var(--tvc-surface-3); color: var(--tvc-text);
    border: 1px solid var(--tvc-border-2);
    font-variant-numeric: tabular-nums;
}
.tvc-code--dim { color: var(--tvc-muted); }
.tvc-chip {
    display: inline-flex; align-items: center; gap: .4rem;
    font-family: 'IBM Plex Mono', monospace; font-size: .7rem;
    padding: .22rem .55rem; border-radius: 6px;
    background: var(--tvc-surface-3); color: var(--tvc-text);
    border: 1px solid var(--tvc-border-2);
    font-variant-numeric: tabular-nums;
}
.tvc-chip--green { color: var(--tvc-green); border-color: rgba(52,211,153,.35); background: rgba(52,211,153,.08); }
.tvc-chip--red   { color: var(--tvc-red); border-color: rgba(248,113,113,.4);  background: rgba(248,113,113,.08); }
.tvc-chip--amber { color: var(--primary); border-color: rgba(59,130,246,.4);   background: rgba(59,130,246,.08); }
.tvc-chips { display: flex; flex-wrap: wrap; gap: .32rem; margin-top: .5rem; }

/* Bloque de fecha (día/mes) */
.tvc-day {
    text-align: center; flex-shrink: 0;
    background: var(--tvc-surface-3);
    border: 1px solid var(--tvc-border-2); border-radius: 10px;
    padding: .45rem .6rem; min-width: 62px;
}
.tvc-day-num {
    font-family: 'Barlow Condensed', sans-serif; font-weight: 800;
    font-size: 1.75rem; line-height: 1; color: var(--tvc-text);
    font-variant-numeric: tabular-nums;
}
.tvc-day-mon {
    font-family: 'IBM Plex Mono', monospace;
    font-size: .58rem; font-weight: 600; letter-spacing: .14em;
    color: var(--tvc-amber); margin-top: .2rem;
}

body.tvcable .badge { font-family: 'IBM Plex Mono', monospace; font-weight: 600; letter-spacing: .03em; }

/* Consola de orden de trabajo (formulario) */
body.tvcable .form-card {
    background: linear-gradient(180deg, var(--tvc-surface), var(--tvc-bg-2));
    border: 1px solid var(--tvc-border-2);
    border-top: 3px solid var(--tvc-amber);
    border-radius: 16px;
}
body.tvcable .form-card h3 {
    font-family: 'Barlow Condensed', sans-serif; font-weight: 700;
    text-transform: uppercase; letter-spacing: .07em; font-size: 1.02rem;
    color: var(--tvc-amber); margin: 1.05rem 0 .6rem;
    display: flex; align-items: center; gap: .5rem;
    border-bottom: 1px dashed var(--tvc-border-2); padding-bottom: .55rem;
}
body.tvcable .form-card h3:first-of-type { margin-top: 0; }
body.tvcable .form-card h3 .icon { color: var(--tvc-amber); }
body.tvcable .form-card hr { border: none; border-top: 1px dashed var(--tvc-border-2); margin: .85rem 0; }
body.tvcable .form-card label { color: var(--tvc-text); }
body.tvcable .form-card input[type="text"],
body.tvcable .form-card input[type="email"],
body.tvcable .form-card input[type="password"],
body.tvcable .form-card input[type="url"],
body.tvcable .form-card input[type="number"],
body.tvcable .form-card input[type="date"],
body.tvcable .form-card input[type="datetime-local"],
body.tvcable .form-card input[type="color"],
body.tvcable .form-card textarea,
body.tvcable .form-card select,
body.tvcable .auth-card input,
body.tvcable .filters input[type="search"],
body.tvcable .filters select {
    background: var(--tvc-bg-2); color: var(--tvc-text);
    border-color: var(--tvc-border-2);
}
body.tvcable .form-card input:focus,
body.tvcable .form-card textarea:focus,
body.tvcable .form-card select:focus,
body.tvcable .filters input:focus,
body.tvcable .filters select:focus,
body.tvcable .auth-card input:focus {
    border-color: var(--tvc-amber);
    box-shadow: 0 0 0 3px rgba(59,130,246,.16);
}
body.tvcable .form-card input[disabled] { opacity: .55; }
body.tvcable .form-card select,
body.tvcable .filters select {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233b82f6' stroke-width='2.5' stroke-linecap='round'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e");
}

/* Resumen de stock en el formulario */
body.tvcable .stock-summary {
    background: linear-gradient(180deg, var(--tvc-surface), var(--tvc-bg-2));
    border-color: var(--tvc-border-2); border-radius: 14px;
}
body.tvcable .stock-summary-icon { background: rgba(59,130,246,.12); color: var(--tvc-amber); border: 1px solid rgba(59,130,246,.25); }
body.tvcable .stock-summary-item strong { font-family: 'Barlow Condensed', sans-serif; font-weight: 700; font-size: 1.5rem; }

/* Filas de decos */
body.tvcable .deco-row {
    background: var(--tvc-surface-2);
    border: 1px solid var(--tvc-border-2); border-radius: 12px;
    padding: .6rem;
}
body.tvcable .deco-row input {
    background: var(--tvc-bg-2); border-color: var(--tvc-border-2);
    color: var(--tvc-text);
    font-family: 'IBM Plex Mono', monospace; font-size: .88rem;
}
body.tvcable .deco-row input:focus { border-color: var(--tvc-amber); box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
body.tvcable .deco-status.ok   { color: var(--tvc-green); }
body.tvcable .deco-status.warn { color: var(--tvc-red); }
body.tvcable .input-icon-holder { color: var(--tvc-muted); }

/* Filtros */
body.tvcable .filters { background: var(--tvc-surface); border: 1px solid var(--tvc-border-2); }
body.tvcable .result-count { color: var(--tvc-muted); }

/* Modales */
body.tvcable .modal { background: var(--tvc-surface); border: 1px solid var(--tvc-border-2); }
body.tvcable .modal-head h3 { font-family: 'Barlow Condensed', sans-serif; text-transform: uppercase; letter-spacing: .05em; color: var(--tvc-amber); }
body.tvcable .modal-result { background: var(--tvc-surface-2); border-color: var(--tvc-border-2); color: var(--tvc-text); }
body.tvcable .modal-result:hover, body.tvcable .modal-result:active { border-color: var(--tvc-amber); background: var(--tvc-surface-3); }
body.tvcable .scan-box { background: var(--tvc-surface); border: 1px solid var(--tvc-border-2); }
body.tvcable .scan-box h3 { color: var(--tvc-text); }

/* Estado vacío */
body.tvcable .empty-state { background: var(--tvc-surface); border: 1px dashed var(--tvc-border-2); }

/* Tablas */
body.tvcable .table { background: var(--tvc-surface); border: 1px solid var(--tvc-border-2); }
body.tvcable .table th { background: var(--tvc-surface-2); color: var(--tvc-muted); font-family: 'IBM Plex Mono', monospace; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; }
body.tvcable .table td, body.tvcable .table th { border-color: var(--tvc-border); }

/* Paneles reutilizados */
body.tvcable .config-card { background: var(--tvc-surface); border-color: var(--tvc-border-2); }
body.tvcable .panel { background: var(--tvc-surface); border: 1px solid var(--tvc-border-2); }
body.tvcable .stat-panel { background: var(--tvc-surface); border-color: var(--tvc-border-2); }

/* Footer */
body.tvcable .footer { color: var(--tvc-muted); }
body.tvcable .footer-links a { color: var(--tvc-amber); }

/* Entrada animada */
body.tvcable main > *:not(.modal-overlay) { animation: tvc-rise .5s cubic-bezier(.22,.7,.22,1) both; }
body.tvcable main > *:not(.modal-overlay):nth-child(2) { animation-delay: .06s; }
body.tvcable main > *:not(.modal-overlay):nth-child(3) { animation-delay: .12s; }
body.tvcable main > *:not(.modal-overlay):nth-child(4) { animation-delay: .18s; }
body.tvcable main > *:not(.modal-overlay):nth-child(5) { animation-delay: .24s; }
@keyframes tvc-rise {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
    body.tvcable main > *:not(.modal-overlay) { animation: none; }
}

@media (max-width: 767px) {
    body.tvcable .tvc-brand-sub { display: none; }
}

/* Directorio de clientes */
.tvc-clients { display: grid; grid-template-columns: 1fr; gap: .8rem; }
.tvc-client {
    display: flex; flex-direction: column; gap: .85rem;
    padding: 1.05rem;
    background: linear-gradient(180deg, var(--tvc-surface), var(--tvc-bg-2));
    border: 1px solid var(--tvc-border-2); border-radius: 16px;
    box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.tvc-client::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
    background: linear-gradient(90deg, #60a5fa, transparent 70%);
}
.tvc-client-top { display: flex; align-items: center; gap: .8rem; }
.tvc-avatar {
    width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-family: 'Barlow Condensed', sans-serif; font-weight: 800; font-size: 1.15rem;
    letter-spacing: .04em; text-transform: uppercase;
    background: color-mix(in srgb, var(--tvc-blue) 15%, transparent);
    color: var(--tvc-blue); border: 1px solid rgba(96,165,250,.35);
}
.tvc-client-name { font-weight: 600; font-size: 1rem; color: var(--tvc-text); line-height: 1.25; }
.tvc-client-meta {
    display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem;
    color: var(--tvc-muted); font-size: .8rem;
}
.tvc-client-meta .icon { color: var(--tvc-amber); }
.tvc-client-gps {
    font-family: 'IBM Plex Mono', monospace; font-size: .7rem;
    color: var(--tvc-muted); display: flex; align-items: center; gap: .4rem;
}
.tvc-client-gps .icon { color: var(--tvc-amber); }
.tvc-client-foot {
    display: flex; align-items: center; justify-content: space-between; gap: .5rem;
    border-top: 1px dashed var(--tvc-border-2); padding-top: .8rem;
}
.tvc-client-date { text-align: right; color: var(--tvc-muted); font-size: .68rem; line-height: 1.45; }
.tvc-client-actions { display: flex; gap: .4rem; }

/* Decos asignados de un cliente */
.tvc-decos { display: grid; grid-template-columns: 1fr; gap: .8rem; }
.tvc-deco {
    padding: .95rem 1rem;
    background: linear-gradient(180deg, var(--tvc-surface), var(--tvc-bg-2));
    border: 1px solid var(--tvc-border-2); border-radius: 14px;
    box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.tvc-deco::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
    background: linear-gradient(90deg, var(--tvc-red), transparent 70%);
}
.tvc-deco-serial {
    display: flex; align-items: center; gap: .5rem;
    font-family: 'IBM Plex Mono', monospace; font-weight: 600; font-size: .92rem;
    color: var(--tvc-text); letter-spacing: .02em;
}
.tvc-deco-serial .icon { color: var(--tvc-red); }
.tvc-deco-mac { color: var(--tvc-muted); font-size: .78rem; margin: .45rem 0 .8rem; }
.tvc-deco-foot { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.tvc-deco-date { color: var(--tvc-muted); font-size: .7rem; }

/* Acciones del hero en varias líneas */
.hero-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

@media (min-width: 768px) {
    body.tvcable .hero h1,
    body.tvcable .container > h1 { font-size: 2.2rem; }
    body.tvcable .tvc-stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
    body.tvcable .tvc-modules { grid-template-columns: repeat(2, 1fr); }
    .tvc-clients { grid-template-columns: repeat(2, 1fr); }
    .tvc-decos { grid-template-columns: repeat(2, 1fr); }
}

