:root {
  --green-900: #0f3324;
  --green-800: #123d2b;
  --green-700: #18513a;
  --green-600: #1f6a4b;
  --green-500: #2f8a63;
  --green-100: #e5f2ea;
  --green-50: #f2f8f4;
  --lime: #d8f36a;
  --ink: #142019;
  --ink-2: #44524a;
  --muted: #7a877f;
  --line: #e3e9e5;
  --bg: #f5f7f4;
  --card: #ffffff;
  --red: #c2412d;
  --red-bg: #fbece8;
  --amber: #a96b00;
  --amber-bg: #fdf3dc;
  --blue: #2a5fa8;
  --blue-bg: #e7effb;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(16, 40, 28, .05), 0 6px 24px rgba(16, 40, 28, .05);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: Manrope, system-ui, sans-serif; color: var(--ink); background: var(--bg); font-size: 14px; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: 'JetBrains Mono', monospace; font-size: 12px; }

/* boot + auth */
.boot { min-height: 100vh; display: grid; place-content: center; text-align: center; gap: 6px; }
.boot h1 { margin: 14px 0 0; font-size: 20px; }
.boot p { margin: 0; color: var(--muted); }
.brand-mark { width: 38px; height: 38px; border-radius: 11px; background: var(--green-800); color: var(--lime); display: grid; place-items: center; font-weight: 800; letter-spacing: -.5px; flex: none; }
.brand-mark.big { width: 56px; height: 56px; border-radius: 16px; font-size: 20px; margin: 0 auto; }
.brand-logo { width: 38px; height: 38px; flex: none; display: block; border-radius: 11px; box-shadow: 0 4px 14px #0f332433; }
.brand-logo.big { width: 64px; height: 64px; border-radius: 18px; margin: 0 auto; }
#storeName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 130px; }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 10%, #1f6a4b22, transparent 40%), var(--bg); }
.auth-card { width: min(420px, 100%); background: var(--card); border-radius: 22px; padding: 32px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.auth-brand { display: flex; gap: 10px; align-items: center; margin-bottom: 22px; }
.auth-brand strong { font-size: 19px; letter-spacing: .5px; } .auth-brand span { color: var(--green-500); font-weight: 700; margin-left: 5px; font-size: 11px; letter-spacing: .18em; }
.auth h1 { margin: 0 0 4px; font-size: 22px; }
.auth form { display: grid; gap: 14px; margin-top: 18px; }
.auth-msg { min-height: 20px; color: var(--red); margin: 12px 0 0; font-size: 13px; }
.auth-msg.ok { color: var(--green-600); }
.auth-links { display: flex; justify-content: space-between; margin-top: 8px; }

/* shell */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { background: var(--green-900); color: #dfeae3; padding: 20px 14px; display: flex; flex-direction: column; gap: 10px; position: sticky; top: 0; height: 100vh; overflow: auto; }
.side-brand { display: flex; gap: 10px; align-items: center; padding: 4px 6px 12px; }
.side-brand strong { color: #fff; font-size: 18px; letter-spacing: .5px; } .side-brand span { color: var(--lime); font-size: 10.5px; font-weight: 700; margin-left: 5px; letter-spacing: .18em; }
.side-brand small { display: block; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: #9fb7a9; margin-top: 2px; }
.store-pill { display: flex; align-items: center; gap: 8px; background: #ffffff10; border: 1px solid #ffffff14; border-radius: 12px; padding: 10px 12px; font-weight: 600; color: #fff; }
.store-pill em { margin-left: auto; font-style: normal; font-size: 11px; color: #9fb7a9; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--lime); }
.side-label { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: #8aa597; margin: 12px 8px 2px; }
#nav { display: grid; gap: 2px; }
#nav button { display: flex; align-items: center; gap: 10px; background: none; border: 0; color: #cfdcd4; padding: 10px 12px; border-radius: 10px; cursor: pointer; text-align: left; font-weight: 600; }
#nav button i { font-style: normal; width: 18px; text-align: center; opacity: .8; }
#nav button b { margin-left: auto; background: #ffffff18; font-size: 11px; padding: 1px 7px; border-radius: 20px; }
#nav button:hover { background: #ffffff0d; color: #fff; }
#nav button.active { background: var(--green-100); color: var(--green-900); }
#nav button.active b { background: var(--green-800); color: #fff; }
.ml-dot { width: 8px; height: 8px; padding: 0 !important; border-radius: 50% !important; background: #6b7f74 !important; }
.ml-dot.on { background: var(--lime) !important; }
.side-foot { margin-top: auto; display: grid; gap: 12px; padding-top: 12px; border-top: 1px solid #ffffff14; }
.cloud { display: flex; gap: 10px; align-items: center; padding: 0 6px; }
.cloud strong { display: block; font-size: 12px; color: #fff; } .cloud small { font-size: 11px; color: #9fb7a9; }
.user { display: flex; gap: 10px; align-items: center; background: #ffffff0b; border-radius: 12px; padding: 10px; }
.user strong { display: block; font-size: 12px; color: #fff; word-break: break-all; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--green-100); color: var(--green-900); display: grid; place-items: center; font-weight: 800; flex: none; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 16px 28px; border-bottom: 1px solid var(--line); background: #fbfcfa; position: sticky; top: 0; z-index: 5; }
.crumbs { color: var(--muted); } .crumbs span { margin: 0 6px; } .crumbs strong { color: var(--ink); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.badge-lock { font-size: 12px; color: var(--ink-2); border: 1px solid var(--line); padding: 6px 10px; border-radius: 20px; background: #fff; }
.menu-btn { display: none; background: none; border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; cursor: pointer; }
.view { padding: 28px; display: grid; gap: 20px; max-width: 1320px; width: 100%; }
.foot { padding: 18px 28px 28px; color: var(--muted); font-size: 12px; }

/* headings */
.eyebrow { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--green-500); font-weight: 700; }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-head h1 { margin: 4px 0 4px; font-size: 28px; letter-spacing: -.5px; }
.page-head p { margin: 0; color: var(--muted); }
.page-head .filters { margin-left: auto; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* controls */
.btn { border: 1px solid var(--line); background: #fff; padding: 9px 14px; border-radius: 10px; cursor: pointer; font-weight: 700; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { border-color: #c9d4cd; }
.btn.primary { background: var(--green-800); border-color: var(--green-800); color: #fff; }
.btn.primary:hover { background: var(--green-700); }
.btn.lime { background: var(--lime); border-color: var(--lime); color: var(--green-900); }
.btn.danger { color: var(--red); }
.btn.small { padding: 6px 10px; font-size: 12px; }
.btn.wide { width: 100%; justify-content: center; }
.btn:disabled { opacity: .55; cursor: wait; }
.link { background: none; border: 0; color: var(--green-600); font-weight: 700; cursor: pointer; padding: 0; }
.link.small { font-size: 11px; color: #9fb7a9; }
select, input, textarea { border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; background: #fff; outline: none; min-width: 0; }
select:focus, input:focus, textarea:focus { border-color: var(--green-500); box-shadow: 0 0 0 3px #2f8a6320; }
label { display: grid; gap: 6px; font-size: 12px; font-weight: 700; color: var(--ink-2); }
.search { min-width: 220px; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.card h2 { margin: 0; font-size: 16px; } .card h2 + p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.card-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head .right { margin-left: auto; display: flex; gap: 8px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; }
.grid-2e { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.metric { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.metric .head { display: flex; justify-content: space-between; color: var(--muted); font-weight: 600; font-size: 13px; }
.metric strong { display: block; font-size: 26px; letter-spacing: -.6px; margin: 10px 0 4px; }
.metric small { color: var(--muted); }
.metric.dark { background: var(--green-800); border-color: var(--green-800); color: #fff; }
.metric.dark .head, .metric.dark small { color: #b9d2c3; }
.banner { display: flex; align-items: center; gap: 14px; background: var(--green-50); border: 1px solid #d3e7da; border-radius: var(--radius); padding: 14px 18px; }
.banner .ico { width: 36px; height: 36px; border-radius: 10px; background: #fff; display: grid; place-items: center; border: 1px solid #d3e7da; flex: none; }
.banner strong { display: block; } .banner span { color: var(--ink-2); font-size: 13px; }
.banner .btn, .banner .link { margin-left: auto; }
.banner.warn { background: var(--amber-bg); border-color: #f1ddb0; }
.banner.alert { background: var(--red-bg); border-color: #f2cfc6; }

/* tables */
.table-wrap { overflow-x: auto; margin: 0 -20px -20px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 700; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fafcfa; white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid #eef2ef; vertical-align: middle; }
tr.click { cursor: pointer; } tr.click:hover td { background: #f7faf8; }
td.num, th.num { text-align: right; white-space: nowrap; }
.prod strong { display: block; font-weight: 700; max-width: 440px; }
.prod small { color: var(--muted); }
.ch { display: inline-grid; place-items: center; width: 28px; height: 20px; border-radius: 6px; font-size: 10px; font-weight: 800; background: #fff3b0; color: #6b5800; margin-right: 6px; }
.ch.sh { background: #ffe1d6; color: #a33a12; }
.chip { display: inline-block; padding: 4px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; background: var(--green-100); color: var(--green-700); white-space: nowrap; }
.chip.amber { background: var(--amber-bg); color: var(--amber); }
.chip.red { background: var(--red-bg); color: var(--red); }
.chip.blue { background: var(--blue-bg); color: var(--blue); }
.chip.gray { background: #eef1ef; color: var(--ink-2); }
.neg { color: var(--red); } .pos { color: var(--green-600); }
.sub { display: block; color: var(--muted); font-size: 11px; }
.empty { padding: 30px; text-align: center; color: var(--muted); }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; color: var(--muted); font-size: 13px; }

/* chart */
.chart { display: flex; align-items: flex-end; gap: 8px; height: 210px; padding-top: 10px; }
.bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; height: 100%; min-width: 0; }
.bar div { width: 100%; max-width: 34px; border-radius: 7px 7px 3px 3px; background: linear-gradient(#5aa881, #2f8a63); min-height: 3px; position: relative; }
.bar div.negb { background: #e2a08f; }
.bar div:hover::after { content: attr(data-v); position: absolute; bottom: 100%; left: 50%; transform: translate(-50%, -6px); background: var(--ink); color: #fff; font-size: 11px; padding: 3px 7px; border-radius: 6px; white-space: nowrap; }
.bar span { font-size: 10px; color: var(--muted); }
.formula { margin-top: 14px; font-size: 12px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 12px; }

/* list rows */
.rows { display: grid; gap: 10px; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.row .ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; font-size: 12px; background: #fff3b0; color: #6b5800; flex: none; }
.row .ic.sh { background: #ffe1d6; color: #a33a12; }
.row .grow { flex: 1; min-width: 0; } .row .grow small { color: var(--muted); display: block; }
.row .right { text-align: right; } .row .right small { color: var(--muted); display: block; }
.comp { display: grid; gap: 0; }
.comp div { display: flex; justify-content: space-between; padding: 11px 0; border-bottom: 1px solid #eef2ef; }
.comp div.total { border-bottom: 0; font-weight: 800; font-size: 16px; padding-top: 14px; }
.kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.kv div { background: var(--green-50); border-radius: 12px; padding: 14px; }
.kv small { color: var(--muted); display: block; } .kv strong { font-size: 20px; }

/* forms + modal */
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.form-grid .span-2 { grid-column: span 2; } .form-grid .span-3 { grid-column: 1 / -1; }
.modal { position: fixed; inset: 0; background: #0f1d1599; display: grid; place-items: center; padding: 20px; z-index: 50; overflow: auto; }
.modal-card { background: #fff; border-radius: 20px; width: min(860px, 100%); max-height: calc(100vh - 40px); overflow: auto; box-shadow: 0 30px 80px #0005; }
.modal-head { display: flex; align-items: center; padding: 20px 24px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 1; }
.modal-head h2 { margin: 0; font-size: 18px; } .modal-head .x { margin-left: auto; background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--muted); }
.modal-body { padding: 22px 24px; display: grid; gap: 18px; }
.modal-foot { display: flex; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: #fff; }
.modal-foot .spacer { flex: 1; }
.preview { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; background: var(--green-50); border-radius: 14px; padding: 14px; }
.preview div small { display: block; color: var(--muted); font-size: 11px; } .preview div strong { font-size: 15px; }
.preview .profit strong { color: var(--green-700); font-size: 18px; }
details.more summary { cursor: pointer; font-weight: 700; color: var(--green-600); }
details.more[open] summary { margin-bottom: 14px; }
.switch { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.switch input { width: 18px; height: 18px; accent-color: var(--green-600); }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 60; box-shadow: 0 10px 30px #0004; font-weight: 600; }
.toast.err { background: var(--red); }
.copy { display: flex; gap: 8px; align-items: center; } .copy input { flex: 1; font-family: 'JetBrains Mono', monospace; font-size: 12px; }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 8px; color: var(--ink-2); }
.activity { display: grid; gap: 0; max-height: 420px; overflow: auto; }
.activity div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid #eef2ef; }
.activity small { color: var(--muted); white-space: nowrap; }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .grid-2e, .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 30% 0 0; z-index: 40; transform: translateX(-102%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 0 100vmax #0006; }
  .menu-btn { display: block; }
  .badge-lock { display: none; }
  .view { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .preview { grid-template-columns: repeat(2, 1fr); }
  .page-head .filters { margin-left: 0; }
}
@media (max-width: 520px) {
  .grid-4 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; } .form-grid .span-2 { grid-column: auto; }
}
