:root {
    --bg: #f5f6f3;
    --surface: #ffffff;
    --text: #24302b;
    --muted: #66736b;
    --line: #dfe5dc;
    --primary: #2f7d5b;
    --primary-dark: #21583f;
    --secondary: #5b6f8f;
    --warning: #c68122;
    --danger: #b83f35;
    --success: #2f7d5b;
    --shadow: 0 10px 30px rgba(36, 48, 43, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Segoe UI, Tahoma, Arial, sans-serif;
    line-height: 1.5;
}

a {
    color: var(--primary);
    text-decoration: none;
}

input,
select,
button {
    font: inherit;
}

.login-page {
    min-height: 100vh;
    background:
        linear-gradient(rgba(18, 32, 26, 0.7), rgba(18, 32, 26, 0.58)),
        url("https://images.unsplash.com/photo-1542838132-92c53300491e?auto=format&fit=crop&w=1600&q=80") center/cover;
}

.login-shell {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
}

.login-panel {
    width: min(440px, 100%);
    padding: clamp(22px, 7vw, 32px);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.brand-mark {
    display: grid;
    width: 64px;
    height: 64px;
    margin-bottom: 18px;
    place-items: center;
    color: #fff;
    background: var(--primary-dark);
    border: 3px solid #d7b46a;
    border-radius: 50%;
    font-size: 1.35rem;
    font-weight: 900;
}

.login-panel h1,
.page-title h1 {
    margin: 0 0 8px;
    font-size: clamp(2rem, 6vw, 3.2rem);
    line-height: 1.05;
}

.login-form,
.movement-forms form {
    display: grid;
    gap: 16px;
}

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

input,
select {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 6px;
}

input:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(47, 125, 91, 0.14);
    outline: none;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--primary-dark);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.muted {
    margin: 0 0 24px;
    color: var(--muted);
}

.demo-access {
    display: grid;
    gap: 4px;
    margin-top: 22px;
    padding-top: 18px;
    color: var(--muted);
    border-top: 1px solid var(--line);
    font-size: 0.9rem;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px clamp(16px, 4vw, 48px);
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(8px);
}

.topbar div,
.topbar nav {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar nav {
    flex-wrap: wrap;
    justify-content: flex-end;
}

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

.topbar nav a:not(.btn) {
    padding: 8px 10px;
    color: var(--muted);
    border-radius: 6px;
    font-weight: 700;
}

.topbar nav a.active {
    color: var(--primary-dark);
    background: #e8f1ec;
}

.container {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 30px 0 56px;
}

.page-title {
    margin-bottom: 26px;
}

.branch-switcher {
    width: min(360px, 100%);
    margin-top: 16px;
}

.page-title.compact h1 {
    font-size: clamp(2rem, 5vw, 2.8rem);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.stat-card,
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.stat-card {
    display: grid;
    gap: 8px;
    padding: 18px;
    border-top: 4px solid var(--secondary);
}

.stat-card strong {
    font-size: 2.2rem;
    line-height: 1;
}

.stat-card span {
    color: var(--muted);
    font-weight: 700;
}

.stat-card.warning {
    border-top-color: var(--warning);
}

.stat-card.danger {
    border-top-color: var(--danger);
}

.stat-card.success {
    border-top-color: var(--success);
}

.content-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr);
    gap: 20px;
    margin-bottom: 20px;
}

.panel {
    padding: 20px;
}

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

.panel h2,
.panel h3 {
    margin: 0;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 680px;
}

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

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

.empty {
    color: var(--muted);
    text-align: center;
}

.filters {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 220px;
    gap: 12px;
    margin-bottom: 18px;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 800;
    text-transform: capitalize;
    white-space: nowrap;
}

.badge-disponible,
.badge-entrada,
.badge-completado,
.badge-entregado {
    color: #1f6b48;
    background: #def3e7;
}

.badge-bajo_stock,
.badge-salida,
.badge-parcial,
.badge-pendiente {
    color: #8a570c;
    background: #fff0d6;
}

.badge-agotado,
.badge-con_faltantes,
.badge-no_disponible,
.badge-cancelado {
    color: #983127;
    background: #ffe1de;
}

.badge-en_proceso {
    color: #375171;
    background: #e4ecf7;
}

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

.movement {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px;
    align-items: start;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

.movement small {
    display: block;
    color: var(--muted);
}

.supply-notice {
    margin-bottom: 20px;
}

.supply-cards,
.process-list,
.delivery-list,
.supply-groups {
    display: grid;
    gap: 12px;
}

.supply-cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.supply-card,
.process-card,
.delivery-card,
.check-row,
.empty-state {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.supply-card {
    display: grid;
    gap: 6px;
    min-width: 0;
    padding: 14px;
    color: var(--text);
}

.supply-card strong,
.process-card h3,
.delivery-card h3 {
    margin: 0;
    word-break: break-word;
}

.supply-card small,
.process-card small,
.check-row small {
    color: var(--muted);
}

.step-heading {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px;
    align-items: start;
    margin-bottom: 18px;
}

.step-number {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    color: #fff;
    background: var(--primary-dark);
    border-radius: 50%;
    font-weight: 900;
}

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

.check-row {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px;
    align-items: center;
    min-width: 0;
    padding: 14px;
    cursor: pointer;
}

.check-row input[type="checkbox"] {
    width: 22px;
    height: 22px;
    min-height: 22px;
    accent-color: var(--primary);
}

.check-row span {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.check-row-strong {
    background: #f7faf8;
}

.supply-group {
    display: grid;
    gap: 8px;
}

.supply-item-row {
    grid-template-columns: auto minmax(0, 1fr) auto;
}

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

.split-actions {
    justify-content: space-between;
}

.process-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    padding: 16px;
}

.process-card p,
.delivery-card p {
    margin: 4px 0;
    color: var(--muted);
}

.process-actions {
    display: flex;
    gap: 8px;
}

.process-actions form,
.panel-actions form {
    margin: 0;
}

.panel-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.empty-state {
    padding: 20px;
    color: var(--muted);
    text-align: center;
}

.stats-grid-compact .stat-card {
    min-height: 116px;
}

.stat-text {
    font-size: 1.2rem;
    line-height: 1.15;
}

.delivery-card {
    display: grid;
    gap: 14px;
    padding: 16px;
}

.delivery-main {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.delivery-controls {
    display: grid;
    grid-template-columns: 190px 180px minmax(220px, 1fr);
    gap: 12px;
    align-items: end;
}

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

.delivery-result div {
    display: grid;
    gap: 4px;
    padding: 10px;
    background: #f7faf8;
    border-radius: 6px;
}

.delivery-result dt {
    color: var(--muted);
    font-weight: 800;
}

.delivery-result dd {
    margin: 0;
    font-weight: 800;
}

.detail-list {
    display: grid;
    gap: 14px;
    margin: 0 0 20px;
}

.detail-list div {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
}

.detail-list dt {
    color: var(--muted);
    font-weight: 700;
}

.detail-list dd {
    margin: 0;
    font-weight: 800;
    text-align: right;
}

.movement-forms {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 9px 14px;
    color: #fff;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 800;
}

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

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

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

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

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

.btn-block {
    width: 100%;
}

.btn-sm {
    min-height: 32px;
    padding: 6px 10px;
    font-size: 0.9rem;
}

.alert {
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: 6px;
    font-weight: 700;
}

.alert-success {
    color: #1f6b48;
    background: #def3e7;
}

.alert-danger {
    color: #983127;
    background: #ffe1de;
}

@media (max-width: 860px) {
    .login-shell {
        align-items: stretch;
        padding: 16px;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
        padding: 12px;
    }

    .topbar div {
        align-items: flex-start;
        flex-direction: column;
        gap: 2px;
    }

    .topbar nav {
        display: grid;
        width: 100%;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .topbar nav a {
        width: 100%;
    }

    .content-grid,
    .movement-forms,
    .filters,
    .checkbox-grid,
    .supply-cards,
    .delivery-controls,
    .delivery-result {
        grid-template-columns: 1fr;
    }

    .process-card,
    .supply-item-row {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .supply-item-row .badge {
        grid-column: 2;
        justify-self: start;
    }

    .process-actions,
    .panel-actions,
    .form-actions,
    .split-actions {
        width: 100%;
        flex-direction: column;
    }

    .process-actions .btn,
    .panel-actions .btn,
    .form-actions .btn {
        width: 100%;
    }

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

    .stat-card {
        min-height: 112px;
        padding: 14px;
    }

    .stat-card strong {
        font-size: 1.8rem;
    }

    .container {
        width: min(100% - 24px, 1180px);
        padding-top: 22px;
    }

    .panel {
        padding: 16px;
    }

    .panel-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .table-wrap {
        overflow: visible;
    }

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

    table {
        border-collapse: separate;
    }

    thead {
        display: none;
    }

    tr {
        margin-bottom: 12px;
        padding: 12px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: #fff;
    }

    td {
        display: flex;
        justify-content: space-between;
        gap: 16px;
        padding: 8px 0;
        border-bottom: 1px solid var(--line);
        text-align: right;
    }

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

    td::before {
        content: attr(data-label);
        color: var(--muted);
        font-weight: 800;
        text-align: left;
    }

    td.empty {
        justify-content: center;
        text-align: center;
    }

    td.empty::before {
        content: "";
    }

    .detail-list div {
        align-items: flex-start;
        flex-direction: column;
        gap: 4px;
    }

    .detail-list dd {
        text-align: left;
    }
}

@media (max-width: 420px) {
    .stats-grid,
    .topbar nav {
        grid-template-columns: 1fr;
    }

    .login-panel h1,
    .page-title h1 {
        font-size: 2rem;
    }
}
