:root {
    --ink: #17221b;
    --muted: #68736b;
    --cream: #f6f2e9;
    --paper: #fffdf8;
    --line: #dedbd1;
    --green: #174f35;
    --green-2: #23724d;
    --orange: #e46f2b;
    --red: #b83c32;
    --shadow: 0 16px 48px rgba(23, 34, 27, .09);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--cream);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--cream); }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
h1, h2, p { margin-top: 0; }
h1, h2 { font-family: Georgia, "Times New Roman", serif; letter-spacing: -.025em; }
h1 { margin-bottom: 0; font-size: clamp(2rem, 4vw, 3.2rem); }
h2 { margin-bottom: .45rem; font-size: 1.45rem; }
p { line-height: 1.65; color: var(--muted); }

.topbar { height: 76px; padding: 0 clamp(20px, 4vw, 64px); display: flex; align-items: center; justify-content: space-between; background: var(--paper); border-bottom: 1px solid var(--line); }
.brand, .account, .auth-brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 38px; height: 38px; display: inline-grid; place-items: center; flex: 0 0 auto; border-radius: 50% 50% 50% 12px; background: var(--green); color: #fff; font-family: Georgia, serif; font-size: 1.3rem; transform: rotate(-5deg); }
.brand-mark.large { width: 52px; height: 52px; font-size: 1.7rem; }
.brand strong, .brand small, .account-name, .account-name small { display: block; }
.brand small, .account-name small { color: var(--muted); font-size: .72rem; margin-top: 2px; }
.avatar { width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: 50%; background: #e2eadf; color: var(--green); font-weight: 700; }
.account-name { font-size: .86rem; font-weight: 600; }
.text-button { border: 0; background: transparent; color: var(--green); font-weight: 700; cursor: pointer; padding: 8px; }
.danger-text { color: var(--red); }

.main-nav { background: var(--paper); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.nav-scroll { display: flex; gap: 4px; overflow-x: auto; padding: 0 clamp(16px, 4vw, 64px); scrollbar-width: none; }
.nav-scroll::-webkit-scrollbar { display: none; }
.main-nav a { text-decoration: none; white-space: nowrap; padding: 16px 14px 13px; color: var(--muted); border-bottom: 3px solid transparent; font-size: .87rem; font-weight: 600; }
.main-nav a:hover, .main-nav a:focus-visible { color: var(--green); }
.main-nav a.active { color: var(--green); border-bottom-color: var(--orange); }

.shell { width: min(1380px, calc(100% - 40px)); margin: 0 auto; padding: 52px 0 72px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 34px; }
.kicker, .eyebrow { display: block; color: var(--orange); font-size: .7rem; letter-spacing: .14em; font-weight: 800; margin-bottom: 8px; }
.api-state, .status { display: inline-flex; align-items: center; gap: 7px; border-radius: 100px; font-size: .76rem; font-weight: 700; white-space: nowrap; }
.api-state { padding: 9px 12px; background: var(--paper); border: 1px solid var(--line); }
.api-state i, .status i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.api-state.ok, .status.open { color: var(--green-2); }
.api-state.warn, .status.closed { color: var(--red); }
.status { padding: 6px 9px; background: #edf4ee; }
.status.closed { background: #f8eae7; }

.alert { margin: 0 0 24px; padding: 14px 16px; border: 1px solid; border-radius: 12px; font-weight: 600; }
.alert.success { background: #e9f4ed; color: #145b39; border-color: #b9dbc5; }
.alert.error { background: #fae9e6; color: #8c2822; border-color: #e7b9b3; }

.hero-status { position: relative; overflow: hidden; min-height: 230px; display: flex; align-items: center; justify-content: space-between; gap: 36px; padding: clamp(30px, 5vw, 60px); color: white; background: var(--green); border-radius: 22px; box-shadow: var(--shadow); }
.hero-status::after { content: ""; position: absolute; right: -60px; top: -110px; width: 340px; height: 340px; border: 70px solid rgba(255,255,255,.055); border-radius: 50%; }
.hero-status.is-closed { background: #58322d; }
.hero-status .eyebrow { color: #f4aa77; }
.hero-status h2 { position: relative; font-size: clamp(2rem, 4vw, 3.2rem); }
.hero-status p { position: relative; color: rgba(255,255,255,.72); margin-bottom: 0; max-width: 620px; }
.hero-status .button { position: relative; z-index: 1; }

.quick-grid, .entity-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-top: 22px; }
.quick-card, .entity-card, .panel, .toolbar-card, .split-panel, .shop-control { background: var(--paper); border: 1px solid var(--line); border-radius: 17px; box-shadow: 0 4px 18px rgba(23,34,27,.04); }
.quick-card { position: relative; min-height: 190px; padding: 26px; text-decoration: none; transition: transform .2s, box-shadow .2s; }
.quick-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.quick-card h2 { margin-top: 26px; }
.quick-card p { margin-bottom: 0; }
.quick-meta { color: var(--orange); font-size: .7rem; letter-spacing: .1em; font-weight: 800; text-transform: uppercase; }
.arrow { position: absolute; top: 24px; right: 24px; font-size: 1.3rem; color: var(--green); }

.button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 10px; padding: 11px 17px; text-decoration: none; font-weight: 700; cursor: pointer; transition: filter .15s, transform .15s; }
.button:hover { filter: brightness(.95); }
.button:active { transform: translateY(1px); }
.button.primary { background: var(--orange); color: #fff; }
.button.danger { background: var(--red); color: #fff; }
.button.secondary { background: #fff; color: var(--green); border-color: var(--line); }
.button.danger-outline { background: #fff; color: var(--red); border-color: #dfbbb6; }
.button.success-outline { background: #fff; color: var(--green-2); border-color: #b6d8c3; }

.split-panel { display: grid; grid-template-columns: 1.1fr .9fr; overflow: hidden; }
.panel-copy { padding: clamp(34px, 6vw, 72px); background: var(--green); color: white; }
.panel-copy h2 { font-size: clamp(2rem, 4vw, 3.2rem); max-width: 580px; }
.panel-copy p { color: rgba(255,255,255,.7); max-width: 560px; }
.current-delivery { width: fit-content; display: flex; align-items: center; gap: 12px; margin: 20px 0 32px; padding: 12px 17px; border: 1px solid rgba(255,255,255,.2); border-radius: 13px; background: rgba(255,255,255,.08); }
.current-delivery strong { font-family: Georgia, serif; font-size: 2.5rem; line-height: 1; color: #fff; }
.current-delivery span { color: rgba(255,255,255,.7); font-size: .72rem; line-height: 1.35; text-transform: uppercase; letter-spacing: .08em; }
.delivery-form { padding: clamp(34px, 6vw, 72px); display: flex; flex-direction: column; justify-content: center; }
label { display: grid; gap: 7px; color: var(--ink); font-weight: 700; font-size: .86rem; }
label small { color: var(--muted); font-weight: 400; }
input, textarea, select { width: 100%; border: 1px solid #cfcfc5; border-radius: 9px; background: #fff; color: var(--ink); padding: 12px 13px; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--green-2); box-shadow: 0 0 0 3px rgba(35,114,77,.12); }
textarea { resize: vertical; line-height: 1.45; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; }
.number-control { display: grid; grid-template-columns: 48px 1fr 48px; margin: 10px 0 12px; }
.number-control input { border-radius: 0; border-left: 0; border-right: 0; text-align: center; font-family: Georgia, serif; font-size: 2rem; }
.number-control button { border: 1px solid #cfcfc5; background: #f4f1e9; color: var(--green); font-size: 1.4rem; cursor: pointer; }
.number-control button:first-child { border-radius: 9px 0 0 9px; }
.number-control button:last-child { border-radius: 0 9px 9px 0; }
.presets { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.presets button { border: 1px solid var(--line); background: transparent; border-radius: 100px; padding: 7px 12px; cursor: pointer; color: var(--green); }
.api-test-panel { margin-top: 18px; padding: 26px; background: var(--paper); border: 1px solid var(--line); border-radius: 17px; box-shadow: 0 4px 18px rgba(23,34,27,.04); }
.api-test-head { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.api-test-head p { margin-bottom: 0; }
.api-test-head code { padding: 2px 6px; border-radius: 5px; background: #f0ede5; color: var(--green); }
.api-result { margin-top: 22px; overflow: hidden; border: 1px solid; border-radius: 11px; }
.api-result.success { border-color: #b9dbc5; background: #f2f8f4; }
.api-result.error { border-color: #e7b9b3; background: #fcf2f0; }
.api-result-title { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 15px; border-bottom: 1px solid rgba(23,34,27,.1); }
.api-result.success .api-result-title { color: #145b39; }
.api-result.error .api-result-title { color: #8c2822; }
.api-result-title span { font-size: .76rem; font-weight: 600; opacity: .7; }
.api-result pre { max-height: 340px; margin: 0; padding: 16px; border-radius: 0; background: transparent; white-space: pre-wrap; overflow-wrap: anywhere; }

.section-intro { max-width: 720px; margin-bottom: 24px; }
.entity-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.entity-card { padding: 22px; }
.entity-actions { display: inline-block; margin: 0 8px 8px 0; }
.entity-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.entity-head h2 { overflow-wrap: anywhere; }
.meta { font-size: .82rem; margin-bottom: 20px; }
details { margin-top: 14px; }
summary { cursor: pointer; color: var(--green); font-weight: 700; }
pre { padding: 12px; overflow: auto; border-radius: 8px; background: #f2efe7; font-size: .75rem; }
.ingredient-list { display: grid; gap: 14px; }
.ingredient-row { padding: 24px; background: var(--paper); border: 1px solid var(--line); border-radius: 17px; box-shadow: 0 4px 18px rgba(23,34,27,.04); }
.ingredient-heading { display: flex; align-items: center; gap: 16px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.ingredient-heading h2 { margin: 0; }
.ingredient-heading .status { margin-left: auto; }
.ingredient-number { width: 42px; height: 42px; display: inline-grid; place-items: center; flex: 0 0 auto; border-radius: 11px; background: #edf1e8; color: var(--green); font-family: ui-monospace, monospace; font-weight: 800; }
.ingredient-fields { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; padding: 20px 0; }
.ingredient-fields label > span { overflow-wrap: anywhere; color: var(--muted); font-size: .72rem; letter-spacing: .04em; }
.ingredient-fields input[readonly] { background: #f1eee7; color: var(--muted); cursor: not-allowed; }
.ingredient-fields textarea { min-height: 100px; }
.ingredient-footer { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.ingredient-footer span { color: var(--muted); font-size: .78rem; }
.ingredient-groups { display: grid; gap: 22px; }
.ingredient-group { overflow: hidden; background: var(--paper); border: 1px solid var(--line); border-radius: 17px; box-shadow: 0 4px 18px rgba(23,34,27,.04); }
.ingredient-group-heading { display: flex; align-items: center; gap: 18px; padding: 22px 24px 17px; cursor: pointer; user-select: none; list-style: none; }
.ingredient-group-heading::-webkit-details-marker { display: none; }
.ingredient-group-heading h2 { margin: 0; }
.ingredient-count { margin-left: auto; padding: 6px 10px; border-radius: 100px; background: #edf1e8; color: var(--green); font-size: .75rem; font-weight: 700; white-space: nowrap; }
.group-chevron { width: 30px; height: 30px; display: inline-grid; place-items: center; flex: 0 0 auto; border-radius: 50%; background: #edf1e8; color: var(--green); font-size: 1.5rem; line-height: 1; transform: rotate(0deg); transition: transform .18s ease; }
.ingredient-group[open] .group-chevron { transform: rotate(90deg); }
.ingredient-group-heading:hover .group-chevron, .ingredient-group-heading:focus-visible .group-chevron { background: #dfe9dc; }
.ingredient-group-heading:focus-visible { outline: 3px solid rgba(35,114,77,.18); outline-offset: -3px; }
.ingredient-table-wrap { overflow-x: auto; border-top: 1px solid var(--line); }
.ingredient-table { min-width: 760px; }
.ingredient-table th { background: #f4f1e9; }
.ingredient-table td { min-width: 145px; }
.ingredient-table input, .ingredient-table select { min-width: 125px; padding: 9px 10px; }
.ingredient-table .action-column { min-width: 118px; width: 118px; text-align: right; }
.ingredient-table tbody tr:hover { background: #fbf9f3; }
.table-empty { color: #aaa; }
.compact-button { min-height: 38px; padding: 8px 12px; font-size: .78rem; }

.toolbar-card { padding: 18px 22px; margin-bottom: 18px; }
.inline-form { display: flex; align-items: flex-end; gap: 12px; }
.slots-layout, .user-layout { display: grid; grid-template-columns: 1.15fr .85fr; gap: 18px; }
.panel { padding: 26px; }
.form-stack { display: grid; gap: 18px; }
.slot-list { display: grid; gap: 8px; margin-top: 20px; }
.slot { display: flex; justify-content: space-between; align-items: center; padding: 13px 15px; border-radius: 9px; background: #f2efe7; }

.shop-control { min-height: 420px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 50px; }
.shop-control h2 { font-size: clamp(2.5rem, 6vw, 5.4rem); }
.shop-control p { max-width: 580px; }
.shop-light { width: 22px; height: 22px; margin-bottom: 24px; border-radius: 50%; background: #36a86f; box-shadow: 0 0 0 9px #def1e5, 0 0 35px rgba(54,168,111,.4); }
.shop-control.is-closed .shop-light { background: var(--red); box-shadow: 0 0 0 9px #f4dedb, 0 0 35px rgba(184,60,50,.35); }

.panel-head, .dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.user-list { display: grid; margin-top: 20px; }
.user-row { display: grid; grid-template-columns: auto minmax(130px,1fr) auto auto; align-items: center; gap: 14px; padding: 15px 0; border-top: 1px solid var(--line); }
.user-info strong, .user-info span { display: block; }
.user-info span { color: var(--muted); font-size: .78rem; margin-top: 3px; }
.role-chip { padding: 14px 0; border-top: 1px solid var(--line); }
.role-chip strong, .role-chip span { display: block; }
.role-chip span { margin-top: 4px; color: var(--muted); font-size: .8rem; }
fieldset { border: 1px solid var(--line); border-radius: 10px; display: grid; gap: 9px; padding: 14px; }
legend { font-weight: 700; font-size: .85rem; padding: 0 6px; }
.check { display: flex; align-items: center; gap: 9px; font-weight: 500; }
.check input { width: 17px; height: 17px; }

.table-panel { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: .84rem; }
th { padding: 11px; color: var(--muted); border-bottom: 2px solid var(--line); white-space: nowrap; }
td { padding: 12px 11px; border-bottom: 1px solid var(--line); vertical-align: top; }
.audit-action { display: inline-block; padding: 4px 7px; border-radius: 5px; background: #edf1ea; font-family: ui-monospace, monospace; font-size: .72rem; }

.empty { padding: 70px 24px; text-align: center; background: var(--paper); border: 1px dashed #c9c7bd; border-radius: 17px; }
.empty.compact { padding: 25px; }
.empty.compact p { margin: 0; }
.empty-icon { width: 50px; height: 50px; display: inline-grid; place-items: center; margin-bottom: 14px; border-radius: 50%; background: #f2eee4; color: var(--orange); font-size: 1.5rem; }

.auth-page { display: grid; place-items: center; background: radial-gradient(circle at 10% 10%, #fff9e9 0, transparent 35%), linear-gradient(135deg, #f0ebdf, #e3eadf); }
.auth-shell { width: min(480px, calc(100% - 32px)); padding: 40px 0; }
.auth-card { padding: clamp(28px, 7vw, 48px); background: var(--paper); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); }
.auth-brand { align-items: flex-start; margin-bottom: 24px; }
.auth-card > p { margin-bottom: 28px; }

dialog { width: min(700px, calc(100% - 28px)); max-height: calc(100vh - 40px); overflow: auto; padding: 0; border: 0; border-radius: 17px; box-shadow: 0 25px 100px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(17,31,22,.62); backdrop-filter: blur(3px); }
.dialog-form { display: grid; gap: 17px; padding: 28px; }
.dialog-close { width: 38px; height: 38px; border: 0; border-radius: 50%; background: #f0ede6; color: var(--ink); font-size: 1.5rem; cursor: pointer; }
.dialog-help { padding: 10px 12px; margin: 0; border-left: 3px solid var(--orange); background: #faf4ea; font-size: .82rem; }

@media (max-width: 960px) {
    .quick-grid, .entity-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .split-panel, .slots-layout, .user-layout { grid-template-columns: 1fr; }
    .ingredient-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
    .topbar { height: 66px; padding: 0 16px; }
    .brand small, .account-name, .api-state { display: none; }
    .shell { width: min(100% - 24px, 1380px); padding-top: 32px; }
    .page-heading { align-items: flex-start; }
    .quick-grid, .entity-grid { grid-template-columns: 1fr; }
    .hero-status { align-items: flex-start; flex-direction: column; }
    .panel-copy, .delivery-form { padding: 30px 22px; }
    .inline-form { align-items: stretch; flex-direction: column; }
    .api-test-head { align-items: stretch; flex-direction: column; }
    .user-row { grid-template-columns: auto 1fr auto; }
    .user-row .status { display: none; }
    .user-row .button { grid-column: 1 / -1; }
    .ingredient-fields { grid-template-columns: 1fr; }
    .ingredient-footer { align-items: stretch; flex-direction: column; }
    .ingredient-group-heading { align-items: flex-start; }
    .shop-control { padding: 38px 20px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
