:root {
    /* Light mode.
       --pri-rgb es el primario en componentes RGB sueltos para poder componer
       tintes translúcidos con rgb(var(--pri-rgb) / α) en hover/focus/activo.
       --pri es solo el color sólido derivado de esos componentes. */
    --fg: #1a1a2e;
    --muted: #6b7280;
    --bd: #e5e7eb;
    --bg: #d5d5d5;
    --card: #ffffff;
    --pri-rgb: 67, 97, 238;          /* indigo equilibrado, no chillón */
    --pri: rgb(var(--pri-rgb));
    --radius: 10px;
}

@media (prefers-color-scheme: dark) {
    :root {
        /* Dark mode por defecto del sistema */
        --fg: #e0e0e0;
        --muted: #9ca3af;
        --bd: #374151;
        --bg: #111827;
        --card: #1f2937;
        --pri-rgb: 124, 150, 255;    /* mismo tono, más luminoso sobre fondo oscuro */
    }
}

[data-theme="dark"] {
    --fg: #e0e0e0;
    --muted: #9ca3af;
    --bd: #374151;
    --bg: #111827;
    --card: #1f2937;
    --pri-rgb: 124, 150, 255;
}

/* Tema claro explícito: anula la preferencia oscura del sistema */
[data-theme="light"] {
    --fg: #1a1a2e;
    --muted: #6b7280;
    --bd: #e5e7eb;
    --bg: #d5d5d5;
    --card: #ffffff;
    --pri-rgb: 67, 97, 238;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, sans-serif;
    color: var(--fg);
    background: var(--bg);
    line-height: 1.6;
    transition: background 0.3s, color 0.3s;
}

a { color: var(--pri); }

.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--bd);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.brand {
    font-weight: 700;
    font-size: 1.25rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--fg);
    text-decoration: none;           /* ← Esto quita el subrayado */
}
.brand:hover {
    color: var(--pri);
}

nav {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
    align-items: center;
    flex-wrap: wrap;
}

nav a:not(.btn) {
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.95rem;
    color: var(--fg);
    /*text-decoration: none;*/
    transition: all 0.2s;
}

nav a:not(.btn):hover { background: rgb(var(--pri-rgb) / 0.10); }
nav a:not(.btn).active {
    background: rgb(var(--pri-rgb) / 0.15);
    color: var(--pri);
    font-weight: 600;
}

.nav-toggle {
    display: none;           /* Oculto siempre */
}

.nav-burger {
    display: none;
    cursor: pointer;
    font-size: 1.5rem;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--bd);
    border-radius: var(--radius);
    background: var(--card);
    color: var(--fg);
}

.theme-toggle {
    background: transparent;
    border: 1px solid var(--bd);
    color: var(--muted);
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    border-radius: var(--radius);
    cursor: pointer;
}

main {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

.card {
    background: var(--card);
    border: 1px solid var(--bd);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);

}

.flash { padding: 0.75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; }
.flash-success { background: #064e3b; color: #a7f3d0; }
.flash-warning { background: #78350f; color: #fde68c; }
.flash-danger  { background: #7f1d1d; color: #fecaca; }

label { display: block; font-size: 0.875rem; color: var(--muted); margin: 0.5rem 0 0.35rem; }

input[type="text"], input[type="url"], input[type="email"], input[type="password"] {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--bd);
    border-radius: var(--radius);
    background: var(--card);
    color: var(--fg);
}

input[type="text"]:focus, input[type="url"]:focus,
input[type="email"]:focus, input[type="password"]:focus {
    outline: none;
    border-color: var(--pri);
    box-shadow: 0 0 0 3px rgb(var(--pri-rgb) / 0.15);
}

button, .btn {
    cursor: pointer;
    border: none;
    border-radius: var(--radius);
    padding: 0.6rem 1rem;
    font-size: 0.95rem;
}
button.is-copied {
    color: #16a34a;
    font-size: 0.65rem;
    border-color: #16a34a;
}

.btn-primary { background: var(--pri); color: white; }
.btn-ghost   { background: transparent; border: 1px solid var(--bd); color: var(--muted); }
.btn-danger  { background: transparent; border: 1px solid #f87171; color: #fda4af; }

.ml-1{
    margin-left: 1px;
}

.table-container {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--bd);
}

table {
    width: 100%;
    min-width: 600px;
    border-collapse: collapse;
}

th, td {
    text-align: left;
    padding: 0.75rem 0.6rem;
    border-bottom: 1px solid var(--bd);
}

th {
    background: rgba(0,0,0,0.05);
    color: var(--muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

@media (prefers-color-scheme: dark) {
    th { background: rgba(255,255,255,0.05); }
}

.list-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}

.search-bar {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    width: 100%;                    /* Ocupa todo el ancho disponible */
    max-width: none;               /* Opcional: límite máximo en desktop */
}

.search-bar input[type="search"] {
    flex: 1;                        /* Crece y ocupa todo el espacio */
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--bd);
    border-radius: var(--radius);
    background: var(--card);
    color: var(--fg);
    font-size: 0.97rem;
    width: 100%;
}

.search-bar input[type="search"]:focus {
    outline: none;
    border-color: var(--pri);
    box-shadow: 0 0 0 3px rgb(var(--pri-rgb) / 0.15);
}

.search-bar select {
    flex: 0 0 auto;                 /* No crece: el input de búsqueda manda */
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--bd);
    border-radius: var(--radius);
    background: var(--card);
    color: var(--fg);
    font-size: 0.97rem;
    cursor: pointer;
}

.search-bar select:focus {
    outline: none;
    border-color: var(--pri);
    box-shadow: 0 0 0 3px rgb(var(--pri-rgb) / 0.15);
}

.muted { color: var(--muted); }

@media (max-width: 768px) {
    .list-head {
        flex-direction: column;
        align-items: stretch;
    }

    .search-bar {
        max-width: none;
        flex-direction: column;     /* Apila input, selector y botón en móvil */
        align-items: stretch;
    }

    .search-bar select {
        width: 100%;                /* El selector ocupa todo el ancho apilado */
    }

    .topbar { flex-wrap: wrap; padding: 0.75rem 1rem; }
    .nav-burger { display: block; order: -1; /* Lo pone al principio en móvil */ }

    nav {
        display: none;
        flex-basis: 100%;
        flex-direction: column;
        align-items: stretch;
        margin: 0.75rem 0 0;
        gap: 0.25rem;
    }

    .nav-toggle:checked ~ nav { display: flex; }

    nav a:not(.btn), nav .btn {
        width: 100%;
        text-align: left;
        padding: 0.75rem;
    }

    main { padding: 0 1rem; margin: 1.5rem auto; }
    .card { padding: 1.25rem; }
}
