body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    margin: 0;
    padding: 0;
    background: linear-gradient(135deg, #eef2f7 0%, #f9fbff 100%);
    color: #1f2733;
}

header {
    background: linear-gradient(120deg, #1f4e79, #244b8a);
    color: white;
    padding: 16px 24px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    position: relative;
    z-index: 5;
}

header h1 {
    margin: 0 0 6px 0;
    font-weight: 600;
}

@media (max-width: 768px) {
    header h1 {
        padding-top: 5px;
        font-weight: 700;
    }
}

body.admin .header-bar,
body.client .header-bar {
    align-items: flex-start;
}

body.admin .header-actions,
body.client .header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

header nav {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

body.client header nav {
    flex-direction: column;
    align-items: flex-end;
    gap: 14px;
}

nav a {
    color: #f2f6fb;
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 6px;
    transition: background 0.2s ease, color 0.2s ease;
}

nav a:hover {
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
}

.nav-user {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 5px 7px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    color: #f2f6fb;
    text-align: center;
}

.avatar-icon {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.18);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.2);
}

.avatar-icon svg {
    width: 24px;
    height: 24px;
    color: #ffffff;
}

.user-name {
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.01em;
    line-height: 1.2;
}

.link-button {
    background: none;
    border: none;
    color: #1f4e79;
    font-weight: 700;
    cursor: pointer;
    padding: 6px 0;
    text-decoration: underline;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fff9e6;
    color: #8a5a00;
    border: 1px solid #f2dfb2;
    border-radius: 10px;
    padding: 8px 10px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0,0,0,0.05);
}

.icon-button svg {
    width: 16px;
    height: 16px;
}

/* Botón hamburguesa (paneles admin y cliente móvil) */
.header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.nav-toggle {
    display: none;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #ffffff;
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.12);
}

main {
    padding: 24px;
    max-width: 1200px;
    margin: 0 auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.06);
}

.table th, .table td {
    border: 1px solid #e4e7ec;
    padding: 10px 12px;
    text-align: left;
}

.table th {
    background: #f3f6fb;
    font-weight: 600;
}

.table tr:nth-child(2n+1) { background: #fafbff; }

.table-scroll {
    width: 100%;
    overflow-x: auto;
}

.hours-tooltip {
    position: relative;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
}

.hours-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 6px);
    transform: translateX(-50%);
    background: #1f2733;
    color: #ffffff;
    font-size: 12px;
    line-height: 1.2;
    padding: 4px 8px;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 10;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

.hours-tooltip:hover::after,
.hours-tooltip:focus::after {
    opacity: 1;
}

form { margin-bottom: 20px; }

label { display: block; margin-bottom: 10px; font-weight: 600; color: #27364a; }

input[type=text], input[type=password], select, input[type=time] {
    padding: 10px 12px;
    width: 100%;
    max-width: 400px;
    box-sizing: border-box;
    border: 1px solid #cfd5de;
    border-radius: 8px;
    background: #fff;
    transition: border 0.2s ease, box-shadow 0.2s ease;
}

input[type=text]:focus, input[type=password]:focus, select:focus, input[type=time]:focus {
    outline: none;
    border-color: #2f6ac8;
    box-shadow: 0 0 0 3px rgba(47, 106, 200, 0.15);
}

input[readonly] {
    background: #f3f4f6;
    color: #5f6b7a;
    cursor: not-allowed;
}

button {
    padding: 10px 16px;
    background: linear-gradient(120deg, #2f6ac8, #1f4e79);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    letter-spacing: 0.01em;
    box-shadow: 0 4px 10px rgba(31, 78, 121, 0.25);
    transition: transform 0.1s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(31, 78, 121, 0.3);
    filter: brightness(1.02);
}

button:active {
    transform: translateY(0);
}

button.secondary {
    background: #8d95a5;
    box-shadow: none;
}

.alert {
    padding: 12px 14px;
    margin-bottom: 14px;
    border-radius: 10px;
    border: 1px solid transparent;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    opacity: 1;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.alert.success { background: #e6f6ed; color: #0f7a39; border-color: #bde5c8; }
.alert.error { background: #fdebec; color: #b4231d; border-color: #f5c2c7; }

#toast-container {
    position: fixed;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 9999;
    align-items: center;
}

#toast-container .alert {
    margin: 0;
    transform: translateY(-6px);
    opacity: 0;
}

#toast-container .alert.visible {
    transform: translateY(0);
    opacity: 1;
}

footer {
    background: #f3f6fb;
    padding: 14px 24px;
    text-align: center;
    color: #4a5568;
    border-top: 1px solid #e4e7ec;
}

.flex { display: flex; gap: 20px; flex-wrap: wrap; align-items: flex-start; }

.card {
    background: white;
    padding: 18px;
    border-radius: 14px;
    box-shadow: 0 8px 18px rgba(0,0,0,0.08);
    margin-bottom: 18px;
    border: 1px solid #e6ebf3;
}

.card h2 {
    margin-top: 0;
    color: #1f2d3d;
}

.inline-form { display: inline; }

details summary {
    cursor: pointer;
    font-weight: 600;
    color: #1f4e79;
}

details {
    margin-bottom: 10px;
}

/* Panel cliente - Horarios */
.instance-card { padding: 22px; }

.instance-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    flex-wrap: wrap;
}

.instance-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.pill {
    background: #eef2f7;
    color: #2b3a4d;
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 13px;
    border: 1px solid #d8deea;
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    line-height: 1.2;
}

.pill.next-action { background: #e8f3ff; border-color: #c7ddff; color: #1f4e79; font-weight: 600; }
.pill.timezone { background: #f7f8fb; }
.pill.info { background: #fdf5e6; color: #8a5a00; border-color: #f2dfb2; }
.pill.status-running { background: #e6f4ea; color: #0f6a2b; border-color: #b7e0c2; font-weight: 600; }
.pill.status-stopped { background: #fdecec; color: #b42318; border-color: #f1b4ae; font-weight: 600; }
.pill.status-neutral { background: #eef2f7; color: #2b3a4d; }

.muted { color: #5f6b7a; margin: 0; }

.actions-row {
    margin: 14px 0 4px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.schedule-section {
    margin-top: 10px;
    border: 1px solid #eef1f7;
    border-radius: 12px;
    padding: 6px 12px;
    background: #fbfcff;
}

.schedule-section summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    list-style: none;
}

.schedule-section summary::-webkit-details-marker { display: none; }

.schedule-section summary::after {
    content: '\25be';
    color: #1f4e79;
    font-size: 14px;
    margin-left: auto;
}

.schedule-section[open] summary::after { content: '\25b4'; }

.schedule-summary-text h3 { margin: 4px 0 6px; }

.schedule-form {
    margin-top: 12px;
}

.schedule-body {
    border-top: 1px solid #eef1f7;
    padding-top: 12px;
    margin-top: 6px;
}

.schedule-body-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
}

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

.schedule-card {
    border: 1px solid #e4e7ec;
    border-radius: 12px;
    padding: 12px 12px 10px;
    background: #fdfdff;
    box-shadow: 0 4px 10px rgba(0,0,0,0.03);
}

.schedule-day {
    font-weight: 700;
    color: #1f2d3d;
    margin-bottom: 8px;
}

.schedule-card input[type=text] {
    max-width: none;
    width: 100%;
    border-radius: 10px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 14px;
}

/* Modales */
body.modal-open {
    overflow: hidden;
}

.modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 20px 14px;
    background: rgba(17, 24, 39, 0.35);
    z-index: 20;
}

.modal.open {
    display: flex;
}

.modal-overlay {
    position: absolute;
    inset: 0;
}

.modal-dialog {
    position: relative;
    width: min(520px, 100%);
    background: #ffffff;
    border-radius: 14px;
    box-shadow: 0 18px 38px rgba(0,0,0,0.22);
    padding: 18px;
    z-index: 1;
    animation: modalIn 0.18s ease;
}

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

.modal-close {
    background: none;
    border: none;
    color: #1f2d3d;
    font-size: 20px;
    cursor: pointer;
}

.modal-body form {
    margin-bottom: 12px;
}

@keyframes modalIn {
    from { transform: translateY(-6px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@media (max-width: 640px) {
    .instance-header { flex-direction: column; }
    .instance-meta { justify-content: flex-start; }
    .form-actions { justify-content: stretch; }
    .form-actions button { width: 100%; }
}

/* Página de entrada */
.body.landing, body.landing {
    background: radial-gradient(120% 120% at 20% 20%, #f8fbff 0%, #eef2f7 45%, #e6ebf3 100%);
}

.landing-header {
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 24px 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-circle {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(140deg, #1f4e79, #2f6ac8);
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 20px;
    box-shadow: 0 8px 18px rgba(31, 78, 121, 0.18);
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 12px;
    color: #44618c;
    margin: 0 0 4px 0;
    font-weight: 700;
}

.landing-header h1 {
    margin: 0;
    color: #182437;
    font-size: 28px;
}

.header-tagline {
    margin: 0;
    color: #31425a;
    font-size: 16px;
}

.landing-main {
    padding: 16px 24px 40px;
    max-width: 1100px;
    margin: 0 auto;
}

.hero {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 28px;
    align-items: start;
}

.hero-copy h2 {
    margin: 8px 0 12px 0;
    color: #1b2a3d;
}

.muted {
    color: #526078;
    line-height: 1.6;
    margin: 0 0 12px 0;
}

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

.landing .pill, body.landing .pill {
    background: #e4edfb;
    color: #27447b;
    padding: 6px 10px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 12px;
    min-height: 0;
}

.landing .pill-neutral, body.landing .pill-neutral {
    background: #f1f5f9;
    color: #374456;
}

.hero-cta {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

.role-card {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px;
    padding: 14px;
    border: 1px solid #e3e9f1;
    border-radius: 12px;
    background: #f9fbff;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.6);
}

.role-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: #eaf1ff;
    display: grid;
    place-items: center;
    font-size: 22px;
    color: #1f4e79;
    border: 1px solid #d6e2f5;
}

.role-card h3 {
    margin: 0 0 8px 0;
    color: #1f2d3d;
}

.role-card ul {
    margin: 0 0 10px 14px;
    color: #3b4860;
    padding: 0;
}

.role-link {
    color: #1f4e79;
    font-weight: 700;
    text-decoration: none;
}

.role-link:hover {
    text-decoration: underline;
}

.helper {
    font-size: 14px;
}

.landing-footer {
    text-align: center;
    padding: 16px 24px 24px;
    color: #4a5568;
    font-size: 14px;
}

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

    .landing-header {
        padding-bottom: 0;
    }
}

/* Ajustes responsivos */
@media (max-width: 900px) {
    header {
        padding: 14px 16px;
    }

    nav a {
        padding: 6px 8px;
    }

    main {
        padding: 18px;
        max-width: 100%;
    }

    .card {
        padding: 16px;
    }

    .instance-header h2 {
        font-size: 22px;
    }
}

@media (max-width: 720px) {
    header {
        padding: 12px 14px;
    }

    header h1 {
        font-size: 20px;
        margin-bottom: 6px;
    }

    body.admin .nav-toggle,
    body.client .nav-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        z-index: 6;
    }

    body.admin nav,
    body.client nav {
        width: 100%;
        display: none;
        flex-direction: column;
        gap: 6px;
        margin-top: 10px;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: linear-gradient(120deg, #1f4e79, #244b8a);
        padding: 10px 12px 14px;
        border-radius: 0 0 14px 14px;
        box-shadow: 0 10px 18px rgba(0,0,0,0.18);
        box-sizing: border-box;
    }

    body.admin.nav-open nav,
    body.client.nav-open nav {
        display: flex;
    }

    nav a {
        padding: 10px 12px;
        display: inline-flex;
        width: 100%;
        background: rgba(255, 255, 255, 0.08);
        justify-content: center;
        box-sizing: border-box;
    }

    .nav-user {
        width: 100%;
        justify-content: center;
        box-sizing: border-box;
    }

    main {
        padding: 14px 16px 18px;
    }

    .card {
        padding: 14px;
    }

    body.admin nav,
    body.client nav {
        margin-top: 0;
    }

    .table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table th,
    .table td {
        white-space: nowrap;
        font-size: 14px;
        padding: 8px 10px;
    }

    .instance-header {
        gap: 12px;
    }

    .instance-meta {
        gap: 8px;
    }

    .pill {
        width: 100%;
        justify-content: flex-start;
    }

    .schedule-grid {
        grid-template-columns: 1fr;
    }

    .actions-row {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .actions-row form {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .actions-row button {
        width: 100%;
    }

    .schedule-body-header {
        align-items: flex-start;
    }

    .schedule-body-header .pill {
        width: auto;
    }

    .hero {
        grid-template-columns: 1fr;
    }

    .hero-cta {
        gap: 10px;
    }

    .role-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 15px;
    }

    header nav {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    body.admin nav {
        margin-top: 0;
        border-radius: 0 0 12px 12px;
    }

    nav a {
        width: 100%;
        justify-content: center;
        text-align: center;
    }

    .schedule-section summary {
        padding: 8px 0;
    }

    .schedule-summary-text h3 {
        font-size: 17px;
    }

    .schedule-summary-text .muted {
        font-size: 14px;
    }

    .landing-header,
    .landing-main {
        padding: 14px 16px;
    }
}
