@font-face { font-family: "Cairo"; src: url("/fonts/Cairo-Regular.ttf") format("truetype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Cairo"; src: url("/fonts/Cairo-SemiBold.ttf") format("truetype"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Cairo"; src: url("/fonts/Cairo-Bold.ttf") format("truetype"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Cairo"; src: url("/fonts/Cairo-Black.ttf") format("truetype"); font-weight: 900; font-style: normal; font-display: swap; }

:root {
  color-scheme: light;
  --ink: #281b19; --ink-soft: #493a36; --muted: #766760;
  --maroon: #681f27; --maroon-2: #51151c; --maroon-deep: #2b0d11; --maroon-soft: #f7e7e3;
  --paper: #fffaf0; --cream: #f7eedb; --cream-deep: #ead9b9; --canvas: #efe5d2;
  --gold: #c9953d; --gold-light: #e1ba6e; --gold-soft: #fbf0d8;
  --green: #0c6b4c; --green-soft: #e7f4ec; --red: #b92c35; --red-soft: #fae9e8;
  --blue: #355f80; --blue-soft: #e8f0f5;
  --line: rgba(104,31,39,.14); --line-strong: rgba(104,31,39,.24);
  --radius: 16px; --radius-sm: 10px;
  --shadow: 0 12px 34px rgba(73,42,33,.08), 0 2px 5px rgba(73,42,33,.04);
  --shadow-raised: 0 24px 60px rgba(54,18,19,.20);
  font-family: "Cairo", Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 16px; background: var(--canvas); }
body {
  margin: 0; min-width: 320px; color: var(--ink); font-family: "Cairo", Tahoma, Arial, sans-serif;
  font-size: 1rem; line-height: 1.65;
  background: radial-gradient(circle at 9% 2%, rgba(201,149,61,.14), transparent 23rem), radial-gradient(circle at 91% 96%, rgba(104,31,39,.08), transparent 26rem), var(--canvas);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 292px minmax(0, 1fr); }

.sidebar {
  position: sticky; top: 0; z-index: 30; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; padding: 18px 16px 16px; color: #fff9e9;
  background: linear-gradient(135deg, transparent 0 47%, rgba(225,186,110,.08) 48% 51%, transparent 52%) 0 0 / 34px 34px, radial-gradient(circle at 50% -10%, rgba(201,149,61,.20), transparent 21rem), linear-gradient(180deg, #59191f 0%, #3a1015 55%, #270b0f 100%);
  border-left: 1px solid rgba(225,186,110,.28); box-shadow: -12px 0 38px rgba(43,13,17,.16);
  scrollbar-width: thin; scrollbar-color: rgba(225,186,110,.35) transparent;
}
.brand { position: relative; display: block; color: inherit; text-decoration: none; padding: 8px 8px 18px; margin-bottom: 12px; border-bottom: 1px solid rgba(255,248,230,.12); }
.brand::after { content: ""; position: absolute; right: 50%; bottom: -5px; width: 9px; height: 9px; background: var(--gold-light); transform: translateX(50%) rotate(45deg); box-shadow: 15px -15px 0 -3px rgba(225,186,110,.7), -15px 15px 0 -3px rgba(225,186,110,.7); }
.brand-logo { display: block; width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border: 1px solid rgba(225,186,110,.28); border-radius: 14px; box-shadow: 0 10px 28px rgba(0,0,0,.24), inset 0 0 0 1px rgba(255,255,255,.04); }
.brand-system { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding: 0 5px; }
.brand-system strong, .brand-system small { display: block; }
.brand-system strong { font-size: .88rem; font-weight: 800; letter-spacing: .01em; }
.brand-system small { margin-top: 1px; color: #d9c5b1; font-size: .72rem; }
.brand-star { position: relative; width: 25px; height: 25px; flex: 0 0 25px; }
.brand-star::before, .brand-star::after { content: ""; position: absolute; inset: 4px; border: 1px solid var(--gold-light); transform: rotate(45deg); }
.brand-star::after { transform: rotate(0); opacity: .65; }

.main-nav { display: grid; gap: 4px; padding: 0 0 14px; }
.nav-section { margin: 13px 11px 5px; color: #d7ad66; font-size: .68rem; font-weight: 800; letter-spacing: .05em; }
.main-nav button {
  position: relative; min-height: 44px; border: 1px solid transparent; color: #e2d6cd; background: transparent; border-radius: 11px;
  padding: 8px 11px; display: flex; align-items: center; gap: 11px; text-align: right; font-weight: 700; font-size: .84rem;
  transition: background .18s ease, border-color .18s ease, transform .18s ease, color .18s ease;
}
.main-nav button:hover { color: #fff9e8; background: rgba(255,248,230,.07); border-color: rgba(225,186,110,.14); transform: translateX(-2px); }
.main-nav button.active { color: #351014; background: linear-gradient(135deg, #efd59a, #c9953d); border-color: #f3dda7; box-shadow: 0 7px 18px rgba(0,0,0,.20), inset 0 1px rgba(255,255,255,.4); }
.main-nav button.active::after { content: ""; position: absolute; left: 12px; width: 7px; height: 7px; background: var(--maroon); transform: rotate(45deg); }
.main-nav svg, .icon-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-foot { margin-top: auto; padding: 14px 9px 2px; display: flex; align-items: center; gap: 11px; border-top: 1px solid rgba(255,248,230,.10); }
.sidebar-foot b, .sidebar-foot small { display: block; }
.sidebar-foot b { color: #f8ecd1; font-size: .76rem; }
.sidebar-foot small { margin-top: 2px; color: #c4ada5; font-size: .68rem; }
.live-dot { width: 10px; height: 10px; flex: 0 0 10px; border-radius: 50%; background: #31b37b; box-shadow: 0 0 0 5px rgba(49,179,123,.12); }

.main-area { position: relative; min-width: 0; isolation: isolate; }
.main-area::before {
  content: ""; position: fixed; z-index: -1; inset: 0 292px 0 0; pointer-events: none; opacity: .42;
  background-image: linear-gradient(45deg, transparent 46%, rgba(104,31,39,.04) 47% 53%, transparent 54%), linear-gradient(-45deg, transparent 46%, rgba(201,149,61,.05) 47% 53%, transparent 54%);
  background-size: 54px 54px; mask-image: linear-gradient(to bottom, rgba(0,0,0,.65), transparent 45%);
}
.topbar {
  position: sticky; top: 0; z-index: 20; min-height: 98px; padding: 14px 28px; display: flex; align-items: center; gap: 20px;
  background: rgba(255,250,240,.93); border-bottom: 1px solid rgba(104,31,39,.14); box-shadow: 0 4px 20px rgba(74,45,34,.05); backdrop-filter: blur(16px);
}
.topbar::after { content: ""; position: absolute; right: 0; bottom: -1px; width: min(34vw, 410px); height: 2px; background: linear-gradient(90deg, transparent, var(--gold), var(--maroon)); }
.page-identity { position: relative; min-width: 220px; margin-left: auto; padding-right: 18px; }
.page-identity::before { content: ""; position: absolute; right: 0; top: 10px; width: 8px; height: 8px; border: 2px solid var(--gold); transform: rotate(45deg); }
.page-identity p, #modalEyebrow { margin: 0 0 2px; color: var(--maroon); font-size: .74rem; font-weight: 800; }
.page-identity h1 { margin: 0; color: #361317; font-size: 1.45rem; font-weight: 900; letter-spacing: -.03em; }
.title-ornament { display: block; width: 52px; height: 2px; margin-top: 5px; background: linear-gradient(90deg, var(--gold), transparent); }
.top-filters { display: flex; align-items: end; gap: 8px; padding: 8px; background: rgba(247,238,219,.68); border: 1px solid var(--line); border-radius: 13px; }
.top-filters label span { display: block; margin: 0 4px 3px; color: var(--muted); font-size: .68rem; font-weight: 700; }
.top-filters input, .top-filters select { min-width: 138px; min-height: 39px; background: var(--paper); }

input, select, textarea { width: 100%; min-height: 44px; padding: 8px 11px; color: var(--ink); background: #fffdf7; border: 1px solid rgba(104,31,39,.22); border-radius: 9px; outline: none; transition: border-color .15s ease, box-shadow .15s ease, background .15s ease; }
input:hover, select:hover, textarea:hover { border-color: rgba(104,31,39,.36); }
input:focus, select:focus, textarea:focus { background: #fff; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,149,61,.18); }
textarea { min-height: 90px; resize: vertical; }
.button { min-height: 42px; border: 1px solid transparent; border-radius: 9px; padding: 7px 15px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-weight: 800; transition: transform .16s ease, box-shadow .16s ease, background .16s ease, border-color .16s ease; }
.button:hover { transform: translateY(-1px); }
.button:active { transform: translateY(0); }
.button:disabled { opacity: .6; cursor: wait; }
.button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; }
.button-primary { color: #fff9ea; background: linear-gradient(135deg, #7b2932, #56171e); border-color: #812e37; box-shadow: 0 6px 16px rgba(82,22,29,.18), inset 0 1px rgba(255,255,255,.12); }
.button-primary:hover { background: linear-gradient(135deg, #8a303a, #621b23); box-shadow: 0 9px 22px rgba(82,22,29,.23); }
.button-secondary { color: var(--maroon); background: #fffaf0; border-color: rgba(104,31,39,.20); }
.button-secondary:hover { background: var(--gold-soft); border-color: rgba(201,149,61,.48); }
.button-danger { color: var(--red); background: var(--red-soft); border-color: rgba(185,44,53,.20); }
.button-small { min-height: 34px; padding: 4px 10px; font-size: .76rem; }
.icon-button { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 9px; color: var(--maroon); background: var(--paper); display: inline-grid; place-items: center; }
.mobile-only { display: none; }

.allocation-notice { margin: 17px 28px 0; }
.notice { position: relative; overflow: hidden; min-height: 58px; padding: 11px 15px; display: flex; align-items: center; gap: 12px; color: #5e3326; background: linear-gradient(90deg, rgba(201,149,61,.11), transparent 22%), #fbf3e2; border: 1px solid rgba(201,149,61,.33); border-radius: 12px; box-shadow: 0 5px 16px rgba(91,56,29,.04); }
.notice::after { content: ""; position: absolute; left: -25px; width: 94px; height: 94px; border: 1px solid rgba(104,31,39,.08); transform: rotate(45deg); }
.notice-icon { position: relative; z-index: 1; width: 34px; height: 34px; flex: 0 0 34px; display: grid; place-items: center; color: #fff4d6; background: var(--maroon); border: 2px solid var(--gold-light); border-radius: 8px; font-size: 1rem; }
.notice strong { display: block; color: var(--maroon); font-size: .82rem; }
.notice p { margin: 1px 0 0; color: var(--muted); font-size: .73rem; line-height: 1.55; }
.notice.warning { color: #744814; background: #fff5dc; border-color: rgba(201,149,61,.42); }
.notice.warning .notice-icon { background: var(--gold); color: #4f2617; }

.content { padding: 20px 28px 46px; }
.loading-card { min-height: 340px; display: grid; place-items: center; align-content: center; gap: 13px; color: var(--muted); }
.spinner { width: 34px; height: 34px; border: 3px solid rgba(104,31,39,.10); border-top-color: var(--maroon); border-right-color: var(--gold); border-radius: 50%; animation: spin .85s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.page-actions { display: flex; align-items: center; justify-content: space-between; gap: 13px; margin-bottom: 16px; }
.page-actions p { margin: 0; color: var(--muted); font-size: .82rem; }
.action-group { display: flex; flex-wrap: wrap; gap: 8px; }

.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; margin-bottom: 18px; }
.metric-card { position: relative; overflow: hidden; min-width: 0; min-height: 146px; padding: 20px 18px 16px; color: var(--ink); background: rgba(255,250,240,.94); border: 1px solid rgba(104,31,39,.13); border-radius: var(--radius); box-shadow: var(--shadow); }
.metric-card::before { content: ""; position: absolute; top: 18px; left: 17px; width: 12px; height: 12px; border: 2px solid var(--gold); transform: rotate(45deg); opacity: .75; }
.metric-card::after { content: ""; position: absolute; right: 0; bottom: 0; width: 100%; height: 4px; background: linear-gradient(90deg, var(--maroon), var(--gold)); }
.metric-card.green::after { background: linear-gradient(90deg, var(--green), #71b795); }
.metric-card.red::after { background: linear-gradient(90deg, var(--red), #d98b82); }
.metric-card.blue::after { background: linear-gradient(90deg, var(--blue), #93b6cb); }
.metric-card.amber::after { background: linear-gradient(90deg, #a96f1b, var(--gold-light)); }
.metric-label { margin-bottom: 10px; color: var(--muted); font-size: .76rem; font-weight: 700; }
.metric-value { direction: ltr; text-align: right; color: #361317; font-size: clamp(1.35rem, 2.1vw, 1.85rem); font-weight: 900; line-height: 1.2; letter-spacing: -.025em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums lining-nums; }
.metric-meta { margin-top: 10px; color: var(--muted); font-size: .68rem; line-height: 1.55; }
.metric-meta.positive { color: var(--green); }
.metric-meta.negative { color: var(--red); }

.split-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(300px, 1fr); gap: 16px; margin-bottom: 16px; }
.panel { position: relative; overflow: hidden; background: rgba(255,250,240,.96); border: 1px solid rgba(104,31,39,.14); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel::before { content: ""; position: absolute; top: 0; right: 0; width: 72px; height: 3px; background: linear-gradient(90deg, var(--gold), var(--maroon)); }
.panel-header { min-height: 64px; padding: 13px 17px; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: linear-gradient(90deg, rgba(247,238,219,.82), rgba(255,250,240,.44)); border-bottom: 1px solid var(--line); }
.panel-header h2, .panel-header h3 { position: relative; margin: 0; padding-right: 15px; color: #4d171d; font-size: .96rem; font-weight: 900; }
.panel-header h2::before, .panel-header h3::before { content: ""; position: absolute; right: 0; top: .55em; width: 7px; height: 7px; background: var(--gold); transform: rotate(45deg); }
.panel-header p { margin: 3px 0 0; color: var(--muted); font-size: .68rem; }
.panel-body { padding: 17px; }
.legend { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .68rem; }
.legend span::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-left: 5px; background: var(--gold); transform: rotate(45deg); }
.legend span:nth-child(2)::before { background: var(--maroon); }
.comparison { display: grid; gap: 18px; }
.comparison-row { display: grid; grid-template-columns: 130px 1fr 112px; align-items: center; gap: 12px; }
.comparison-row span { color: var(--ink-soft); font-size: .76rem; font-weight: 700; }
.comparison-row b { direction: ltr; text-align: right; color: var(--maroon); font-size: .78rem; font-variant-numeric: tabular-nums; }
.bar-track { height: 10px; overflow: hidden; direction: ltr; background: #eadfca; border-radius: 2px; }
.bar-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, #ac7626, var(--gold-light)); }
.bar-fill.blue { background: linear-gradient(90deg, #571820, #8b333c); }
.bar-fill.green { background: var(--green); }
.bar-fill.red { background: var(--red); }
.donut-wrap { display: grid; grid-template-columns: 156px 1fr; align-items: center; gap: 18px; }
.donut { position: relative; width: 146px; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--maroon) 0 60%, var(--gold) 60% 100%); box-shadow: inset 0 0 0 1px rgba(104,31,39,.14), 0 8px 24px rgba(84,36,28,.12); }
.donut::after { content: ""; width: 90px; aspect-ratio: 1; border-radius: 50%; background: var(--paper); box-shadow: 0 0 0 1px rgba(104,31,39,.10); }
.donut-label { position: absolute; z-index: 1; text-align: center; }
.donut-label b { display: block; color: var(--maroon); font-size: 1.05rem; }
.donut-label small { color: var(--muted); font-size: .63rem; }
.branch-list { display: grid; gap: 12px; }
.branch-item { padding-bottom: 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; border-bottom: 1px solid var(--line); }
.branch-item:last-child { padding-bottom: 0; border-bottom: 0; }
.branch-name { display: flex; align-items: center; gap: 9px; color: var(--ink-soft); font-size: .77rem; font-weight: 700; }
.branch-name i { width: 9px; height: 9px; background: var(--maroon); transform: rotate(45deg); }
.branch-item:nth-child(2) i { background: var(--gold); }
.branch-item b { direction: ltr; color: var(--maroon); font-size: .9rem; font-variant-numeric: tabular-nums; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; min-width: 760px; border-collapse: separate; border-spacing: 0; }
th { position: sticky; top: 0; z-index: 1; padding: 12px 14px; color: #5e2428; background: #f0e1c5; border-bottom: 2px solid rgba(201,149,61,.48); text-align: right; white-space: nowrap; font-size: .71rem; font-weight: 800; }
td { padding: 12px 14px; color: var(--ink-soft); background: rgba(255,253,247,.72); border-bottom: 1px solid rgba(104,31,39,.09); vertical-align: middle; font-size: .76rem; }
tbody tr:nth-child(even) td { background: rgba(247,238,219,.42); }
tbody tr:hover td { background: #fff2d6; }
tr:last-child td { border-bottom: 0; }
.numeric { direction: ltr; text-align: right; color: #3b2520; font-variant-numeric: tabular-nums lining-nums; white-space: nowrap; }
.badge { display: inline-flex; align-items: center; min-height: 26px; padding: 3px 9px; color: var(--muted); background: #efe6d7; border: 1px solid rgba(104,31,39,.10); border-radius: 7px; white-space: nowrap; font-size: .66rem; font-weight: 800; }
.badge.green { color: var(--green); background: var(--green-soft); border-color: rgba(12,107,76,.14); }
.badge.red { color: var(--red); background: var(--red-soft); border-color: rgba(185,44,53,.13); }
.badge.amber { color: #775019; background: var(--gold-soft); border-color: rgba(201,149,61,.20); }
.badge.blue { color: var(--blue); background: var(--blue-soft); border-color: rgba(53,95,128,.14); }
.muted { color: var(--muted); }
.danger { color: var(--red) !important; }
.success { color: var(--green) !important; }
.empty-state { padding: 54px 20px; color: var(--muted); text-align: center; }
.empty-state::before { content: "✦"; width: 44px; height: 44px; margin: 0 auto 10px; display: grid; place-items: center; color: var(--gold); background: var(--gold-soft); border: 1px solid rgba(201,149,61,.25); border-radius: 12px; font-size: 1.2rem; }
.empty-state strong { display: block; margin-bottom: 5px; color: var(--maroon); }

.cards-list { display: grid; gap: 10px; }
.record-card { padding: 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: rgba(255,253,247,.78); border: 1px solid var(--line); border-radius: 11px; }
.record-card h3 { margin: 0; color: #4d171d; font-size: .86rem; }
.record-card p { margin: 4px 0 0; color: var(--muted); font-size: .68rem; }
.record-value { direction: ltr; text-align: right; font-variant-numeric: tabular-nums; }
.record-value strong { display: block; color: var(--maroon); font-size: 1rem; }
.record-value small { color: var(--muted); }
.category-section { margin-bottom: 18px; overflow: hidden; background: rgba(255,253,247,.82); border: 1px solid rgba(104,31,39,.13); border-radius: 18px; box-shadow: 0 8px 22px rgba(73,42,33,.055); transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease; }
.category-section:hover { border-color: rgba(201,149,61,.52); box-shadow: 0 12px 28px rgba(73,42,33,.09); }
.category-title { position: relative; margin: 0; min-height: 68px; padding: 15px 22px 15px 18px; display: flex; align-items: center; justify-content: space-between; gap: 14px; color: #4d171d; background: linear-gradient(105deg, rgba(251,240,216,.74), rgba(255,253,247,.95)); font-size: 1rem; }
.category-title::before { content: ""; position: absolute; right: 0; top: 0; bottom: 0; width: 5px; background: linear-gradient(180deg, var(--gold-light), var(--maroon)); }
.category-title::after { content: ""; position: absolute; right: 17px; bottom: 12px; width: 24px; height: 2px; background: var(--gold); opacity: .7; }
.category-title > span:first-child { display: inline-flex; align-items: center; gap: 10px; font-weight: 900; }
.category-title > span:first-child::before { content: "✦"; width: 27px; height: 27px; display: inline-grid; place-items: center; color: var(--maroon); background: var(--gold-soft); border: 1px solid rgba(201,149,61,.38); border-radius: 9px; font-size: .82rem; }
.category-section[open] { border-color: rgba(201,149,61,.58); box-shadow: 0 14px 30px rgba(73,42,33,.10); }
.category-section[open] > .ingredient-grid { border-top: 1px solid rgba(104,31,39,.10); }
.product-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.product-card { position: relative; overflow: hidden; padding: 13px; display: grid; gap: 8px; background: rgba(255,250,240,.94); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 4px 12px rgba(73,42,33,.035); transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease; }
.product-card::after { content: ""; position: absolute; right: 0; top: 0; width: 4px; height: 100%; background: linear-gradient(var(--gold), var(--maroon)); opacity: .7; }
.product-card:hover { transform: translateY(-2px); border-color: rgba(201,149,61,.42); box-shadow: 0 11px 24px rgba(73,42,33,.08); }
.product-card header { display: flex; justify-content: space-between; gap: 8px; }
.product-card h3 { margin: 0; color: var(--ink); font-size: .78rem; line-height: 1.55; }
.product-price { direction: ltr; color: var(--maroon); font-size: .78rem; font-weight: 900; white-space: nowrap; font-variant-numeric: tabular-nums; }
.product-meta { color: var(--muted); font-size: .65rem; }
.product-actions { display: flex; gap: 6px; margin-top: 2px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.form-grid .full { grid-column: 1 / -1; }
.field label, label.field { display: grid; gap: 6px; color: #543a33; font-size: .74rem; font-weight: 800; }
.field small { color: var(--muted); font-size: .68rem; font-weight: 400; line-height: 1.55; }
.form-actions { grid-column: 1 / -1; margin-top: 18px; padding-top: 15px; display: flex; justify-content: flex-start; gap: 8px; border-top: 1px solid var(--line); }
.line-editor { grid-column: 1 / -1; overflow: hidden; border: 1px solid var(--line); border-radius: 11px; }
.line-editor-header { padding: 10px 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--maroon); background: #f3e7d1; border-bottom: 1px solid var(--line); }
.line-editor-header strong { font-size: .76rem; }
.line-row { padding: 10px; display: grid; grid-template-columns: 2fr 1fr 1fr 42px; align-items: center; gap: 8px; background: rgba(255,253,247,.76); border-top: 1px solid var(--line); }
.line-row:first-child { border-top: 0; }
.line-row:nth-child(even) { background: rgba(247,238,219,.42); }
.line-row.five { grid-template-columns: 1.7fr 1fr 1fr 1fr 42px; }
.line-row input, .line-row select { min-height: 38px; font-size: .74rem; }
.remove-line { width: 34px; height: 34px; border: 1px solid rgba(185,44,53,.15); border-radius: 8px; color: var(--red); background: var(--red-soft); font-size: 1.05rem; }
.inline-summary { grid-column: 1 / -1; padding: 12px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; background: linear-gradient(135deg, #f8eed8, #fffaf0); border: 1px dashed rgba(104,31,39,.24); border-radius: 11px; }
.inline-summary div { padding-right: 9px; border-right: 2px solid rgba(201,149,61,.45); }
.inline-summary span { color: var(--muted); font-size: .67rem; }
.inline-summary b { direction: ltr; display: block; margin-top: 3px; color: var(--maroon); font-size: .88rem; font-variant-numeric: tabular-nums; }
.sales-products { max-height: 50vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 11px; background: #fffdf8; }
.sales-category { position: sticky; top: 0; z-index: 2; padding: 8px 12px; color: #5c2026; background: #f0e1c5; border-top: 1px solid var(--line); border-bottom: 1px solid rgba(201,149,61,.35); font-size: .72rem; font-weight: 900; }
.sales-line { padding: 8px 11px; display: grid; grid-template-columns: minmax(180px, 1fr) 100px 110px; align-items: center; gap: 8px; border-top: 1px solid rgba(104,31,39,.08); }
.sales-line:hover { background: #fff5df; }
.sales-line span { color: var(--ink-soft); font-size: .74rem; }
.sales-line b { direction: ltr; color: var(--maroon); font-size: .72rem; font-variant-numeric: tabular-nums; }
.sales-line input { min-height: 36px; direction: ltr; text-align: center; }

.modal { width: min(920px, calc(100vw - 28px)); max-height: calc(100vh - 28px); padding: 0; overflow: visible; border: 0; background: transparent; }
.modal::backdrop { background: rgba(38,9,12,.74); backdrop-filter: blur(6px); }
.modal-card { position: relative; overflow: hidden; max-height: calc(100vh - 28px); display: flex; flex-direction: column; background: var(--paper); border: 1px solid rgba(225,186,110,.45); border-radius: 18px; box-shadow: var(--shadow-raised); }
.modal-card::before { content: ""; position: absolute; z-index: 2; top: 0; right: 0; left: 0; height: 4px; background: linear-gradient(90deg, var(--maroon), var(--gold), var(--maroon)); }
.modal-card > header { padding: 18px 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; background: linear-gradient(135deg, #f4e5c9, #fffaf0); border-bottom: 1px solid var(--line); }
.modal-card h2 { margin: 0; color: var(--maroon); font-size: 1.1rem; font-weight: 900; }
.modal-body { padding: 19px 20px 21px; overflow-y: auto; }
.toasts { position: fixed; left: 18px; bottom: 18px; z-index: 100; display: grid; gap: 9px; }
.toast { min-width: 290px; max-width: 430px; padding: 13px 15px; color: #fff8e8; background: linear-gradient(135deg, #5f1a22, #3f1016); border: 1px solid rgba(225,186,110,.35); border-radius: 10px; box-shadow: 0 16px 36px rgba(43,13,17,.28); font-size: .78rem; animation: toast-in .22s ease; }
.toast.error { background: linear-gradient(135deg, #9c2630, #661820); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.scrim { display: none; }

@media (max-width: 1200px) {
  .app-shell { grid-template-columns: 270px minmax(0, 1fr); }
  .main-area::before { inset: 0 270px 0 0; }
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .top-filters label:first-child { display: none; }
}
@media (max-width: 900px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; right: 0; width: 286px; transform: translateX(106%); transition: transform .22s ease; box-shadow: -22px 0 55px rgba(43,13,17,.32); }
  body.menu-open .sidebar { transform: translateX(0); }
  .scrim { position: fixed; inset: 0; z-index: 25; background: rgba(43,13,17,.52); backdrop-filter: blur(2px); }
  body.menu-open .scrim { display: block; }
  .main-area::before { inset: 0; }
  .mobile-only { display: inline-grid; }
  .topbar { min-height: 78px; padding: 11px 15px; flex-wrap: wrap; }
  .page-identity { margin-left: auto; }
  .top-filters { order: 3; width: 100%; padding: 7px; overflow-x: auto; }
  .top-filters label:first-child { display: block; }
  .allocation-notice { margin: 12px 14px 0; }
  .content { padding: 14px 14px 30px; }
  .split-grid { grid-template-columns: 1fr; }
  .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 580px) {
  body { font-size: .95rem; }
  .topbar { gap: 10px; }
  .page-identity { min-width: 0; padding-right: 14px; }
  .page-identity p { display: none; }
  .page-identity h1 { font-size: 1.05rem; }
  .title-ornament { width: 38px; }
  .top-filters { display: grid; grid-template-columns: 1fr 1fr; overflow: visible; }
  .top-filters label { min-width: 0; }
  .top-filters input, .top-filters select { min-width: 0; width: 100%; }
  .top-filters .button { min-width: 0; align-self: end; }
  .notice { align-items: flex-start; }
  .notice p { font-size: .68rem; }
  .metrics-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .metric-card { min-height: 130px; padding: 15px 13px 12px; }
  .metric-card::before { width: 9px; height: 9px; top: 13px; left: 12px; }
  .metric-value { font-size: 1.1rem; }
  .metric-label { font-size: .67rem; line-height: 1.5; }
  .metric-meta { font-size: .62rem; }
  .product-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full, .form-actions, .line-editor, .inline-summary { grid-column: 1; }
  .inline-summary { grid-template-columns: 1fr 1fr; }
  .line-row, .line-row.five { grid-template-columns: 1fr 1fr; }
  .line-row select:first-child { grid-column: 1 / -1; }
  .sales-line { grid-template-columns: minmax(140px, 1fr) 78px; }
  .sales-line b { display: none; }
  .donut-wrap { grid-template-columns: 128px 1fr; }
  .donut { width: 120px; }
  .comparison-row { grid-template-columns: 108px 1fr 95px; gap: 8px; }
  .page-actions { align-items: stretch; flex-direction: column; }
  .action-group { width: 100%; }
  .action-group .button { flex: 1; }
  .modal { width: calc(100vw - 16px); max-height: calc(100vh - 16px); }
  .modal-card { max-height: calc(100vh - 16px); border-radius: 14px; }
  .modal-body { padding: 15px; }
}
@media print {
  body { background: #fff; }
  .sidebar, .topbar, .allocation-notice, .page-actions, .button { display: none !important; }
  .app-shell { display: block; }
  .content { padding: 0; }
  .panel, .metric-card { box-shadow: none; break-inside: avoid; }
}
