* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Arial, sans-serif;
    background: #f0f4f8;
    color: #1a2b3c;
    padding: 2rem;
    padding-bottom: calc(3.5rem + 48px);
    min-height: 100vh;
}

.container {
    max-width: 680px;
    margin: 0 auto;
}

h1 {
    font-size: 2rem;
    color: #0288d1;
    margin-bottom: 0.25rem;
}

/* ── Cabecera y pestañas ─────────────────────── */

header {
    margin-bottom: 0.3rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0 0.55rem;
}

.rosa-rumbos {
    width: 2.6rem;
    height: 2.6rem;
    display: block;
    flex-shrink: 0;
}

.tabs {
    width: 100%;
    display: flex;
    gap: 0.25rem;
    margin-top: 0.4rem;
    border-bottom: 2px solid #c8d8e8;
    padding-bottom: 0;
}

.tab {
    display: inline-block;
    padding: 0.5rem 1.25rem;
    color: #607d8b;
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    border-radius: 4px 4px 0 0;
    border: 2px solid transparent;
    border-bottom: none;
    transition: color 0.15s;
}

.tab:hover {
    color: #1565c0;
}

.tab.activa {
    color: #0288d1;
    background: #ffffff;
    border-color: #c8d8e8;
    border-bottom: 2px solid #ffffff;
    margin-bottom: -2px;
}

.tab-api {
    margin-left: auto;
    color: #0277bd;
    border: 1px solid #b3d9f0;
    border-radius: 4px;
    background: #e1f5fe;
    padding: 0.3rem 0.9rem;
    align-self: center;
}
.tab-api:hover {
    background: #b3d9f0;
    color: #01579b;
}

.contenido-tab {
    padding-top: 0.3rem;
}

/* ── Formulario ─────────────────────────────── */

form {
    background: #ffffff;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.3rem;
    color: #0288d1;
    font-size: 0.9rem;
}

input[type="number"] {
    width: 100%;
    padding: 0.6rem 0.8rem;
    background: #f0f4f8;
    border: 1px solid #b0c8e0;
    border-radius: 4px;
    color: #1a2b3c;
    font-size: 1rem;
}

input[type="number"]:focus {
    outline: none;
    border-color: #0288d1;
}

small {
    display: block;
    color: #546e7a;
    margin-top: 0.3rem;
    font-size: 0.78rem;
}

button {
    width: 100%;
    padding: 0.75rem;
    background: #0288d1;
    color: #ffffff;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    margin-top: 0.5rem;
    transition: background 0.2s;
}

button:hover {
    background: #0297c4;
}

/* ── Alertas ─────────────────────────────────── */

.alerta {
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.alerta.error {
    background: #fff0f0;
    color: #b71c1c;
    border-left: 3px solid #ef5350;
}

/* ── Tabla de resultados ─────────────────────── */

h2 {
    color: #0288d1;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #ffffff;
    border-radius: 8px;
    overflow: hidden;
}

thead {
    background: #e4ecf5;
}

th {
    padding: 0.75rem 1rem;
    text-align: left;
    color: #607d8b;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

td {
    padding: 0.85rem 1rem;
    border-top: 1px solid #c8d8e8;
}

.tipo {
    font-weight: 700;
}

.fila-pleamar .tipo { color: #0288d1; }
.fila-bajamar .tipo { color: #e67043; }

.fila-pleamar .altura { color: #0288d1; }
.fila-bajamar .altura { color: #e67043; }

tr:hover td {
    background: #e8f0f8;
}

/* ── Pestaña API ─────────────────────────────── */

input[type="date"] {
    width: 100%;
    padding: 0.6rem 0.8rem;
    background: #f0f4f8;
    border: 1px solid #b0c8e0;
    border-radius: 4px;
    color: #1a2b3c;
    font-size: 1rem;
    color-scheme: light;
}

input[type="date"]:focus {
    outline: none;
    border-color: #0288d1;
}

.meta-api {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1.25rem;
    font-size: 0.88rem;
    color: #546e7a;
}

.meta-api span:first-child {
    color: #1565c0;
    font-weight: 600;
}

/* ── Previsión: parámetros ajustados ─────────── */

.params-box {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.param-item {
    background: #ffffff;
    border-radius: 6px;
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.param-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #546e7a;
}

.param-valor {
    font-size: 1.1rem;
    font-weight: 700;
    color: #0288d1;
}

/* ── Previsión y API: tabla compacta por días ── */

.tabla-semana {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.dia-bloque {
    background: #ffffff;
    border-radius: 6px;
    overflow: hidden;
}

.dia-titulo {
    background: #e4ecf5;
    padding: 0.4rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 700;
    color: #607d8b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.dia-fila {
    display: flex;
    flex-direction: column;
    padding: 0.45rem 0.75rem;
    border-top: 1px solid #c8d8e8;
    font-size: 0.85rem;
    gap: 0.1rem;
}

.dia-fila .tipo   { font-weight: 700; font-size: 0.78rem; }
.dia-fila.fila-pleamar .tipo   { color: #0288d1; }
.dia-fila.fila-bajamar .tipo   { color: #e67043; }
.dia-fila.fila-pleamar .altura { color: #0288d1; }
.dia-fila.fila-bajamar .altura { color: #e67043; }

@media (max-width: 500px) {
    .params-box { grid-template-columns: repeat(2, 1fr); }
}

/* ── Comparación: desfase ────────────────────── */

.desfase {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.desfase-ok    { color: #388e3c; }
.desfase-medio { color: #f57c00; }
.desfase-mal   { color: #d32f2f; }

.color-ok    { color: #388e3c !important; }
.color-medio { color: #f57c00 !important; }
.color-mal   { color: #d32f2f !important; }

.leyenda-comparacion {
    margin-top: 0.6rem;
    font-size: 0.78rem;
    color: #546e7a;
    text-align: center;
}

/* ── Pestaña A Coruña ────────────────────────── */

.corunha-header {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.corunha-titulo {
    font-size: 1.4rem;
    font-weight: 700;
    color: #0288d1;
}

.corunha-fecha {
    font-size: 0.9rem;
    color: #546e7a;
    text-transform: capitalize;
}

.corunha-seccion {
    margin-bottom: 2rem;
}

/* ── Cuadro de estado de marea ──────────────────── */

.marea-estado {
    background: #ffffff;
    border-radius: 8px;
    padding: 1rem 1.25rem 0.9rem;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.marea-indice {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.marea-subiendo { color: #0288d1; }
.marea-bajando  { color: #e67043; }

.marea-barra-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.marea-barra-label {
    font-size: 0.72rem;
    color: #546e7a;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

.marea-barra {
    position: relative;
    flex: 1;
    height: 6px;
    background: #e4ecf5;
    border-radius: 3px;
    overflow: visible;
}

.marea-barra-fill {
    position: absolute;
    inset: 0 auto 0 0;
    background: linear-gradient(90deg, #e67043, #0288d1);
    border-radius: 3px;
    transition: width 0.3s;
}

.marea-barra-mid {
    position: absolute;
    left: 50%;
    top: -3px;
    width: 1px;
    height: 12px;
    background: #c8d8e8;
    transform: translateX(-50%);
}

.marea-marker {
    position: absolute;
    top: 50%;
    width: 12px;
    height: 12px;
    background: #1a2b3c;
    border: 2px solid #f0f4f8;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
}

.marea-marker::after {
    content: '';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    border: 8px solid transparent;
    filter: drop-shadow(0 0 3px currentColor);
}

.marea-marker--subiendo::after {
    left: calc(100% + 5px);
    border-left: 12px solid #0288d1;
    border-right-width: 0;
}

.marea-marker--bajando::after {
    right: calc(100% + 5px);
    border-right: 12px solid #e67043;
    border-left-width: 0;
}

.marea-proximo {
    font-size: 0.82rem;
    color: #546e7a;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.marea-tiempo-hasta {
    color: #1565c0;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* ── Tarjetas de datos en tiempo real ──────────── */

.info-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.25rem;
    margin: 1.5rem 0 2.5rem;
}

.info-card {
    background: #ffffff;
    border-radius: 8px;
    overflow: hidden;
}

.info-card-titulo {
    background: #e4ecf5;
    padding: 0.45rem 0.9rem;
    font-size: 0.78rem;
    font-weight: 700;
    color: #607d8b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.info-card-cuerpo {
    padding: 0.75rem 0.9rem;
}

.info-cargando {
    color: #546e7a;
    font-size: 0.85rem;
    font-style: italic;
}

.info-fila {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0.3rem 0;
    border-top: 1px solid #c8d8e8;
    font-size: 0.88rem;
    gap: 0.5rem;
}

.info-fila:first-child {
    border-top: none;
}

.info-label {
    color: #546e7a;
    font-size: 0.78rem;
    flex-shrink: 0;
}

.info-valor {
    font-weight: 600;
    color: #1a2b3c;
    text-align: right;
}

@media (max-width: 500px) {
    .info-cards { grid-template-columns: 1fr; }
}

/* ── Botón de error en tarjeta ─────────────────── */

.info-error-btn {
    width: auto;
    padding: 0.25rem 0.75rem;
    background: transparent;
    color: #d32f2f;
    border: 1px solid #d32f2f;
    border-radius: 4px;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    margin: 0;
    transition: background 0.15s, color 0.15s;
}

.info-error-btn:hover {
    background: #d32f2f;
    color: #ffffff;
}

/* ── Modal de detalle de error ─────────────────── */

.error-modal {
    background: #ffffff;
    color: #1a2b3c;
    border: 1px solid #c8d8e8;
    border-radius: 8px;
    padding: 1.5rem;
    max-width: min(680px, 92vw);
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.error-modal::backdrop {
    background: rgba(0, 0, 0, 0.35);
}

.error-modal-cerrar {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: auto;
    padding: 0.2rem 0.55rem;
    background: transparent;
    color: #546e7a;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    margin: 0;
    border-radius: 4px;
    transition: color 0.15s;
}

.error-modal-cerrar:hover {
    color: #1a2b3c;
    background: transparent;
}

/* ── Pestaña Previsión 7 días ────────────────── */

.prevision-header {
    margin-bottom: 0.2rem;
}

.prevision-titulo {
    font-size: 1.2rem;
    font-weight: 700;
    color: #0288d1;
}

.prevision-graficas {
    display: flex;
    flex-direction: column;
    gap: 0px;
}

.prevision-cards {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}

.pcard {
    flex: 1;
    background: #fff;
    border-radius: 8px;
    padding: 0.5rem 0.4rem;
    text-align: center;
    min-width: 0;
}

.pcard-titulo {
    font-size: 0.65rem;
    font-weight: 700;
    color: #607d8b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.25rem;
}

.pcard-cuerpo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.pcard-dir {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 0.72rem;
    color: #455a64;
}

.pcard-arrow {
    width: 22px;
    height: 22px;
    object-fit: contain;
    transform-origin: center center;
}

.pcard-arrow--viento {
    width: 18px;
    height: 18px;
}

.pcard-valor {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1a2b3c;
}

.pcard-sub {
    font-size: 0.7rem;
    color: #607d8b;
}

.grafica-wrap {
    width: 100%;
    background: #f0f4f8;
    border-radius: 8px;
    overflow: hidden;
}

.grafica-wrap canvas {
    display: block;
}

/* ── Barra de localización (pie fijo) ────────── */

.nav-lugares {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    background: #01579b;
    z-index: 100;
    height: 48px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
}
.nav-lugares::-webkit-scrollbar { display: none; }

.nav-lugar-btn {
    flex: 1;
    min-width: 72px;
    border: none;
    border-top: 2px solid transparent;
    background: transparent;
    color: rgba(255, 255, 255, 0.65);
    font-size: 0.78rem;
    font-family: inherit;
    cursor: pointer;
    padding: 0 8px;
    white-space: nowrap;
    transition: color 0.15s;
}
.nav-lugar-btn.activa {
    color: #fff;
    font-weight: 700;
    border-top-color: #fff;
}

/* ── Vista deslizante ────────────────────────── */

.desliz-graficas {
    display: flex;
    flex-direction: column;
    gap: 0px;
}

.desliz-graficas .grafica-wrap canvas {
    cursor: grab;
    touch-action: none;
}

.desliz-graficas .grafica-wrap canvas:active {
    cursor: grabbing;
}

.desliz-controles {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 6px 0 4px;
}

.desliz-slider-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.desliz-slider {
    width: 100%;
    height: 28px;
    cursor: pointer;
    accent-color: #0288d1;
}

.desliz-rango {
    text-align: center;
    font-size: 0.7rem;
    color: #607d8b;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.desliz-btn {
    width: auto;
    min-width: 32px;
    padding: 0.3rem 0.55rem;
    background: #e4ecf5;
    color: #1565c0;
    border: 1px solid #c8d8e8;
    border-radius: 4px;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    margin: 0;
    flex-shrink: 0;
    transition: background 0.15s;
}

.desliz-btn:hover {
    background: #c8d8e8;
}

.desliz-btn-ahora {
    font-size: 0.72rem;
    padding: 0.3rem 0.45rem;
}

/* ── Responsive smartphone ───────────────────── */

@media (max-width: 600px) {
    body {
        padding: 0.75rem 0;
        padding-bottom: 48px;
    }

    .container {
        padding: 0;
    }

    header {
        padding: 0 0.5rem;
    }

    .tabs {
        overflow-x: auto;
        scrollbar-width: none;
        flex-wrap: nowrap;
    }
    .tabs::-webkit-scrollbar { display: none; }

    .tab {
        padding: 0.35rem 0.7rem;
        font-size: 0.75rem;
        white-space: nowrap;
    }

    .prevision-graficas {
        border-radius: 0;
    }
}

/* ── Pestaña Configuración ──────────────────────────────────── */

.config-panel {
    max-width: 560px;
    margin: 1.5rem auto 0;
}

.config-titulo {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1a2b3c;
    margin-bottom: 0.4rem;
}

.config-desc-global {
    font-size: 0.82rem;
    color: #607d8b;
    margin-bottom: 1.2rem;
    line-height: 1.45;
}

.config-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.config-opcion {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 0.85rem 1rem;
    border: 1.5px solid #cfd8dc;
    border-radius: 8px;
    cursor: pointer;
    background: #fff;
    transition: border-color 0.15s, background 0.15s;
}

.config-opcion:hover {
    border-color: #90caf9;
    background: #f7fbff;
}

.config-opcion--activa {
    border-color: #0288d1;
    background: #e3f2fd;
}

.config-opcion input[type="radio"] {
    display: none;
}

.config-opcion-titulo {
    font-size: 0.92rem;
    font-weight: 600;
    color: #1a2b3c;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.config-badge {
    font-size: 0.68rem;
    font-weight: 500;
    padding: 0.1rem 0.45rem;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.config-badge--default {
    background: #e0f7fa;
    color: #00838f;
}

.config-opcion-detalle {
    font-size: 0.78rem;
    color: #546e7a;
    line-height: 1.5;
}

.config-opcion-detalle code {
    font-family: 'Consolas', 'Courier New', monospace;
    background: #eceff1;
    padding: 0.05rem 0.3rem;
    border-radius: 3px;
    font-size: 0.76rem;
}

.config-guardar {
    align-self: flex-start;
    margin-top: 0.25rem;
    padding: 0.5rem 1.4rem;
    background: #0288d1;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.config-guardar:hover {
    background: #0277bd;
}

.config-estado {
    margin-top: 1.2rem;
    font-size: 0.8rem;
    color: #78909c;
}

.config-estado strong {
    color: #0288d1;
}
