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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #000;
    color: #e0e0e0;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

.container {
    display: flex;
    height: 100vh;
    height: 100dvh;
}

.sidebar {
    width: 33.333%;
    min-width: 320px;
    background: #0a0a1a;
    color: #fff;
    padding: 20px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.logo {
    text-align: center;
    padding: 15px 0;
    border-bottom: 2px solid rgba(255,255,255,0.1);
    margin-bottom: 20px;
    flex-shrink: 0;
}

.logo img {
    max-width: 100%;
    height: auto;
    max-height: 120px;
}

.clock {
    text-align: center;
    font-size: 2.5em;
    font-weight: bold;
    padding: 15px 0;
    font-family: 'Courier New', monospace;
    flex-shrink: 0;
}

.calendar {
    flex: 0 0 auto;
    margin-top: 10px;
}

.cal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    font-size: 1.1em;
    font-weight: bold;
}

.cal-header button {
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    transition: background 0.2s;
}

.cal-header button:hover {
    background: rgba(255,255,255,0.3);
}

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    text-align: center;
}

.cal-grid .day-name {
    font-size: 0.8em;
    padding: 6px 0;
    opacity: 0.7;
    font-weight: 600;
}

.cal-grid .day {
    padding: 8px 0;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.95em;
}

.cal-grid .day:hover {
    background: rgba(255,255,255,0.2);
}

.cal-grid .day.selected {
    background: #00897b;
    font-weight: bold;
}

.cal-grid .day.other-month {
    opacity: 0.35;
}

.cal-grid .day.today {
    border: 2px solid rgba(255,255,255,0.6);
}

.resumen-dia {
    flex-shrink: 0;
    margin-top: 15px;
    padding: 12px 14px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
}

.resumen-titulo {
    color: #00bfa5;
    font-size: 0.75em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.resumen-fila {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 3px 0;
    font-size: 0.9em;
}

.resumen-tiempo {
    font-size: 1em;
}

.resumen-tiempo strong {
    color: #00bfa5;
    font-size: 1.05em;
}

.resumen-tipos {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 8px 0;
}

.resumen-espera {
    color: #bbb;
    font-size: 0.85em;
}

.main {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    gap: 15px;
    flex-wrap: wrap;
}

.main-header h2 {
    font-size: 1.4em;
    color: #00bfa5;
    flex-shrink: 0;
}

.header-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.table-wrapper {
    flex: 1;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    background: #1a1a2e;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

table {
    width: 100%;
    border-collapse: collapse;
}

#citasTable { min-width: 1130px; }
#citasTable th { white-space: nowrap; }
#tratTable { min-width: 1250px; }

thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

th {
    background: #0d0d2b;
    color: #00bfa5;
    padding: 12px 10px;
    text-align: left;
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 1px;
}

td {
    padding: 10px;
    border-bottom: 1px solid #333;
    font-size: 0.95em;
    cursor: pointer;
    transition: background 0.15s;
    color: #e0e0e0;
}

td:hover {
    background: #2a2a3e;
}

td.empty {
    color: #666;
    font-style: italic;
}

td .clave-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-weight: bold;
    font-size: 0.9em;
    letter-spacing: 1px;
}

.clave-WE { background: #00c853; color: #000; }
.clave-WR { background: #ff1744; color: #fff; }
.clave-BE { background: #2979ff; color: #fff; }
.clave-BR { background: #ffd600; color: #000; }

.tipos-cell {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
}

.tipo-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 0.72em;
    font-weight: 700;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.tipo-MANTENIMIENTO { background: #1565c0; color: #fff; }
.tipo-AVERIA { background: #c62828; color: #fff; }
.tipo-CHAPA { background: #6a1b9a; color: #fff; }
.tipo-BATERIA { background: #f9a825; color: #000; }
.tipo-NEUMATICOS { background: #546e7a; color: #fff; }
.tipo-OTROS { background: #6d4c41; color: #fff; }

.espera-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 0.72em;
    font-weight: 700;
    white-space: nowrap;
}

.espera-ESPERA { background: #00897b; color: #000; }
.espera-NO_ESPERA { background: #37474f; color: #fff; }

.sustitucion-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 0.72em;
    font-weight: 700;
    white-space: nowrap;
    background: #00897b;
    color: #fff;
}

.online-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 0.72em;
    font-weight: 700;
    white-space: nowrap;
}

.online-si { background: #00c853; color: #000; }
.online-no { background: #455a64; color: #cfd8dc; }

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-primary {
    background: #1a237e;
    color: #fff;
}

.btn-primary:hover {
    background: #283593;
}

.btn-secondary {
    background: #757575;
    color: #fff;
}

.btn-secondary:hover {
    background: #616161;
}

.btn-danger {
    background: #c62828;
    color: #fff;
}

.btn-danger:hover {
    background: #e53935;
}

.btn-email {
    display: inline-block;
    padding: 10px 16px;
    background: #00c853;
    color: #000;
    font-size: 0.9em;
    font-weight: 700;
    border: 2px solid #00e676;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.btn-email:hover {
    background: #00e676;
}

.btn-stats {
    padding: 9px 12px;
    background: #37474f;
    color: #fff;
    border: 2px solid #546e7a;
    font-size: 1em;
    line-height: 1;
}

.btn-stats:hover {
    background: #455a64;
}

.stats-claves {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
}

.stats-fechas {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
    margin-bottom: 15px;
}

.stats-fechas .form-group {
    flex: 1;
    min-width: 140px;
}

.stats-fechas .btn {
    padding: 8px 14px;
    font-size: 0.9em;
}

.stats-chip {
    padding: 8px 14px;
    border-radius: 20px;
    border: 2px solid #444;
    background: #0d0d2b;
    color: #ccc;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.9em;
    transition: all 0.2s;
}

.stats-chip:hover {
    border-color: #888;
}

.stats-chip.active {
    border-color: #00bfa5;
    color: #00bfa5;
    background: #1a1a30;
}

.stats-chip .n {
    opacity: 0.75;
    font-weight: 600;
    margin-left: 3px;
    font-size: 0.9em;
}

.stats-resultado {
    text-align: center;
}

.stats-numero {
    font-size: 3em;
    font-weight: 800;
    color: #00bfa5;
    line-height: 1.1;
}

.stats-sub {
    color: #aaa;
    margin-bottom: 6px;
}

.stats-rango {
    color: #888;
    font-size: 0.85em;
    margin-bottom: 16px;
}

.stats-tabla {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.stats-tabla thead {
    position: static;
}

.stats-tabla th,
.stats-tabla td {
    padding: 6px 10px;
    border-bottom: 1px solid #333;
    font-size: 0.9em;
    text-align: left;
    cursor: default;
}

.stats-tabla th {
    color: #00bfa5;
    text-transform: uppercase;
    font-size: 0.75em;
    letter-spacing: 1px;
}

.stats-tabla th:last-child,
.stats-tabla td:last-child {
    text-align: right;
}

.alert-success {
    background: #1b5e20;
    color: #a5d6a7;
    padding: 12px;
    border-radius: 6px;
    font-weight: 600;
}

.alert-error {
    background: #b71c1c;
    color: #ef9a9a;
    padding: 12px;
    border-radius: 6px;
    font-weight: 600;
}

.loading {
    text-align: center;
    padding: 15px;
    color: #888;
}

.email-destinatarios {
    margin-top: 12px;
}

.fecha-stepper {
    display: flex;
    gap: 6px;
    align-items: center;
}

.fecha-stepper input {
    flex: 1;
    min-width: 0;
}

.btn-flecha,
.btn-hoy {
    padding: 8px 11px;
    border: 1px solid #444;
    border-radius: 6px;
    background: #0d0d2b;
    color: #ddd;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.2s;
    flex-shrink: 0;
}

.btn-flecha:hover,
.btn-hoy:hover {
    border-color: #00bfa5;
    color: #00bfa5;
}

.btn-hoy {
    font-size: 0.8em;
    font-weight: 600;
}

.email-dest-titulo {
    color: #aaa;
    font-size: 0.85em;
    font-weight: 600;
    margin-bottom: 6px;
}

.email-dest-lista {
    list-style: none;
    max-height: 190px;
    overflow-y: auto;
    border: 1px solid #333;
    border-radius: 8px;
    background: #0d0d2b;
}

.email-dest-lista li {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 7px 10px;
    border-bottom: 1px solid #222;
    font-size: 0.85em;
}

.email-dest-lista li:last-child {
    border-bottom: none;
}

.email-dest-lista .hora {
    color: #00bfa5;
    font-weight: 700;
    flex-shrink: 0;
}

.email-dest-lista .cliente {
    color: #ddd;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.email-dest-lista .correo {
    color: #888;
    font-size: 0.9em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 45%;
}

.email-sin-dest {
    color: #888;
    font-size: 0.85em;
    font-style: italic;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: #1a1a2e;
    border-radius: 12px;
    padding: 30px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 40px rgba(0,0,0,0.6);
    border: 1px solid #333;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 18px;
    font-size: 28px;
    cursor: pointer;
    color: #999;
    transition: color 0.2s;
}

.modal-close:hover {
    color: #fff;
}

.modal-content h2 {
    margin-bottom: 20px;
    color: #00bfa5;
}

.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 12px;
}

.form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-size: 0.85em;
    font-weight: 600;
    color: #aaa;
    margin-bottom: 4px;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 8px 10px;
    border: 1px solid #444;
    border-radius: 6px;
    font-size: 0.95em;
    font-family: inherit;
    transition: border-color 0.2s;
    background: #0d0d2b;
    color: #e0e0e0;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #00bfa5;
    box-shadow: 0 0 0 2px rgba(0,191,165,0.15);
}

.opciones-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.opciones-pills label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border: 1px solid #444;
    border-radius: 20px;
    background: #0d0d2b;
    color: #ddd;
    cursor: pointer;
    font-size: 0.82em;
    font-weight: 600;
    transition: all 0.2s;
}

.opciones-pills label:hover {
    border-color: #888;
}

.opciones-pills label:has(input:checked) {
    border-color: #00bfa5;
    background: rgba(0,191,165,0.15);
    color: #00bfa5;
}

.opciones-pills input[type="checkbox"],
.opciones-pills input[type="radio"] {
    width: auto;
    padding: 0;
    margin: 0;
    border: none;
    background: none;
    box-shadow: none;
    accent-color: #00bfa5;
    flex-shrink: 0;
}

.opciones-pills input[type="checkbox"]:focus,
.opciones-pills input[type="radio"]:focus {
    outline: none;
    box-shadow: none;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.btn-trat-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 9px 14px;
    background: #2e7d32;
    color: #fff;
    font-size: 0.85em;
    font-weight: 700;
    text-decoration: none;
    border-radius: 8px;
    white-space: nowrap;
    transition: background 0.2s;
}

.btn-trat-link:hover {
    background: #388e3c;
    color: #fff;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.topbar-logo {
    height: 36px;
    width: auto;
}

.trat-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #0a0a1a;
    color: #00bfa5;
    padding: 15px 25px;
    border-bottom: 2px solid #1a1a3e;
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 10px;
}

.trat-topbar h1 {
    font-size: 1.3em;
    font-weight: 700;
}

.btn-back-trat {
    color: #aaa;
    text-decoration: none;
    font-size: 0.95em;
    padding: 7px 14px;
    border: 1px solid #444;
    border-radius: 6px;
    transition: all 0.2s;
}

.btn-back-trat:hover {
    color: #fff;
    border-color: #00bfa5;
}

.trat-body {
    flex: 1;
    padding: 20px 25px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #000;
}

.trat-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    gap: 15px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.trat-filter {
    display: flex;
    align-items: center;
    gap: 8px;
}

.trat-filter label {
    color: #aaa;
    font-size: 0.85em;
    font-weight: 600;
}

.trat-filter select {
    padding: 7px 12px;
    border: 1px solid #444;
    border-radius: 6px;
    font-size: 0.9em;
    background: #0d0d2b;
    color: #e0e0e0;
}

.btn-add-trat {
    background: #00c853;
    color: #000;
    font-weight: 700;
    border: 2px solid #00e676;
}

.btn-add-trat:hover {
    background: #00e676;
}

.trat-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 0.8em;
    font-weight: 700;
}

.badge-ok { background: #00c853; color: #000; }
.badge-reservado { background: #0277bd; color: #fff; }
.badge-warn { background: #00897b; color: #fff; }
.badge-err { background: #c62828; color: #fff; }

.acciones-cell {
    white-space: nowrap;
}

.btn-sm {
    padding: 4px 8px;
    border: 1px solid #555;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    margin: 0 2px;
    transition: all 0.2s;
    background: transparent;
}

.btn-sm:hover { transform: scale(1.15); }
.btn-sm:disabled { opacity: 0.25; cursor: not-allowed; transform: none; }

.btn-sm-edit { color: #42a5f5; border-color: #42a5f5; }
.btn-sm-edit:hover:not(:disabled) { background: rgba(66,165,245,0.15); }
.btn-sm-assign { color: #ffa726; border-color: #ffa726; }
.btn-sm-assign:hover:not(:disabled) { background: rgba(255,167,38,0.15); }
.btn-sm-return { color: #66bb6a; border-color: #66bb6a; }
.btn-sm-return:hover:not(:disabled) { background: rgba(102,187,106,0.15); }
.btn-sm-del { color: #ef5350; border-color: #ef5350; }
.btn-sm-del:hover:not(:disabled) { background: rgba(239,83,80,0.15); }
.btn-sm-print { color: #ab47bc; border-color: #ab47bc; }
.btn-sm-print:hover { background: rgba(171,71,188,0.15); }

#tratTable td {
    padding: 8px 10px;
    vertical-align: middle;
}

@media (max-width: 900px) {
    .container {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        min-width: unset;
        max-height: 42vh;
        padding: 12px;
    }
    .logo {
        padding: 8px 0;
        margin-bottom: 10px;
    }
    .logo img {
        max-height: 70px;
    }
    .clock {
        font-size: 1.8em;
        padding: 6px 0;
    }
    .main {
        padding: 12px;
    }
    .main-header h2 {
        font-size: 1.15em;
    }
    .form-row {
        flex-direction: column;
        gap: 8px;
    }
    .btn {
        padding: 8px 14px;
        font-size: 0.9em;
    }
    .btn-email {
        padding: 8px 12px;
        font-size: 0.85em;
    }
    .btn-trat-link {
        padding: 8px 12px;
        font-size: 0.8em;
    }
    .modal-content {
        width: 95%;
        padding: 18px;
        max-height: 94vh;
    }
    .trat-body {
        padding: 12px;
    }
    .trat-topbar {
        padding: 10px 12px;
    }
    .trat-topbar h1 {
        font-size: 1.05em;
    }
    .topbar-logo {
        height: 28px;
    }
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px;
    }
}

@media (max-height: 800px) and (min-width: 901px) {
    .sidebar {
        padding: 12px 16px;
    }
    .logo {
        padding: 6px 0;
        margin-bottom: 10px;
    }
    .logo img {
        max-height: 80px;
    }
    .clock {
        font-size: 2em;
        padding: 6px 0;
    }
    .calendar {
        margin-top: 4px;
    }
    .cal-header {
        padding: 6px 0;
        font-size: 1em;
    }
    .cal-header button {
        padding: 6px 10px;
    }
    .cal-grid .day-name {
        padding: 4px 0;
    }
    .cal-grid .day {
        padding: 5px 0;
        font-size: 0.9em;
    }
    .resumen-dia {
        margin-top: 10px;
        padding: 10px 12px;
    }
    .resumen-titulo {
        margin-bottom: 6px;
    }
    .resumen-fila {
        padding: 2px 0;
    }
    .resumen-tipos {
        margin: 6px 0;
    }
}
