:root {
    --bg: #ded9cc;
    --panel: #ffffff;
    --panel-light: #f4f1e6;
    --border: #cec8b6;
    --text: #1c1c1a;
    --text-dim: #6b6a5f;
    --accent: #000000;
    --accent-dark: #000000;
    --accent-hover: #2b2b2b;
    --green: #16a34a;
    --red: #dc2626;
    --yellow: #f6e7a3;
    --yellow-text: #5c4d10;
    --orange: #f4511e;
    --icon-bg: #cfe3f5;
    --header-bg: #a6a296;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

a { color: var(--text); text-decoration: none; }
a:hover { text-decoration: underline; }

.site-header {
    background:
        linear-gradient(rgba(166,162,150,0.82), rgba(166,162,150,0.82)),
        url('../img/textures/granito-fino.jpg');
    background-size: cover;
    background-position: center;
    border-bottom: 1px solid var(--border);
}
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    max-width: 1100px;
    margin: 0 auto;
    padding: 14px 24px;
    gap: 12px;
}

.brand a { font-size: 1.15rem; font-weight: 700; color: #16130c; text-decoration: none; }

nav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; font-size: calc(0.9rem + 2pt); }
nav a { color: #201d16; font-weight: 600; }
nav .userinfo { color: #3a3730; font-style: italic; margin-left: 4px; font-weight: 400; }

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 28px 24px;
}

h1, h2, h3 { color: #14120d; }

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}

/* Aviso de referencias sugeridas pendientes de aprobación (panel de admins) */
.alert-bell-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: #fff7e0;
    border: 1px solid #f0d98a;
    color: #6b5710;
    text-decoration: none;
    cursor: pointer;
}
.alert-bell-card:hover { border-color: #e0c060; }
.alert-bell-card strong { font-size: 1.05em; }
.bell-blink {
    font-size: 1.8rem;
    line-height: 1;
    animation: bell-blink-anim 1.1s ease-in-out infinite;
}
@keyframes bell-blink-anim {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.35; transform: scale(1.15); }
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.stat {
    background:
        linear-gradient(rgba(246,231,163,0.25), rgba(246,231,163,0.25)),
        linear-gradient(rgba(255,255,255,0.3), rgba(255,255,255,0.3)),
        url('../img/textures/patina-oxido-uniforme.jpg');
    background-size: cover;
    background-position: center;
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.stat .num { font-size: 2rem; font-weight: 700; color: var(--yellow-text); }
.stat .label { color: #5c5747; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; }

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-weight: 600; text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.03em; }
tr:hover { background: rgba(0,0,0,0.03); }

form.stacked label { display: block; margin: 12px 0 4px; font-size: 0.88rem; color: var(--text-dim); }
input, select, textarea {
    width: 100%;
    padding: 9px 11px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.95rem;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: #000; }

button, .btn {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    margin-top: 14px;
    font-weight: 600;
}
button:hover, .btn:hover { background: var(--accent-hover); text-decoration: none; }
.btn-secondary { background: var(--panel-light); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #e9e4d5; }
.btn-danger { background: #b91c1c; }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--panel-light);
    color: var(--text-dim);
}
.badge.general { background: #c2410c; color: #fff; }
.badge.zona { background: #a16207; color: #fff; }
.badge.usuario { background: #0369a1; color: #fff; }
.badge.valida { background: #16a34a; color: #fff; }
.badge.no-valida { background: #dc2626; color: #fff; }
.badge.m2m { background: #7c3aed; color: #fff; }

.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; }
.alert-error { background: #fbe2e0; color: #8a2318; border: 1px solid #e8a89f; }
.alert-success { background: #e3f3e1; color: #205c1c; border: 1px solid #a9d6a1; }

.login-box { max-width: 380px; margin: 60px auto; }

#map { height: 420px; border-radius: var(--radius); margin-bottom: 20px; border: 1px solid var(--border); }

.progress-bar {
    background: var(--panel-light);
    border-radius: 999px;
    height: 10px;
    overflow: hidden;
    margin: 6px 0;
    border: 1px solid var(--border);
}
.progress-bar > div { background: var(--orange); height: 100%; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 700px) { .two-col { grid-template-columns: 1fr; } }

.hero-stats-row { grid-template-columns: 1.7fr 1fr; height: 360px; }
.hero-stats-row .hero-img-card { height: 100%; }
.hero-stats-row .hero-stats-grid { grid-template-columns: 1fr 1fr; grid-template-rows: repeat(3, 1fr); height: 100%; }
@media (max-width: 700px) {
    .hero-stats-row { height: auto; }
    .hero-stats-row .hero-img-card { height: 220px; }
    .hero-stats-row .hero-stats-grid { height: auto; grid-template-rows: none; }
}

.site-footer {
    background: #ffffff;
    border-top: 1px solid var(--border);
    margin-top: 40px;
}
.footer-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 24px;
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 24px;
}
.footer-inner h3 { color: #14120d; }
.footer-inner h4 { margin: 0 0 8px; color: var(--text-dim); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
.footer-inner p { margin: 4px 0; font-size: 0.92rem; }
.footer-inner a { color: var(--text-dim); }
@media (max-width: 700px) { .footer-inner { grid-template-columns: 1fr 1fr; } }

/* Icono circular para bloques de funcionalidades (estilo mockup) */
.feature-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--icon-bg);
    background-size: cover;
    background-position: center;
    font-size: 1.3rem;
    margin-bottom: 10px;
    box-shadow: inset 0 0 0 2px rgba(255,255,255,0.5);
}
.feature-icon.tx-bronce { background-image: url('../img/textures/bronce-viejo.jpg'); }
.feature-icon.tx-verdin { background-image: url('../img/textures/verdin-monumental.jpg'); }
.feature-icon.tx-patina { background-image: url('../img/textures/turquesa-patina.jpg'); }

/* Tarjetas de Spot (Cluster en vivo) */
.spots-container {
    border: 2px solid var(--orange);
    border-radius: var(--radius);
    padding: 18px;
    background: var(--panel-light);
}
.spots-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 18px;
}
.spot-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.spot-card-top {
    margin-bottom: 10px;
}
.spot-ref-code { font-size: 1.3rem; font-weight: 800; color: #14120d; }
.spot-ref-name { color: var(--text-dim); font-size: 0.85rem; }
.spot-freq { text-align: right; }
.spot-freq-num { font-size: 1.25rem; font-weight: 700; margin-top: 4px; }
.spot-card-activador {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}
.spot-avatar {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
    flex-shrink: 0;
}
.spot-callsign { font-weight: 700; font-size: 1.05rem; }
.spot-onair { background: #16a34a; color: #fff; font-weight: 700; margin-top: 2px; }
.spot-comment {
    background: var(--panel-light);
    border-radius: 8px;
    padding: 12px 14px;
    font-style: italic;
    color: #4a4736;
    font-size: 0.9rem;
    margin-bottom: 14px;
}
.spot-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border);
    padding-top: 12px;
    gap: 10px;
}
.spot-lastspot { font-size: 0.85rem; color: var(--text-dim); }
.spot-time { color: #9c9788; font-size: 0.8rem; }
.respot-btn { border-radius: 999px; padding: 8px 16px; font-size: 0.85rem; }
.spot-history {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.spot-history-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 0.82rem;
    color: #4a4736;
}

/* Menú desplegable "Bitácora" en el header */
.dropdown { position: relative; }
.dropdown-toggle {
    background: none;
    border: none;
    color: #201d16;
    font-weight: 600;
    font-size: inherit;
    cursor: pointer;
    padding: 0;
    margin-top: 0;
    font-family: inherit;
}
.dropdown-toggle:hover { text-decoration: underline; background: none; }
.dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.12);
    min-width: 180px;
    padding: 6px 0;
    z-index: 20;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a {
    display: block;
    padding: 9px 16px;
    color: var(--text);
    font-weight: 500;
    font-size: 0.9rem;
}
.dropdown-menu a:hover { background: var(--panel-light); text-decoration: none; }

.card-half { max-width: 50%; }
@media (max-width: 700px) { .card-half { max-width: 100%; } }

/* Detalle de referencia: mapa 1/3 + descripción 2/3 */
.ref-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}
.ref-map-card { padding: 0; overflow: hidden; }
#ref-detail-map { height: 320px; width: 100%; }
@media (max-width: 800px) {
    .ref-detail-grid { grid-template-columns: 1fr; }
    #ref-detail-map { height: 260px; }
}

.clickable-row:hover { background: rgba(0,0,0,0.04); }

/* Dashboard: 5 tarjetas de estadísticas en una sola fila */
.dash-stats-row { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 900px) { .dash-stats-row { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .dash-stats-row { grid-template-columns: 1fr; } }

/* Fondo con textura de granito muy sutil para el hero de la landing */
.hero-title-card {
    background:
        linear-gradient(135deg, rgba(255,255,255,0.94), rgba(244,241,230,0.94)),
        url('../img/textures/granito-grueso.jpg');
    background-size: cover;
    background-position: center;
}

/* Re-Spot expandible dentro de la tarjeta de spot */
.respot-details { position: relative; }
.respot-details summary.respot-btn {
    list-style: none;
    cursor: pointer;
    display: inline-block;
}
.respot-details summary.respot-btn::-webkit-details-marker { display: none; }
.respot-details[open] summary.respot-btn { background: var(--panel-light); }
.respot-form {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.15);
    padding: 14px;
    width: 240px;
    z-index: 30;
}
.respot-form label { font-size: 0.8rem; }
.respot-form input { font-size: 0.9rem; padding: 7px 9px; }
.respot-form button { width: 100%; }

/* Galería de certificados: 3 columnas fijas, más angostas que el grid genérico */
.certs-grid { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 800px) { .certs-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 500px) { .certs-grid { grid-template-columns: 1fr; } }

/* ============================= */
/* Responsive general / mobile   */
/* ============================= */

/* Tablas: scroll horizontal dentro de su tarjeta en vez de desbordar la página */
.card { overflow-x: auto; }
table { min-width: 480px; }
/* Tablas angostas (pocas columnas cortas, ej: ranking) no necesitan el ancho
   mínimo de arriba: así no aparece una barra de desplazamiento innecesaria
   cuando la tarjeta es más angosta que 480px (p.ej. dos tarjetas lado a lado). */
table.table-compact { min-width: 0; width: 100%; }
table.table-compact th, table.table-compact td { white-space: nowrap; padding-left: 6px; padding-right: 6px; }

.hero-h1 { font-size: clamp(1.4rem, 5vw, 2.2rem); }

/* Menú hamburguesa */
.nav-toggle {
    display: none;
    background: none;
    border: 1px solid rgba(0,0,0,0.2);
    color: #16130c;
    font-size: 1.3rem;
    line-height: 1;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    margin: 0;
}

@media (max-width: 760px) {
    .topbar { padding: 12px 16px; flex-wrap: nowrap; }
    .brand a span { font-size: 1rem; }
    .brand-logo { height: 42px !important; width: 42px !important; }

    .nav-toggle { display: block; }

    .topbar nav {
        display: none;
        width: 100%;
        flex-basis: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
        margin-top: 12px;
        font-size: 1rem;
    }
    .topbar.nav-open nav { display: flex; }
    .topbar nav a,
    .topbar nav .dropdown-toggle {
        display: block;
        width: 100%;
        padding: 10px 4px;
        border-top: 1px solid rgba(0,0,0,0.08);
    }
    .topbar nav a.btn { width: auto; display: inline-block; }
    .topbar nav .userinfo { padding: 10px 4px 0; margin-left: 0; }

    .dropdown { width: 100%; }
    .dropdown-menu {
        display: none;
        position: static;
        box-shadow: none;
        border: none;
        width: 100%;
        min-width: 0;
        padding: 0 0 0 14px;
    }
    .dropdown.open .dropdown-menu { display: block; }
    .dropdown-menu a { padding: 8px 4px; }
}

@media (max-width: 600px) {
    .container { padding: 18px 14px; }
    h1 { font-size: 1.6rem; }
    h2 { font-size: 1.25rem; }
    .card { padding: 14px; }
    .login-box { margin: 24px auto; }

    .grid { grid-template-columns: 1fr; }
    .spots-grid { grid-template-columns: 1fr; }

    .respot-form {
        position: fixed;
        left: 12px;
        right: 12px;
        top: auto;
        width: auto;
        max-width: none;
    }

    .spot-card-activador { flex-wrap: wrap; }
    .spot-freq { text-align: left; }

    .footer-inner { grid-template-columns: 1fr; text-align: left; }
}

/* Panel de administración general */
.admin-stats { grid-template-columns: repeat(4, 1fr); margin-bottom: 28px; }
@media (max-width: 600px) { .admin-stats { grid-template-columns: repeat(2, 1fr); } }
.admin-toolbar { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin: 0 0 20px; }
.admin-toolbar input[type=search] { flex: 1; min-width: 220px; max-width: 420px; margin: 0; }
.admin-card { padding: 0; }
.admin-table { min-width: 0; font-size: 0.88rem; }
.admin-table th { background: var(--panel-light); font-size: 0.72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); padding: 9px 8px; white-space: nowrap; }
.admin-table td { padding: 8px; vertical-align: middle; border-bottom: 1px solid var(--border); }
.admin-table tbody tr:hover { background: var(--panel-light); }
.admin-table td.cs { font-weight: 700; letter-spacing: .02em; white-space: nowrap; }
.admin-table td:nth-child(5) { white-space: nowrap; }
.admin-table tr.row-inactive td { opacity: .55; }
.admin-table tr.row-inactive td:last-child { opacity: 1; }
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.status-dot.on { background: var(--green); }
.status-dot.off { background: var(--red); }
.admin-actions { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; }
.admin-actions form { display: flex; gap: 4px; align-items: center; margin: 0; }
.admin-actions select { width: 112px; margin: 0; padding: 5px 4px; font-size: 0.82rem; }
.admin-actions input[type=text] { width: 48px; margin: 0; padding: 5px 4px; font-size: 0.82rem; text-align: center; }
.admin-actions button { margin: 0; padding: 6px 9px; font-size: 0.8rem; white-space: nowrap; }

/* Dashboard */
.dash-hero {
    display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
    padding: 22px 26px; margin-bottom: 20px; border-radius: var(--radius); border: 1px solid var(--border);
    background:
        linear-gradient(135deg, rgba(255,255,255,0.94), rgba(244,241,230,0.94)),
        url('../img/textures/granito-grueso.jpg');
    background-size: cover; background-position: center;
}
.dash-hello { font-size: clamp(1.4rem, 4vw, 2rem); font-weight: 800; color: #14120d; line-height: 1.2; }
.dash-sub { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-top: 8px; color: var(--text-dim); font-size: 0.92rem; }
.dash-section { margin: 26px 0 12px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-dim); }
.dash-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
@media (max-width: 900px) { .dash-stats { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .dash-stats { grid-template-columns: 1fr; } }
.dash-stat {
    position: relative; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px 16px 14px; border-top: 4px solid var(--yellow); transition: transform .15s, box-shadow .15s;
}
.dash-stat:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.08); }
.dash-stat.accent { border-top-color: #7c3aed; }
.dash-stat .ico { position: absolute; top: 12px; right: 14px; font-size: 1.3rem; opacity: .85; }
.dash-stat .num { font-size: 2.2rem; font-weight: 800; color: #14120d; line-height: 1.1; }
.dash-stat .label { margin-top: 4px; font-size: 0.78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); }
.dash-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 900px) { .dash-actions { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .dash-actions { grid-template-columns: 1fr; } }
.dash-tile {
    display: flex; flex-direction: column; gap: 4px; padding: 18px; text-decoration: none; color: var(--text);
    background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
    transition: transform .15s, box-shadow .15s, border-color .15s;
}
.dash-tile:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.1); border-color: #000; }
.dash-tile .ico { font-size: 1.8rem; margin-bottom: 6px; }
.dash-tile small { color: var(--text-dim); }
.dash-tile.primary { background: #14120d; color: #fff; border-color: #14120d; }
.dash-tile.primary small { color: #cfcabb; }

/* Documentación: pestañas y reglamento */
.doc-tabs { display: flex; gap: 8px; margin: 0 0 18px; flex-wrap: wrap; }
.doc-tabs a { padding: 9px 18px; border: 1px solid var(--border); border-radius: 999px; background: var(--panel); color: var(--text); text-decoration: none; font-weight: 600; font-size: 0.92rem; }
.doc-tabs a:hover { border-color: #000; }
.doc-tabs a.active { background: #14120d; color: #fff; border-color: #14120d; }
.doc-card h2 { margin-top: 0; }
.doc-card h3 { margin: 26px 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.doc-card h4 { margin: 16px 0 6px; color: var(--text-dim); }
.doc-card ul { padding-left: 22px; }
.doc-card li { margin: 7px 0; }
.doc-card ul ul { margin-top: 8px; }

.footer-version { text-align: center; font-size: 0.75rem; color: var(--text-dim); padding: 10px 0 4px; letter-spacing: .04em; }
