/* Lua back office. Loaded after ../assets/lua.css (brand tokens). */

:root {
  --sb-w: 244px;
  --bar-h: 33px;           /* height of the mockup strip */
  --top-h: 64px;
}

html { background: var(--bg); }
body { font-size: 14px; line-height: 1.45; color: var(--ink); background: var(--bg); min-width: 1240px; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; }
:focus-visible { outline: 2px solid var(--gold-deep); outline-offset: 2px; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: var(--sb-w) minmax(0, 1fr); min-height: calc(100vh - var(--bar-h)); }

.sb { position: sticky; top: var(--bar-h); height: calc(100vh - var(--bar-h)); background: var(--espresso);
  color: #E9E1D6; display: flex; flex-direction: column; padding: 22px 14px 16px; }
.sb-logo { display: flex; align-items: center; gap: 10px; padding: 2px 10px 22px; text-decoration: none; }
.sb-logo img { height: 34px; width: auto; }
.sb-logo span { font: 400 12px/1.2 var(--sans); color: #A89C8C; border-left: 1px solid #3A342C; padding-left: 10px; }
.sb-nav { display: flex; flex-direction: column; gap: 2px; }
.sb-nav a { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 8px; text-decoration: none;
  color: #CFC5B8; font-weight: 400; font-size: 14px; position: relative; }
.sb-nav a svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.5; opacity: .9; }
.sb-nav a:hover { background: #26221D; color: #F5EFE7; }
.sb-nav a.on { background: #2E2922; color: #F5EFE7; }
.sb-nav a.on::before { content: ''; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--gold); }
.sb-nav .badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--gold);
  color: var(--espresso); font: 600 11px/20px var(--sans); text-align: center; }
.sb-sec { margin: 22px 10px 8px; font-size: 12px; color: #8A7F73; }
.sb-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }
.sb-sync { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border: 1px solid #332E27; border-radius: 10px; font-size: 12px; color: #B5AA9C; line-height: 1.4; }
.sb-sync b { display: block; color: #E9E1D6; font-weight: 500; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #7FA58A; flex: none; margin-top: 4px; box-shadow: 0 0 0 3px rgba(127,165,138,.18); }
.sb-user { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 10px; text-decoration: none; }
.sb-user:hover { background: #26221D; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--blush); color: var(--espresso); display: grid; place-items: center;
  font: 500 13px/1 var(--sans); flex: none; }
.sb-user .who { font-size: 13px; color: #F5EFE7; line-height: 1.25; }
.sb-user .who small { display: block; color: #A89C8C; font-size: 12px; }
.sb-powered { font-size: 11px; color: #6E655A; padding: 0 10px; }
.sb-powered b { font-weight: 500; color: #8A7F73; }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: var(--bar-h); z-index: 20; height: var(--top-h); display: flex; align-items: center; gap: 16px;
  padding: 0 32px; background: rgba(247,243,238,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.search { flex: 0 1 460px; display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 12px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 9px; color: var(--ink-3); }
.search svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.6; }
.search input { border: 0; outline: 0; background: none; flex: 1; font-size: 14px; color: var(--ink); min-width: 0; }
.search kbd { font: 500 11px/1 var(--sans); padding: 4px 6px; border: 1px solid var(--line); border-radius: 5px; color: var(--ink-3); background: var(--paper); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--ink-2); }
.store-pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); text-decoration: none; }
.store-pill .dot { margin: 0; }
.icon-btn { width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; cursor: pointer; position: relative; color: var(--ink-2); }
.icon-btn svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.5; }
.icon-btn .pip { position: absolute; top: 7px; right: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--gold-deep); border: 2px solid var(--surface); }

.content { padding: 28px 32px 64px; max-width: 1360px; width: 100%; }

/* ---------- page head ---------- */
.crumbs { font-size: 13px; color: var(--ink-3); margin-bottom: 6px; }
.crumbs a { text-decoration: none; color: var(--ink-3); }
.crumbs a:hover { color: var(--ink); }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 24px; }
.page-head h1 { font: 500 38px/1.05 var(--serif); margin: 0; letter-spacing: -.005em; }
.page-head p { margin: 6px 0 0; color: var(--ink-2); font-size: 14px; }
.page-head .actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: 9px; border: 1px solid var(--line-2);
  background: var(--surface); color: var(--ink); font-size: 14px; font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--ink-3); }
.btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.6; }
.btn.primary { background: var(--espresso); border-color: var(--espresso); color: var(--cream); }
.btn.primary:hover { background: var(--espresso-3); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--espresso); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--paper); border-color: var(--line); }
.btn.danger { color: var(--bad); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn.lg { height: 44px; padding: 0 22px; font-size: 15px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.link { color: var(--gold-deep); text-decoration: none; font-weight: 500; cursor: pointer; background: none; border: 0; padding: 0; }
.link:hover { text-decoration: underline; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.card-h { display: flex; align-items: center; gap: 12px; padding: 18px 20px 0; }
.card-h h2, .card-h h3 { font: 500 15px/1.3 var(--sans); margin: 0; }
.card-h .sub { color: var(--ink-3); font-size: 13px; }
.card-h .right { margin-left: auto; display: flex; gap: 10px; align-items: center; font-size: 13px; color: var(--ink-3); }
.card-b { padding: 16px 20px 20px; }
.card-b.flush { padding: 8px 0 0; }
.grid { display: grid; gap: 20px; }
.g-2 { grid-template-columns: 1fr 1fr; }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-main { grid-template-columns: minmax(0, 1.75fr) minmax(320px, 1fr); }
.g-side { grid-template-columns: minmax(0, 1fr) 380px; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- ledger strip (key figures) ---------- */
.ledger { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 20px; }
.ledger > div { padding: 18px 22px 20px; border-left: 1px solid var(--line); min-width: 0; }
.ledger > div:first-child { border-left: 0; }
.ledger .lbl { font-size: 13px; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.ledger .val { font: 500 40px/1.1 var(--serif); margin: 8px 0 6px; font-variant-numeric: lining-nums tabular-nums; letter-spacing: -.01em; }
.ledger .val small { font: 400 15px var(--sans); color: var(--ink-3); margin-left: 4px; letter-spacing: 0; }
.ledger .foot { font-size: 12.5px; color: var(--ink-3); }
.ledger .foot b { color: var(--ink-2); font-weight: 500; }
.ledger a.val { display: block; text-decoration: none; }
.split { display: flex; height: 4px; border-radius: 2px; overflow: hidden; background: var(--sand); margin: 2px 0 8px; }
.split i { display: block; height: 100%; }
.key { display: inline-flex; align-items: center; gap: 6px; }
.key::before { content: ''; width: 9px; height: 9px; border-radius: 2px; background: var(--c, var(--espresso)); }

/* ---------- chips ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 11px; font-size: 12px; font-weight: 500; white-space: nowrap;
  background: var(--paper); color: var(--ink-2); border: 1px solid var(--line); }
.chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.chip.plain::before { display: none; }
.chip.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.chip.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.chip.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.chip.info { background: var(--info-bg); color: var(--info); border-color: transparent; }
.chip.gold { background: #F3E9D9; color: var(--gold-deep); border-color: transparent; }
.chip.dark { background: var(--espresso); color: var(--cream); border-color: transparent; }

/* ---------- tables ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-weight: 500; font-size: 12.5px; color: var(--ink-3); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); }
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl th:first-child, .tbl td:first-child { padding-left: 20px; }
.tbl th:last-child, .tbl td:last-child { padding-right: 20px; }
.tbl .r { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .c { text-align: center; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover td { background: #FCFAF7; }
.tbl tfoot td { font-weight: 500; border-top: 1px solid var(--line-2); border-bottom: 0; background: var(--paper); }
.tbl .sub-row td { background: #FCFAF7; font-size: 13px; color: var(--ink-2); padding-top: 8px; padding-bottom: 8px; }
.tbl .sub-row td:first-child { padding-left: 76px; }
.pname { display: flex; align-items: center; gap: 12px; min-width: 0; }
.pname b { font-weight: 500; display: block; }
.pname small { display: block; color: var(--ink-3); font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.neg { color: var(--bad); }
.pos { color: var(--ok); }

/* product image tile */
.thumb { width: 44px; height: 44px; border-radius: 9px; background: var(--blush-soft); flex: none; display: grid; place-items: center; overflow: hidden; position: relative; }
.thumb:nth-child(odd) { background: var(--cream); }
.thumb img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.thumb.miss::after { content: attr(data-i); font: 500 17px var(--serif); color: var(--gold-deep); }
.thumb.sm { width: 34px; height: 34px; border-radius: 7px; }
.thumb.lg { width: 64px; height: 64px; border-radius: 12px; }
.tone-sand { background: var(--sand) !important; }
.tone-blush { background: var(--blush-soft) !important; }
.tone-cream { background: var(--cream) !important; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .lbl-sm { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.field .hint { font-size: 12px; color: var(--ink-3); }
.input, .select, .textarea { height: 40px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 9px; background: var(--surface); font-size: 14px; width: 100%; outline: 0; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--gold-deep); box-shadow: 0 0 0 3px rgba(200,168,122,.22); }
.textarea { height: auto; padding: 10px 12px; line-height: 1.5; resize: vertical; }
.select { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' fill='none' stroke='%238A7F73' stroke-width='1.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.affix { display: flex; align-items: center; border: 1px solid var(--line-2); border-radius: 9px; background: var(--surface); height: 40px; overflow: hidden; }
.affix:focus-within { border-color: var(--gold-deep); box-shadow: 0 0 0 3px rgba(200,168,122,.22); }
.affix span { padding: 0 10px; color: var(--ink-3); font-size: 14px; }
.affix input { border: 0; outline: 0; height: 100%; flex: 1; min-width: 0; padding: 0 12px 0 0; font-size: 14px; background: none; font-variant-numeric: tabular-nums; }
.input.num-in { text-align: right; font-variant-numeric: tabular-nums; }
.row { display: grid; gap: 14px; }
.row-2 { grid-template-columns: 1fr 1fr; }
.row-3 { grid-template-columns: repeat(3, 1fr); }
.ar-in { font-family: var(--arabic); direction: rtl; text-align: right; }

/* switch */
.switch { position: relative; display: inline-block; width: 36px; height: 20px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 10px; background: var(--line-2); transition: background .15s; }
.switch i::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s; }
.switch input:checked + i { background: var(--espresso); }
.switch input:checked + i::after { transform: translateX(16px); }
.switch input:focus-visible + i { outline: 2px solid var(--gold-deep); outline-offset: 2px; }

/* segmented / tabs */
.seg { display: inline-flex; padding: 3px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; gap: 2px; }
.seg button { border: 0; background: none; height: 30px; padding: 0 12px; border-radius: 7px; font-size: 13px; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--espresso); color: var(--cream); }
.tabs { display: flex; gap: 26px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tabs button, .tabs a { border: 0; background: none; padding: 0 0 12px; font-size: 14px; color: var(--ink-2); cursor: pointer; position: relative; display: inline-flex; gap: 8px; align-items: center; text-decoration: none; }
.tabs .on { color: var(--ink); font-weight: 500; }
.tabs .on::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--espresso); }
.tabs .count { font-size: 12px; color: var(--ink-3); background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 0 7px; line-height: 18px; font-weight: 500; }
.tabs .on .count { background: var(--espresso); color: var(--cream); border-color: var(--espresso); }

/* toolbar */
.toolbar { display: flex; gap: 10px; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.toolbar .search { flex: 0 1 300px; height: 36px; }
.toolbar .select { height: 36px; width: auto; min-width: 150px; font-size: 13px; }
.toolbar .end { margin-left: auto; font-size: 13px; color: var(--ink-3); }

/* list rows (dashboard) */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 11px 20px; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list li > .grow { flex: 1; min-width: 0; }
.list li b { font-weight: 500; }
.list li small { color: var(--ink-3); font-size: 12.5px; display: block; }
.list a.li { display: contents; text-decoration: none; }
.list li.click { cursor: pointer; }
.list li.click:hover { background: #FCFAF7; }

/* bars */
.hbar { height: 8px; background: var(--paper); border-radius: 4px; overflow: hidden; border: 1px solid var(--line); }
.hbar i { display: block; height: 100%; background: var(--espresso); border-radius: 4px; }

/* chart */
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font: 400 11px var(--sans); fill: var(--ink-3); }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--ink-2); }
.tip { position: absolute; pointer-events: none; background: var(--espresso); color: var(--cream); font-size: 12px; padding: 8px 10px; border-radius: 8px; line-height: 1.5; white-space: nowrap; box-shadow: var(--shadow-2); opacity: 0; transition: opacity .1s; z-index: 5; }
.tip b { font-weight: 500; }

/* notes / banners */
.note { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; background: var(--paper); border: 1px solid var(--line); font-size: 13px; color: var(--ink-2); }
.note svg { width: 18px; height: 18px; flex: none; stroke: var(--gold-deep); fill: none; stroke-width: 1.6; margin-top: 1px; }
.note b { color: var(--ink); font-weight: 500; }
.note.warn { background: var(--warn-bg); border-color: transparent; }
.note.ok { background: var(--ok-bg); border-color: transparent; }

/* save bar */
.savebar { position: sticky; bottom: 0; z-index: 15; display: flex; align-items: center; gap: 12px; padding: 14px 32px; background: rgba(28,25,20,.97); color: var(--cream); margin-top: auto; }
.savebar .msg { font-size: 14px; display: flex; gap: 10px; align-items: center; }
.savebar .msg::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); }
.savebar .btn { margin-left: 0; }
.savebar .btns { margin-left: auto; display: flex; gap: 10px; }
.savebar .btn.ghost { color: #D8CFC3; }
.savebar .btn.ghost:hover { background: #2E2922; border-color: #3A342C; }

/* toast */
.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0; background: var(--espresso); color: var(--cream); padding: 12px 18px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow-3); transition: all .2s; z-index: 2000; display: flex; gap: 10px; align-items: center; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); }

/* modal */
.scrim { position: fixed; inset: 0; background: rgba(28,25,20,.42); display: none; align-items: center; justify-content: center; z-index: 1500; }
.scrim.show { display: flex; }
.modal { width: 460px; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-3); overflow: hidden; }
.modal-h { padding: 22px 24px 4px; }
.modal-h h3 { font: 500 26px/1.15 var(--serif); margin: 0; }
.modal-h p { margin: 6px 0 0; color: var(--ink-2); font-size: 14px; }
.modal-b { padding: 16px 24px; display: flex; flex-direction: column; gap: 10px; }
.modal-f { padding: 16px 24px 22px; display: flex; justify-content: flex-end; gap: 10px; }
.radio { display: flex; gap: 12px; align-items: center; padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-size: 14px; }
.radio:hover { border-color: var(--line-2); }
.radio input { accent-color: var(--espresso); margin: 0; }
.radio:has(input:checked) { border-color: var(--espresso); background: var(--paper); }

/* definition rows */
.dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; font-size: 13.5px; }
.dl dt { color: var(--ink-3); }
.dl dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.sum-row { display: flex; justify-content: space-between; padding: 7px 0; font-size: 14px; font-variant-numeric: tabular-nums; }
.sum-row.total { border-top: 1px solid var(--line-2); margin-top: 6px; padding-top: 12px; font-weight: 500; font-size: 15px; }
.sum-row .muted { font-weight: 400; }

.big-serif { font: 500 30px/1.1 var(--serif); font-variant-numeric: lining-nums tabular-nums; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }

@media (max-width: 1360px) {
  :root { --sb-w: 224px; }
  .content { padding: 24px 24px 56px; }
  .top { padding: 0 24px; }
  .ledger .val { font-size: 34px; }
  .g-side { grid-template-columns: minmax(0, 1fr) 340px; }
}
@media print {
  .mk-bar, .sb, .top, .savebar { display: none !important; }
  .app { display: block; }
}

/* keep the sidebar colour running the full height of long pages */
.app { background: linear-gradient(to right, var(--espresso) var(--sb-w), transparent var(--sb-w)); }
.main { background: var(--bg); }

[hidden] { display: none !important; }
