:root {
    --ink: #1a1a1a;
    --muted: #5c6b69;
    --line: #d4e3df;
    --paper: #f4f8f7;
    --card: #ffffff;
    --teal: #3a9a8c;
    --teal-2: #2f7f74;
    --teal-dark: #1f5c55;
    --accent: #c45c26;
    --danger: #b42318;
    --ok: #157a4b;
    --shadow: 0 18px 40px rgba(31, 92, 85, .12);
    --radius: 16px;
    font-family: "Segoe UI", Arial, Helvetica, sans-serif;
}

* { box-sizing: border-box; }
i.dot { font-style: normal; }
html, body { margin: 0; min-height: 100%; color: var(--ink); background: var(--paper); }
button, input, select { font: inherit; }
a { color: var(--teal); }

.page-auth {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at 12% 0%, #dceeea, transparent 42%),
        linear-gradient(180deg, #ffffff, #eaf4f2);
}
.auth-card {
    width: min(420px, 100%);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 24px;
    padding: 32px 28px;
    box-shadow: var(--shadow);
    text-align: center;
}
.auth-card .form-stack,
.auth-card form { text-align: left; }
.brand-hero { margin-bottom: 8px; }
.logo-hero {
    display: block;
    width: 148px;
    height: auto;
    margin: 0 auto 8px;
    object-fit: contain;
}
.brand-kicker, .sheet-kicker {
    margin: 0;
    letter-spacing: .18em;
    text-transform: uppercase;
    font-size: 11px;
    color: var(--teal);
    font-weight: 700;
}
h1 { margin: 6px 0 10px; font-size: 28px; letter-spacing: -.03em; }
.auth-card h1 { font-size: 22px; line-height: 1.25; margin-bottom: 6px; }
.lede { color: var(--muted); margin: 0 0 18px; line-height: 1.45; }
.form-stack, .sheet-form { display: grid; gap: 12px; }
label { display: grid; gap: 6px; font-size: 13px; font-weight: 650; color: var(--muted); }
input, select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 11px 12px;
    background: #fff;
    color: var(--ink);
}
.btn, .icon-btn {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 999px;
    padding: 10px 16px;
    cursor: pointer;
}
.btn-primary { background: var(--teal); color: #fff; border-color: var(--teal); font-weight: 800; }
.btn-anotar {
    width: 100%;
    min-height: 48px;
    font-size: 16px;
    letter-spacing: .01em;
    box-shadow: 0 8px 16px rgba(58, 154, 140, .28);
}
.btn-danger { background: #fff5f4; color: var(--danger); border-color: #f0c7c2; }
.icon-btn { width: 40px; height: 40px; padding: 0; font-size: 22px; line-height: 1; }
.error-msg, .ok-msg, .flash {
    border-radius: 12px;
    padding: 10px 12px;
    margin: 0 0 12px;
}
.error-msg { background: #fff1ef; color: var(--danger); }
.ok-msg { background: #eaf7ef; color: var(--ok); }
.hint { color: var(--muted); font-size: 14px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--ink); }
.check input { width: auto; }

.page-ingreso {
    min-height: 100vh;
    min-height: 100dvh;
    background: #fff;
    display: flex;
    flex-direction: column;
}
.ingreso-top {
    background: var(--teal);
    min-height: 52px;
    display: flex;
    align-items: center;
    padding: 0 12px;
}
.menu-btn {
    border: 0;
    background: transparent;
    color: #fff;
    font-size: 26px;
    line-height: 1;
    padding: 6px 10px;
    cursor: pointer;
}
.ingreso {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: min(430px, 100%);
    margin: 0 auto;
    padding: 20px 28px 28px;
}
.ingreso-head { text-align: center; }
.logo-ingreso {
    width: 148px;
    height: auto;
    display: block;
    margin: 8px auto 16px;
    object-fit: contain;
}
.ingreso-head h1 {
    font-size: 34px;
    margin: 0 0 8px;
    font-weight: 800;
    letter-spacing: -.03em;
}
.ingreso-head p {
    margin: 0 0 28px;
    font-size: 15px;
    color: #222;
}
.ingreso-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    flex: 1;
}
.ingreso-form input {
    border: 1px solid #cfcfcf;
    border-radius: 10px;
    padding: 14px 16px;
    font-size: 16px;
    background: #fff;
}
.btn-entrar {
    margin-top: auto;
    width: 100%;
    border: 0;
    background: var(--teal);
    color: #fff;
    font-weight: 800;
    font-size: 18px;
    padding: 14px;
    border-radius: 12px;
    cursor: pointer;
}
.menu-sheet {
    width: min(360px, 92vw);
    border: 0;
    border-radius: 18px;
    padding: 0;
}
.menu-inner { display: grid; gap: 12px; padding: 20px; }
.menu-inner p { margin: 0; color: var(--muted); line-height: 1.45; }

.page-app {
    min-height: 100dvh;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    background:
        radial-gradient(circle at 80% -10%, #d7efe9 0%, transparent 42%),
        var(--paper);
}
body.sidebar-open { overflow: hidden; }

.app-main {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* --- Sidebar (celular) --- */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(22, 30, 38, .45);
    z-index: 40;
}
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(320px, 88vw);
    background: #fff;
    z-index: 50;
    display: flex;
    flex-direction: column;
    transform: translateX(-105%);
    transition: transform .25s ease;
    box-shadow: 8px 0 32px rgba(31, 92, 85, .15);
    padding-bottom: env(safe-area-inset-bottom);
}
.sidebar.is-open { transform: translateX(0); }
.sidebar-head {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--teal);
    color: #fff;
    padding: max(16px, env(safe-area-inset-top)) 16px 16px;
}
.sidebar-head strong {
    flex: 1;
    font-size: 16px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sidebar-close {
    border: 0;
    background: rgba(255,255,255,.15);
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
}
.sidebar-nav {
    flex: 1;
    overflow: auto;
    padding: 8px 0;
}
.sidebar-foot {
    display: flex;
    justify-content: space-between;
    padding: 12px 16px max(16px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
}
.sidebar-foot-link {
    color: var(--teal-dark);
    text-decoration: none;
    font-size: 14px;
    font-weight: 700;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    border: 0;
    background: transparent;
    padding: 14px 16px;
    cursor: pointer;
    text-align: left;
    color: var(--ink);
    font-size: 15px;
    font-weight: 650;
}
.nav-item:hover,
.nav-item.is-on { background: #eaf6f3; }
.nav-ico {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #e7f4f1;
    display: grid;
    place-items: center;
    font-size: 16px;
    flex: 0 0 auto;
}
.nav-item.is-on .nav-ico { background: var(--teal); color: #fff; }
.nav-ico-user { background: rgba(255,255,255,.2); }
.nav-label { flex: 1; min-width: 0; }
.nav-chev {
    color: #9aa8a5;
    font-size: 20px;
    line-height: 1;
}
.nav-badge {
    background: var(--teal);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    min-width: 20px;
    height: 20px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    padding: 0 6px;
}

/* --- Topbar --- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(14px);
    color: var(--ink);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 5;
}
.topbar-app {
    padding-top: max(10px, env(safe-area-inset-top));
}
.menu-btn {
    border: 0;
    background: transparent;
    color: var(--teal-dark);
    font-size: 26px;
    line-height: 1;
    padding: 6px 8px;
    cursor: pointer;
    flex: 0 0 auto;
}
.nav-desktop { display: none; }
.nav-desktop .nav-item {
    width: auto;
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    gap: 0;
}
.nav-desktop .nav-item.is-on {
    background: var(--teal);
    color: #fff;
}
.nav-link {
    color: var(--teal-dark);
    text-decoration: none;
    font-size: 13px;
    font-weight: 700;
    padding: 8px 10px;
    white-space: nowrap;
}
.nav-link:hover { color: var(--teal); }
.topbar-user { display: none; }
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: inherit;
    text-decoration: none;
    min-width: 0;
}
.logo-mark {
    width: 40px;
    height: 40px;
    object-fit: contain;
    flex: 0 0 auto;
    background: #fff;
}
.brand-text { display: grid; line-height: 1.15; min-width: 0; }
.brand-text strong {
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.brand-text small {
    color: var(--teal-2);
    letter-spacing: .16em;
    font-size: 11px;
    font-weight: 700;
}
.topbar-sub { opacity: .7; margin-left: 8px; font-size: 13px; }
.topbar-right, .topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.link-quiet { color: var(--teal-dark); text-decoration: none; font-size: 13px; font-weight: 600; }
.who {
    font-size: 13px;
    font-weight: 650;
    max-width: 42vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cupo {
    font-size: 12px;
    font-weight: 700;
    background: #e7f4f1;
    color: var(--teal-dark);
    padding: 4px 10px;
    border-radius: 999px;
}

.vista { flex: 1; }
.resumen-page { padding-top: 0; }

.month-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: min(1120px, 100%);
    margin: 0 auto;
    padding: 16px 14px 8px;
}
.month-title {
    display: grid;
    justify-items: center;
    gap: 6px;
    min-width: 0;
}
.month-nav h1 {
    margin: 0;
    font-size: clamp(18px, 5vw, 26px);
    text-transform: capitalize;
    letter-spacing: -.03em;
    text-align: center;
}
.month-nav .icon-btn {
    width: 44px;
    height: 44px;
    border: 0;
    background: #fff;
    box-shadow: 0 6px 16px rgba(31, 92, 85, .08);
}

.resumen {
    width: min(1120px, 100%);
    margin: 0 auto;
    padding: 0 12px 10px;
}
.resumen-card {
    background: #fff;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 10px 24px rgba(31, 92, 85, .08);
}
.resumen-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 14px 16px 10px;
}
.resumen-head strong { font-size: 16px; }
.resumen-head span { color: var(--muted); font-size: 13px; font-weight: 650; }
.resumen-vacio {
    margin: 0;
    padding: 6px 16px 16px;
    color: var(--muted);
    font-size: 14px;
}
.resumen-lista {
    list-style: none;
    margin: 0;
    padding: 0;
}
.resumen-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    background: transparent;
    border: 0;
    border-top: 1px solid #eef3f2;
    border-radius: 0;
    padding: 12px 16px;
    cursor: pointer;
    min-height: 56px;
    text-align: left;
}
.resumen-item:active,
.resumen-item:hover { background: #eaf6f3; }
.resumen-ico {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 14px;
    font-weight: 800;
    flex: 0 0 auto;
}
.resumen-txt {
    display: grid;
    gap: 2px;
    min-width: 0;
    flex: 1;
}
.resumen-txt strong {
    font-size: 15px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.resumen-txt small {
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}
.resumen-chev {
    color: #9aa8a5;
    font-size: 22px;
    line-height: 1;
    flex: 0 0 auto;
}

.cal-wrap {
    width: min(1120px, 100%);
    margin: 0 auto;
    padding: 8px 12px 24px;
}
.grid {
    display: grid;
    gap: 8px;
    background: transparent;
    border: 0;
    padding: 0;
}
.grid.periferico { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid.jachal { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.dow {
    color: var(--muted);
    text-align: center;
    font-size: 11px;
    letter-spacing: .08em;
    text-transform: uppercase;
    padding: 4px 0 2px;
    font-weight: 800;
}
.cell {
    background: var(--card);
    min-height: 118px;
    padding: 8px;
    cursor: pointer;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: 0 8px 18px rgba(31, 92, 85, .04);
    min-width: 0;
    transition: transform .15s ease, box-shadow .15s ease;
}
.cell:not(.out):active { transform: scale(.98); }
.cell.out {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    cursor: default;
}
.cell.hoy {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(58, 154, 140, .18);
}
.cell.feriado { background: #f7f1ea; }
.cell.ocupado { background: #f3fbf8; }
.num {
    align-self: flex-end;
    min-width: 26px;
    height: 26px;
    padding: 0 6px;
    border: 0;
    border-radius: 999px;
    display: grid;
    place-items: center;
    font-size: 13px;
    font-weight: 800;
    background: #eef6f4;
    color: var(--teal-dark);
}
.cell.hoy .num { background: var(--teal); color: #fff; }
.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex: 0 0 auto;
}
.lineas { display: grid; gap: 4px; font-size: 12px; line-height: 1.2; }
.linea {
    display: flex;
    gap: 6px;
    align-items: center;
    min-width: 0;
}
.linea.tachado { text-decoration: line-through; opacity: .45; }
.lugar {
    color: var(--muted);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 650;
}
.nombre {
    font-weight: 700;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-left: auto;
}
.nombre.vacio { font-weight: 500; color: #9aa8a5; }
.tachado { text-decoration: line-through; opacity: .55; }
.mandato { font-size: 11px; color: var(--accent); font-weight: 700; }
.nota-dia { font-size: 11px; color: var(--accent); font-style: italic; }
.nombre-jachal {
    flex: 1;
    display: grid;
    place-items: center;
    text-align: center;
    font-weight: 700;
    font-size: 13px;
    padding: 4px 2px 6px;
    overflow: hidden;
}
.nombre-jachal.vacio { display: none; }
.leyenda {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    justify-content: center;
    padding: 14px 4px 0;
}
.leyenda-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 650;
    color: var(--muted);
}

.flash {
    position: fixed;
    left: 50%;
    bottom: max(18px, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    background: var(--teal-dark);
    color: #fff;
    z-index: 20;
    min-width: 220px;
    max-width: calc(100vw - 24px);
    text-align: center;
}

.sheet {
    width: min(520px, 94vw);
    border: 0;
    border-radius: 20px;
    padding: 0;
    box-shadow: var(--shadow);
}
.sheet::backdrop { background: rgba(22, 30, 38, .45); }
.sheet-head, .sheet-form { padding: 18px 18px 8px; display: flex; justify-content: space-between; gap: 12px; }
.sheet-form { display: grid; }
.sheet-body { padding: 8px 18px 18px; display: grid; gap: 10px; }
.sheet h2 { margin: 0; }
.lugar-card {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 14px;
    background: #f7fbfa;
    display: grid;
    gap: 10px;
}
.lugar-card h3 { margin: 0; font-size: 16px; display: flex; justify-content: space-between; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 5px 10px; font-size: 13px; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.row-btns .btn-anotar { flex: 1 1 100%; }
.admin { width: min(980px, 100%); margin: 0 auto; padding: 18px 12px; display: grid; gap: 16px; }
.panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
}
.panel-head { display: flex; justify-content: space-between; align-items: center; }
.panel h1 { font-size: 20px; margin: 0 0 8px; }
.inline-form { display: flex; gap: 10px; align-items: end; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); font-size: 14px; }
.table-wrap { overflow: auto; }

@media (max-width: 920px) {
    .brand-text strong { display: none; }
    .cell-peri .lugar { display: none; }
    .cell-peri { min-height: 96px; }
    .lineas { font-size: 11px; }
}

@media (max-width: 720px) {
    .topbar { padding-left: 12px; padding-right: 12px; }
    .cell-peri {
        min-height: 78px;
        padding: 8px 6px 10px;
        border-radius: 14px;
    }
    .cell-peri .nombre { display: none; }
    .cell-peri .lineas {
        display: flex;
        flex-wrap: wrap;
        gap: 5px;
        margin-top: auto;
    }
    .cell-peri .linea { width: auto; }
    .cell-peri .linea:not(.ocupado) .dot { opacity: .28; }
    .grid.jachal .cell {
        min-height: 72px;
        padding: 6px 4px 8px;
        border-radius: 12px;
    }
    .nombre-jachal {
        font-size: 10px;
        padding: 2px 0 0;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
}

@media (max-width: 560px) {
    .page-app { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
    .cal-wrap { padding: 4px 10px 20px; }
    .month-nav { padding: 12px 10px 6px; }
    .month-nav h1 { font-size: 20px; }
    .grid { gap: 7px; }
    .cell-peri { min-height: 82px; }
    .grid.jachal .cell { min-height: 78px; }
    .num { min-width: 26px; height: 26px; font-size: 13px; }
    .dot { width: 9px; height: 9px; }
    .leyenda { gap: 8px; padding-top: 16px; }
    .leyenda-item { font-size: 12px; }
    .sheet {
        width: 100%;
        max-width: 100%;
        margin: auto 0 0;
        border-radius: 22px 22px 0 0;
        max-height: 90dvh;
    }
    .sheet-head { padding: 16px 16px 6px; align-items: center; }
    .resumen { padding: 0 10px 12px; }
    .sheet-body {
        overflow: auto;
        padding: 8px 16px max(22px, env(safe-area-inset-bottom));
        gap: 12px;
    }
    .btn-anotar {
        min-height: 52px;
        font-size: 17px;
        border-radius: 14px;
    }
}

@media (min-width: 1100px) {
    .cell-peri { min-height: 132px; }
}

@media (min-width: 900px) {
    .menu-btn { display: none; }
    .sidebar,
    .sidebar-backdrop { display: none !important; }
    .nav-desktop {
        display: flex;
        align-items: center;
        gap: 4px;
        flex: 1;
        justify-content: center;
        flex-wrap: wrap;
    }
    .topbar-app {
        padding: 12px 20px;
        gap: 16px;
    }
    .topbar-user {
        display: flex;
        align-items: center;
    }
    .brand-text strong { display: block; }
    .resumen {
        width: min(720px, 100%);
    }
}

@media (max-width: 899px) {
    .topbar-right.topbar-user { display: none; }
    .brand-text strong { display: none; }
}
