:root {
    color-scheme: light;
    --bg: #f4f6f9;
    --surface: #ffffff;
    --border: #e2e6ec;
    --text: #1c2333;
    --text-muted: #6b7280;
    --primary: #2f6feb;
    --primary-hover: #2558c4;
    --primary-contrast: #ffffff;
    --success: #1c9d6f;
    --danger: #d84343;
    --radius-lg: 16px;
    --radius-md: 10px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 12px rgba(16, 24, 40, .06);
    font-size: 16px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Header */
.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.site-header__brand {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

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

.site-header__username {
    font-size: .92rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* Page */
.page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px 16px 80px;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0 0 12px;
}

/* Buttons */
.btn {
    appearance: none;
    display: inline-block;
    border: none;
    border-radius: var(--radius-md);
    font-size: .95rem;
    font-weight: 600;
    padding: 12px 18px;
    cursor: pointer;
    text-decoration: none;
    transition: background .12s ease, transform .06s ease;
}

.btn:active { transform: scale(.98); }

.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

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

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

.btn--secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn--secondary:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn--login {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 10px 18px;
}

.btn--login:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn--plus {
    flex-shrink: 0;
    width: 46px;
    height: 46px;
    padding: 0;
    font-size: 1.4rem;
    line-height: 1;
    background: var(--surface);
    color: var(--primary);
    border: 1px solid var(--border);
}

.btn--plus:hover { border-color: var(--primary); }

/* Search bar section */
.search-bar-section { margin-bottom: 20px; }

.search-bar {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.search-bar__input-wrap {
    position: relative;
    flex: 1 1 auto;
}

.search-bar__input-wrap input[type="text"] {
    width: 100%;
}

input[type="text"] {
    font-size: 1rem;
    padding: 13px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
}

input[type="text"]:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}

.btn--filter {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    flex-shrink: 0;
    position: relative;
    padding: 12px 16px;
}

.btn--filter:hover { border-color: var(--primary); }

.btn--filter__icon {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

.filter-badge {
    background: var(--primary);
    color: #fff;
    font-size: .72rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}

/* Suggestions dropdown (shared by main search + chip searches) */
.suggestions {
    list-style: none;
    margin: 4px 0 0;
    padding: 4px;
    position: absolute;
    z-index: 30;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    max-height: 260px;
    overflow-y: auto;
}

.suggestions li {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: .95rem;
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.suggestions li:hover,
.suggestions li[aria-selected="true"] {
    background: var(--bg);
}

.suggestions li .suggestion__meta {
    color: var(--text-muted);
    font-size: .8rem;
}

.suggestions__group-label {
    padding: 8px 12px 2px;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
}

.suggestions__empty {
    padding: 10px 12px;
    color: var(--text-muted);
    font-size: .9rem;
}

/* Table sections */
.table-section, .totals-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 20px;
}

.table-scroll {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    max-height: 60vh;
    border-radius: var(--radius-md);
}

table {
    border-collapse: collapse;
    width: 100%;
    min-width: 640px;
    font-size: .92rem;
}

.totals-table { min-width: 480px; }

thead th {
    position: sticky;
    top: 0;
    background: var(--bg);
    text-align: left;
    padding: 10px 12px;
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr:hover { background: var(--bg); }

.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 600;
}

.badge--yes {
    background: rgba(28, 157, 111, .12);
    color: var(--success);
}

.badge--no {
    background: rgba(107, 114, 128, .12);
    color: var(--text-muted);
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 24px 12px 8px;
    font-size: .95rem;
}

/* Filter drawer */
.filter-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(16, 24, 40, .45);
    z-index: 40;
}

.filter-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(380px, 100vw);
    background: var(--surface);
    z-index: 50;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform .22s ease;
    box-shadow: -8px 0 24px rgba(16, 24, 40, .12);
}

.filter-drawer.is-open { transform: translateX(0); }

.filter-drawer__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}

.filter-drawer__header h2 {
    margin: 0;
    font-size: 1.1rem;
}

.filter-drawer__close {
    appearance: none;
    border: none;
    background: transparent;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    border-radius: 50%;
}

.filter-drawer__close:hover {
    background: var(--bg);
    color: var(--text);
}

.filter-drawer__body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.filter-drawer__footer {
    display: flex;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.filter-drawer__footer .btn { flex: 1 1 50%; }

.filter-group__label {
    font-size: .8125rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    margin: 0 0 10px;
}

.chip-search {
    display: flex;
    gap: 8px;
}

.chip-search__input-wrap {
    position: relative;
    flex: 1 1 auto;
}

.chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 6px 8px 6px 12px;
    font-size: .88rem;
    font-weight: 500;
}

.chip__remove {
    appearance: none;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.1rem;
    line-height: 1;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
}

.chip__remove:hover {
    background: rgba(216, 67, 67, .12);
    color: var(--danger);
}

/* Order grid */
.order-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.order-btn {
    appearance: none;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 1rem;
    font-weight: 600;
    padding: 12px 0;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background .12s ease, color .12s ease, border-color .12s ease;
}

.order-btn:hover { border-color: var(--primary); }

.order-btn[aria-pressed="true"] {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--primary-contrast);
}

/* Checkboxes */
.filter-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    cursor: pointer;
    font-size: .95rem;
}

.filter-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* Responsive */
@media (min-width: 720px) {
    .page { padding-top: 32px; }
}

@media (max-width: 560px) {
    .search-bar { flex-wrap: wrap; }
    .btn--filter { flex: 1 1 auto; justify-content: center; }
    .search-bar__input-wrap { flex: 1 1 100%; }
    .filter-drawer { width: 100vw; }
}
