/* =========================================================
   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 {
    --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);
}

* { 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); }

.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; } /* solo en móvil */

/* ---------- 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; }

/* ---------- 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;
}

.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; }

