:root {
  --bg: #f7f3ed; --card: #fff; --line: #e9e2d8; --line-2: #f1ebe2;
  --text: #1a1208; --muted: #6e6862; --faint: #a39b92;
  --accent: #e8822f; --accent-soft: #fbeedd; --ink: #1a1208;
  --ok: #1f8a4c; --ok-soft: #e3f4ea; --bad: #c0392b; --bad-soft: #fbe6e3; --warn: #b7791f; --warn-soft: #fdf3dc;
  --radius: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", "Noto Sans Ethiopic", sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }

.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; padding: 18px 12px; background: var(--ink); color: #f7f3ed; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; padding: 4px 10px 18px; }
.mark { color: var(--accent); font-size: 20px; }
.side a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; text-decoration: none; color: #d8d0c5; }
.side a:hover { background: #2a2119; color: #fff; }
.side a.on { background: #33281e; color: #fff; }
.side .ic { width: 18px; text-align: center; opacity: .8; }
.badge { margin-left: auto; background: var(--accent); color: #1a1208; border-radius: 999px; font-size: 12px; padding: 0 7px; min-width: 20px; text-align: center; }
.me { margin-top: auto; padding: 12px; font-size: 12px; color: #a39b92; display: flex; flex-direction: column; gap: 4px; }
.link { background: none; border: 0; padding: 0; color: #f59e4b; cursor: pointer; text-align: left; }

main { padding: 24px 28px 80px; min-width: 0; outline: none; }
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 12px; }
.sub { color: var(--muted); margin: 0 0 20px; }
.loading, .empty { color: var(--muted); padding: 24px 0; }

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-bottom: 18px; }
.two { grid-template-columns: 1fr 1fr; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.kpi .v { font-size: 26px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: 12px; }
.kpi .d { font-size: 12px; color: var(--faint); margin-top: 2px; }
.kpi.hot { border-color: var(--accent); background: var(--accent-soft); }

.seg { display: inline-flex; background: #ece5db; border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 999px; cursor: pointer; color: var(--muted); }
.seg button.on { background: #fff; color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
td.n, th.n { text-align: right; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #faf6f0; }
.scroll { overflow-x: auto; }

.pill { display: inline-block; border-radius: 999px; padding: 1px 9px; font-size: 12px; background: #eee7dd; color: var(--muted); white-space: nowrap; }
.pill.paid, .pill.approved { background: var(--ok-soft); color: var(--ok); }
.pill.pending { background: var(--warn-soft); color: var(--warn); }
.pill.rejected, .pill.refunded { background: var(--bad-soft); color: var(--bad); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }

input[type=search], input[type=text], select, textarea { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
textarea { width: 100%; min-height: 80px; resize: vertical; }
.btn { border: 0; border-radius: 999px; padding: 8px 16px; cursor: pointer; font-weight: 600; background: var(--ink); color: #fff; }
.btn.ok { background: var(--ok); }
.btn.bad { background: #fff; color: var(--bad); border: 1px solid #efc7c1; }
.btn.ghost { background: #fff; color: var(--text); border: 1px solid var(--line); }
.btn:disabled { opacity: .5; cursor: default; }

/* Payments queue */
.pay { display: grid; grid-template-columns: 160px 1fr; gap: 16px; }
.pay + .pay { margin-top: 14px; }
.pay__img { width: 160px; height: 200px; border-radius: 12px; background: #f1ebe2; display: grid; place-items: center; overflow: hidden; color: var(--muted); font-size: 12px; text-align: center; }
.pay__img img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.pay__ref { font-family: ui-monospace, Menlo, monospace; font-size: 15px; background: var(--accent-soft); padding: 8px 12px; border-radius: 10px; word-break: break-all; }
.pay h3 { margin: 0 0 4px; font-size: 16px; }
.pay .acts { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.note { white-space: pre-wrap; color: var(--muted); font-size: 12px; margin-top: 6px; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.8); display: grid; place-items: center; z-index: 50; cursor: zoom-out; }
.lightbox img { max-width: 94vw; max-height: 94vh; border-radius: 8px; }

/* Charts */
.chart svg { width: 100%; height: 180px; display: block; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.bar { height: 8px; border-radius: 4px; background: var(--accent); min-width: 2px; }
.barrow { display: grid; grid-template-columns: 140px 1fr 50px; gap: 10px; align-items: center; padding: 4px 0; font-size: 13px; }
.step { margin: -2px 0 4px 150px; }
.barrow span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Drawer */
.drawer { position: fixed; inset: 0; z-index: 40; }
.drawer__bg { position: absolute; inset: 0; background: rgba(26,18,8,.35); }
.drawer__panel { position: absolute; right: 0; top: 0; bottom: 0; width: min(560px, 100%); background: var(--bg); overflow-y: auto; padding: 24px; box-shadow: -8px 0 30px rgba(0,0,0,.12); }
.drawer__x { position: absolute; right: 14px; top: 10px; border: 0; background: none; font-size: 28px; cursor: pointer; color: var(--muted); }
dl.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; word-break: break-word; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: flex; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.timeline li span:first-child { color: var(--faint); width: 120px; flex: none; }

/* Conversations */
.msgs { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 10px; }
.msg { max-width: 85%; padding: 8px 12px; border-radius: 14px; white-space: pre-wrap; word-break: break-word; }
.msg.in { background: #fff; border: 1px solid var(--line); align-self: flex-start; }
.msg.out { background: var(--accent-soft); align-self: flex-end; }
.msg small { display: block; color: var(--faint); font-size: 11px; margin-top: 2px; }
.thread + .thread { margin-top: 14px; }
.unanswered { border-color: var(--accent); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; z-index: 60; max-width: 90vw; }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; flex-direction: row; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); z-index: 30; justify-content: space-around; }
  .brand, .me { display: none; }
  .side a { flex-direction: column; gap: 2px; padding: 6px 8px; font-size: 11px; position: relative; }
  .side .ic { font-size: 16px; }
  .badge { position: absolute; top: 0; right: 0; margin: 0; font-size: 10px; }
  main { padding: 16px 16px 100px; }
  .two { grid-template-columns: 1fr; }
  .pay { grid-template-columns: 1fr; }
  .pay__img { width: 100%; height: 260px; }
  .barrow { grid-template-columns: 100px 1fr 40px; }
  .step { margin-left: 110px; }
  .hide-m { display: none; }
}
