:root {
    --color-primary: #78b4c9;
    --color-primary-dark: #4a8aa1;
    --color-accent: #f0a35c;
    --color-bg: #edf3f6;
    --color-surface: #ffffff;
    --color-heading: #22313b;
    --color-text: #3e4a53;
    --color-muted: #6f7c84;
    --color-border: rgba(34, 49, 59, 0.12);
    --color-shadow: 0 20px 45px rgba(34, 49, 59, 0.12);
    --color-success: #2f9d70;
    --color-warning: #c17b25;
    --sidebar-width: 260px;
    --border-radius: 14px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Inter', 'Segoe UI', Tahoma, sans-serif;
    background: linear-gradient(135deg, #f4f7f9 0%, #e9f0f4 100%);
    color: var(--color-text);
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease, background 0.2s ease;
}

a:hover {
    color: var(--color-primary-dark);
}

h1,
h2,
h3,
h4,
h5,
h6 {
    margin: 0;
    color: var(--color-heading);
    font-weight: 700;
}

.layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    padding: 2rem 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    box-shadow: 12px 0 35px rgba(34, 49, 59, 0.06);
    position: relative;
    z-index: 2;
}

.sidebar .logo img {
    max-width: 150px;
    height: auto;
}

.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.sidebar nav a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0.95rem;
    border-radius: 10px;
    color: var(--color-text);
    font-weight: 600;
    background: transparent;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.sidebar nav a:hover {
    background: rgba(120, 180, 201, 0.18);
    color: var(--color-heading);
    transform: translateX(4px);
}

.sidebar nav a.active {
    background: rgba(120, 180, 201, 0.28);
    color: var(--color-heading);
    box-shadow: inset 0 0 0 1px rgba(74, 138, 161, 0.25);
}

.sidebar .user-block {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    color: var(--color-muted);
    font-weight: 600;
}

.main {
    background: transparent;
    padding: 2.5rem 3rem 3rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    width: 100%;
}

.page-header,
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.page-heading {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.page-title {
    font-size: clamp(1.65rem, 2.4vw, 2.2rem);
    line-height: 1.15;
}

.page-subtitle {
    color: var(--color-muted);
    font-size: 0.95rem;
}

.flash {
    padding: 0.85rem 1.1rem;
    border-radius: 10px;
    background: rgba(120, 180, 201, 0.18);
    color: var(--color-heading);
    border: 1px solid rgba(120, 180, 201, 0.25);
}

.card {
    background: var(--color-surface);
    border-radius: var(--border-radius);
    padding: clamp(1.15rem, 2vw, 1.75rem);
    box-shadow: var(--color-shadow);
    border: 1px solid rgba(34, 49, 59, 0.06);
}

.card h3 {
    margin-bottom: 0.45rem;
}

.card-stack {
    display: flex;
    flex-direction: column;
    gap: 1.4rem;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
}

.section-header {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
}

.section-header .grow {
    flex: 1 1 320px;
}

.button {
    background: var(--color-primary);
    color: #ffffff;
    border: none;
    padding: 0.7rem 1.35rem;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.button:hover {
    background: var(--color-primary-dark);
    box-shadow: 0 12px 25px rgba(74, 138, 161, 0.25);
    transform: translateY(-1px);
}

.button.secondary {
    background: rgba(34, 49, 59, 0.08);
    color: var(--color-heading);
}

.button.secondary:hover {
    background: rgba(34, 49, 59, 0.16);
}

.button.secondary.is-active {
    background: var(--color-primary);
    color: #ffffff;
}

.button.danger {
    background: #e16a6a;
    color: #ffffff;
}

.button.danger:hover {
    background: #c85050;
    box-shadow: 0 12px 25px rgba(193, 80, 80, 0.26);
}

.form-actions {
    display: flex;
    gap: 0.85rem;
    flex-wrap: wrap;
}

.form-actions .button {
    min-width: 140px;
}

.input {
    width: 100%;
    padding: 0.7rem 0.85rem;
    border-radius: 10px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    font: inherit;
    color: var(--color-text);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.input:focus,
.input:focus-visible {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(120, 180, 201, 0.25);
    background: #fbfdfe;
}

textarea.input {
    min-height: 120px;
    resize: vertical;
}

.form-card {
    width: 100%;
}

.narrow-card {
    max-width: 640px;
    margin: 0 auto;
    width: 100%;
}

.form-layout {
    display: grid;
    gap: 1.25rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 1.1rem;
    grid-auto-flow: row dense;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-group label {
    font-weight: 600;
    color: var(--color-heading);
}

.detail-list {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 0.4rem 1rem;
    margin: 0;
}

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

.detail-list dd {
    margin: 0;
}

.filters-toolbar {
    display: flex;
    align-items: flex-end;
    gap: 1.25rem;
    flex-wrap: wrap;
    justify-content: space-between;
}

.filters-form {
    display: grid;
    grid-template-columns: minmax(220px, 2fr) minmax(170px, 1fr) minmax(170px, 1fr) auto;
    gap: 0.85rem;
    align-items: end;
    flex: 1;
}

.filters-form .button {
    min-width: 150px;
}

.filters-form .filters-search {
    grid-column: auto;
}

.inline-form {
    display: flex;
    gap: 0.85rem;
    flex-wrap: wrap;
    align-items: flex-end;
}

.inline-form .input {
    flex: 1 1 220px;
    min-width: 180px;
}

.inline-form .button {
    flex: 0 0 auto;
}

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.table thead {
    background: rgba(120, 180, 201, 0.16);
}

.table th,
.table td {
    padding: 0.85rem 0.95rem;
    text-align: left;
    border-bottom: 1px solid rgba(34, 49, 59, 0.08);
    color: var(--color-text);
    font-size: 0.95rem;
}

.table th {
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.78rem;
    color: var(--color-muted);
}

.table tbody tr {
    transition: background 0.2s ease;
}

.table tbody tr:hover {
    background: rgba(120, 180, 201, 0.12);
}

.responsive-table {
    overflow-x: auto;
    border-radius: var(--border-radius);
    border: 1px solid rgba(34, 49, 59, 0.08);
    background: var(--color-surface);
    box-shadow: inset 0 0 0 1px rgba(34, 49, 59, 0.03);
}

.responsive-table table {
    min-width: 740px;
}

.responsive-table::-webkit-scrollbar {
    height: 8px;
}

.responsive-table::-webkit-scrollbar-thumb {
    background: rgba(34, 49, 59, 0.18);
    border-radius: 999px;
}

.table-actions {
    display: flex;
    gap: 0.55rem;
    flex-wrap: wrap;
}

.table-actions form {
    margin: 0;
}

.table-inline-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.5rem;
    align-items: center;
}

.table-inline-form .input {
    min-width: 140px;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.85rem;
}

.badge.success {
    background: rgba(47, 157, 112, 0.14);
    color: var(--color-success);
}

.badge.warning {
    background: rgba(193, 123, 37, 0.14);
    color: var(--color-warning);
}

.badge.status-pedido {
    background: rgba(120, 180, 201, 0.2);
    color: #2f6f86;
}

.badge.status-no_pedido {
    background: rgba(240, 163, 92, 0.18);
    color: #a6641d;
}

.badge.status-falta {
    background: rgba(217, 83, 79, 0.18);
    color: #8d1b18;
}

/* legacy supply badges kept for other modules */
.badge.status-pendiente {
    background: rgba(240, 163, 92, 0.18);
    color: #a6641d;
}

.badge.status-enviado {
    background: rgba(120, 180, 201, 0.2);
    color: #3c7488;
}

.badge.status-entregado {
    background: rgba(47, 157, 112, 0.18);
    color: #1d6e4b;
}

.pagination {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.pagination .button.secondary {
    min-width: 44px;
    justify-content: center;
}

@media (max-width: 1200px) {
    .main {
        padding: 2.25rem 2.25rem 2.75rem;
    }

    .filters-form {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }
}

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

    .sidebar {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 1.25rem 1.5rem;
        border-right: none;
        border-bottom: 1px solid var(--color-border);
        box-shadow: 0 12px 30px rgba(34, 49, 59, 0.08);
        position: sticky;
        top: 0;
        z-index: 10;
    }

    .sidebar nav {
        flex-direction: row;
        gap: 0.6rem;
        overflow-x: auto;
        padding-bottom: 0.2rem;
    }

    .sidebar nav a {
        padding: 0.6rem 0.85rem;
    }

    .main {
        padding: 2rem 1.75rem 2.75rem;
    }
}

@media (max-width: 768px) {
    .page-header,
    .topbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .filters-toolbar {
        align-items: stretch;
    }

    .filters-form {
        grid-template-columns: 1fr;
    }

    .filters-form .button {
        width: 100%;
    }

    .responsive-table table {
        min-width: 640px;
    }

    .form-actions .button {
        flex: 1 1 auto;
    }
}

@media (max-width: 600px) {
    .sidebar {
        padding: 1rem 1.25rem;
    }

    .sidebar nav a {
        padding: 0.55rem 0.75rem;
        font-size: 0.9rem;
    }

    .main {
        padding: 1.75rem 1.25rem 2.5rem;
    }

    .card {
        padding: 1rem;
    }

    .pagination .button.secondary,
    .table-actions .button {
        flex: 1 1 auto;
    }
}
