:root {
    --bg: #f4f0e6;
    --paper: #fff9e6;
    --ink: #1a1a1a;
    --muted: #5c5c5c;
    --accent: #c45c26;
    --accent-dark: #8f3f18;
    --border: #d4c9a8;
    --cell: #fffdf5;
    --success: #2d6a4f;
    --danger: #9b2226;
    --radius: 10px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    --sidebar-width: 240px;
    --sidebar-bg: #1a1a1a;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "DM Sans", system-ui, sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.5;
    min-height: 100vh;
}

.wrap {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.25rem;
}

/* Layout: sidebar izquierda + contenido */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--sidebar-bg);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 200;
}

.sidebar-brand {
    padding: 1.25rem 1rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand {
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.82rem;
    line-height: 1.35;
    display: block;
    word-break: break-word;
}

.brand-sub {
    display: block;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.55);
    margin-top: 0.2rem;
}

.sidebar-nav {
    flex: 1;
    padding: 0.75rem 0.65rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    overflow-y: auto;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.65rem 0.85rem;
    color: rgba(255, 255, 255, 0.82);
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.sidebar-link.active {
    background: var(--accent);
    color: #fff;
}

.sidebar-icon {
    width: 1.25rem;
    text-align: center;
    font-size: 0.85rem;
    opacity: 0.9;
}

.sidebar-user {
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-user-info {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 0.75rem;
}

.sidebar-user .user-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
    line-height: 1.3;
}

.sidebar-logout {
    display: block;
    text-align: center;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.88rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, 0.25);
    transition: background 0.15s;
}

.sidebar-logout:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    padding: 1.5rem 1.75rem 2rem;
    max-width: 1200px;
    width: 100%;
}

.sidebar-toggle {
    display: none;
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 300;
    width: 2.5rem;
    height: 2.5rem;
    border: none;
    border-radius: 8px;
    background: var(--sidebar-bg);
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: var(--shadow);
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 150;
}

.sidebar-backdrop.open {
    display: block;
}

.hero {
    background: var(--paper);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.hero h1 {
    margin: 0 0 0.5rem;
    font-size: 1.75rem;
}

.hero p {
    margin: 0;
    color: var(--muted);
}

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

.card-link {
    display: block;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s, box-shadow 0.15s;
}

.card-link:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--accent);
}

.card-link h2 {
    margin: 0 0 0.35rem;
    font-size: 1.15rem;
    color: var(--accent-dark);
}

.page-title {
    margin: 0 0 1.5rem;
    font-size: 1.5rem;
}

.panel {
    background: var(--paper);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 1rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    background: var(--accent);
    color: #fff;
}

.btn:hover {
    background: var(--accent-dark);
}

.btn-secondary {
    background: #fff;
    color: var(--ink);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--cell);
}

.btn-danger {
    background: var(--danger);
}

input,
select {
    font: inherit;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

th,
td {
    border: 1px solid var(--border);
    padding: 0.65rem 0.75rem;
    text-align: left;
}

th {
    background: #efe6cc;
    font-weight: 600;
}

.horario-table th.dia-col {
    text-align: center;
    min-width: 110px;
    font-size: 0.85rem;
}

.horario-table td {
    background: var(--cell);
    text-align: center;
    vertical-align: middle;
}

.horario-table td.turno-label {
    text-align: left;
    font-weight: 600;
    background: #efe6cc;
    white-space: nowrap;
}

.cell-btn {
    width: 100%;
    min-height: 2.5rem;
    border: 1px dashed var(--border);
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    font: inherit;
    color: var(--ink);
    padding: 0.35rem;
}

.cell-btn:hover {
    border-color: var(--accent);
    background: #fff;
}

.cell-btn.asignado {
    border-style: solid;
    background: #fff;
    font-weight: 600;
}

.cell-btn.libre {
    color: var(--muted);
    font-style: italic;
}

.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge-ok {
    background: #d8f3dc;
    color: var(--success);
}

.badge-off {
    background: #eee;
    color: var(--muted);
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
}

.modal-backdrop.open {
    display: flex;
}

.modal {
    background: #fff;
    border-radius: var(--radius);
    padding: 1.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow);
}

.modal h3 {
    margin: 0 0 1rem;
}

.form-row {
    margin-bottom: 0.85rem;
}

.form-row label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1rem;
}

.flash {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    display: none;
}

.flash.show {
    display: block;
}

.flash.ok {
    background: #d8f3dc;
    color: var(--success);
}

.flash.err {
    background: #fde8e8;
    color: var(--danger);
}

.badge-rol {
    display: inline-block;
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.85);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.btn-sm {
    padding: 0.35rem 0.65rem;
    font-size: 0.85rem;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}

.login-card {
    background: var(--paper);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow);
}

.login-card h1 {
    margin: 0;
    font-size: 1.35rem;
}

.login-sub {
    color: var(--muted);
    margin: 0.25rem 0 1.5rem;
}

.login-form .form-row {
    margin-bottom: 1rem;
}

.panel-compact {
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
}

.dash-reloj {
    margin: 0;
    font-weight: 600;
}

.dash-periodo {
    margin: 0.25rem 0 0;
    color: var(--muted);
}

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

.dash-panel h2 {
    margin: 0 0 0.75rem;
    font-size: 1.05rem;
}

.dash-panel.dash-en-turno {
    border-color: var(--success);
    background: #f0faf4;
}

.dash-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.dash-list li {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.dash-list li:last-child {
    border-bottom: none;
}

.dash-list li span {
    color: var(--muted);
    font-size: 0.9rem;
}

.dash-hint {
    margin: -0.5rem 0 0.75rem;
    font-size: 0.85rem;
    color: var(--muted);
}

.historial-filtros {
    align-items: flex-end;
}

.form-row.inline {
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
}

.empleado-resumen {
    background: #fff;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-top: 1rem;
    border: 1px solid var(--border);
}

.hist-grid {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 1rem;
}

@media (max-width: 900px) {
    .hist-grid {
        grid-template-columns: 1fr;
    }
}

.site-footer {
    padding: 1rem 1.75rem 1.25rem;
    color: var(--muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.35);
}

@media (max-width: 768px) {
    .sidebar-toggle {
        display: block;
    }

    .sidebar {
        position: fixed;
        left: 0;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .app-main {
        width: 100%;
    }

    .main-content {
        padding: 3.25rem 1rem 1.5rem;
    }

    body.sidebar-open {
        overflow: hidden;
    }
}

.empty {
    color: var(--muted);
    font-style: italic;
}

@media (max-width: 720px) {
    .horario-scroll {
        overflow-x: auto;
    }

    .horario-table {
        min-width: 640px;
    }
}
