:root {
    --brand: #1f5130;
    --brand-dark: #163c23;
    --accent: #769203;
    --bg: #f4f6f3;
    --surface: #ffffff;
    --border: #e1e5df;
    --text: #1f2a22;
    --muted: #6b766d;
    --danger: #b42318;
    --danger-bg: #fef3f2;
    --radius: 10px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Instrument Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

a {
    color: var(--brand);
}

/* Buttons and form controls */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: 8px;
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s;
}

.btn-primary {
    color: #fff;
    background: var(--brand);
}

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

.btn-ghost {
    color: var(--text);
    background: transparent;
    border-color: var(--border);
}

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

.btn-block {
    width: 100%;
}

.field {
    margin-bottom: 18px;
}

.field label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 14px;
}

.field input[type='text'],
.field input[type='email'],
.field input[type='url'],
.field input[type='number'],
.field input[type='password'],
.field input[type='search'],
.field input[type='tel'],
.field input[type='date'],
.field select,
.field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
    color: var(--text);
    background: #fff;
}

.field textarea {
    resize: vertical;
    line-height: 1.6;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(31, 81, 48, 0.15);
}

.field-error {
    margin-top: 6px;
    font-size: 13px;
    color: var(--danger);
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 22px;
    font-size: 14px;
    color: var(--muted);
}

.checkbox input {
    accent-color: var(--brand);
}

.checkbox-list {
    margin: 0 0 18px;
    padding: 0;
    border: 0;
}

.checkbox-list legend {
    margin-bottom: 10px;
    padding: 0;
    font-weight: 600;
    font-size: 14px;
}

.checkbox-list .checkbox {
    margin-bottom: 8px;
}

.alert {
    margin-bottom: 18px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
    color: var(--danger);
    background: var(--danger-bg);
}

/* Login page */

.auth-page {
    display: flex;
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background: linear-gradient(160deg, var(--brand) 0%, var(--brand-dark) 55%, #0f2a18 100%);
}

.auth-card {
    width: 100%;
    max-width: 400px;
    padding: 36px 32px;
    border-radius: 14px;
    background: var(--surface);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

.auth-logo {
    display: block;
    max-width: 240px;
    height: auto;
    margin: 0 auto 24px;
}

.auth-card h1 {
    margin: 0 0 4px;
    font-size: 20px;
    text-align: center;
}

.auth-card .subtitle {
    margin: 0 0 26px;
    font-size: 14px;
    text-align: center;
    color: var(--muted);
}

.auth-footer {
    margin-top: 20px;
    font-size: 12px;
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
}

/* Admin layout */

.admin-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    flex: 0 0 250px;
    flex-direction: column;
    width: 250px;
    height: 100vh;
    border-right: 1px solid var(--border);
    background: var(--surface);
}

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

.sidebar-logo img {
    display: block;
    height: 34px;
    width: auto;
}

.sidebar-foot {
    padding: 14px 16px 16px;
    border-top: 1px solid var(--border);
}

.sidebar-foot form {
    margin: 0;
}

.sidebar-user-name {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}

.sidebar-user-email {
    margin: 0 0 10px;
    font-size: 12px;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.admin-main {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
}

/* Mobile menu controls, hidden on wide screens */

.sidebar-toggle {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
}

.topbar,
.sidebar-open,
.sidebar-close,
.sidebar-scrim {
    display: none;
}

.sidebar-open,
.sidebar-close {
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    background: var(--surface);
    cursor: pointer;
}

.sidebar-open svg,
.sidebar-close svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    align-items: center;
    gap: 14px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.topbar-title {
    font-size: 15px;
    font-weight: 600;
}

.container {
    width: 100%;
    max-width: 1140px;
    margin: 0 auto;
    padding: 32px 28px 48px;
}

.page-header {
    margin-bottom: 28px;
}

.page-header h1 {
    margin: 0 0 4px;
    font-size: 26px;
}

.page-header p {
    margin: 0;
    color: var(--muted);
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 18px;
    margin-bottom: 28px;
}

.card {
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.card-label {
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--muted);
}

.card-value {
    margin: 0;
    font-size: 28px;
    font-weight: 700;
    color: var(--brand);
}

.card-value.small {
    font-size: 16px;
    word-break: break-all;
}

.card-note {
    margin: 6px 0 0;
    font-size: 13px;
    color: var(--muted);
}

.dashboard-heading {
    margin: 0 0 12px;
    font-size: 16px;
}

.card-link {
    display: block;
    color: inherit;
    text-decoration: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.card-link:hover,
.card-link:focus-visible {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(31, 81, 48, 0.12);
}

.card-warning {
    border-color: #f3c8c4;
    background: var(--danger-bg);
}

.card-warning .card-value {
    color: var(--danger);
}

.panel-heading-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 16px;
}

.panel-heading-row h2 {
    margin: 0;
}

.panel {
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.panel h2 {
    margin: 0 0 8px;
    font-size: 18px;
}

.panel p {
    margin: 0;
    color: var(--muted);
}

.field-hint {
    margin: 6px 0 0;
    font-size: 13px;
    color: var(--muted);
}

.alert-success {
    color: var(--brand);
    background: #ecf5ee;
}

/* Navigation */

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px 20px;
}

.sidebar-group {
    margin: 20px 0 6px;
    padding: 0 12px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.sidebar-nav a {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    color: var(--muted);
    transition: color 0.15s, background-color 0.15s;
}

.sidebar-nav a + a {
    margin-top: 2px;
}

.sidebar-nav svg {
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sidebar-nav a:hover {
    color: var(--text);
    background: var(--bg);
}

.sidebar-nav a.active {
    color: var(--brand);
    background: #ecf5ee;
}

.sidebar-nav a.active::before {
    content: '';
    position: absolute;
    top: 50%;
    left: -12px;
    width: 3px;
    height: 22px;
    transform: translateY(-50%);
    border-radius: 0 3px 3px 0;
    background: var(--accent);
}

/* Page pieces */

.page-header-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
}

.breadcrumb {
    margin: 0 0 8px !important;
    font-size: 14px;
}

.breadcrumb a {
    text-decoration: none;
}

.form-panel {
    max-width: 520px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table th,
.table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    white-space: nowrap;
}

.table th {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--muted);
    background: #fafbf9;
}

.table tbody tr:last-child td {
    border-bottom: 0;
}

.badge {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    color: var(--brand);
    background: #ecf5ee;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-top: 20px;
    font-size: 14px;
    color: var(--muted);
}

/* Banners */

.field input[type='file'] {
    display: block;
    width: 100%;
    padding: 10px;
    border: 1px dashed var(--border);
    border-radius: 8px;
    font: inherit;
    font-size: 14px;
    background: #fafbf9;
}

.field .optional {
    font-weight: 400;
    color: var(--muted);
}

.banner-thumb {
    display: block;
    width: 180px;
    height: auto;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    border-radius: 6px;
    background: var(--bg);
}

.logo-thumb {
    display: block;
    width: 96px;
    height: 48px;
    object-fit: contain;
}

.logo-preview {
    display: block;
    max-width: 240px;
    max-height: 120px;
    margin-bottom: 10px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    object-fit: contain;
}

.cell-note-wide {
    max-width: 520px;
    white-space: normal;
}

.banner-preview {
    display: block;
    width: 100%;
    height: auto;
    margin-bottom: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.cell-note {
    max-width: 280px;
    overflow: hidden;
    font-size: 12px;
    text-overflow: ellipsis;
    color: var(--muted);
}

.badge-blocked {
    color: var(--danger);
    background: var(--danger-bg);
}

.badge-muted {
    color: var(--muted);
    background: #eef0ed;
}

.text-right {
    text-align: right !important;
}

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

.row-actions form {
    margin: 0;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-danger {
    color: var(--danger);
    background: transparent;
    border-color: #f3c8c4;
}

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

.empty-state {
    text-align: center;
}

.empty-state p {
    margin-bottom: 18px;
}

.table td {
    vertical-align: middle;
}

/* Product categories */

.wide-form {
    max-width: 820px;
}

.form-section {
    margin-bottom: 20px;
}

.form-section > h2,
.section-heading h2 {
    margin: 0 0 18px;
    font-size: 18px;
}

.section-heading p {
    margin: -10px 0 18px;
    font-size: 14px;
}

.field-row {
    max-width: 200px;
}

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

.highlight-row {
    display: grid;
    grid-template-columns: 140px minmax(0, 1fr) minmax(0, 2fr);
    gap: 0 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}

.highlight-row:last-child {
    border-bottom: 0;
    margin-bottom: 0;
}

.panel-item-row {
    display: grid;
    grid-template-columns: 160px minmax(0, 1fr);
    gap: 0 12px;
}

@media (max-width: 760px) {
    .field-pair,
    .panel-item-row,
    .highlight-row {
        grid-template-columns: minmax(0, 1fr);
    }
}

.category-thumb {
    display: block;
    width: 140px;
    height: auto;
    aspect-ratio: 735 / 210;
    object-fit: cover;
    border-radius: 6px;
    background: var(--bg);
}

.recipe-thumb {
    display: block;
    width: 96px;
    height: auto;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 6px;
    background: var(--bg);
}

.recipe-preview {
    display: block;
    width: 100%;
    max-width: 360px;
    height: auto;
    margin-bottom: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.category-preview {
    display: block;
    width: 100%;
    max-width: 735px;
    height: auto;
    margin-bottom: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.product-groups,
.recipe-sections {
    display: grid;
    gap: 16px;
    margin-bottom: 16px;
}

.product-group,
.recipe-section {
    padding: 16px 18px 2px;
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    background: #fafbf9;
}

.product-group-header,
.recipe-section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.product-group-number,
.recipe-section-number {
    font-weight: 700;
}

.product-count {
    flex: 1;
    font-size: 13px;
    color: var(--muted);
}

/* Date picker */

.datefield {
    position: relative;
    display: block;
}

.field .datefield input[type='date'] {
    padding-right: 34px;
}

.datefield input[type='date']::-webkit-calendar-picker-indicator {
    display: none;
}

.datefield input[type='date']::-webkit-inner-spin-button {
    display: none;
}

.datefield-button {
    position: absolute;
    top: 50%;
    right: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    transform: translateY(-50%);
    border: 0;
    border-radius: 6px;
    color: var(--muted);
    background: transparent;
    cursor: pointer;
}

.datefield-button:hover {
    color: var(--brand);
    background: #ecf5ee;
}

.datefield-button svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.datepicker {
    position: absolute;
    z-index: 40;
    width: 280px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 16px 40px rgba(16, 30, 20, 0.18);
}

.datepicker[hidden] {
    display: none;
}

.datepicker-head {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
}

.datepicker-nav {
    display: flex;
    flex: 0 0 28px;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    background: var(--surface);
    cursor: pointer;
}

.datepicker-nav:hover {
    background: var(--bg);
}

.datepicker-nav svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.datepicker-month,
.datepicker-year {
    height: 28px;
    padding: 0 4px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    background: var(--surface);
    cursor: pointer;
}

.datepicker-month {
    flex: 1;
    min-width: 0;
}

.datepicker-weekdays,
.datepicker-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.datepicker-weekdays span {
    padding: 4px 0;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-align: center;
    text-transform: uppercase;
    color: var(--muted);
}

.datepicker-day {
    padding: 0;
    height: 32px;
    border: 0;
    border-radius: 6px;
    font: inherit;
    font-size: 13px;
    color: var(--text);
    background: transparent;
    cursor: pointer;
}

.datepicker-day:hover:not(:disabled) {
    background: var(--bg);
}

.datepicker-day.is-outside {
    color: #aab3ab;
}

.datepicker-day.is-today {
    font-weight: 700;
    box-shadow: inset 0 0 0 1px var(--border);
}

.datepicker-day.is-selected {
    color: #fff;
    font-weight: 700;
    background: var(--brand);
    box-shadow: none;
}

.datepicker-day:disabled {
    color: #c7cec8;
    cursor: default;
}

.datepicker-day:focus-visible,
.datepicker-nav:focus-visible,
.datefield-button:focus-visible,
.datepicker-action:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 1px;
}

.datepicker-foot {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.datepicker-action {
    padding: 4px 8px;
    border: 0;
    border-radius: 6px;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--brand);
    background: transparent;
    cursor: pointer;
}

.datepicker-action:hover {
    background: #ecf5ee;
}

/* Enquiries */

.details {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 10px 16px;
    margin: 0 0 24px;
    font-size: 14px;
}

.details dt {
    color: var(--muted);
}

.details dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.enquiry-message {
    white-space: pre-line;
    line-height: 1.7;
    overflow-wrap: anywhere;
}

.filters {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) repeat(4, minmax(150px, 1fr)) auto;
    align-items: end;
    gap: 0 12px;
    margin-bottom: 20px;
    padding: 18px 20px 0;
}

.filters-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 18px;
}

.badge-new {
    color: #5c4a00;
    background: #fff4c2;
}

.enquiry-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-top: 20px;
}

.inline-form {
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

.inline-form .field {
    margin-bottom: 0;
}

.filters-compact {
    grid-template-columns: minmax(0, 1fr) auto;
}

.product-list-file {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px 24px;
    margin-bottom: 28px;
}

.product-list-file h2 {
    margin: 0 0 8px;
    font-size: 18px;
}

.product-list-file p {
    margin: 0;
}

.product-list-heading h2 {
    margin: 0 0 4px;
    font-size: 20px;
}

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

    .filters-search,
    .filters-actions {
        grid-column: 1 / -1;
    }
}

@media (max-width: 960px) {
    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        height: 100%;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.2);
    }

    .topbar,
    .sidebar-open,
    .sidebar-close {
        display: flex;
    }

    .sidebar-toggle:checked ~ .admin-shell .sidebar {
        transform: none;
    }

    .sidebar-toggle:checked ~ .admin-shell .sidebar-scrim {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 15;
        background: rgba(15, 25, 18, 0.45);
    }

    .sidebar-toggle:focus-visible ~ .admin-shell .sidebar-open {
        outline: 2px solid var(--brand);
        outline-offset: 2px;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 24px 16px 40px;
    }

    .auth-card {
        padding: 28px 20px;
    }
}
