:root {
    --bg: #f4f8fb;
    --ink: #172335;
    --muted: #66758b;
    --line: #d7e2ea;
    --panel: #ffffff;
    --brand: #18a7e0;
    --brand-dark: #0277bd;
    --brand-soft: #e8f7fd;
    --accent: #f47b20;
    --danger: #d90912;
    --leaf: #129a35;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
    -webkit-text-size-adjust: 100%;
}

.login-body {
    display: grid;
    place-items: center;
    padding: 24px;
    background: var(--bg);
}

.login-box {
    width: min(420px, 100%);
}

.login-box img {
    display: block;
    width: 240px;
    max-width: 80%;
    margin: 0 auto 18px;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 210px;
    height: 100dvh;
    padding: 10px 8px;
    background: #ffffff;
    color: var(--ink);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    overscroll-behavior: contain;
    scrollbar-width: thin;
}

.brand {
    font-weight: 700;
    margin-bottom: 6px;
    display: grid;
    justify-items: center;
}

.brand img {
    width: 100%;
    max-width: 125px;
    display: block;
}

nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 0;
    overflow-y: auto;
    padding-right: 3px;
    scrollbar-width: thin;
}

nav::-webkit-scrollbar {
    width: 8px;
}

nav::-webkit-scrollbar-thumb {
    background: #c9d8e4;
    border-radius: 999px;
}

nav a {
    display: flex;
    align-items: center;
    color: var(--ink);
    min-height: 33px;
    padding: 5px 8px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 14px;
    line-height: 1.15;
}

nav a:hover {
    background: var(--brand-soft);
    color: var(--brand-dark);
}

.nav-top,
.nav-exit {
    font-weight: 700;
}

.nav-exit {
    margin-top: auto;
    color: var(--danger);
}

.nav-group {
    border: 1px solid transparent;
    border-radius: 8px;
}

.nav-group[open] {
    background: #f8fbfd;
    border-color: #edf3f7;
}

.nav-group summary {
    display: flex;
    align-items: center;
    min-height: 34px;
    padding: 5px 8px;
    border-radius: 7px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0;
    cursor: pointer;
    user-select: none;
}

.nav-group summary::-webkit-details-marker {
    display: none;
}

.nav-group summary::after {
    content: ">";
    margin-left: auto;
    color: var(--brand-dark);
    transition: transform .16s ease;
}

.nav-group[open] summary::after {
    transform: rotate(90deg);
}

.nav-group div {
    display: grid;
    gap: 2px;
    padding: 0 4px 5px;
}

.nav-group a {
    min-height: 31px;
    padding-left: 12px;
    font-size: 13px;
}

.main {
    margin-left: 210px;
    padding: 28px;
}

.back-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    margin-bottom: 14px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    font-weight: 700;
    cursor: pointer;
}

.back-button::before {
    content: "<";
    margin-right: 8px;
}

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

h1 {
    margin: 0;
    font-size: 30px;
}

h2 {
    font-size: 18px;
    margin: 20px 0 8px;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--danger);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 16px;
    border: 0;
    border-radius: 6px;
    background: linear-gradient(135deg, #22b8f0, #039be5);
    color: #fff;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.button.secondary {
    background: var(--brand-soft);
    color: var(--ink);
}

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

.button:hover {
    filter: brightness(1.03);
}

.row-plus {
    width: 44px;
    min-width: 44px;
    padding: 0;
    font-size: 22px;
    line-height: 1;
}

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

.actions form {
    margin: 0;
}

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

.section-head h2 {
    margin: 0;
}

.summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.dashboard-search {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px 16px;
    margin: -4px 0 18px;
    max-width: 520px;
}

.employee-tools {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) 220px;
    gap: 12px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 18px;
}

.supplier-alerts {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 18px;
}

.supplier-alerts h2 {
    margin-top: 0;
}

.alert-row {
    display: grid;
    grid-template-columns: auto minmax(160px, 1fr) minmax(90px, .7fr) auto auto;
    align-items: center;
    gap: 10px;
    border-top: 1px solid var(--line);
    padding: 10px 0;
}

.check-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
}

.check-panel legend {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 0 6px;
}

.check-panel label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--ink);
    font-weight: 400;
}

.check-panel input {
    width: 18px;
    min-height: 18px;
}

.summary > div {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    border-top: 4px solid var(--accent);
}

.summary span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 8px;
}

.summary strong {
    font-size: 24px;
}

.summary small {
    display: block;
    color: var(--muted);
    margin-top: 6px;
}

.payroll-preview {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    margin: 4px 0 10px;
}

.payroll-preview > div {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fbfd;
    padding: 10px 12px;
}

.payroll-preview span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 4px;
}

.payroll-preview strong {
    display: block;
    font-size: 18px;
}

.payroll-preview.compact {
    grid-template-columns: repeat(5, minmax(110px, 1fr));
    margin: 12px 0 0;
}

.payroll-preview.compact > div {
    padding: 8px 10px;
}

.payroll-preview.compact strong {
    font-size: 15px;
}

.period-suggestion {
    display: grid;
    align-content: center;
    gap: 4px;
    min-height: 68px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fbfd;
}

.period-suggestion span {
    color: var(--brand-dark);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.period-suggestion strong {
    font-size: 18px;
    line-height: 1.25;
}

.report-summary {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.report-filters {
    margin-bottom: 18px;
}

.report-detail {
    margin-top: 16px;
}

.price-guide-filter {
    margin-bottom: 16px;
}

.price-recommendation {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.price-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
}

.price-card.best {
    border-color: #62c783;
    box-shadow: 0 8px 24px rgba(19, 115, 51, .08);
}

.price-card h2 {
    margin: 12px 0 8px;
    font-size: 18px;
}

.price-card strong {
    display: block;
    font-size: 22px;
    margin-bottom: 8px;
}

.price-card p,
.price-card small {
    color: var(--muted);
}

.table-wrap,
.panel,
.receipt {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
}

.table-wrap {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    table-layout: auto;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 10px 8px;
    text-align: left;
    vertical-align: top;
    overflow-wrap: break-word;
    word-break: normal;
}

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

a {
    color: var(--brand-dark);
}

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

.row-actions form {
    margin: 0;
}

.link-button {
    border: 0;
    background: transparent;
    color: var(--danger);
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    padding: 0;
    text-decoration: underline;
}

#employeesTable {
    table-layout: fixed;
}

#employeesTable th:nth-child(1),
#employeesTable td:nth-child(1) {
    width: 30%;
}

#employeesTable th:nth-child(2),
#employeesTable td:nth-child(2) {
    width: 28%;
}

#employeesTable th:nth-child(3),
#employeesTable td:nth-child(3) {
    width: 12%;
}

#employeesTable th:nth-child(4),
#employeesTable td:nth-child(4) {
    width: 12%;
}

#employeesTable th:nth-child(5),
#employeesTable td:nth-child(5) {
    width: 18%;
}

.cell-title,
.cell-stack,
.cell-subline {
    display: block;
    max-width: 100%;
    overflow-wrap: anywhere;
}

.cell-title {
    margin-bottom: 3px;
    color: var(--ink);
}

.cell-subline {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.25;
}

.money-cell {
    text-align: right;
    white-space: nowrap;
}

.money-cell small {
    color: var(--muted);
}

#employeesTable .row-actions {
    margin-top: 8px;
}

.pill {
    display: inline-block;
    min-width: 72px;
    padding: 4px 8px;
    border-radius: 999px;
    background: #eaf5ff;
    color: var(--brand-dark);
    text-align: center;
    font-size: 12px;
    font-weight: 700;
}

.muted {
    color: var(--muted);
}

.notice {
    margin: 0 0 14px;
    padding: 10px 12px;
    border-left: 4px solid var(--accent);
    background: #fff7ed;
}

.form {
    width: 100%;
    display: grid;
    gap: 14px;
}

.login-box .form {
    max-width: 420px;
}

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 9px 10px;
    color: var(--ink);
    font: inherit;
    background: #fff;
}

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

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.grid-2 .wide {
    grid-column: 1 / -1;
}

.items {
    display: grid;
    gap: 8px;
}

.item-row {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr) 160px 120px;
    gap: 8px;
}

.surtido-row {
    grid-template-columns: minmax(220px, 1fr) 160px minmax(180px, .8fr) 120px;
}

.row-add {
    justify-self: start;
    width: auto;
}

.row-remove {
    align-self: end;
    min-height: 44px;
    background: #fff2f2;
    color: var(--danger);
}

.panel-lite {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: #fbfdff;
}

.sign-panel {
    max-width: 820px;
}

.weekly-form {
    max-width: 1180px;
}

.weekly-list {
    display: grid;
    gap: 12px;
}

.weekly-employee {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfdff;
    padding: 14px;
}

.include-row {
    display: flex;
    grid-template-columns: none;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    margin-bottom: 12px;
}

.include-row input {
    width: 20px;
    min-height: 20px;
    flex: 0 0 auto;
}

.include-row span {
    display: grid;
    gap: 2px;
}

.include-row small {
    color: var(--muted);
    font-weight: 400;
}

.weekly-grid {
    display: grid;
    grid-template-columns: .55fr .55fr .7fr .9fr .85fr .85fr 1.1fr 1.4fr;
    gap: 8px;
}

.weekly-grid .wide {
    min-width: 0;
}

.queue-tools {
    display: grid;
    grid-template-columns: minmax(280px, 1.3fr) minmax(240px, 1fr) auto;
    gap: 12px;
    align-items: end;
    margin-bottom: 16px;
}

.queue-filter {
    margin: 0;
}

.queue-counts {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    align-items: center;
}

.queue-counts span {
    border-radius: 999px;
    background: var(--brand-soft);
    color: var(--brand-dark);
    font-size: 12px;
    font-weight: 700;
    padding: 8px 10px;
    white-space: nowrap;
}

.signature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.signature-card {
    display: grid;
    gap: 14px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
}

.signature-card h2 {
    margin: 10px 0 4px;
    font-size: 18px;
    line-height: 1.2;
}

.signature-card p {
    margin: 0 0 10px;
    color: var(--muted);
}

.signature-card strong {
    font-size: 22px;
}

.pill.done {
    background: #e8f8ef;
    color: #137333;
}

.pill.pending {
    background: #fff4e5;
    color: #a34f00;
}

canvas {
    display: block;
    width: 100%;
    height: auto;
    border: 2px dashed #bac5bf;
    border-radius: 8px;
    background: #fff;
    margin-bottom: 12px;
    touch-action: none;
}

@media (max-width: 780px) {
    body {
        background: #fff;
    }

    .sidebar {
        position: sticky;
        top: 0;
        z-index: 10;
        width: auto;
        height: auto;
        max-height: 48vh;
        overflow: hidden;
        padding: 10px 12px 12px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
        box-shadow: 0 4px 18px rgba(23, 35, 53, .06);
    }

    .brand {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
        margin-bottom: 10px;
    }

    .brand img {
        width: 162px;
        max-width: 62vw;
    }

    nav {
        display: flex;
        flex-direction: row;
        gap: 6px;
        max-height: 142px;
        overflow: auto;
    }

    nav a {
        flex: 0 0 148px;
        min-height: 42px;
        padding: 10px 6px;
        background: var(--brand-soft);
        color: var(--brand-dark);
        text-align: center;
        font-size: 13px;
        font-weight: 700;
    }

    .nav-group {
        flex: 0 0 172px;
        background: #f8fbfd;
        border-color: var(--line);
    }

    .nav-group summary {
        min-height: 42px;
        color: var(--ink);
        background: #fff;
    }

    .nav-group a {
        flex-basis: auto;
        justify-content: flex-start;
        min-height: 36px;
        text-align: left;
    }

    .nav-exit {
        margin-top: 0;
    }

    .main {
        margin-left: 0;
        padding: 16px 12px 26px;
    }

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

    .page-head {
        gap: 12px;
        margin-bottom: 14px;
    }

    h1 {
        font-size: 24px;
        line-height: 1.15;
    }

    h2 {
        font-size: 16px;
    }

    .button {
        width: 100%;
        min-height: 46px;
        padding: 0 14px;
        font-size: 15px;
    }

    .summary,
    .grid-2,
    .grid-3,
    .payroll-preview,
    .item-row,
    .weekly-grid {
        grid-template-columns: 1fr;
    }

    .payroll-preview.compact {
        grid-template-columns: 1fr;
    }

    .summary {
        gap: 8px;
        margin-bottom: 12px;
    }

    .report-summary {
        grid-template-columns: 1fr;
    }

    .price-recommendation {
        grid-template-columns: 1fr;
    }

    .summary > div {
        padding: 12px 14px;
        border-top-width: 0;
        border-left: 4px solid var(--accent);
    }

    .summary span {
        margin-bottom: 4px;
    }

    .summary strong {
        font-size: 21px;
    }

    .dashboard-search,
    .employee-tools,
    .supplier-alerts,
    .queue-tools,
    .table-wrap,
    .panel,
    .receipt {
        max-width: none;
        border-left: 0;
        border-right: 0;
        border-radius: 0;
        margin-left: -12px;
        margin-right: -12px;
        padding: 14px 12px;
    }

    .dashboard-search {
        margin-top: 0;
        margin-bottom: 12px;
    }

    .employee-tools {
        grid-template-columns: 1fr;
        margin-bottom: 12px;
    }

    .alert-row {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .check-panel {
        grid-template-columns: 1fr;
    }

    .queue-tools {
        grid-template-columns: 1fr;
        align-items: stretch;
        gap: 10px;
    }

    .queue-counts {
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .signature-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .signature-card {
        border-left: 0;
        border-right: 0;
        border-radius: 0;
        margin-left: -12px;
        margin-right: -12px;
        padding: 14px 12px;
    }

    input,
    select,
    textarea {
        min-height: 48px;
        font-size: 16px;
        border-radius: 8px;
    }

    label {
        font-size: 12px;
    }

    .item-row,
    .weekly-employee {
        gap: 8px;
        padding: 12px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: #fbfdff;
    }

    .weekly-form {
        gap: 12px;
    }

    .weekly-list {
        gap: 10px;
    }

    .include-row {
        align-items: flex-start;
    }

    table,
    thead,
    tbody,
    tr,
    th,
    td {
        display: block;
    }

    thead {
        display: none;
    }

    table {
        border-collapse: separate;
        border-spacing: 0;
    }

    tbody {
        display: grid;
        gap: 10px;
    }

    tr {
        border: 1px solid var(--line);
        border-radius: 8px;
        background: #fff;
        padding: 10px;
        box-shadow: 0 3px 12px rgba(23, 35, 53, .05);
    }

    td {
        display: grid;
        grid-template-columns: minmax(92px, 38%) 1fr;
        gap: 10px;
        align-items: start;
        border-bottom: 1px solid #edf3f7;
        padding: 8px 0;
        word-break: break-word;
    }

    td:last-child {
        border-bottom: 0;
    }

    td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 11px;
        font-weight: 700;
        text-transform: uppercase;
    }

    td[data-label="Accion"] a {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 40px;
        border-radius: 8px;
        background: var(--brand-soft);
        color: var(--brand-dark);
        font-weight: 700;
        text-decoration: none;
    }

    .row-actions {
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
    }

    .link-button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        min-height: 40px;
        border-radius: 8px;
        background: #fff1f1;
        text-decoration: none;
    }

    .pill {
        min-width: 0;
        width: fit-content;
    }

    .sign-panel {
        padding-bottom: 18px;
    }

    canvas {
        min-height: 210px;
        border-radius: 10px;
    }
}

@media (max-width: 420px) {
    .brand img {
        width: 138px;
    }

    nav a {
        font-size: 12px;
    }

    td {
        grid-template-columns: 1fr;
        gap: 4px;
    }
}


.pwa-install {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 9999;
    min-height: 44px;
    padding: 0 18px;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, #22b8f0, #039be5);
    color: #fff;
    font-weight: 700;
    box-shadow: 0 10px 24px rgba(23, 35, 53, .22);
    cursor: pointer;
}

.pwa-ios-hint {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: 18px;
    z-index: 9998;
    padding: 12px 14px;
    border-radius: 12px;
    background: #172335;
    color: #fff;
    text-align: center;
    box-shadow: 0 10px 24px rgba(23, 35, 53, .22);
}

.field-hint {
    display: block;
    margin-top: 6px;
    color: #65758b;
    font-size: 12px;
    line-height: 1.35;
}

.evidence-panel {
    max-width: 760px;
}

.evidence-list {
    display: grid;
    gap: 10px;
}

.evidence-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid #dfe7ef;
    border-radius: 8px;
    background: #ffffff;
    color: inherit;
    text-decoration: none;
}

.evidence-item span {
    color: #65758b;
    font-size: 13px;
    overflow-wrap: anywhere;
    text-align: right;
}

@media (max-width: 520px) {
    .pwa-install {
        right: 14px;
        bottom: 14px;
    }

    .evidence-item {
        align-items: flex-start;
        flex-direction: column;
    }

    .evidence-item span {
        text-align: left;
    }
}

/* Inventario: acordeones y busqueda de insumos */
.inventory-accordion {
    padding: 0;
    overflow: hidden;
}
.inventory-accordion details {
    width: 100%;
}
.inventory-summary {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    font-weight: 800;
    list-style: none;
}
.inventory-summary::-webkit-details-marker {
    display: none;
}
.inventory-accordion details[open] .summary-arrow {
    transform: rotate(180deg);
}
.summary-arrow {
    transition: transform .2s ease;
    font-size: .9rem;
}
.accordion-body {
    padding: 0 1.25rem 1.25rem;
}
.error-text {
    color: #b42318;
}
