/* ========================================
   REMOTIZADOR DINAGAL - Estilos principales
   ======================================== */

/* Reset y base */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --color-primary: #001a5c;
    --color-primary-light: #1a3a8a;
    --color-primary-dark: #000d3d;
    --color-accent: #4a7ec7;
    --color-bg: #d0d4db;
    --color-white: #ffffff;
    --color-text: #333333;
    --color-text-light: #666666;
    --color-success: #28a745;
    --color-danger: #dc3545;
    --color-warning: #ffc107;
    --color-info: #17a2b8;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.2);
    --radius: 8px;
    --transition: all 0.3s ease;
}

html {
    font-size: 16px;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    width: 100%;
    min-height: 100vh;
}

/* ========================================
   Alertas / Flash Messages
   ======================================== */
.flash-messages {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    max-width: 400px;
    width: 90%;
}

.alert {
    padding: 14px 40px 14px 18px;
    border-radius: var(--radius);
    margin-bottom: 10px;
    font-size: 0.95rem;
    position: relative;
    animation: slideIn 0.3s ease;
    box-shadow: var(--shadow-md);
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border-left: 4px solid var(--color-success);
}

.alert-danger {
    background-color: #f8d7da;
    color: #721c24;
    border-left: 4px solid var(--color-danger);
}

.alert-warning {
    background-color: #fff3cd;
    color: #856404;
    border-left: 4px solid var(--color-warning);
}

.alert-info {
    background-color: #d1ecf1;
    color: #0c5460;
    border-left: 4px solid var(--color-info);
}

.alert-close {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    cursor: pointer;
    font-size: 1.3rem;
    font-weight: bold;
    opacity: 0.6;
    transition: var(--transition);
}

.alert-close:hover {
    opacity: 1;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ========================================
   Login Page
   ======================================== */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--color-primary-dark) 0%, var(--color-primary) 50%, var(--color-accent) 100%);
    padding: 20px;
}

.login-card {
    background: var(--color-white);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 40px 36px;
    width: 100%;
    max-width: 420px;
    text-align: center;
}

.login-logo {
    margin-bottom: 20px;
}

.login-logo img {
    max-width: 220px;
    width: 80%;
    height: auto;
}

.login-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 30px;
    line-height: 1.3;
}

/* ========================================
   Formularios
   ======================================== */
.login-form {
    text-align: left;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid #dde1e7;
    border-radius: var(--radius);
    font-size: 1rem;
    color: var(--color-text);
    transition: var(--transition);
    outline: none;
}

.form-group input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(0, 26, 92, 0.15);
}

.form-group input::placeholder {
    color: #aab0b8;
}

/* ========================================
   Botones
   ======================================== */
.btn {
    display: inline-block;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
    text-align: center;
}

.btn-primary {
    width: 100%;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
    color: var(--color-white);
    font-size: 1.05rem;
    padding: 14px;
    margin-top: 8px;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--color-primary-light) 0%, var(--color-primary) 100%);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-logout {
    background-color: transparent;
    color: var(--color-white);
    border: 2px solid rgba(255, 255, 255, 0.6);
    padding: 8px 18px;
    font-size: 0.9rem;
}

.btn-logout:hover {
    background-color: rgba(255, 255, 255, 0.15);
    border-color: var(--color-white);
}

/* ========================================
   Navbar
   ======================================== */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, var(--color-primary-dark) 0%, var(--color-primary) 100%);
    padding: 12px 24px;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.navbar-logo {
    height: 40px;
    width: auto;
    border-radius: 4px;
}

.navbar-title {
    color: var(--color-white);
    font-size: 1.15rem;
    font-weight: 600;
}

.navbar-menu {
    display: flex;
    align-items: center;
    gap: 16px;
}

.navbar-user {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.95rem;
}

.navbar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--color-white);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px 8px;
}

/* ========================================
   Landing Page
   ======================================== */
.landing-wrapper {
    min-height: 100vh;
    background-color: var(--color-bg);
}

.landing-content {
    padding: 40px 24px;
    max-width: 1200px;
    margin: 0 auto;
}

.landing-content h1 {
    font-size: 1.8rem;
    color: var(--color-primary);
    margin-bottom: 12px;
}

.landing-content p {
    font-size: 1.1rem;
    color: var(--color-text-light);
}

/* ========================================
   Simulador Card
   ======================================== */
.simulator-card {
    background: var(--color-white);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    padding: 28px;
    margin-top: 28px;
}

.section-divider {
    height: 1px;
    background: linear-gradient(to right, transparent, #ccd0d8, transparent);
    margin: 24px 0;
}

/* Gráfico de Actuador */
.chart-section h2 {
    font-size: 1.3rem;
    color: var(--color-primary);
    margin: 0 0 16px 0;
}

.chart-container {
    position: relative;
    width: 100%;
    height: 350px;
    background: #f8f9fb;
    border-radius: 10px;
    padding: 16px;
    border: 1px solid #dde1e8;
}

.simulator-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.simulator-header h2 {
    font-size: 1.3rem;
    color: var(--color-primary);
    margin: 0;
}

.simulator-badge {
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background-color: #e9ecef;
    color: var(--color-text-light);
}

.badge-active {
    background-color: #d4edda;
    color: #155724;
    animation: pulse-badge 1.5s infinite;
}

.badge-stopped {
    background-color: #f8d7da;
    color: #721c24;
}

@keyframes pulse-badge {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.simulator-controls {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
}

.sim-field {
    flex: 1;
    min-width: 140px;
}

.sim-field label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 6px;
}

.sim-field select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #dde1e7;
    border-radius: var(--radius);
    font-size: 0.95rem;
    color: var(--color-text);
    background: var(--color-white);
    cursor: pointer;
    transition: var(--transition);
    outline: none;
}

.sim-field select:focus {
    border-color: var(--color-primary);
}

.sim-field select:disabled {
    background-color: #f0f2f5;
    cursor: not-allowed;
    opacity: 0.7;
}

.sim-buttons {
    display: flex;
    gap: 10px;
    min-width: 220px;
}

.btn-start {
    flex: 1;
    background: var(--color-success);
    color: var(--color-white);
    padding: 10px 20px;
    font-size: 0.95rem;
}

.btn-start:hover:not(:disabled) {
    background-color: #218838;
    box-shadow: var(--shadow-sm);
}

.btn-start:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-stop {
    flex: 1;
    background: var(--color-danger);
    color: var(--color-white);
    padding: 10px 20px;
    font-size: 0.95rem;
}

.btn-stop:hover:not(:disabled) {
    background-color: #c82333;
    box-shadow: var(--shadow-sm);
}

.btn-stop:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Monitor de lecturas */
.simulator-monitor {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #e9ecef;
}

.monitor-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
}

.monitor-item {
    background: var(--color-bg);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
}

.monitor-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.monitor-value {
    display: block;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--color-primary);
}

.monitor-time {
    font-size: 1rem;
}

/* ========================================
   Tabla de datos
   ======================================== */
.data-table-card {
    background: var(--color-white);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    padding: 28px;
    margin-top: 0;
}

.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.table-header h2 {
    font-size: 1.3rem;
    color: var(--color-primary);
    margin: 0;
}

.table-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.table-controls select {
    padding: 8px 12px;
    border: 2px solid #dde1e7;
    border-radius: var(--radius);
    font-size: 0.9rem;
    color: var(--color-text);
    background: var(--color-white);
    cursor: pointer;
    outline: none;
    transition: var(--transition);
}

.table-controls select:focus {
    border-color: var(--color-primary);
}

.btn-refresh {
    background: var(--color-accent);
    color: var(--color-white);
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn-refresh:hover {
    background: var(--color-primary-light);
}

.btn-truncate {
    background: var(--color-danger);
    color: var(--color-white);
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn-truncate:hover {
    background-color: #c82333;
}

.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table thead {
    background: linear-gradient(135deg, var(--color-primary-dark), var(--color-primary));
}

.data-table thead th {
    color: var(--color-white);
    padding: 12px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.data-table tbody tr {
    border-bottom: 1px solid #eef0f3;
    transition: var(--transition);
}

.data-table tbody tr:hover {
    background-color: #f5f7fb;
}

.data-table tbody tr:nth-child(even) {
    background-color: #f9fafb;
}

.data-table tbody tr:nth-child(even):hover {
    background-color: #f0f3f8;
}

.data-table tbody td {
    padding: 10px 14px;
    color: var(--color-text);
    white-space: nowrap;
}

.table-empty {
    text-align: center;
    padding: 30px 14px !important;
    color: var(--color-text-light);
    font-style: italic;
}

/* ========================================
   Responsive - Tablet (max 768px)
   ======================================== */
@media (max-width: 768px) {
    .login-card {
        padding: 32px 24px;
    }

    .login-title {
        font-size: 1.2rem;
    }

    .login-logo img {
        max-width: 180px;
    }

    .navbar {
        padding: 10px 16px;
        flex-wrap: wrap;
    }

    .navbar-toggle {
        display: block;
    }

    .navbar-menu {
        display: none;
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        padding-top: 12px;
        border-top: 1px solid rgba(255, 255, 255, 0.2);
        margin-top: 10px;
    }

    .navbar-menu.active {
        display: flex;
    }

    .btn-logout {
        width: 100%;
        text-align: center;
    }

    .landing-content {
        padding: 24px 16px;
    }

    .landing-content h1 {
        font-size: 1.4rem;
    }

    .simulator-card {
        padding: 20px;
    }

    .simulator-controls {
        flex-direction: column;
    }

    .sim-field {
        width: 100%;
    }

    .sim-buttons {
        width: 100%;
    }

    .data-table-card {
        padding: 20px;
    }

    .table-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .table-controls {
        width: 100%;
    }

    .table-controls select {
        flex: 1;
    }

    .data-table {
        font-size: 0.85rem;
    }

    .data-table thead th,
    .data-table tbody td {
        padding: 8px 10px;
    }
}

/* ========================================
   Responsive - Móvil (max 480px)
   ======================================== */
@media (max-width: 480px) {
    .login-card {
        padding: 28px 20px;
        border-radius: 8px;
    }

    .login-title {
        font-size: 1.1rem;
    }

    .login-logo img {
        max-width: 160px;
    }

    .form-group input {
        padding: 10px 12px;
        font-size: 0.95rem;
    }

    .btn-primary {
        padding: 12px;
        font-size: 1rem;
    }

    .navbar-title {
        font-size: 1rem;
    }

    .navbar-logo {
        height: 32px;
    }

    .landing-content h1 {
        font-size: 1.2rem;
    }

    .simulator-card {
        padding: 16px;
        margin-top: 20px;
    }

    .simulator-header h2 {
        font-size: 1.1rem;
    }

    .monitor-value {
        font-size: 1.3rem;
    }

    .data-table-card {
        padding: 14px;
        margin-top: 16px;
    }

    .table-header h2 {
        font-size: 1.1rem;
    }

    .table-controls {
        flex-direction: column;
    }

    .table-controls select,
    .btn-refresh {
        width: 100%;
    }

    .data-table {
        font-size: 0.8rem;
    }

    .flash-messages {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
        width: auto;
    }
}

/* ── Mode Toggle & Slider ────────────────────────────── */
.mode-toggle {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-bottom: 12px;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    color: var(--color-text);
    cursor: pointer;
    user-select: none;
}

.toggle-label input[type="radio"] {
    accent-color: var(--color-primary);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.toggle-label input[type="radio"]:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.slider-section {
    background: var(--color-bg);
    border: 2px solid #dde1e7;
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    transition: var(--transition);
}

.slider-section.hidden {
    display: none;
}

.slider-section label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-light);
    margin-bottom: 8px;
}

.slider-section input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(to right, var(--color-primary), var(--color-accent));
    outline: none;
    cursor: pointer;
    margin-bottom: 6px;
}

.slider-section input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--color-white);
    border: 3px solid var(--color-primary);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    transition: var(--transition);
}

.slider-section input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    border-color: var(--color-accent);
}

.slider-section input[type="range"]::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--color-white);
    border: 3px solid var(--color-primary);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.slider-range {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    color: var(--color-text-light);
}

.slider-value {
    text-align: center;
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-top: 4px;
}

/* ── Diagrama del Estanque ────────────────────────────── */
.diagram-card {
    background: var(--color-white);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

/* ── Reloj en vivo ────────────────────────────────────── */
.clock-card {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: linear-gradient(135deg, #0a1628, #1a2845);
    padding: 10px 28px;
    margin: 0;
    box-shadow: var(--shadow);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.clock-icon {
    font-size: 1.6rem;
}

.clock-datetime {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.clock-date {
    font-size: 0.85rem;
    color: #99bbdd;
    letter-spacing: 0.5px;
}

.clock-time {
    font-family: 'Courier New', Courier, monospace;
    font-size: 1.8rem;
    font-weight: 700;
    color: #00ff88;
    letter-spacing: 2px;
    text-shadow: 0 0 10px rgba(0, 255, 136, 0.4);
}

/* ── Botón scroll-to-top en cada sección ──────────────── */
.simulator-card,
.diagram-card {
    position: relative;
}

.btn-scroll-top {
    position: absolute;
    right: -50px;
    top: 50%;
    transform: translateY(-50%);
    width: 42px;
    height: 42px;
    border: 2px solid #cc0000;
    border-radius: 6px;
    background: #fff;
    color: #cc0000;
    font-size: 1.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: background 0.2s, color 0.2s, transform 0.2s;
    z-index: 10;
}
.btn-scroll-top:hover {
    background: #cc0000;
    color: #fff;
    transform: translateY(-50%) scale(1.1);
}
.btn-scroll-top:active {
    transform: translateY(-50%) scale(0.95);
}

@media (max-width: 900px) {
    .btn-scroll-top {
        right: 10px;
        top: auto;
        bottom: 10px;
        transform: none;
        position: absolute;
    }
    .btn-scroll-top:hover {
        transform: scale(1.1);
    }
}

/* ── Simuladores compactos (junto al gráfico) ────────── */
.compact-simulators {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 8px;
}

.compact-sim-card {
    background: #f0f2f5;
    border-radius: 10px;
    padding: 14px 16px;
    border-left: 4px solid #0078d4;
}
.compact-sim-card.compact-nivel {
    border-left-color: #28a745;
}

.compact-sim-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 0.9rem;
    color: var(--color-primary-dark);
}

.compact-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: #e0e0e0;
    color: #666;
}
.compact-badge.badge-active {
    background: #28a745;
    color: #fff;
}

.compact-sim-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
}

.compact-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.compact-field label {
    font-size: 0.72rem;
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
}
.compact-field select {
    padding: 4px 6px;
    font-size: 0.8rem;
    border-radius: 5px;
    border: 1px solid #ccc;
    min-width: 90px;
}

.compact-buttons {
    display: flex;
    gap: 6px;
    align-items: flex-end;
}
.btn-sm {
    padding: 5px 12px !important;
    font-size: 0.78rem !important;
    border-radius: 6px !important;
}

.compact-slider {
    margin-top: 8px;
    padding: 8px 10px;
    background: #e4e7ec;
    border-radius: 8px;
}
.compact-slider label {
    font-size: 0.8rem;
    color: #333;
}
.compact-slider input[type="range"] {
    width: 100%;
    margin: 4px 0;
}
.compact-slider .slider-range {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: #888;
}

@media (max-width: 768px) {
    .compact-simulators {
        grid-template-columns: 1fr;
    }
}

/* ── Programador de Actuador ──────────────────────────── */
.actuador-card {
    border-left: 4px solid #ffaa00;
}

.badge-actuador {
    background: #ffaa00 !important;
    color: #1a1a2e !important;
    font-weight: 700;
}

.actuador-programmer {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    align-items: end;
    margin-bottom: 16px;
}

.act-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

/* Presets de apertura */
.act-presets {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.act-presets-label {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--color-text-light);
    margin-right: 4px;
}

.btn-preset {
    padding: 6px 14px;
    font-size: 0.8rem;
    font-weight: 700;
    border: 2px solid #1a2a4a;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #fff;
}

.btn-preset:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0,0,0,0.25);
}

.preset-0 {
    background: #dc3545;
    border-color: #dc3545;
}
.preset-0:hover { background: #c82333; }

.preset-25 {
    background: #e67e22;
    border-color: #e67e22;
}
.preset-25:hover { background: #d35400; }

.preset-50 {
    background: #f0ad4e;
    border-color: #f0ad4e;
    color: #1a2a4a;
}
.preset-50:hover { background: #ec971f; }

.preset-75 {
    background: #5bc0de;
    border-color: #5bc0de;
    color: #1a2a4a;
}
.preset-75:hover { background: #31b0d5; }

.preset-100 {
    background: #28a745;
    border-color: #28a745;
}
.preset-100:hover { background: #218838; }

/* ========================================
   Programador de Reglas Condicionales
   ======================================== */
.reglas-card {
    border-left: 4px solid #17a2b8;
}

.badge-reglas {
    background: #17a2b8;
    color: #fff;
    padding: 4px 12px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.8rem;
}

.reglas-info {
    margin-bottom: 20px;
}

.reglas-ref-table {
    width: 100%;
    max-width: 500px;
    border-collapse: collapse;
    font-size: 0.8rem;
    margin: 0 auto;
}

.reglas-ref-table th {
    background: #1a2a4a;
    color: #fff;
    padding: 6px 10px;
    text-align: center;
    font-size: 0.75rem;
}

.reglas-ref-table td {
    padding: 4px 10px;
    text-align: center;
    border-bottom: 1px solid #dde1e8;
    font-size: 0.8rem;
}

.reglas-ref-table tr:nth-child(even) {
    background: #f8f9fb;
}

.regla-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: #f0f4f8;
    border-radius: 8px;
    border: 1px solid #dde1e8;
}

.regla-label {
    font-weight: 800;
    font-size: 0.8rem;
    color: #17a2b8;
    min-width: 65px;
}

.regla-row label {
    font-weight: 600;
    font-size: 0.8rem;
    color: #555;
}

.regla-row select,
.regla-row input[type="date"],
.regla-row input[type="time"] {
    padding: 5px 8px;
    border: 1px solid #bbb;
    border-radius: 5px;
    font-size: 0.8rem;
    background: #fff;
}

.regla-row select:focus,
.regla-row input:focus {
    border-color: #17a2b8;
    outline: none;
    box-shadow: 0 0 4px rgba(23, 162, 184, 0.3);
}

.btn-regla-add {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #17a2b8;
    color: #fff;
    border: none;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.btn-regla-add:hover { background: #138496; transform: scale(1.1); }

.btn-regla-remove {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #dc3545;
    color: #fff;
    border: none;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.btn-regla-remove:hover { background: #c82333; transform: scale(1.1); }

.reglas-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin: 16px 0;
}

.btn-regla-now {
    padding: 8px 16px;
    background: #17a2b8;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}
.btn-regla-now:hover { background: #138496; }

.btn-enviar-programa {
    padding: 10px 24px;
    background: linear-gradient(135deg, #28a745, #218838);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
}
.btn-enviar-programa:hover {
    background: linear-gradient(135deg, #218838, #1e7e34);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
}

.regla-estado {
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 700;
}
.regla-estado.activa { background: #d4edda; color: #155724; }
.regla-estado.ejecutada { background: #cce5ff; color: #004085; }
.regla-estado.inactiva { background: #f8d7da; color: #721c24; }

.btn-regla-reset,
.btn-regla-del {
    padding: 3px 8px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s;
}
.btn-regla-reset { background: #ffc107; color: #1a2a4a; }
.btn-regla-reset:hover { background: #e0a800; }
.btn-regla-del { background: #dc3545; color: #fff; }
.btn-regla-del:hover { background: #c82333; }

.act-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.act-field label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-light);
}

.act-field input[type="number"],
.act-field input[type="date"],
.act-field input[type="time"] {
    padding: 10px 12px;
    border: 2px solid #dde1e7;
    border-radius: var(--radius);
    font-size: 1rem;
    color: var(--color-text);
    background: var(--color-white);
    outline: none;
    transition: var(--transition);
}

.act-field input:focus {
    border-color: #ffaa00;
    box-shadow: 0 0 0 3px rgba(255, 170, 0, 0.15);
}

.act-setpoint-display {
    background: linear-gradient(135deg, #0a1628, #1a2845);
    color: #ffaa00;
    font-family: 'Courier New', Courier, monospace;
    font-size: 1.4rem;
    font-weight: 700;
    text-align: center;
    padding: 8px 14px;
    border-radius: var(--radius);
    border: 2px solid #ffaa00;
    text-shadow: 0 0 8px rgba(255, 170, 0, 0.4);
}

.btn-schedule {
    background: linear-gradient(135deg, #ffaa00, #ff8800);
    color: #1a1a2e;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}

.btn-schedule:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 170, 0, 0.4);
}

.btn-apply-now {
    background: linear-gradient(135deg, #00cc66, #00aa55);
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}

.btn-apply-now:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 204, 102, 0.4);
}

.act-buttons-row {
    flex-direction: row !important;
    gap: 10px !important;
    align-items: stretch;
}

.btn-now {
    background: var(--color-accent);
    color: var(--color-white);
    border: none;
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-now:hover {
    opacity: 0.9;
}

.act-message {
    padding: 10px 16px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    margin-top: 12px;
    transition: var(--transition);
}

.act-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.act-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

@media (max-width: 600px) {
    .actuador-programmer {
        grid-template-columns: 1fr 1fr;
    }

    .act-actions {
        flex-direction: column;
    }

    .clock-time {
        font-size: 1.4rem;
    }

    .clock-card {
        padding: 10px 16px;
    }
}

.diagram-card h2 {
    font-size: 1.3rem;
    color: var(--color-text);
    margin-bottom: 16px;
    text-align: center;
}

.diagram-container {
    position: relative;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    user-select: none;
}

.diagram-img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: var(--radius);
}

/* Displays superpuestos */
.diagram-display {
    position: absolute;
    background: rgba(0, 20, 60, 0.88);
    color: #00ff88;
    border: 2px solid #00ff88;
    border-radius: 6px;
    padding: 6px 10px;
    font-family: 'Courier New', Courier, monospace;
    text-align: center;
    min-width: 90px;
    z-index: 10;
    box-shadow: 0 0 10px rgba(0, 255, 136, 0.3);
    transition: all 0.3s ease;
}

.diagram-display:hover {
    box-shadow: 0 0 18px rgba(0, 255, 136, 0.5);
    transform: scale(1.05);
}

.display-tag {
    display: block;
    font-size: 0.65rem;
    font-weight: 700;
    color: #66ccff;
    letter-spacing: 1px;
    margin-bottom: 2px;
}

.display-value {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    color: #00ff88;
    line-height: 1.2;
}

.display-rp {
    display: block;
    font-size: 0.65rem;
    color: #99ddbb;
    margin-top: 1px;
}

/* Posiciones de los displays sobre la imagen */
/* F1 - Flujómetro entrada (izquierda abajo) */
.display-f1 {
    bottom: 42%;
    left: 1%;
}

/* F2 - Flujómetro salida (derecha abajo) */
.display-f2 {
    bottom: 38%;
    right: 1%;
}

/* N1 - Nivel ultrasónico (centro arriba) */
.display-n1 {
    top: 18%;
    left: 35%;
}

/* A1 - Actuador (derecha arriba) */
.display-a1 {
    top: 2%;
    right: 1%;
    border-color: #ffaa00;
    box-shadow: 0 0 10px rgba(255, 170, 0, 0.3);
}

.display-a1:hover {
    box-shadow: 0 0 18px rgba(255, 170, 0, 0.5);
}

.display-a1 .display-tag {
    color: #ffcc44;
}

.display-a1 .display-value {
    color: #ffaa00;
}

.display-a1 .display-rp {
    color: #ddbb77;
}

/* Responsive diagram */
@media (max-width: 600px) {
    .diagram-display {
        min-width: 70px;
        padding: 4px 6px;
        font-size: 0.8rem;
    }

    .display-value {
        font-size: 0.85rem;
    }

    .display-tag,
    .display-rp {
        font-size: 0.55rem;
    }

    .diagram-card {
        padding: 12px;
    }
}
