:root {
    --wine: #78001c;
    --wine-dark: #520014;
    --wine-soft: #f6e9ed;
    --bg: #fafafa;
    --panel: #ffffff;
    --text: #252525;
    --muted: #6f6f6f;
    --line: #e5e5e5;
    --danger: #d92d20;
    --warning: #f79009;
    --blue: #2563eb;
    --green: #039855;
}

* {
    box-sizing: border-box;
}

html {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
}

a {
    color: inherit;
}

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 224px;
    background: #fff;
    border-right: 1px solid var(--line);
    z-index: 20;
    overflow-y: auto;
}

.sidebar-brand {
    height: 46px;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 16px;
    background: linear-gradient(90deg, var(--wine-dark), var(--wine));
    color: #fff;
    text-decoration: none;
    font-size: 18px;
    font-weight: 800;
}

.school-mark {
    width: 38px;
    height: 38px;
    border: 1px solid rgba(255,255,255,.7);
    border-radius: 4px;
    background: rgba(255,255,255,.08);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex: 0 0 auto;
}

.school-mark img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.side-nav {
    display: grid;
    gap: 6px;
    padding: 22px 8px;
}

.side-nav a {
    display: flex;
    align-items: center;
    gap: 13px;
    min-height: 40px;
    border-radius: 6px;
    padding: 0 16px;
    color: #2d2d2d;
    text-decoration: none;
    font-weight: 700;
}

.side-nav a span {
    color: var(--wine);
    width: 18px;
    text-align: center;
    font-size: 18px;
}

.side-nav a.active,
.side-nav a:hover {
    background: var(--wine-soft);
    color: var(--wine-dark);
}

.staff-card {
    margin: 8px 10px 18px;
    padding: 14px 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
}

.staff-card h3 {
    margin: 0 0 13px;
    color: var(--wine);
    font-size: 14px;
}

.staff-mini {
    display: flex;
    gap: 9px;
    align-items: center;
    margin-bottom: 11px;
}

.avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--wine);
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    flex: 0 0 auto;
}

.avatar.light {
    background: #fff;
    color: var(--wine);
}

.staff-mini strong,
.top-user strong {
    display: block;
    font-size: 12px;
}

.staff-mini small,
.top-user small {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--muted);
    font-size: 11px;
}

.staff-mini i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
    background: #9ca3af;
}

.staff-mini i.online {
    background: #12b76a;
}

.staff-link {
    min-height: 34px;
    margin-top: 12px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--wine);
    text-decoration: none;
    font-weight: 800;
    font-size: 12px;
}

.app-shell {
    margin-left: 224px;
    min-height: 100vh;
    min-width: 0;
}

.topbar {
    height: 46px;
    background: linear-gradient(90deg, var(--wine-dark), var(--wine));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 22px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.menu-button {
    background: transparent;
    color: #fff;
    border: 0;
    font-size: 22px;
    min-height: 0;
    padding: 0;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.notice {
    position: relative;
    font-size: 20px;
}

.notice b {
    position: absolute;
    right: -7px;
    top: -8px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    color: var(--wine);
    display: grid;
    place-items: center;
    font-size: 10px;
}

.top-user {
    display: flex;
    align-items: center;
    gap: 8px;
}

.top-user small {
    color: rgba(255,255,255,.82);
}

.logout-link {
    color: #fff;
    text-decoration: none;
    font-weight: 700;
}

.container {
    padding: 22px;
    max-width: 1240px;
    min-width: 0;
}

.mobile-actions {
    display: none;
}

.bottom-nav {
    display: none;
}

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    margin-bottom: 18px;
}

h1, h2, h3 {
    letter-spacing: 0;
}

h1 {
    margin: 0 0 6px;
    font-size: 23px;
}

h2 {
    margin: 0;
    font-size: 16px;
}

.page-head p,
.muted {
    margin: 0;
    color: var(--muted);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(150px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
    min-width: 0;
}

.stat-card {
    position: relative;
    min-height: 120px;
    padding: 22px 20px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 6px;
    box-shadow: 0 10px 30px rgba(0,0,0,.04);
}

.stat-card span {
    display: block;
    color: #404040;
    font-size: 13px;
    margin-bottom: 12px;
}

.stat-card strong {
    display: block;
    font-size: 30px;
    line-height: 1;
    margin-bottom: 10px;
}

.stat-card small {
    color: var(--muted);
}

.stat-icon {
    position: absolute;
    right: 20px;
    top: 50px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-style: normal;
    font-size: 20px;
}

.stat-icon.pending {
    color: var(--danger);
    background: #fee4e2;
}

.stat-icon.process {
    color: var(--warning);
    background: #fff0d7;
}

.stat-icon.done {
    color: var(--blue);
    background: #dbeafe;
}

.stat-icon.approved {
    color: var(--green);
    background: #dcfae6;
}

.stat-icon.rejected {
    color: var(--danger);
    background: #fee4e2;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 6px;
    box-shadow: 0 10px 30px rgba(0,0,0,.04);
    padding: 18px;
    margin-bottom: 18px;
}

.task-panel {
    padding: 16px 18px;
}

.task-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 12px;
}

.filters {
    display: flex;
    gap: 16px;
}

.filters select {
    width: 150px;
    min-height: 30px;
    padding: 5px 10px;
}

form {
    display: grid;
    gap: 14px;
}

label {
    display: grid;
    gap: 6px;
    font-weight: 700;
}

input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 10px 11px;
    font: inherit;
    background: #fff;
    color: var(--text);
}

input:focus, select:focus, textarea:focus {
    outline: 2px solid rgba(120, 0, 28, .14);
    border-color: var(--wine);
}

textarea {
    min-height: 110px;
    resize: vertical;
}

.row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    min-width: 0;
}

button, .button {
    min-height: 34px;
    border: 0;
    border-radius: 5px;
    background: var(--wine);
    color: #fff;
    padding: 0 14px;
    font-weight: 800;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.page-head .button::before {
    content: "+";
    font-size: 20px;
    line-height: 1;
    margin-right: 8px;
}

button:hover, .button:hover {
    background: var(--wine-dark);
}

.button.secondary {
    background: #4b5563;
}

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

.button.small {
    min-height: 27px;
    padding: 0 9px;
    font-size: 11px;
}

.button.outline {
    background: #fff;
    color: var(--wine);
    border: 1px solid #b66b7b;
}

.alert {
    border-radius: 5px;
    padding: 11px 13px;
    margin-bottom: 16px;
    background: #fff4ed;
    color: #9a3412;
    border: 1px solid #fed7aa;
}

.alert.success {
    background: #ecfdf3;
    color: var(--green);
    border-color: #abefc6;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid var(--line);
    table-layout: auto;
}

th, td {
    text-align: left;
    padding: 10px 13px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
    overflow-wrap: anywhere;
}

th {
    color: #555;
    font-size: 12px;
    font-weight: 700;
    background: #fff;
}

td strong {
    display: block;
    margin-bottom: 4px;
}

.badge {
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 700;
    display: inline-block;
    background: #f2f4f7;
    color: #344054;
}

.badge.prioridad-urgente,
.badge.rechazada {
    background: #fee4e2;
    color: var(--danger);
}

.badge.prioridad-normal,
.badge.pendiente {
    background: #ffefd6;
    color: #dc6803;
}

.badge.en_proceso {
    background: #dbeafe;
    color: var(--blue);
}

.badge.completada {
    background: #dbeafe;
    color: var(--blue);
}

.badge.aprobada {
    background: #dcfae6;
    color: var(--green);
}

.badge.entrada {
    background: #dcfae6;
    color: var(--green);
}

.badge.salida {
    background: #fee4e2;
    color: var(--danger);
}

.badge.ajuste {
    background: #dbeafe;
    color: var(--blue);
}

.evidencia {
    width: 58px;
    height: 42px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--line);
}

.more {
    color: #111827;
    font-size: 20px;
    line-height: 1;
    padding: 0 4px;
}

.table-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 14px;
    color: var(--muted);
    font-size: 12px;
}

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

.pager button,
.pager b {
    min-width: 28px;
    height: 28px;
    border-radius: 5px;
    border: 1px solid var(--line);
    background: #fff;
    color: #6b7280;
    display: grid;
    place-items: center;
}

.pager b {
    border-color: var(--wine);
    background: var(--wine);
    color: #fff;
}

.login {
    max-width: 450px;
    margin: 58px auto;
}

.login-logo {
    width: 160px;
    max-width: 100%;
    display: block;
    margin-bottom: 18px;
}

.calendar-grid {
    display: grid;
    gap: 12px;
}

.calendar-item {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 16px;
    align-items: center;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 14px 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,.04);
}

.calendar-item time {
    color: var(--wine);
    font-weight: 800;
}

.calendar-item p {
    margin: 4px 0 8px;
    color: var(--muted);
}

.inline-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    margin-top: 14px;
}

.inventory-product-form {
    grid-template-columns: 1.2fr 1fr 140px 140px auto;
}

.inventory-grid {
    grid-template-columns: repeat(5, minmax(140px, 1fr));
}

.settings-list {
    display: grid;
    gap: 0;
    margin-top: 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    overflow: hidden;
}

.settings-list div {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 16px;
    padding: 13px 14px;
    border-bottom: 1px solid var(--line);
}

.settings-list div:last-child {
    border-bottom: 0;
}

.settings-list span {
    color: var(--muted);
}

.repeat-box {
    display: grid;
    gap: 14px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fffafa;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.check-row input {
    width: auto;
}

.alert-list {
    display: grid;
    gap: 10px;
    margin-top: 12px;
}

.alert-list div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid #fed7aa;
    border-radius: 5px;
    background: #fff7ed;
}

.alert-list strong {
    color: var(--wine);
}

@media (max-width: 1050px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .filters {
        flex-wrap: wrap;
    }
}

@media (max-width: 760px) {
    body {
        background: #f7f7f8;
        padding-bottom: 82px;
        font-size: 13px;
    }

    .sidebar {
        display: none;
    }

    .app-shell {
        margin-left: 0;
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
    }

    .topbar {
        position: sticky;
        height: 58px;
        padding: 0 14px;
        border-radius: 0 0 14px 14px;
        box-shadow: 0 12px 24px rgba(82, 0, 20, .22);
        width: 100%;
        max-width: 100vw;
    }

    .container {
        padding: 16px 12px 0;
        max-width: 100%;
        overflow-x: hidden;
    }

    .mobile-actions {
        display: none;
    }

    .menu-button {
        font-size: 0;
    }

    .menu-button::after {
        content: "Servicio Escolar";
        font-size: 17px;
        font-weight: 800;
    }

    .topbar-right {
        gap: 8px;
    }

    .notice,
    .logout-link {
        display: none;
    }

    .top-user strong {
        max-width: 86px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .top-user small {
        max-width: 86px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .page-head {
        background: #fff;
        border: 1px solid var(--line);
        border-radius: 14px;
        padding: 15px;
        box-shadow: 0 10px 25px rgba(0,0,0,.04);
        margin-bottom: 12px;
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    h1 {
        font-size: 22px;
    }

    .page-head .button,
    form button,
    .button {
        min-height: 42px;
        border-radius: 10px;
    }

    .stats-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        overflow-x: hidden;
        gap: 10px;
        padding: 2px 2px 10px;
        margin-bottom: 10px;
        width: 100%;
        max-width: 100%;
    }

    .stat-card {
        min-width: 0;
        max-width: 100%;
        min-height: 112px;
        padding: 16px;
        border-radius: 14px;
        width: 100%;
    }

    .stat-card strong {
        font-size: 28px;
    }

    .stat-icon {
        width: 34px;
        height: 34px;
        right: 14px;
        top: 44px;
    }

    .panel {
        border-radius: 14px;
        padding: 14px;
        overflow: hidden;
        width: 100%;
        max-width: 100%;
    }

    .task-panel {
        padding: 14px;
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }

    .task-panel-head {
        gap: 10px;
    }

    .page-head,
    .task-panel-head {
        flex-direction: column;
        align-items: stretch;
    }

    .row,
    .inline-form,
    .inventory-product-form,
    .calendar-item,
    .settings-list div {
        grid-template-columns: 1fr;
    }

    .filters {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
        width: 100%;
        max-width: 100%;
    }

    .filters select {
        width: 100%;
        min-height: 40px;
        border-radius: 10px;
    }

    input, select, textarea {
        min-height: 42px;
        border-radius: 10px;
        font-size: 16px;
        min-width: 0;
    }

    form,
    label,
    .row,
    .filters {
        min-width: 0;
    }

    table, thead, tbody, tr, th, td {
        display: block;
        width: 100%;
        max-width: 100%;
    }

    thead {
        display: none;
    }

    tr {
        border: 1px solid var(--line);
        border-radius: 14px;
        margin-bottom: 12px;
        overflow: hidden;
        background: #fff;
        box-shadow: 0 8px 20px rgba(0,0,0,.035);
        max-width: 100%;
    }

    td {
        border-bottom: 0;
        display: grid;
        grid-template-columns: minmax(78px, 32%) minmax(0, 1fr);
        gap: 10px;
        padding: 10px 12px;
        align-items: start;
        min-width: 0;
    }

    td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 12px;
        font-weight: 800;
    }

    td:first-child {
        grid-template-columns: 1fr;
        padding-top: 14px;
    }

    td:first-child::before {
        display: none;
    }

    td strong {
        font-size: 15px;
        overflow-wrap: anywhere;
    }

    .actions {
        gap: 6px;
        width: 100%;
    }

    .button.small {
        min-height: 34px;
        border-radius: 8px;
        font-size: 12px;
        flex: 1 1 92px;
        min-width: 0;
        padding: 0 8px;
        white-space: normal;
        text-align: center;
    }

    .evidencia {
        width: 88px;
        height: 64px;
    }

    .table-foot {
        display: none;
    }

    .calendar-item {
        border-radius: 14px;
    }

    .alert-list div {
        flex-direction: column;
        min-width: 0;
    }

    .bottom-nav {
        position: fixed;
        left: 10px;
        right: 10px;
        bottom: 10px;
        height: 62px;
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        gap: 4px;
        align-items: center;
        padding: 6px;
        background: #fff;
        border: 1px solid var(--line);
        border-radius: 18px;
        box-shadow: 0 16px 35px rgba(82, 0, 20, .22);
        z-index: 50;
        max-width: calc(100vw - 20px);
    }

    .role-servicio .bottom-nav {
        grid-template-columns: repeat(4, 1fr);
    }

    .role-admin .bottom-nav,
    .role-supervisor .bottom-nav {
        grid-template-columns: repeat(6, 1fr);
        gap: 2px;
    }

    .bottom-nav a {
        height: 50px;
        border-radius: 14px;
        display: grid;
        place-items: center;
        align-content: center;
        gap: 2px;
        color: #555;
        text-decoration: none;
        font-size: 10px;
        font-weight: 800;
        min-width: 0;
        overflow: hidden;
    }

    .bottom-nav a span {
        width: 22px;
        height: 22px;
        border-radius: 50%;
        display: grid;
        place-items: center;
        background: #f2f4f7;
        color: var(--wine);
        font-size: 11px;
    }

    .role-admin .bottom-nav a,
    .role-supervisor .bottom-nav a {
        font-size: 9px;
    }

    .role-admin .bottom-nav a span,
    .role-supervisor .bottom-nav a span {
        width: 20px;
        height: 20px;
        font-size: 10px;
    }

    .bottom-nav a.active {
        background: var(--wine-soft);
        color: var(--wine);
    }

    .bottom-nav a.active span {
        background: var(--wine);
        color: #fff;
    }
}
