:root {
    --gustino-primary: #c8332d;
    --gustino-primary-dark: #8f1f19;
    --gustino-success: #198754;
    --gustino-warning: #f59f00;
    --gustino-danger: #dc3545;
    --gustino-info: #2f9ed8;
    --gustino-purple: #8b4bd6;
    --gustino-muted: #6c757d;
    --gustino-bg: #f7f8fb;
    --gustino-card-radius: 0.95rem;
    --gustino-border: #e9edf3;
    --gustino-shadow: 0 0.6rem 1.8rem rgba(19, 27, 44, 0.07);
}

body {
    background:
        radial-gradient(circle at top left, rgba(200, 51, 45, 0.05), transparent 30rem),
        var(--gustino-bg);
    color: #1f2933;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    min-height: 100vh;
}

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-main {
    flex: 1;
    padding-bottom: 2.5rem;
}

.app-header {
    background: #fff;
    border-bottom: 1px solid var(--gustino-border);
    box-shadow: 0 0.25rem 1.2rem rgba(19, 27, 44, 0.06);
    z-index: 1020;
}

.app-header-top {
    background: #fff;
    padding: 0.7rem 0;
}

.app-header-row {
    align-items: center;
    display: flex;
    gap: 1rem;
}

.app-header-menu {
    flex: 1 1 auto;
    min-width: 0;
}

.app-user-actions {
    align-items: center;
    display: flex;
    flex: 0 0 auto;
    gap: 1rem;
    margin-left: auto;
}

.brand-lockup {
    align-items: center;
    color: #1f2933;
    display: inline-flex;
    gap: 0.75rem;
    text-decoration: none;
}

.brand-mark {
    align-items: center;
    background: linear-gradient(135deg, #fff1ef, #ffe2df);
    border: 1px solid rgba(200, 51, 45, 0.18);
    border-radius: 1rem;
    color: var(--gustino-primary);
    display: inline-flex;
    font-size: 0.8rem;
    font-weight: 900;
    height: 2.75rem;
    justify-content: center;
    letter-spacing: -0.04em;
    width: 2.75rem;
}

.brand-mark-lg {
    border-radius: 1.25rem;
    font-size: 1.05rem;
    height: 3.4rem;
    width: 3.4rem;
}

.brand-text {
    display: flex;
    flex-direction: column;
    font-size: 0.95rem;
    font-weight: 900;
    letter-spacing: 0.04em;
    line-height: 1.05;
    text-transform: uppercase;
}

.brand-text small {
    color: var(--gustino-primary);
    font-size: 0.85rem;
    letter-spacing: 0.12em;
}

.user-chip {
    align-items: center;
    gap: 0.65rem;
}

.user-avatar {
    align-items: center;
    background: #fff1ef;
    border-radius: 50%;
    color: var(--gustino-primary);
    display: inline-flex;
    font-weight: 800;
    height: 2.35rem;
    justify-content: center;
    width: 2.35rem;
}

.user-chip strong,
.user-chip small {
    display: block;
    line-height: 1.15;
}

.user-chip small {
    color: var(--gustino-muted);
    font-size: 0.72rem;
}

.app-nav-list {
    display: flex;
    gap: 0.25rem;
    justify-content: flex-start;
    list-style: none;
    margin: 0;
    padding-left: 0;
    width: 100%;
}

.app-nav-list .nav-item {
    list-style: none;
}

.app-menu-toggler {
    display: none;
}

.app-header-menu .nav-link {
    align-items: center;
    border-bottom: 3px solid transparent;
    border-radius: 0.85rem;
    color: #344054;
    display: flex;
    font-size: 0.78rem;
    font-weight: 500;
    gap: 0.4rem;
    min-height: 2.5rem;
    padding: 0.55rem 0.65rem;
}

.app-header-menu .nav-link:hover,
.app-header-menu .nav-link:focus {
    background: #fbfbfc;
    color: var(--gustino-primary);
}

.app-header-menu .nav-link.active {
    background: rgba(200, 51, 45, 0.07);
    border-bottom-color: var(--gustino-primary);
    color: var(--gustino-primary);
}

.nav-icon {
    align-items: center;
    background: #f3f5f8;
    border-radius: 50%;
    display: inline-flex;
    font-size: 0.65rem;
    font-weight: 800;
    height: 1.2rem;
    justify-content: center;
    width: 1.2rem;
}

.page-title,
h1.h3,
h1.h4 {
    letter-spacing: -0.03em;
}

.page-title {
    font-size: clamp(1.55rem, 2vw, 2rem);
    font-weight: 800;
}

.app-page-header {
    align-items: center;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    width: 100%;
}

.eyebrow {
    color: var(--gustino-primary);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.card {
    border: 1px solid var(--gustino-border);
    border-radius: var(--gustino-card-radius);
}

.card.shadow-sm,
.shadow-sm {
    box-shadow: var(--gustino-shadow) !important;
}

.btn-primary {
    --bs-btn-bg: var(--gustino-primary);
    --bs-btn-border-color: var(--gustino-primary);
    --bs-btn-hover-bg: var(--gustino-primary-dark);
    --bs-btn-hover-border-color: var(--gustino-primary-dark);
}

.table > :not(caption) > * > * {
    padding: 0.9rem 1rem;
}

.data-table-card {
    border: 0;
    box-shadow: var(--gustino-shadow);
    width: 100%;
}

.data-table-card .card-body {
    padding: 1.25rem;
}

.table-card-toolbar {
    align-items: center;
    background: #f8fafc;
    border: 1px solid var(--gustino-border);
    border-radius: 0.9rem;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding: 0.85rem 1rem;
}

.filter-field {
    flex: 1 1 18rem;
}

.filter-field .form-label {
    color: #344054;
    font-size: 0.82rem;
    font-weight: 800;
    margin-bottom: 0.35rem;
}

.filter-actions {
    align-items: end;
    display: flex;
    flex: 0 0 auto;
    gap: 0.6rem;
}

.equipment-filter-toolbar {
    align-items: end;
}

.table-responsive-app {
    border: 1px solid var(--gustino-border);
    border-radius: 0.95rem;
    overflow: hidden;
}

.app-table {
    min-width: 760px;
    table-layout: fixed;
    width: 100%;
}

.app-table thead th {
    background: #f8fafc;
    border-bottom: 1px solid var(--gustino-border);
    color: #344054;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.app-table tbody tr:hover {
    background: #fbfcfe;
}

.app-table td,
.app-table th {
    vertical-align: middle;
    word-break: break-word;
}

.app-table .col-drag {
    width: 7rem;
}

.app-table .col-photo {
    width: 8rem;
}

.app-table .col-main {
    width: auto;
}

.app-table .col-status {
    width: 8rem;
}

.app-table .col-actions {
    width: 21rem;
}

.zone-table {
    min-width: 880px;
}

.zone-table .col-main {
    width: auto;
}

.form-control,
.form-select {
    border-radius: 0.75rem;
}

.badge-status-done,
.badge-status-success {
    background: var(--gustino-success);
    color: #fff;
}

.badge-status-todo {
    background: #e9ecef;
    color: #344054;
}

.badge-status-late,
.badge-status-danger {
    background: var(--gustino-danger);
    color: #fff;
}

.badge-status-anomaly {
    background: var(--gustino-warning);
    color: #111827;
}

.badge-status-impossible {
    background: #343a40;
    color: #fff;
}

.dashboard-card {
    border: 0;
    overflow: hidden;
}

.dashboard-card .display-6 {
    line-height: 1;
}

.login-page {
    min-height: calc(100vh - 9rem);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    border: 0;
    border-radius: 1.25rem;
    box-shadow: var(--gustino-shadow);
}

.login-shell {
    background: #fff;
    border: 1px solid var(--gustino-border);
    border-radius: 1.4rem;
    box-shadow: 0 1rem 3rem rgba(19, 27, 44, 0.08);
    display: grid;
    grid-template-columns: minmax(16rem, 0.9fr) minmax(18rem, 1fr);
    max-width: 62rem;
    overflow: hidden;
    width: min(100%, 62rem);
}

.login-brand-panel {
    background:
        radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.35), transparent 12rem),
        linear-gradient(135deg, var(--gustino-primary), var(--gustino-primary-dark));
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 29rem;
    padding: 3rem;
}

.login-brand-panel .brand-mark {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.3);
    color: #fff;
    margin-bottom: 1.5rem;
}

.login-brand-panel h1 {
    font-size: clamp(1.8rem, 3vw, 2.6rem);
    font-weight: 900;
    letter-spacing: -0.04em;
    line-height: 1;
    margin-bottom: 1rem;
}

.login-brand-panel p {
    color: rgba(255, 255, 255, 0.82);
    margin: 0;
}

.login-form-panel {
    align-items: center;
    display: flex;
    padding: 2rem;
}

.login-form-panel .login-card {
    width: 100%;
}

.app-footer {
    background: transparent;
    border-top: 0;
    color: var(--gustino-muted);
}

.dashboard-hero {
    align-items: center;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

.dashboard-date {
    align-items: center;
    background: #fff;
    border: 1px solid var(--gustino-border);
    border-radius: 0.8rem;
    box-shadow: 0 0.25rem 1rem rgba(19, 27, 44, 0.05);
    color: #475467;
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
}

.dashboard-date small {
    color: var(--gustino-muted);
}

.section-heading {
    align-items: center;
    display: flex;
    gap: 0.65rem;
}

.section-heading span {
    background: var(--gustino-primary);
    border-radius: 999px;
    display: inline-block;
    height: 1.35rem;
    width: 0.22rem;
}

.section-heading h2,
.section-heading h3 {
    font-size: 1rem;
    font-weight: 800;
    margin: 0;
}

.section-heading-sm h3 {
    font-size: 0.95rem;
}

.haccp-overview-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.haccp-overview-grid .stat-card:nth-child(n+5) {
    grid-column: span 1;
}

.stat-card {
    border: 0;
    box-shadow: var(--gustino-shadow);
    overflow: hidden;
    position: relative;
}

.stat-card::after {
    background: currentColor;
    bottom: 0.75rem;
    content: "";
    height: 0.22rem;
    left: 1rem;
    opacity: 0.9;
    position: absolute;
    right: 1rem;
}

.stat-card .card-body {
    align-items: flex-start;
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem;
    min-height: 6.15rem;
    padding: 1rem 1.1rem;
}

.stat-icon,
.admin-icon,
.quick-icon {
    align-items: center;
    border-radius: 0.8rem;
    display: inline-flex;
    flex: 0 0 auto;
    font-weight: 900;
    height: 2.35rem;
    justify-content: center;
    width: 2.35rem;
}

.stat-label {
    color: #667085;
    font-size: 0.76rem;
    font-weight: 700;
}

.stat-value {
    color: #1f2937;
    font-size: 1.65rem;
    font-weight: 900;
    line-height: 1.1;
}

.stat-progress {
    flex-basis: 100%;
    height: 0.35rem;
    margin-top: 0.15rem;
}

.stat-card-primary,
.stat-card-primary .progress-bar {
    color: #2f80ed;
}

.stat-card-info,
.stat-card-info .progress-bar {
    color: var(--gustino-info);
}

.stat-card-warning,
.stat-card-warning .progress-bar {
    color: var(--gustino-warning);
}

.stat-card-success,
.stat-card-success .progress-bar {
    color: var(--gustino-success);
}

.stat-card-danger,
.stat-card-danger .progress-bar {
    color: #e4693d;
}

.stat-card-purple,
.stat-card-purple .progress-bar {
    color: var(--gustino-purple);
}

.stat-progress .progress-bar {
    background-color: currentColor;
}

.stat-card-primary .stat-icon { background: #eef6ff; color: #2f80ed; }
.stat-card-info .stat-icon { background: #eaf8fd; color: var(--gustino-info); }
.stat-card-warning .stat-icon { background: #fff8e6; color: var(--gustino-warning); }
.stat-card-success .stat-icon { background: #eaf7ef; color: var(--gustino-success); }
.stat-card-danger .stat-icon { background: #fff1ed; color: #e4693d; }
.stat-card-purple .stat-icon { background: #f5efff; color: var(--gustino-purple); }

.admin-card {
    border: 0;
    box-shadow: var(--gustino-shadow);
}

.admin-card .card-body {
    padding: 1.35rem;
}

.admin-card-users {
    background:
        radial-gradient(circle at 92% 76%, rgba(200, 51, 45, 0.08), transparent 4rem),
        #fff6f6;
}

.admin-icon {
    background: #ffe5e2;
    color: var(--gustino-primary);
}

.card-link-arrow {
    color: var(--gustino-primary);
    display: inline-flex;
    font-size: 0.82rem;
    font-weight: 800;
    margin-top: 1.15rem;
    text-decoration: none;
}

.card-link-arrow::after {
    content: "→";
    margin-left: 0.4rem;
}

.empty-state {
    background: #f1fbf5;
    border-radius: 0.85rem;
    color: var(--gustino-success);
    padding: 1rem;
    text-align: center;
}

.app-alert {
    background: #fff;
    border: 1px solid var(--gustino-border);
    border-radius: 0.9rem;
    color: #667085;
}

.quick-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
}

.quick-card {
    align-items: center;
    background: #fff;
    border: 1px solid var(--gustino-border);
    border-radius: 0.9rem;
    box-shadow: 0 0.25rem 1rem rgba(19, 27, 44, 0.05);
    color: #1f2937;
    display: flex;
    gap: 0.8rem;
    padding: 1rem;
    text-decoration: none;
    transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.quick-card:hover {
    box-shadow: var(--gustino-shadow);
    color: #1f2937;
    transform: translateY(-2px);
}

.quick-card strong,
.quick-card small {
    display: block;
}

.quick-card small {
    color: var(--gustino-muted);
    font-size: 0.74rem;
}

.quick-arrow {
    color: var(--gustino-muted);
    margin-left: auto;
}

.quick-card-danger .quick-icon { background: #fff1ed; color: var(--gustino-primary); }
.quick-card-primary .quick-icon { background: #eef6ff; color: #2f80ed; }
.quick-card-purple .quick-icon { background: #f5efff; color: var(--gustino-purple); }
.quick-card-success .quick-icon { background: #eaf7ef; color: var(--gustino-success); }
.quick-card-warning .quick-icon { background: #fff8e6; color: var(--gustino-warning); }

.drag-handle {
    align-items: center;
    background: #f3f5f8;
    border-radius: 0.7rem;
    color: #667085;
    cursor: grab;
    display: inline-flex;
    font-weight: 900;
    height: 2rem;
    justify-content: center;
    user-select: none;
    width: 2rem;
}

[data-sortable-zone-row].is-dragging {
    opacity: 0.55;
}

.zone-thumb,
.equipment-thumb {
    border-radius: 0.75rem;
    height: 3.2rem;
    object-fit: cover;
    width: 4.6rem;
}

.zone-thumb-empty,
.equipment-thumb-empty {
    align-items: center;
    background: #f3f5f8;
    color: #98a2b3;
    display: inline-flex;
    font-size: 0.72rem;
    font-weight: 700;
    justify-content: center;
}

.zone-form,
.equipment-form {
    width: 100%;
}

.zone-form-row,
.equipment-form-row {
    align-items: start;
    display: grid;
    gap: 1.25rem;
    grid-template-columns: minmax(15rem, 18rem) minmax(13rem, 16rem) minmax(22rem, 1fr) minmax(10rem, 12rem);
    width: 100%;
}

.zone-form-row .form-label,
.equipment-form-row .form-label {
    color: #344054;
    font-weight: 700;
    margin-bottom: 0.45rem;
}

.zone-form-row .form-control,
.equipment-form-row .form-control {
    width: 100%;
}

.zone-form-description textarea,
.equipment-form-description textarea {
    min-height: 8.9rem;
    resize: vertical;
}

.zone-photo-box,
.equipment-photo-box {
    align-items: center;
    background: #f8fafc;
    border: 1px dashed #d0d5dd;
    border-radius: 1rem;
    color: #98a2b3;
    display: flex;
    font-weight: 700;
    justify-content: center;
    min-height: 8.9rem;
    overflow: hidden;
}

.zone-photo-box img,
.equipment-photo-box img {
    height: 100%;
    min-height: 8.9rem;
    object-fit: cover;
    width: 100%;
}

.zone-active-switch,
.equipment-active-switch {
    background: #f8fafc;
    border: 1px solid var(--gustino-border);
    border-radius: 0.85rem;
    min-height: 3.5rem;
    padding: 0.9rem 0.9rem 0.9rem 2.8rem;
}

.zone-form-actions,
.equipment-form-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

@media (max-width: 1199.98px) {
    .haccp-overview-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .zone-form-row,
    .equipment-form-row {
        grid-template-columns: minmax(14rem, 18rem) minmax(14rem, 1fr);
    }

    .zone-form-description,
    .equipment-form-description {
        grid-column: 1 / -1;
    }
}

@media (max-width: 767.98px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .btn-lg,
    .btn {
        min-height: 44px;
    }

    .table-responsive {
        border-radius: var(--gustino-card-radius);
    }

    .dashboard-hero {
        align-items: flex-start;
        flex-direction: column;
    }

    .dashboard-date {
        width: 100%;
    }

    .app-page-header,
    .table-card-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .app-page-header .btn,
    .table-card-toolbar .btn,
    .filter-actions {
        width: 100%;
    }

    .filter-actions {
        flex-direction: column;
    }

    .haccp-overview-grid {
        grid-template-columns: 1fr;
    }

    .zone-form-row,
    .equipment-form-row {
        grid-template-columns: 1fr;
    }

    .zone-form-description,
    .equipment-form-description {
        grid-column: auto;
    }

    .zone-form-actions,
    .equipment-form-actions {
        flex-direction: column;
    }

    .login-shell {
        grid-template-columns: 1fr;
    }

    .login-brand-panel {
        min-height: auto;
        padding: 2rem;
    }

    .login-form-panel {
        padding: 1rem;
    }

    .app-user-actions {
        gap: 0.5rem;
    }

    .app-menu-toggler {
        display: block;
    }
}

@media (max-width: 1199.98px) {
    .app-header-row {
        flex-wrap: wrap;
    }

    .app-header-menu {
        flex-basis: 100%;
        order: 4;
    }

    .app-nav-list {
        gap: 0.35rem;
        padding: 0.75rem 0 0.25rem;
    }

    .app-header-menu .nav-link {
        border-bottom: 0;
        border-radius: 0.75rem;
        padding: 0.75rem 1rem;
    }

    .app-header-menu .nav-link.active {
        background: rgba(200, 51, 45, 0.1);
    }
}

@media (min-width: 1200px) {
    .app-header-menu.collapse {
        display: flex !important;
    }
}
