/* FoodDesk — base styles */

:root {
    --bg:         #fafaf7;
    --surface:    #ffffff;
    --text:       #1a1a1a;
    --muted:      #6b6b6b;
    --border:     #e5e5e0;
    --primary:    #c0581e;  /* warm crust orange — EU-first brand cue */
    --primary-ink:#ffffff;
    --success-bg: #e6f4ea;
    --success-fg: #1e6b3a;
    --error-bg:   #fdeaea;
    --error-fg:   #9b1c1c;
    --radius:     10px;
    --shadow-sm:  0 1px 2px rgba(0,0,0,0.04);
    --shadow-md:  0 4px 16px rgba(0,0,0,0.06);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

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

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0 0 0.5em; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 600; }

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

/* ---- Flash messages ---- */
.flash {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    box-shadow: var(--shadow-md);
    max-width: 90%;
}
.flash--success { background: var(--success-bg); color: var(--success-fg); }
.flash--error   { background: var(--error-bg);   color: var(--error-fg); }

/* ---- Auth pages ---- */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem 1rem;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem;
    box-shadow: var(--shadow-md);
}
.auth-card--wide { max-width: 480px; }

.auth-brand { text-align: center; margin-bottom: 2rem; }
.auth-brand h1 { margin-bottom: 0.25rem; }
.auth-brand .tagline { color: var(--muted); font-size: 0.95rem; margin: 0; }

/* ---- Forms ---- */
.form { display: flex; flex-direction: column; gap: 1.1rem; }

.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field > span { font-weight: 500; font-size: 0.875rem; }
.field small { color: var(--muted); font-size: 0.8rem; }

input[type="text"],
input[type="email"],
input[type="password"],
select,
textarea {
    font: inherit;
    padding: 0.65rem 0.85rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(192, 88, 30, 0.15);
}

textarea {
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
}

.btn {
    font: inherit;
    font-weight: 500;
    padding: 0.7rem 1.1rem;
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn--primary {
    background: var(--primary);
    color: var(--primary-ink);
}
.btn--primary:hover { background: #a84a18; text-decoration: none; }

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

.form-meta {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    align-items: center;
    font-size: 0.875rem;
    color: var(--muted);
    margin-top: 0.5rem;
}

/* ---- App shell ---- */
.app-body { background: var(--bg); }

.app-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.app-header__inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    height: 60px;
    display: flex;
    align-items: center;
    gap: 2rem;
}
.app-brand { font-weight: 700; font-size: 1.2rem; color: var(--text); }
.app-brand:hover { text-decoration: none; }

.app-nav { display: flex; gap: 1.25rem; flex: 1; }
.app-nav a {
    color: var(--muted);
    font-weight: 500;
    padding: 0.3rem 0;
    border-bottom: 2px solid transparent;
}
.app-nav a:hover { color: var(--text); text-decoration: none; }
.app-nav a.is-active {
    color: var(--text);
    border-bottom-color: var(--primary);
}

.app-logout { margin: 0; }

.app-main { padding: 2.5rem 0; }

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.notice {
    background: #fff7ed;
    border: 1px solid #fbd8b4;
    color: #7c3a0a;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin: 1rem 0 2rem;
    font-size: 0.9rem;
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
    margin-top: 2rem;
}
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
}
.card h2 { margin-bottom: 0.25rem; }
.card .muted { font-size: 0.9rem; margin: 0 0 1rem; }

.site-footer {
    padding: 2rem 1.5rem;
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
}

/* ---- Page head (title + primary action) ---- */
.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.page-head h1 { margin: 0 0 0.15em; }
.page-head .muted { font-size: 0.9rem; margin: 0; }

/* ---- Search bar ---- */
.search-bar {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 1.25rem;
}
.search-bar input[type="search"] {
    flex: 1;
    max-width: 380px;
    padding: 0.55rem 0.8rem;
    font: inherit;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}
.search-bar input[type="search"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(192, 88, 30, 0.15);
}

/* ---- Narrow container variant for forms ---- */
.container--narrow { max-width: 820px; }

/* ---- Tables ---- */
.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-x: auto;
    box-shadow: var(--shadow-sm);
}
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.table thead th {
    text-align: left;
    padding: 0.8rem 1rem;
    font-weight: 600;
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
    background: #fafaf7;
}
.table tbody td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafaf7; }
.table .right { text-align: right; }
.table .mono { font-variant-numeric: tabular-nums; }

/* ---- Inline action form (delete button styled as link) ---- */
.inline-form {
    display: inline;
    margin: 0 0 0 0.75rem;
}
.link-btn {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font: inherit;
    padding: 0;
}
.link-btn:hover { text-decoration: underline; }

/* ---- Pills (for allergen badges) ---- */
.pill {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 500;
    margin: 0 0.2rem 0.2rem 0;
    line-height: 1.4;
}
.pill--allergen {
    background: #fef3e7;
    color: #7c3a0a;
    border: 1px solid #fbd8b4;
}

/* ---- Empty states ---- */
.empty-state {
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 2.5rem 1.5rem;
    text-align: center;
    color: var(--muted);
}
.empty-state p { margin: 0 0 1rem; }
.empty-state .btn { display: inline-flex; }

/* ---- Pager ---- */
.pager {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
    padding: 0 0.5rem;
    font-size: 0.9rem;
}
.pager a { font-weight: 500; }

/* ---- Form as card (for create/edit pages) ---- */
.form--card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow-sm);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.1rem;
    margin-bottom: 1.5rem;
}
.field--full { grid-column: 1 / -1; }

.fieldset {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin: 0 0 1.5rem;
}
.fieldset legend {
    padding: 0 0.5rem;
    font-weight: 600;
    font-size: 0.95rem;
}
.fieldset .small { font-size: 0.85rem; margin: 0 0 1rem; }

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.5rem 1rem;
}
.checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
}
.checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}

.nutrition-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.8rem 1rem;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

input[type="search"],
input[type="number"] {
    font: inherit;
    padding: 0.65rem 0.85rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}
input[type="number"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(192, 88, 30, 0.15);
}

/* ========== Allergen + property tiles ========== */
.subhead {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 1.75rem 0 0.25rem;
}

.legend-chip {
    display: inline-block;
    padding: 0.1rem 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 500;
    margin: 0 0.15rem;
    border: 1px solid transparent;
    vertical-align: middle;
}
.legend-chip--none     { background: #f0f0ec; color: #6b6b6b; border-color: #e5e5e0; }
.legend-chip--contains { background: var(--primary); color: white; }
.legend-chip--may      { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }

.tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 0.6rem;
    margin: 0.75rem 0 0.25rem;
}

.tile {
    position: relative;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 12px;
    padding: 0.75rem 0.5rem 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 0.35rem;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
    min-height: 100px;
}
.tile:hover     { border-color: #b9b9b0; transform: translateY(-1px); }
.tile:focus     { outline: none; box-shadow: 0 0 0 3px rgba(192, 88, 30, 0.2); }

.tile__icon {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.45;
    transition: opacity 0.15s;
}
.tile__icon img { width: 100%; height: 100%; }

.tile__label {
    font-size: 0.72rem;
    font-weight: 500;
    text-align: center;
    line-height: 1.2;
    color: var(--muted);
    transition: color 0.15s;
}

.tile__state {
    position: absolute;
    top: 0.3rem;
    left: 0.5rem;
    right: 0.5rem;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: center;
    line-height: 1.1;
    color: white;
    opacity: 0;
    transition: opacity 0.15s;
}
.tile__state-contains, .tile__state-may { display: none; }

/* Allergen: contains */
.tile--allergen[data-state="contains"] {
    background: var(--primary);
    border-color: var(--primary);
}
.tile--allergen[data-state="contains"] .tile__icon { opacity: 1; filter: brightness(0) invert(1); }
.tile--allergen[data-state="contains"] .tile__label { color: white; font-weight: 700; }
.tile--allergen[data-state="contains"] .tile__state { opacity: 1; }
.tile--allergen[data-state="contains"] .tile__state-contains { display: block; }

/* Allergen: may contain */
.tile--allergen[data-state="may_contain"] {
    background: #dbeafe;
    border-color: #93c5fd;
}
.tile--allergen[data-state="may_contain"] .tile__icon { opacity: 1; }
.tile--allergen[data-state="may_contain"] .tile__label { color: #1e40af; font-weight: 700; }
.tile--allergen[data-state="may_contain"] .tile__state { opacity: 1; color: #1e40af; }
.tile--allergen[data-state="may_contain"] .tile__state-may { display: block; }

/* Property: on */
.tile--property[data-on="1"] {
    background: #e6f4ea;
    border-color: #86c89c;
}
.tile--property[data-on="1"] .tile__icon { opacity: 1; }
.tile--property[data-on="1"] .tile__label { color: #1e6b3a; font-weight: 700; }

/* ========== Pills: may-contain + properties ========== */
.pill--may {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}
.pill--prop {
    background: #e6f4ea;
    color: #1e6b3a;
    border: 1px solid #b5dcc1;
}

/* ========== Brand / logo ========== */
.app-brand {
    display: inline-flex;
    align-items: center;
    padding: 4px 0;
}
.app-brand img {
    display: block;
    height: 28px;
    width: auto;
}
.app-brand:hover { text-decoration: none; opacity: 0.85; }

.auth-logo {
    display: block;
    margin: 0 auto 0.75rem;
}

/* ========== Recipe line items table ========== */
.line-items {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}
.line-items th {
    text-align: left;
    padding: 0.5rem 0.5rem;
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
}
.line-items td {
    padding: 0.4rem 0.5rem 0.4rem 0;
    vertical-align: middle;
}
.line-items td:first-child { padding-left: 0.5rem; }
.line-items select,
.line-items input[type="number"] {
    width: 100%;
    padding: 0.5rem 0.65rem;
    font-size: 0.9rem;
}
.line-items .line-remove {
    font-size: 1.2rem;
    line-height: 1;
    padding: 0.25rem 0.5rem;
    color: var(--muted);
}
.line-items .line-remove:hover { color: var(--error-fg); }

/* ========== Margin colouring ========== */
.margin-good { color: #1e6b3a; font-weight: 600; }
.margin-ok   { color: #7c3a0a; font-weight: 600; }
.margin-low  { color: #9b1c1c; font-weight: 600; }

/* ========== Override tile — "from ingredients" footer ========== */
.tile__base {
    position: absolute;
    bottom: 0.3rem;
    left: 0.5rem;
    right: 0.5rem;
    font-size: 0.58rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: center;
    color: var(--muted);
    opacity: 0.7;
}
.tile--allergen[data-state="contains"] .tile__base,
.tile--allergen[data-state="may_contain"] .tile__base {
    color: currentColor;
    opacity: 0.8;
}
.tile--override { min-height: 110px; }

/* Action separator between table-row actions */
.action-sep {
    color: var(--border);
    margin: 0 0.3rem;
}

/* ========== Customer status badges ========== */
.status {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border: 1px solid transparent;
}
.status--active {
    background: #e6f4ea;
    color: #1e6b3a;
    border-color: #b5dcc1;
}
.status--paused {
    background: #fef3c7;
    color: #7c3a0a;
    border-color: #fde68a;
}
.status--closed {
    background: #f0f0ec;
    color: #6b6b6b;
    border-color: #e5e5e0;
}

/* ========== Delivery-day checkbox pills ========== */
.checkbox-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.3rem;
}
.checkbox-pill {
    position: relative;
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 0.9rem;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
    user-select: none;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--muted);
    transition: all 0.15s;
}
.checkbox-pill input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.checkbox-pill:hover { border-color: #b9b9b0; }
.checkbox-pill:has(input:checked) {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    font-weight: 600;
}

/* ========== Inline field (checkbox + label) ========== */
.field--inline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-direction: row;
}
.field--inline input[type="checkbox"] {
    width: auto;
    margin: 0;
}
.field--inline > span {
    margin: 0;
    font-weight: normal;
}

/* ========== Catalogue page ========== */
.catalogue-table .inline-input {
    width: 100%;
    padding: 0.4rem 0.55rem;
    font-size: 0.9rem;
    text-align: right;
}
.catalogue-table .row-inactive {
    opacity: 0.55;
}
.catalogue-table .row-inactive strong {
    text-decoration: line-through;
}

/* Inline "add recipe" row */
.form-inline-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
}
.field--inline-flex {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    flex: 1;
    min-width: 0;
}
.field--inline-flex > span {
    font-weight: 500;
    margin-bottom: 0;
}

/* Toggle switch */
.switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    vertical-align: middle;
    cursor: pointer;
}
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.switch__slider {
    position: absolute;
    inset: 0;
    background: #d1d1cc;
    border-radius: 999px;
    transition: background 0.15s;
}
.switch__slider::before {
    content: "";
    position: absolute;
    left: 2px;
    top: 2px;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    transition: transform 0.15s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.switch input:checked + .switch__slider {
    background: #1e6b3a;
}
.switch input:checked + .switch__slider::before {
    transform: translateX(16px);
}
.switch input:focus + .switch__slider {
    box-shadow: 0 0 0 3px rgba(30, 107, 58, 0.25);
}

/* Badge for zero-price warning */
.badge {
    display: inline-block;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 600;
    margin-left: 0.35rem;
    vertical-align: middle;
}
.badge--warn {
    background: #fef3c7;
    color: #7c3a0a;
    border: 1px solid #fde68a;
}

/* Generic panel (used for "add recipe" section) */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
}
.panel__title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.75rem 0;
}

/* ========== Order status badges ========== */
.status--open {
    background: #e0edff;
    color: #1e3a8a;
    border-color: #bfdbfe;
}
.status--delivered {
    background: #e6f4ea;
    color: #1e6b3a;
    border-color: #b5dcc1;
}
.status--cancelled {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fecaca;
}

/* ========== Page-head actions cluster ========== */
.page-head__actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

/* ========== Info badge (custom line marker, etc.) ========== */
.badge--info {
    background: #e0edff;
    color: #1e3a8a;
    border: 1px solid #bfdbfe;
}

/* ========== Line adders row ========== */
.line-adders {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

/* ========== Two-panel grid (order show page) ========== */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}
@media (max-width: 720px) {
    .grid-2 { grid-template-columns: 1fr; }
}

/* ========== Key-value list ========== */
dl.kv {
    margin: 0;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.3rem 1rem;
}
dl.kv dt {
    color: var(--muted);
    font-size: 0.85rem;
}
dl.kv dd {
    margin: 0;
}

/* tfoot totals on order show */
.table tfoot td { padding: 0.5rem; }
.table tfoot tr:last-child td { border-top: 1px solid var(--border); }

/* ========== Portal-specific ========== */
.btn--block {
    display: block;
    width: 100%;
    text-align: center;
}
.form-actions--stack {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: stretch;
}
.form-actions--stack .center { text-align: center; }

.portal-whoami {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.invite-summary {
    background: #fdf8f3;
    border: 1px solid #ecddcf;
    padding: 0.9rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}
.invite-summary p { margin: 0.2rem 0; }

/* Disabled inputs — greyed out */
input:disabled {
    background: #f5f5f1;
    color: #6b6b6b;
    cursor: not-allowed;
}

/* Center text helper */
.center { text-align: center; }

/* Portal uses <main class="auth-main"> as a wrapper; reuse auth-card inside */
.auth-main {
    width: 100%;
    display: flex;
    justify-content: center;
}

/* ========== Portal dashboard stat cards ========== */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
}
.stat-card__label {
    font-size: 0.8rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.35rem;
}
.stat-card__value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: 0.5rem;
    color: var(--primary);
}

/* Buyer order placement table — wider qty input */
.buyer-order-table .buyer-qty {
    text-align: right;
    font-weight: 600;
}

/* ========== Accounting subnav ========== */
.subnav {
    display: flex;
    gap: 0.25rem;
    margin-top: 0.35rem;
    font-size: 0.85rem;
}
.subnav a {
    color: var(--muted);
    text-decoration: none;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    border: 1px solid transparent;
}
.subnav a:hover {
    color: var(--primary);
    background: #faf8f3;
}
.subnav a.is-active {
    color: var(--primary);
    border-color: var(--border);
    background: #faf8f3;
    font-weight: 600;
}

/* ========== Filter bar (date range + dropdown) ========== */
.filter-bar {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    flex-wrap: wrap;
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
}
.field--inline {
    gap: 0.2rem;
}
.field--inline > span {
    font-size: 0.75rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.field--inline input,
.field--inline select {
    margin: 0;
}

/* ========== Alert box ========== */
.alert {
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
}
.alert--info {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e3a8a;
}
.alert--warning {
    background: #fef3c7;
    border: 1px solid #fcd34d;
    color: #78350f;
}
.alert strong {
    display: inline-block;
    margin-right: 0.3rem;
}

/* ========== Credit note form table ========== */
.credit-note-table .cn-qty {
    text-align: right;
    font-weight: 600;
    max-width: 110px;
    margin-left: auto;
}
.credit-note-table .cn-qty:disabled {
    background: #f5f5f5;
    color: #aaa;
    cursor: not-allowed;
}

/* Line-total cell fade for zero-qty lines */
.credit-note-table .line-credit-cell {
    color: #991b1b;
}

/* ================================================================
   INGREDIENT SPEC SHEET — Nutritics-inspired layout
   ================================================================ */

.spec-section {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}
.spec-section--overview {
    border-top: 0;
    padding-top: 0;
    margin-top: 1rem;
}
.spec-section__title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    background: var(--muted);
    color: #fff;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    margin: 0 0 1rem 0;
    display: block;
}

.spec-block-label {
    font-size: 0.75rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    background: #eae7df;
    color: #555;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    display: inline-block;
    margin-bottom: 0.75rem;
}

/* -- Overview grid: image | donut | props -- */
.spec-overview-grid {
    display: grid;
    grid-template-columns: minmax(220px, 320px) 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
}
@media (max-width: 900px) {
    .spec-overview-grid { grid-template-columns: 1fr; }
}

.spec-image {
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    aspect-ratio: 1 / 1;
    background: #f5f2eb;
}
.spec-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.spec-image__placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #ccc;
}
.spec-image__placeholder p {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--muted);
}

/* -- Calorie donut -- */
.spec-calories {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 1rem;
}
.donut {
    position: relative;
    width: 180px;
    height: 180px;
}
.donut svg { transform: rotate(-90deg); }
.donut-bg, .donut-seg {
    fill: none;
    stroke-width: 6;
}
.donut-bg { stroke: #eae7df; }
.donut-seg.seg-carb    { stroke: #2563eb; }
.donut-seg.seg-protein { stroke: #059669; }
.donut-seg.seg-fat     { stroke: #f97316; }

.donut-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}
.donut-value {
    font-size: 2rem;
    font-weight: 700;
    color: #3a2418;
}
.donut-label {
    font-size: 0.75rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.donut-legend {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 1rem;
    font-size: 0.9rem;
}
.donut-legend .swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 0.5rem;
    vertical-align: middle;
}
.donut-legend .swatch.seg-carb    { background: #2563eb; }
.donut-legend .swatch.seg-protein { background: #059669; }
.donut-legend .swatch.seg-fat     { background: #f97316; }

/* -- Properties / dietary icons -- */
.prop-icons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}
.prop-icon { text-align: center; }
.prop-icon__circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--primary);
    background: var(--surface);
    margin: 0 auto;
}
.prop-icon__label {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    margin-top: 0.3rem;
    color: var(--muted);
}

/* -- EU Label panel -- */
.spec-eu-label {
    max-width: 520px;
}
.eu-label__head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}
.eu-label__cols {
    display: flex;
    gap: 2.5rem;
}
.eu-label__row {
    display: grid;
    grid-template-columns: 1fr 120px 60px;
    gap: 1rem;
    align-items: center;
    padding: 0.45rem 0;
    border-bottom: 1px solid #f5f2eb;
}
.eu-label__row--sub {
    padding-left: 1.2rem;
    font-style: italic;
    color: var(--muted);
}
.eu-label__value {
    text-align: right;
    padding: 4px 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    font-weight: 700;
}
.eu-label__value .muted { font-weight: 400; }
.eu-label__ri { text-align: right; }

/* RI pills */
.ri-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 700;
    min-width: 30px;
    text-align: center;
}
.ri-pill--inline {
    padding: 1px 6px;
    font-size: 0.7rem;
    margin-left: 0.3rem;
    vertical-align: middle;
}
.ri-low  { background: #d1fae5; color: #065f46; }
.ri-med  { background: #fef3c7; color: #78350f; }
.ri-high { background: #fee2e2; color: #991b1b; }

/* -- Pack sizes grid -- */
.packs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}
.pack-card {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
    background: var(--surface);
}
.pack-card--default {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(179, 82, 42, 0.1);
}
.pack-card__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}
.pack-card__label {
    font-weight: 700;
    font-size: 1.05rem;
}
.pack-card__body {
    margin: 0;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.3rem 0.8rem;
    font-size: 0.9rem;
}
.pack-card__body dt {
    color: var(--muted);
    font-size: 0.8rem;
}
.pack-card__body dd { margin: 0; }

/* -- Nutrient breakdown (3-col grid) -- */
.nutrient-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}
@media (max-width: 900px) {
    .nutrient-grid { grid-template-columns: 1fr; }
}
.nutrient-block {
    margin-bottom: 1.5rem;
}
.nutrient-block__title {
    background: #b3522a;
    color: #fff;
    padding: 0.35rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    border-radius: 4px;
    text-align: center;
    margin-bottom: 0.5rem;
}
.nutrient-row {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 0;
    font-size: 0.88rem;
    border-bottom: 1px solid #f5f2eb;
}
.nutrient-row:last-child { border-bottom: 0; }
.nutrient-row__name { color: #444; }
.nutrient-row__value {
    color: #222;
    font-weight: 600;
    white-space: nowrap;
}

/* -- Spec sheet footer -- */
.spec-footer {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--border);
    text-align: center;
}

/* -- Ingredient form — pack size rows + extended nutrition collapsibles -- */
.ext-nutrition details {
    margin-bottom: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    background: var(--surface);
}
.ext-nutrition summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--primary);
    font-size: 0.9rem;
    padding: 0.25rem 0;
}
.ext-nutrition__fields {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.5rem;
    margin-top: 0.75rem;
}
.ext-nutrition__fields label {
    font-size: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.ext-nutrition__fields label > span {
    color: var(--muted);
    font-size: 0.75rem;
}
.ext-nutrition__fields input {
    padding: 4px 6px;
    font-size: 0.85rem;
    font-family: monospace;
    text-align: right;
}

.pack-row {
    display: grid;
    grid-template-columns: auto 2fr 1fr 1fr 1.5fr 40px;
    gap: 0.5rem;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f5f2eb;
}
.pack-row input[type="text"],
.pack-row input[type="number"] {
    padding: 6px 8px;
    font-size: 0.9rem;
    margin: 0;
}
.pack-row__default {
    text-align: center;
}

/* ================================================================
   SETTINGS TABS
   ================================================================ */

.settings-tabs {
    display: flex;
    gap: 0;
    margin: 1.5rem 0 1rem;
    border-bottom: 2px solid var(--border);
}
.settings-tab {
    padding: 0.75rem 1.25rem;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--muted);
    text-decoration: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}
.settings-tab:hover {
    color: var(--text);
}
.settings-tab.is-active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.field__label {
    font-size: 0.75rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.25rem;
    font-weight: 600;
}
