:root {
    --bg: #f3f5f9;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #d8dee9;
    --primary: #1d4ed8;
    --primary-dark: #1e40af;
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #d97706;
    --info: #0f766e;
    --yellow: #f5b301;
    --radius: 12px;
    --shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.container {
    width: min(1280px, calc(100% - 32px));
    margin: 24px auto;
}

.page-header {
    margin-bottom: 20px;
}

.page-header h1 {
    margin: 0 0 6px;
    font-size: 28px;
}

.page-header p {
    margin: 0;
    color: var(--muted);
}

.topbar {
    background: #0f172a;
    color: #fff;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar-inner {
    width: min(1280px, calc(100% - 32px));
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 0;
    flex-wrap: wrap;
}

.brand {
    color: #fff;
    font-weight: 700;
    font-size: 18px;
    text-decoration: none;
}

.brand:hover {
    text-decoration: none;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.main-nav > a,
.nav-dropdown summary {
    color: #dbeafe;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    list-style: none;
}

.main-nav > a:hover,
.nav-dropdown summary:hover {
    background: rgba(255, 255, 255, 0.1);
    text-decoration: none;
}

.nav-dropdown {
    position: relative;
}

.nav-dropdown summary::-webkit-details-marker {
    display: none;
}

.dropdown-panel {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 220px;
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
    overflow: hidden;
    padding: 6px;
}

.dropdown-panel a {
    display: block;
    padding: 9px 10px;
    color: var(--text);
    border-radius: 8px;
}

.dropdown-panel a:hover {
    background: #eff6ff;
    text-decoration: none;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.user-name {
    font-weight: 700;
}

.user-role {
    color: #cbd5e1;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    margin-bottom: 20px;
}

.card h2 {
    margin: 0 0 14px;
    font-size: 20px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.card-header h2 {
    margin: 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    margin-bottom: 0;
}

.stat-card h3 {
    margin: 0 0 8px;
    font-size: 14px;
    color: var(--muted);
}

.stat-value {
    font-size: 30px;
    font-weight: 700;
}

.form {
    max-width: 100%;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
    margin-bottom: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-weight: 700;
}

.form-group small {
    color: var(--muted);
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="time"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    color: var(--text);
    outline: none;
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12);
}

input[readonly] {
    background: #f8fafc;
    color: var(--muted);
}

.checkbox-group {
    justify-content: flex-end;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 400;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 10px;
}

.checkbox-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
    background: #fff;
}

.checkbox-item small {
    display: block;
    color: var(--muted);
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    display: inline-block;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    padding: 10px 14px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 700;
    text-decoration: none;
    line-height: 1;
}

.btn:hover {
    text-decoration: none;
    opacity: 0.92;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.btn-success {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}

.btn-warning {
    background: var(--warning);
    border-color: var(--warning);
    color: #fff;
}

.btn-secondary {
    background: #6b7280;
    border-color: #6b7280;
    color: #fff;
}

.btn-yellow {
    background: var(--yellow);
    border-color: var(--yellow);
    color: #1f2937;
}

.btn-block {
    width: 100%;
}

.btn.small {
    padding: 7px 10px;
    font-size: 12px;
    border-radius: 8px;
}

.table-responsive {
    overflow: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

th,
td {
    border: 1px solid var(--border);
    padding: 10px;
    vertical-align: top;
    text-align: left;
}

th {
    background: #f8fafc;
    white-space: nowrap;
}

tbody tr:nth-child(even) {
    background: #fafcff;
}

.action-cell {
    min-width: 150px;
    white-space: nowrap;
}

.inline-form {
    display: inline-block;
    margin-left: 6px;
}

.badge {
    display: inline-block;
    padding: 5px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    margin: 1px 0;
}

.badge-prepared {
    background: #64748b;
}

.badge-checked {
    background: var(--warning);
}

.badge-approved {
    background: var(--success);
}

.badge-cleaning {
    background: var(--info);
}

.alert {
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 16px;
    border: 1px solid transparent;
}

.alert-success {
    background: #f0fdf4;
    color: #166534;
    border-color: #bbf7d0;
}

.alert-error {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}

.subnav {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.subnav a {
    padding: 8px 12px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid var(--border);
    color: var(--text);
}

.subnav a:hover {
    background: #eff6ff;
    text-decoration: none;
}

.filter-box {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-box select {
    width: auto;
}

.text-muted {
    color: var(--muted);
}

.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
    background: linear-gradient(135deg, #0f172a, #1d4ed8);
}

.login-box {
    width: min(430px, 100%);
    background: #fff;
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 28px;
}

.login-box h1 {
    margin: 0 0 6px;
    font-size: 22px;
}

.login-box h2 {
    margin: 0 0 18px;
    font-size: 16px;
    color: var(--muted);
}

.login-demo {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px dashed var(--border);
    color: var(--muted);
}

.login-demo p {
    margin: 4px 0;
}

/* ================================
   v2: subnav active & bar chart
   ================================ */

.subnav a.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    padding: 10px 0 0;
    min-height: 260px;
    border-bottom: 2px solid var(--border);
    overflow-x: auto;
}

.bar-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    min-width: 60px;
}

.bar-value {
    font-weight: 700;
}

.bar {
    width: 100%;
    max-width: 70px;
    background: linear-gradient(180deg, #3b82f6, #1d4ed8);
    border-radius: 8px 8px 0 0;
}

.bar-label {
    color: var(--muted);
    font-size: 12px;
    padding-top: 6px;
}

.bar-shots {
    color: var(--muted);
    font-size: 11px;
}

/* ================================
   v3: toolbar form & pagination
   ================================ */

.toolbar-form {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.toolbar-form label {
    font-weight: 700;
}

.toolbar-form select {
    width: auto;
}

.pagination {
    margin-top: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.page-info {
    color: var(--muted);
    font-size: 12px;
}

.page-links {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.page-item {
    padding: 7px 11px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font-weight: 700;
    text-decoration: none;
}

.page-item:hover {
    background: #eff6ff;
    text-decoration: none;
}

.page-item.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.page-item.disabled {
    opacity: 0.45;
    pointer-events: none;
    background: #f8fafc;
}

/* ================================
   v4: toast floating & modal cleaning
   ================================ */

.toast-container {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(380px, calc(100% - 32px));
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid transparent;
    border-left-width: 5px;
    box-shadow: var(--shadow);
    font-weight: 600;
    background: #fff;
    animation: toast-in 0.25s ease-out;
}

.toast-success {
    background: #f0fdf4;
    color: #166534;
    border-color: #bbf7d0;
    border-left-color: var(--success);
}

.toast-error {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
    border-left-color: var(--danger);
}

.toast-close {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    font-size: 18px;
    line-height: 1;
    opacity: 0.6;
    padding: 0 2px;
}

.toast-close:hover {
    opacity: 1;
}

.toast.hide {
    animation: toast-out 0.3s ease-in forwards;
}

@keyframes toast-in {
    from {
        transform: translateX(40px);
        opacity: 0;
    }
    to {
        transform: none;
        opacity: 1;
    }
}

@keyframes toast-out {
    from {
        opacity: 1;
    }
    to {
        transform: translateX(40px);
        opacity: 0;
    }
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 2500;
}

.modal-overlay.open {
    display: flex;
}

.modal {
    width: min(560px, 100%);
    background: #fff;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 25px 60px rgba(15, 23, 42, 0.35);
    animation: toast-in 0.2s ease-out;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 16px;
    background: var(--yellow);
    color: #1f2937;
    font-weight: 800;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    color: #1f2937;
    opacity: 0.7;
}

.modal-close:hover {
    opacity: 1;
}

.modal-body {
    padding: 16px;
}

.modal-info {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 14px;
    display: grid;
    gap: 6px;
}

.modal-info .row {
    display: flex;
    gap: 6px;
}

.modal-info .label {
    font-weight: 700;
    min-width: 70px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 0 16px 16px;
}

.required {
    color: var(--danger);
}

.field-error {
    border-color: var(--danger) !important;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15) !important;
}

@media (max-width: 768px) {
    .topbar-inner {
        align-items: flex-start;
    }

    .main-nav {
        width: 100%;
    }

    .user-info {
        width: 100%;
        justify-content: flex-start;
    }

    .checkbox-group {
        justify-content: flex-start;
    }
}