/* SAB Books admin panel. Brand teal matches the storefront (#0f7e77). */
:root {
  --brand: #0f7e77; --brand-d: #0b625c; --brand-l: #e7f4f3;
  --bg: #f4f6f8; --card: #fff; --ink: #1f2933; --ink-2: #4b5563; --muted: #6b7280;
  --line: #e3e7eb; --line-2: #d3d9df;
  --ok: #137333; --ok-bg: #e6f4ea; --warn: #8a5300; --warn-bg: #fff4dc; --bad: #b42318; --bad-bg: #fdecea; --info: #1d4f91; --info-bg: #e8f0fb;
  --radius: 12px; --shadow: 0 1px 2px rgba(16,24,40,.05), 0 2px 8px rgba(16,24,40,.04);
  --side: 240px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0 0 10px; }
code { background: #f1f3f5; padding: 1px 5px; border-radius: 5px; font-size: 12.5px; }
small, .muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

/* ---- shell ---- */
.shell { display: flex; min-height: 100vh; }
.side { width: var(--side); flex: none; background: #0d2b2a; color: #cfe3e1; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .brand { display: flex; gap: 10px; align-items: center; padding: 18px 18px 14px; color: #fff; }
.side .brand:hover { text-decoration: none; }
.side .brand small { display: block; color: #8fb9b5; font-size: 12px; }
.side .mark { width: 36px; height: 36px; border-radius: 9px; background: var(--brand); display: grid; place-items: center; }
.side nav { padding: 6px 10px; display: grid; gap: 2px; }
.side nav a, .side .soon, .side-foot a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: #cfe3e1; }
.side nav a:hover, .side-foot a:hover { background: rgba(255,255,255,.07); text-decoration: none; color: #fff; }
.side nav a.on { background: var(--brand); color: #fff; font-weight: 600; }
.side .nav-h { margin: 14px 10px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #6f9995; }
.side .soon { color: #6f9995; cursor: default; }
.side .soon em { margin-left: auto; font-style: normal; font-size: 10.5px; background: rgba(255,255,255,.08); border-radius: 20px; padding: 1px 7px; }
.side-foot { margin-top: auto; padding: 10px; border-top: 1px solid rgba(255,255,255,.08); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 12px 24px; background: rgba(255,255,255,.92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.top h1 { font-size: 18px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-actions { display: flex; gap: 8px; }
.content { padding: 22px 24px 48px; max-width: 1240px; width: 100%; }
.menu-btn { display: none; }

.me { position: relative; }
.me summary { list-style: none; display: flex; align-items: center; gap: 9px; cursor: pointer; padding: 4px 6px; border-radius: 9px; }
.me summary::-webkit-details-marker { display: none; }
.me summary:hover { background: #f1f3f5; }
.me-name { line-height: 1.2; font-weight: 600; }
.me-name small { display: block; font-weight: 400; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-l); color: var(--brand-d); display: grid; place-items: center; font-weight: 700; }
.me-menu { position: absolute; right: 0; top: calc(100% + 6px); background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(16,24,40,.12); min-width: 180px; padding: 6px; z-index: 10; }
.me-menu a, .me-menu button { display: flex; gap: 8px; align-items: center; width: 100%; padding: 8px 10px; border-radius: 7px; color: var(--ink); background: none; border: 0; font: inherit; cursor: pointer; text-align: left; }
.me-menu a:hover, .me-menu button:hover { background: #f1f3f5; text-decoration: none; }
.me-menu form { margin: 0; }

/* ---- building blocks ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.card + .card, .grid + .card, .card + .grid, .stats + .grid, .stats + .card, .alert + .card { margin-top: 16px; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-h p { margin: 2px 0 0; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.stats { display: grid; gap: 14px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.stat .k { color: var(--muted); font-size: 12.5px; }
.stat .v { font-size: 26px; font-weight: 750; letter-spacing: -.01em; margin-top: 2px; }
.stat .s { font-size: 12.5px; color: var(--ink-2); }
.stat.ok { border-left: 4px solid var(--ok); } .stat.warn { border-left: 4px solid #e0a100; } .stat.bad { border-left: 4px solid var(--bad); }
.empty { text-align: center; padding: 34px 20px; }
.empty h2 { margin-bottom: 6px; }

.alert { border-radius: 10px; padding: 11px 14px; margin-bottom: 14px; border: 1px solid transparent; }
.alert ul { margin: 6px 0 0; padding-left: 18px; }
.alert.ok, .alert.success { background: var(--ok-bg); color: var(--ok); border-color: #c7e6d0; }
.alert.error { background: var(--bad-bg); color: var(--bad); border-color: #f5c6c2; }
.alert.warn { background: var(--warn-bg); color: var(--warn); border-color: #f2dca8; }
.alert.info { background: var(--info-bg); color: var(--info); border-color: #c9daf3; }

.pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 20px; padding: 2px 9px; font-size: 12px; font-weight: 600; background: #eef0f2; color: var(--ink-2); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); } .pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); } .pill.info { background: var(--info-bg); color: var(--info); }
.pill.brand { background: var(--brand-l); color: var(--brand-d); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 15px; border-radius: 9px; border: 1px solid var(--brand); background: var(--brand); color: #fff; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--brand-d); text-decoration: none; }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line-2); }
.btn.ghost:hover { background: #f5f7f9; }
.btn.danger { background: #fff; color: var(--bad); border-color: #f0b8b2; }
.btn.danger:hover { background: var(--bad-bg); }
.btn.sm { height: 31px; padding: 0 11px; font-size: 13px; }
.btn.block { width: 100%; }
.icon-btn { width: 38px; height: 38px; border-radius: 9px; border: 1px solid var(--line-2); background: #fff; display: inline-grid; place-items: center; cursor: pointer; color: var(--ink); }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; margin: 0 -20px; }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.t th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 10px 12px; border-bottom: 1px solid #eef1f3; vertical-align: top; }
table.t th:first-child, table.t td:first-child { padding-left: 20px; }
table.t th:last-child, table.t td:last-child { padding-right: 20px; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr:hover td { background: #fafbfc; }
table.t .num { text-align: right; font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 8px 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* ---- forms ---- */
form.stack { display: grid; gap: 14px; }
.field { display: grid; gap: 5px; }
.field > label, .field > .label { font-weight: 600; font-size: 13px; color: #374151; }
.field .hint { font-size: 12.5px; color: var(--muted); }
.field .from-sw { font-size: 12px; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=url], input[type=search], select, textarea {
  width: 100%; border: 1px solid var(--line-2); border-radius: 9px; padding: 0 12px; height: 40px; font: inherit; color: var(--ink); background: #fff; }
textarea { padding: 10px 12px; height: auto; min-height: 120px; resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15,126,119,.16); }
input[dir=rtl], textarea[dir=rtl] { font-family: "Noto Nastaliq Urdu", "Noto Naskh Arabic", "Jameel Noori Nastaleeq", system-ui, sans-serif; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.form-foot { display: flex; gap: 10px; align-items: center; padding-top: 6px; }
.sticky-foot { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: 18px 0 4px; margin-top: 4px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 14px; }
.filters .field { min-width: 160px; }
.logo-prev { display: flex; gap: 14px; align-items: center; }
.logo-prev .box { width: 64px; height: 64px; border: 1px dashed var(--line-2); border-radius: 10px; display: grid; place-items: center; background: #0f7e77; overflow: hidden; }
.logo-prev img { max-width: 100%; max-height: 100%; }

.branch-row { border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: grid; gap: 12px; background: #fbfcfc; }
.branch-row + .branch-row { margin-top: 12px; }
.branch-row .bh { display: flex; justify-content: space-between; align-items: center; }

.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid #eef1f3; }
.checklist li:last-child { border-bottom: 0; }
.checklist .st { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; }
.checklist .st.ok { background: var(--ok-bg); color: var(--ok); } .checklist .st.warn { background: var(--warn-bg); color: var(--warn); } .checklist .st.bad { background: var(--bad-bg); color: var(--bad); }
.checklist .tx { flex: 1; min-width: 0; }
.checklist .tx small { display: block; }
.bar { height: 8px; border-radius: 6px; background: #edf0f2; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brand); }
.pager { display: flex; gap: 8px; justify-content: space-between; align-items: center; margin-top: 14px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a { padding: 9px 14px; border-bottom: 2px solid transparent; color: var(--ink-2); font-weight: 600; }
.tabs a.on { border-color: var(--brand); color: var(--brand-d); }
.tabs a:hover { text-decoration: none; color: var(--ink); }

/* ---- sign-in pages ---- */
body.auth { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg, #0d2b2a 0%, #0f7e77 100%); padding: 24px 16px; }
.auth-box { width: 100%; max-width: 410px; }
.auth-box .card { padding: 28px; }
.auth-brand { display: flex; gap: 12px; align-items: center; color: #fff; margin-bottom: 18px; justify-content: center; }
.auth-brand .mark { width: 42px; height: 42px; border-radius: 11px; background: rgba(255,255,255,.15); display: grid; place-items: center; }
.auth-brand b { font-size: 18px; display: block; } .auth-brand small { color: #bfe0dd; }
.auth-box h1 { font-size: 20px; margin-bottom: 4px; }
.auth-box .sub { color: var(--muted); margin-bottom: 18px; }
.auth-foot { text-align: center; color: #bfe0dd; font-size: 12.5px; margin-top: 14px; }
.auth-foot a { color: #fff; }

/* ---- small screens ---- */
@media (max-width: 1100px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid.g3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 860px) {
  .side { position: fixed; left: 0; top: 0; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  body.side-open .side { transform: none; }
  body.side-open .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 20; }
  .menu-btn { display: inline-grid; }
  .top { padding: 10px 16px; }
  .content { padding: 16px 16px 40px; }
  .grid, .grid.g3 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .row2, .row3 { grid-template-columns: 1fr; }
  .me-name { display: none; }
  .table-wrap { margin: 0 -20px; }
  .kv { grid-template-columns: 1fr; gap: 2px; } .kv dd { margin-bottom: 8px; }
}
@media (max-width: 480px) { .stats { grid-template-columns: 1fr 1fr; gap: 10px; } .stat .v { font-size: 22px; } .top-actions .btn span { display: none; } }

/* ---- books ---- */
.thumb { display: block; width: 40px; height: 56px; border-radius: 4px; overflow: hidden; background: #eef1f3; border: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb span { display: grid; place-items: center; height: 100%; color: #a0aab4; }
table.books td { vertical-align: middle; }
tr.is-hidden td { opacity: .55; }
tr.is-hidden td:first-child { opacity: 1; }
.book-grid { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; align-items: start; }
.book-main { display: grid; gap: 16px; }
.book-main .card + .card { margin-top: 0; }
.cover-card { position: sticky; top: 76px; }
.cover-big { aspect-ratio: 2 / 3; border-radius: 8px; overflow: hidden; background: #eef1f3; border: 1px solid var(--line); display: grid; place-items: center; }
.cover-big img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.no-cover { display: grid; gap: 8px; justify-items: center; text-align: center; color: #9aa4ae; padding: 16px; }
.cover-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.cover-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.cover-item { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.cover-item .img { aspect-ratio: 2 / 3; background: #f3f5f7; display: grid; place-items: center; }
.cover-item .img img { width: 100%; height: 100%; object-fit: contain; }
.cover-item .meta { padding: 8px 10px; font-size: 12.5px; line-height: 1.35; flex: 1; }
.cover-item .meta b { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cover-item .acts { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); }
.cover-item .acts button { border: 0; background: #fff; padding: 8px; font: inherit; font-weight: 600; cursor: pointer; }
.cover-item .acts button + button { border-left: 1px solid var(--line); }
.cover-item .acts .ok { color: var(--ok); } .cover-item .acts .no { color: var(--bad); }
.cover-item .acts button:hover { background: #f5f7f9; }
.cover-item.done { opacity: .45; pointer-events: none; }
.runner { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.runner .log { font-size: 12.5px; color: var(--ink-2); max-height: 180px; overflow: auto; background: #f8fafb; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; white-space: pre-line; }
.sortable td input[type=text] { height: 34px; }
@media (max-width: 860px) { .book-grid { grid-template-columns: 1fr; } .cover-card { position: static; } .cover-big { max-width: 220px; } }

/* ---- orders ---- */
.tabs.scroll { overflow-x: auto; white-space: nowrap; }
.tabs .count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: #eef0f2; color: var(--ink-2); font-size: 11.5px; margin-left: 4px; text-align: center; }
.tabs a.on .count { background: var(--brand-l); color: var(--brand-d); }
table.orders td { vertical-align: top; }
tr.is-new td:nth-child(2) { box-shadow: inset 3px 0 0 #e0a100; }
.order-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 16px; }
.stage-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.stage-actions form { margin: 0; }
.set-stage { display: flex; gap: 6px; } .set-stage select { width: auto; height: 38px; }
details.cancel { position: relative; }
details.cancel summary { list-style: none; } details.cancel summary::-webkit-details-marker { display: none; }
details.cancel .pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 6; width: 300px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(16,24,40,.14); padding: 12px; display: grid; gap: 8px; }
.order-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 16px; align-items: start; }
.order-main, .order-side { display: grid; gap: 16px; }
.order-main > .card + .card, .order-side > .card + .card { margin-top: 0; }
table.lines input[type=text] { height: 34px; }
table.lines input.need { border-color: #e0a100; background: #fffaf0; }
.rm { display: inline-flex; gap: 3px; align-items: center; color: var(--bad); cursor: pointer; font-size: 12px; }
.ok-text { color: var(--ok); } .warn-text { color: var(--warn); }
.totals { margin: 14px 0 0 auto; max-width: 340px; display: grid; gap: 6px; }
.totals > div { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.totals input { width: 120px; height: 34px; text-align: right; }
.totals .grand { border-top: 1px solid var(--line); padding-top: 8px; font-size: 16px; }
.btn.wa { background: #25d366; border-color: #25d366; color: #fff; } .btn.wa:hover { background: #1ebe5b; }
.msg-box { display: grid; gap: 10px; } .msg-box select { width: auto; max-width: 100%; }
.note-form { display: grid; gap: 8px; margin-bottom: 14px; } .note-form .btn { justify-self: start; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 16px; border-left: 2px solid var(--line); display: grid; gap: 12px; }
.timeline li { position: relative; }
.timeline li::before { content: ''; position: absolute; left: -22px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: #c8d0d6; border: 2px solid #fff; }
.timeline li.stage::before { background: var(--brand); } .timeline li.note::before { background: #e0a100; } .timeline li.message::before { background: #25d366; }
.timeline .when { display: block; font-size: 12px; color: var(--muted); }
.timeline li > div { color: var(--ink-2); white-space: normal; }
.kpis { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.chart-wrap { position: relative; }
.chart-wrap svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-tip { position: absolute; pointer-events: none; background: #1f2933; color: #fff; font-size: 12px; padding: 6px 9px; border-radius: 7px; white-space: nowrap; transform: translate(-50%, -110%); opacity: 0; transition: opacity .1s; }
.rank td.bar-cell { width: 40%; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; }
.presets a { padding: 6px 11px; border-radius: 20px; border: 1px solid var(--line-2); color: var(--ink-2); font-weight: 600; font-size: 13px; background: #fff; }
.presets a.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.presets a:hover { text-decoration: none; border-color: var(--brand); }
.nav-badge { margin-left: auto; background: #e0a100; color: #1f2933; border-radius: 10px; font-size: 11px; font-weight: 700; padding: 0 7px; line-height: 18px; }
@media (max-width: 1000px) { .order-grid { grid-template-columns: 1fr; } }
/* Landing page editor */
.lp-search { position: relative; }
.lp-results { display: grid; gap: 6px; margin-top: 8px; max-height: 340px; overflow: auto; }
.lp-results:empty { display: none; }
.lp-hit { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.lp-hit .lp-t { min-width: 0; } .lp-hit .lp-t b { display: block; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .lp-hit small { font-size: 12px; }
.landing-form .branch-row .field label small { font-weight: 400; }
