/* ==========================================================================
   DPAH AEMET Admin Styles
   ========================================================================== */

/* Admin Wrap
   ========================================================================== */
.dpah-admin-wrap {
    max-width: 1200px;
    margin: 20px;
}

.dpah-header {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    border-left: 4px solid #0073aa;
}

.dpah-header h1 {
    margin: 0 0 5px 0;
    color: #23282d;
    font-size: 28px;
    font-weight: 600;
}

.dpah-header p {
    margin: 0;
    color: #666;
    font-size: 14px;
}

/* Stats Grid
   ========================================================================== */
.dpah-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.dpah-stat-card {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    text-align: center;
    border-left: 4px solid #0073aa;
}

.dpah-stat-number {
    display: block;
    font-size: 32px;
    font-weight: bold;
    color: #0073aa;
    line-height: 1;
    margin-bottom: 5px;
}

.dpah-stat-label {
    font-size: 14px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Config Panel
   ========================================================================== */
.dpah-config-panel {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.dpah-config-panel h3 {
    margin-top: 0;
    color: #23282d;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.dpah-config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.dpah-config-item {
    padding: 10px;
    background: #f9f9f9;
    border-radius: 4px;
    border-left: 3px solid #0073aa;
}

.dpah-config-item strong {
    color: #23282d;
}

/* Form Sections
   ========================================================================== */
.dpah-form-section {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.dpah-form-section h2 {
    margin-top: 0;
    color: #23282d;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.dpah-form-section h3 {
    color: #23282d;
    margin-bottom: 15px;
}

/* Form Elements
   ========================================================================== */
.dpah-form-group {
    margin-bottom: 15px;
}

.dpah-form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #23282d;
}

.dpah-form-input {
    width: 100%;
    max-width: 400px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.dpah-form-input:focus {
    border-color: #0073aa;
    box-shadow: 0 0 0 1px #0073aa;
    outline: none;
}

.dpah-form-input[readonly] {
    background-color: #f5f5f5;
    color: #666;
    cursor: not-allowed;
}

/* Buttons
   ========================================================================== */
.dpah-btn {
    background: #0073aa;
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
    transition: background 0.3s ease;
    margin-right: 10px;
    margin-bottom: 10px;
}

.dpah-btn:hover {
    background: #005a87;
    color: #fff;
}

.dpah-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Loading States
   ========================================================================== */
.dpah-loading {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.dpah-spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #0073aa;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: dpah-spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes dpah-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Results Display
   ========================================================================== */
.dpah-results {
    margin-top: 20px;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 4px;
    border: 1px solid #ddd;
    display: none;
}

.dpah-results.active {
    display: block;
}

.dpah-weather-card {
    background: #fff;
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 10px;
    border-left: 4px solid #0073aa;
}

.dpah-weather-card h4 {
    margin: 0 0 10px 0;
    color: #23282d;
}

.dpah-weather-data {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}

.dpah-weather-item {
    text-align: center;
    padding: 10px;
    background: #f5f5f5;
    border-radius: 4px;
}

.dpah-weather-value {
    font-size: 18px;
    font-weight: bold;
    color: #0073aa;
    display: block;
}

.dpah-weather-label {
    font-size: 12px;
    color: #666;
    text-transform: uppercase;
}

/* Status Indicators
   ========================================================================== */
.dpah-cron-status {
    margin-top: 20px;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 4px;
}

.dpah-status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

.dpah-status-item:last-child {
    border-bottom: none;
}

.dpah-status-badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.dpah-status-success {
    background: #d4edda;
    color: #155724;
}

.dpah-status-warning {
    background: #fff3cd;
    color: #856404;
}

.dpah-status-error {
    background: #f8d7da;
    color: #721c24;
}

/* Autocomplete Styles
   ========================================================================== */
.dpah-autocomplete-container {
    position: relative;
    display: inline-block;
    width: 100%;
    max-width: 400px;
}

.dpah-autocomplete-results {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ccc;
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 1000;
    max-height: 200px;
    overflow-y: auto;
}

.dpah-autocomplete-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s ease;
}

.dpah-autocomplete-item:hover {
    background-color: #f5f5f5;
}

.dpah-autocomplete-item:last-child {
    border-bottom: none;
}

.dpah-autocomplete-item strong {
    color: #0073aa;
}

/* jQuery UI Autocomplete Overrides
   ========================================================================== */
.ui-autocomplete {
    max-height: 200px;
    overflow-y: auto;
    overflow-x: hidden;
    background: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 10000;
}

.ui-autocomplete .ui-menu-item {
    padding: 0;
    border-bottom: 1px solid #f0f0f0;
}

.ui-autocomplete .ui-menu-item:last-child {
    border-bottom: none;
}

.ui-autocomplete .ui-menu-item-wrapper {
    padding: 10px 12px;
    border: none;
    background: transparent;
    color: #333;
    transition: background-color 0.2s ease;
}

.ui-autocomplete .ui-menu-item-wrapper:hover,
.ui-autocomplete .ui-menu-item-wrapper.ui-state-active {
    background-color: #f5f5f5;
    border: none;
    margin: 0;
    color: #333;
}

.ui-autocomplete .ui-menu-item strong {
    color: #0073aa;
    font-weight: 600;
}

.ui-autocomplete .ui-menu-item small {
    color: #666;
    font-size: 12px;
    margin-left: 5px;
}

/* Tables
   ========================================================================== */
.dpah-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.dpah-table th,
.dpah-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.dpah-table th {
    background: #f5f5f5;
    font-weight: 600;
    color: #23282d;
    white-space: nowrap;
}

.dpah-table tr:hover {
    background: #f9f9f9;
}

/* Zebra striping for readability */
.dpah-table tbody tr:nth-child(even) {
    background: #fcfcfc;
}

/* Right-align numeric cells */
.dpah-table td.dpah-num,
.dpah-table th.dpah-num,
.dpah-table td[data-sort-value] {
    text-align: right;
}

/* Sortable indicators */
table.dpah-sortable thead th {
    cursor: pointer;
    position: relative;
}

table.dpah-sortable thead th .dpah-sort-indicator {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
}

table.dpah-sortable thead th.is-sorted-asc .dpah-sort-indicator {
    border-bottom: 7px solid #0073aa;
}

table.dpah-sortable thead th.is-sorted-desc .dpah-sort-indicator {
    border-top: 7px solid #0073aa;
}

/* Sortable Tables */
.dpah-sortable th {
    cursor: pointer;
    position: relative;
    user-select: none;
}

.dpah-sortable th .dpah-sort-indicator {
    font-size: 11px;
    margin-left: 6px;
    color: #888;
}

.dpah-sortable th.is-sorted-asc .dpah-sort-indicator::after {
    content: "▲";
}

.dpah-sortable th.is-sorted-desc .dpah-sort-indicator::after {
    content: "▼";
}

/* Cards (WordPress native style)
   ========================================================================== */
.dpah-admin-wrap .card {
    background: #fff;
    border: 1px solid #ccd0d4;
    border-radius: 4px;
    box-shadow: 0 1px 1px rgba(0,0,0,0.04);
    margin-bottom: 20px;
}

.dpah-admin-wrap .card h2 {
    font-size: 18px;
    padding: 15px 20px;
    margin: 0;
    border-bottom: 1px solid #eee;
    background: #f5f5f5;
}

.dpah-admin-wrap .card .form-table {
    margin: 0;
}

.dpah-admin-wrap .card .form-table th {
    padding: 20px 10px 20px 0;
    width: 200px;
}

.dpah-admin-wrap .card .form-table td {
    padding: 15px 10px;
}

/* Responsive Design
   ========================================================================== */
@media (max-width: 768px) {
    .dpah-admin-wrap {
        margin: 10px;
    }
    
    .dpah-stats-grid {
        grid-template-columns: 1fr;
    }
    
    .dpah-config-grid {
        grid-template-columns: 1fr;
    }
    
    .dpah-form-input {
        max-width: 100%;
    }
    
    .dpah-weather-data {
        grid-template-columns: 1fr;
    }
    
    .dpah-table {
        font-size: 14px;
    }
    
    .dpah-table th,
    .dpah-table td {
        padding: 8px;
    }
}

/* Print Styles
   ========================================================================== */
@media print {
    .dpah-btn,
    .dpah-form-input,
    .dpah-autocomplete-container {
        display: none;
    }
    
    .dpah-admin-wrap {
        margin: 0;
        box-shadow: none;
    }
    
    .dpah-stat-card,
    .dpah-config-panel,
    .dpah-form-section {
        box-shadow: none;
        border: 1px solid #000;
    }
}

/* Utility Classes
   ========================================================================== */
.dpah-text-center {
    text-align: center;
}

.dpah-text-right {
    text-align: right;
}

.dpah-text-left {
    text-align: left;
}

.dpah-mt-0 { margin-top: 0; }
.dpah-mt-10 { margin-top: 10px; }
.dpah-mt-20 { margin-top: 20px; }
.dpah-mb-0 { margin-bottom: 0; }
.dpah-mb-10 { margin-bottom: 10px; }
.dpah-mb-20 { margin-bottom: 20px; }

.dpah-hidden {
    display: none;
}

.dpah-visible {
    display: block;
}

/* Dark Mode Support (WordPress 5.3+)
   ========================================================================== */
@media (prefers-color-scheme: dark) {
    .dpah-admin-wrap {
        color-scheme: dark;
    }
    
    .dpah-header,
    .dpah-stat-card,
    .dpah-config-panel,
    .dpah-form-section,
    .dpah-admin-wrap .card {
        background: #1d2327;
        color: #f0f0f1;
    }
    
    .dpah-header h1,
    .dpah-config-panel h3,
    .dpah-form-section h2,
    .dpah-form-section h3,
    .dpah-form-group label,
    .dpah-table th {
        color: #f0f0f1;
    }
    
    .dpah-header p,
    .dpah-stat-label,
    .dpah-config-item,
    .dpah-form-input[readonly] {
        color: #a7aaad;
    }
    
    .dpah-form-input {
        background: #2c3338;
        border-color: #3c434a;
        color: #f0f0f1;
    }
    
    .dpah-form-input:focus {
        border-color: #72aee6;
        box-shadow: 0 0 0 1px #72aee6;
    }
    
    .ui-autocomplete,
    .dpah-autocomplete-results {
        background: #2c3338;
        border-color: #3c434a;
        color: #f0f0f1;
    }
    
    .dpah-autocomplete-item,
    .ui-autocomplete .ui-menu-item-wrapper {
        color: #f0f0f1;
    }
    
    .dpah-autocomplete-item:hover,
    .ui-autocomplete .ui-menu-item-wrapper:hover,
    .ui-autocomplete .ui-menu-item-wrapper.ui-state-active {
        background-color: #383f45;
    }
    
    .dpah-estadisticas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.dpah-estadistica-item {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 4px;
    border-left: 3px solid #0073aa;
}
}

/* Origen de datos: tonos de fondo en filas de tabla */
.widefat.fixed.striped tbody tr.dpah-row-observacion { background-color: #eaf4ff; }
.widefat.fixed.striped tbody tr.dpah-row-hora { background-color: #fff8cc; }
.widefat.fixed.striped tbody tr.dpah-row-dia { background-color: #ffe9d6; }
.dpah-wind-arrow { display:inline-block; font-size:12px; margin-left:4px; vertical-align:middle; }
.dpah-legal { font-size:12px; color:#555; margin-top:4px; }
.dpah-legal a { color:#0073aa; text-decoration:none; }
.dpah-legal a:hover { text-decoration:underline; }
.dpah-legal .dpah-logos { display:flex; gap:8px; align-items:center; margin-bottom:4px; }
.dpah-legal .dpah-logos img { height:20px; }

/* Leyenda compacta de origen */
.dpah-legend { margin-top: 6px; font-size: 12px; display: flex; gap: 12px; align-items: center; }
.dpah-legend .dpah-swatch { display: inline-block; width: 12px; height: 12px; border: 1px solid #ccc; margin-right: 4px; }
.dpah-legend .dpah-swatch.observacion { background: #eaf4ff; border-color: #cfe4ff; }
.dpah-legend .dpah-swatch.hora { background: #fff8cc; border-color: #efe5a3; }
.dpah-legend .dpah-swatch.dia { background: #ffe9d6; border-color: #f6cda9; }

/* Layout Columns for Admin Panels
   ========================================================================== */
.dpah-columns {
    display: grid;
    gap: 20px;
    align-items: start;
}

.dpah-columns-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.dpah-columns-1 {
    grid-template-columns: 1fr;
}

@media (max-width: 1024px) {
    .dpah-columns-2 { grid-template-columns: 1fr; }
}

.dpah-col { min-width: 0; }

/* Generic Panel styling (used across admin pages)
   ========================================================================== */
.dpah-panel {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    border: 1px solid #e3e6ea;
    margin-bottom: 20px;
}

.dpah-panel-title {
    margin: 0 0 10px 0;
    color: #23282d;
    font-size: 18px;
    font-weight: 600;
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
}

/* Ajustes: panel de equipos por niveles y subtabla de municipios */
#dpah_station_teams_table { table-layout: fixed; }
#dpah_station_teams_table th { white-space: normal; line-height: 1.2; font-size: 13px; padding: 6px 8px; }
#dpah_station_teams_table td { padding: 6px 8px; }
#dpah_station_teams_table th:nth-child(1), #dpah_station_teams_table td:nth-child(1) { width: 44px; }
#dpah_station_teams_table th:nth-child(2), #dpah_station_teams_table td:nth-child(2) { width: 82px; }
#dpah_station_teams_table th:nth-child(3), #dpah_station_teams_table td:nth-child(3) { width: 160px; }
#dpah_station_teams_table th:nth-child(4), #dpah_station_teams_table td:nth-child(4) { width: 100px; }
#dpah_station_teams_table th:nth-child(5), #dpah_station_teams_table td:nth-child(5) { width: 74px; }
#dpah_station_teams_table th:nth-child(6), #dpah_station_teams_table td:nth-child(6) { width: 74px; }
#dpah_station_teams_table th:nth-child(7), #dpah_station_teams_table td:nth-child(7) { width: 74px; }
#dpah_station_teams_table th:nth-child(8), #dpah_station_teams_table td:nth-child(8) { width: 64px; }
#dpah_station_teams_table th:nth-child(9), #dpah_station_teams_table td:nth-child(9) { width: 84px; }
#dpah_station_teams_table th:nth-child(10), #dpah_station_teams_table td:nth-child(10) { width: 92px; }
#dpah_station_teams_table td:nth-child(3), #dpah_station_teams_table td:nth-child(4) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dpah-muni-row > td { padding: 0; }
.dpah-muni-row > td > table { width: 100%; display: block; overflow-x: auto; border-collapse: collapse; }
.dpah-muni-row > td > table th,
.dpah-muni-row > td > table td { white-space: nowrap; }

/* Vista Observaciones: full width */
.dpah-observations-full { max-width: none; padding-right: 12px; }
.dpah-observations-full .dpah-panel { max-width: none; }
.dpah-observations-full .dpah-table { width: 100%; }
.dpah-observations-full .dpah-table th,
.dpah-observations-full .dpah-table td { padding: 6px 8px; font-size: 13px; }

/* Subtabla de municipios: scroll horizontal visible */
.dpah-subtable-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 6px; }
.dpah-subtable-scroll table { min-width: 860px; table-layout: fixed; }
.dpah-subtable-scroll table th { white-space: normal; line-height: 1.2; font-size: 12px; padding: 6px 8px; hyphens: auto; word-break: break-word; }
.dpah-subtable-scroll table td { padding: 6px 8px; }
.dpah-subtable-scroll table th:nth-child(1), .dpah-subtable-scroll table td:nth-child(1) { width: 180px; }
.dpah-subtable-scroll table th:nth-child(2), .dpah-subtable-scroll table td:nth-child(2) { width: 80px; }
.dpah-subtable-scroll table th:nth-child(3), .dpah-subtable-scroll table td:nth-child(3) { width: 80px; }
.dpah-subtable-scroll table th:nth-child(4), .dpah-subtable-scroll table td:nth-child(4) { width: 68px; }
.dpah-subtable-scroll table th:nth-child(5), .dpah-subtable-scroll table td:nth-child(5) { width: 90px; }
.dpah-subtable-scroll table th:nth-child(6), .dpah-subtable-scroll table td:nth-child(6) { width: 110px; }
.dpah-subtable-scroll table th:nth-child(7), .dpah-subtable-scroll table td:nth-child(7) { width: 130px; }
.dpah-subtable-scroll table th:nth-child(8), .dpah-subtable-scroll table td:nth-child(8) { width: 120px; }
.dpah-subtable-scroll table th:nth-child(9), .dpah-subtable-scroll table td:nth-child(9) { width: 120px; }
.dpah-subtable-scroll table td:nth-child(9) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dpah-subtable-scroll table th:nth-child(10), .dpah-subtable-scroll table td:nth-child(10) { width: 100px; }
.dpah-subtable-scroll table th:nth-child(11), .dpah-subtable-scroll table td:nth-child(11) { width: 100px; }
.dpah-subtable-scroll table th,
.dpah-subtable-scroll table td { white-space: nowrap; }

/* Fondos diferenciados: tabla principal vs subtablas */
#dpah_station_teams_table { background: #ffffff; }
.dpah-assignments-table { background: #ffffff; }
.dpah-muni-row > td { background: #f4f8ff; }
.dpah-muni-row > td > .dpah-subtable-scroll table { background: transparent; }
.dpah-candidates-row > td { background: #fff7f0; }
.dpah-candidates-row > td .dpah-subtable-scroll table { background: transparent; }
.dpah-muni-suggest > td { background: #fffbea; }

/* Alerts (neutral, success, warning, error)
   ========================================================================== */
.dpah-alert {
    padding: 10px 12px;
    border-radius: 4px;
    margin: 8px 0 12px 0;
    border: 1px solid #ccd0d4;
    background: #f8f9fa;
    color: #2c3338;
}
.dpah-alert-success { background: #e6f4ea; color: #1e4620; border-color: #b7dfbd; }
.dpah-alert-warning { background: #fff8e6; color: #5b4b1b; border-color: #ffecb3; }
.dpah-alert-error { background: #fdecea; color: #5f2120; border-color: #f5c2c7; }

/* Thematic Styling: Weather-inspired admin components
   ========================================================================== */
:root {
    --dpah-color-primary: #1e88e5; /* cielo azul */
    --dpah-color-secondary: #43a047; /* verde saludable */
    --dpah-color-warning: #fb8c00; /* naranja aviso */
    --dpah-color-danger: #e53935; /* rojo peligro */
    --dpah-color-muted: #6b7280;
    --dpah-bg-gradient: linear-gradient(90deg, #e3f2fd 0%, #f1f8e9 100%);
}

.dpah-hero {
    background: var(--dpah-bg-gradient);
    border: 1px solid #e3e6ea;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}
.dpah-hero h1 {
    margin: 0 0 6px 0; font-size: 26px; color: #1f2937;
}
.dpah-hero .dpah-hero-sub {
    color: var(--dpah-color-muted);
}

.dpah-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin: 10px 0 20px 0;
}
.dpah-kpi {
    background: #fff;
    border: 1px solid #e3e6ea;
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.06);
}
.dpah-kpi .dpah-kpi-value { font-size: 28px; font-weight: 700; color: var(--dpah-color-primary); }
.dpah-kpi .dpah-kpi-label { font-size: 12px; color: var(--dpah-color-muted); text-transform: uppercase; letter-spacing: .5px; }
.dpah-kpi.ok .dpah-kpi-value { color: var(--dpah-color-secondary); }
.dpah-kpi.warn .dpah-kpi-value { color: var(--dpah-color-warning); }
.dpah-kpi.err .dpah-kpi-value { color: var(--dpah-color-danger); }

.dpah-status-bar {
    height: 8px; background: #e5e7eb; border-radius: 999px; overflow: hidden; margin-top: 10px;
}
.dpah-status-bar > span { display:block; height:100%; background: var(--dpah-color-primary); width: 60%; }

.dpah-badge { display:inline-block; padding: 4px 8px; font-size:12px; border-radius: 999px; border:1px solid #e3e6ea; color:#374151; background:#fff; }
.dpah-badge.ok { background:#e6f4ea; color:#1e4620; border-color:#b7dfbd; }
.dpah-badge.warn { background:#fff3cd; color:#856404; border-color:#ffe69c; }
.dpah-badge.err { background:#fdecea; color:#5f2120; border-color:#f5c2c7; }

.dpah-callout {
    border-left: 4px solid var(--dpah-color-primary);
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    padding: 12px 14px;
    border-radius: 6px;
    margin: 12px 0;
}
.dpah-callout.warn { border-left-color: var(--dpah-color-warning); }
.dpah-callout.err { border-left-color: var(--dpah-color-danger); }
.dpah-callout strong { display:block; margin-bottom:4px; }

.dpah-stepper { display:flex; flex-wrap:wrap; gap:12px; margin: 10px 0 20px 0; }
.dpah-step {
    flex: 1 1 260px; min-width: 240px;
    border:1px solid #e3e6ea; border-radius:8px; background:#fff; padding:12px;
}
.dpah-step h4 { margin:0 0 8px 0; font-size:16px; color:#111827; }
.dpah-step .dpah-step-desc { color:#6b7280; font-size:13px; }
.dpah-step .dpah-step-actions { margin-top:10px; }
.dpah-step .button { margin-right:8px; }
.dpah-step.danger { border-color: var(--dpah-color-danger); }
/* --- Mejora de tablas: evitar desbordes y mejorar legibilidad --- */
.dpah-table {
  table-layout: auto;
  width: max-content; /* crece si hay muchas columnas */
  min-width: 100%;    /* no se reduce por debajo del contenedor */
}
.dpah-table th,
.dpah-table td {
  white-space: normal;
  overflow: visible;
  text-overflow: initial;
}
/* Fechas: mantener en una sola línea para evitar particiones visuales */
.dpah-table td.dpah-obs-last,
.dpah-table td.dpah-hourly-last,
.dpah-table td.dpah-daily-last { white-space: nowrap; }
/* Mantener algunas celdas en una línea para legibilidad numérica */
.dpah-table .dpah-distance-cell { white-space: nowrap; }
/* El panel no fuerza scroll horizontal; lo gestiona el contenedor específico */
.dpah-panel { overflow-x: auto; }

/* --- Compactación de columnas y pilas de celdas para Asignaciones --- */
/* Cabeceras estrechas para columnas con títulos largos */
.dpah-th-narrow { width: 110px; max-width: 130px; }
.dpah-th-xs { width: 100px; max-width: 120px; }

/* Pila de fechas en una sola celda */
.dpah-date-stack { display: grid; grid-template-rows: auto auto auto; gap: 2px; font-size: 12px; line-height: 1.25; }
.dpah-date-stack > div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Botones compactos apilados (Actualizar) */
.dpah-update-stack { display: grid; grid-template-rows: auto auto auto; gap: 4px; }
.dpah-update-stack .button { padding: 2px 6px; font-size: 12px; }

/* Acciones AEMET compactas */
.dpah-aemet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.dpah-aemet-actions .button { padding: 2px 6px; font-size: 12px; }

/* Ajustes de ancho específicos de columnas */
.dpah-table th.col-prov, .dpah-table td.col-prov { width: 110px; }
.dpah-table th.col-est, .dpah-table td.col-est { width: 110px; }
.dpah-table th.col-dist, .dpah-table td.col-dist { width: 90px; }
.dpah-table th.col-alt, .dpah-table td.col-alt { width: 110px; }
.dpah-table th.col-dates, .dpah-table td.col-dates { width: 150px; }
.dpah-table th.col-aemet, .dpah-table td.col-aemet { width: 120px; }

/* Asignaciones: layout mucho más compacto de las primeras columnas */
.dpah-assignments-table { table-layout: fixed; width: 100%; border-collapse: collapse; font-size: 9px; line-height: 1.2; }
.dpah-assignments-table th,
.dpah-assignments-table td { padding: 2px 3px; }
/* Selección */
.dpah-assignments-table thead th:first-child,
.dpah-assignments-table tbody td:first-child { width: 20px; }
/* Municipio (recorta con elipsis) */
.dpah-assignments-table thead th:nth-child(2),
.dpah-assignments-table tbody td:nth-child(2) { width: 70px; }
.dpah-assignments-table tbody td:nth-child(2) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Provincias */
.dpah-assignments-table thead th:nth-child(3),
.dpah-assignments-table tbody td:nth-child(3) { width: 50px; text-align: center; }
/* Estación actual */
.dpah-assignments-table thead th:nth-child(4),
.dpah-assignments-table tbody td:nth-child(4) { width: 60px; text-align: center; }
/* Código y nombre apilados (Est. act.) */
.dpah-assignments-table .dpah-current-primary { display: grid; grid-template-rows: auto auto; align-items: center; justify-items: center; line-height: 1.1; }
.dpah-assignments-table .dpah-current-primary .dpah-station-code { font-weight: 600; white-space: nowrap; }
.dpah-assignments-table .dpah-current-primary .dpah-station-name { font-size: 9px; color: #555; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Distancia km */
.dpah-assignments-table thead th:nth-child(5),
.dpah-assignments-table tbody td:nth-child(5) { width: 60px; text-align: center; white-space: nowrap; }
/* Mejora legibilidad sin cambiar ancho */
.dpah-assignments-table thead th:nth-child(5),
.dpah-assignments-table tbody td:nth-child(5) { font-size: 11.5px; }
/* Diferencia altitud */
.dpah-assignments-table thead th:nth-child(6),
.dpah-assignments-table tbody td:nth-child(6) { width: 60px; text-align: center; white-space: nowrap; }
/* Mejora legibilidad sin cambiar ancho */
.dpah-assignments-table thead th:nth-child(6),
.dpah-assignments-table tbody td:nth-child(6) { font-size: 11.5px; }
/* Fechas (apiladas) */
.dpah-assignments-table thead th:nth-child(7),
.dpah-assignments-table tbody td:nth-child(7) { width: 100px; }
.dpah-assignments-table .dpah-date-stack { font-size: 11px; }
/* Candidatas (select) */
.dpah-assignments-table thead th:nth-child(8),
.dpah-assignments-table tbody td:nth-child(8) { width: 120px; }
.dpah-assignments-table tbody td:nth-child(8) select { width: 100%; max-width: 100%; font-size: 10px; padding: 2px 3px; }
/* Aplicar */
.dpah-assignments-table thead th:nth-child(9),
.dpah-assignments-table tbody td:nth-child(9) { width: 54px; text-align: center; }
.dpah-assignments-table tbody td:nth-child(9) .button { padding: 1px 5px; font-size: 11px; }
/* Actualizar (Obs/Hor/Diar) */
.dpah-assignments-table thead th:nth-child(10),
.dpah-assignments-table tbody td:nth-child(10) { width: 84px; }
.dpah-assignments-table .dpah-update-stack { gap: 2px; }
.dpah-assignments-table .dpah-update-stack .button { padding: 1px 5px; font-size: 11px; }
/* Acciones AEMET */
.dpah-assignments-table thead th:nth-child(11),
.dpah-assignments-table tbody td:nth-child(11) { width: 90px; }
.dpah-assignments-table .dpah-aemet-actions { gap: 2px; grid-template-columns: 1fr 1fr; }
.dpah-assignments-table .dpah-aemet-actions .button { padding: 1px 5px; font-size: 9px; }

/* Aumentar tamaño de letra desde Municipio (2) hasta Actualizar (10) */
.dpah-assignments-table thead th:nth-child(2),
.dpah-assignments-table thead th:nth-child(3),
.dpah-assignments-table thead th:nth-child(4),
.dpah-assignments-table thead th:nth-child(5),
.dpah-assignments-table thead th:nth-child(6),
.dpah-assignments-table thead th:nth-child(7),
.dpah-assignments-table thead th:nth-child(8),
.dpah-assignments-table thead th:nth-child(9),
.dpah-assignments-table thead th:nth-child(10),
.dpah-assignments-table tbody td:nth-child(2),
.dpah-assignments-table tbody td:nth-child(3),
.dpah-assignments-table tbody td:nth-child(4),
.dpah-assignments-table tbody td:nth-child(5),
.dpah-assignments-table tbody td:nth-child(6),
.dpah-assignments-table tbody td:nth-child(7),
.dpah-assignments-table tbody td:nth-child(8),
.dpah-assignments-table tbody td:nth-child(9),
.dpah-assignments-table tbody td:nth-child(10) { font-size: 10.5px; }

/* Autoajuste de fuente por longitud (aplicado vía clases JS en celdas) */
.dpah-assignments-table td.len-0-12 { font-size: 9px; }
.dpah-assignments-table td.len-13-20 { font-size: 8px; }
.dpah-assignments-table td.len-21-30 { font-size: 7.5px; }
.dpah-assignments-table td.len-31-40 { font-size: 7px; }
.dpah-assignments-table td.len-41-plus { font-size: 6.5px; }