/* The shop's back office. A neutral, temporary identity (the owner's D5, 2026-11-05: three proposals come later) on the
   owner's standing rules from the farm: IBM Plex Sans Arabic for both scripts; radii 4/6/10; 1px borders; white panels
   on a grey page; body 14/22, tables 13, heads 12/500, h1 22/600; no weight above 600; no letter-spacing; nothing under
   12px; Western digits; logical properties only, so RTL and LTR are one attribute; the menu button at the top, its icon
   alone; no bar at the bottom of a phone. */

:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --raised: #eef0f3;
  --ink: #1b222c;
  --ink-2: #39424e;
  --muted: #5b6573;
  --hair: #e1e4e9;
  --line: #c9ced6;
  --field: #ffffff;
  --primary: #232b36;
  --on-primary: #ffffff;
  --primary-hover: #364150;
  --link: #255f9e;
  --focus: #2f6fb8;
  --good: #1f6b45;
  --good-soft: #e3f1e9;
  --warn: #835c00;
  --warn-soft: #fbf0d6;
  --bad: #b3261e;
  --bad-soft: #fbe7e5;
  --scrim: rgba(17, 22, 29, .38);
  --shadow: 0 10px 30px rgba(17, 22, 29, .14);
  --r-panel: 10px;
  --r-field: 6px;
  --r-chip: 4px;
  --side: 256px;
  --font: 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101317; --panel: #181c22; --raised: #222831; --ink: #e6e9ed; --ink-2: #c5cbd3; --muted: #99a2ad;
    --hair: #29303a; --line: #3a424d; --field: #13171c; --primary: #e6e9ed; --on-primary: #101317; --primary-hover: #c9cfd6;
    --link: #8db6e6; --focus: #8db6e6; --good: #7cc79f; --good-soft: #17301f; --warn: #e2b862; --warn-soft: #33290f;
    --bad: #f0928b; --bad-soft: #3a1b19; --scrim: rgba(0, 0, 0, .55); --shadow: 0 10px 30px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #101317; --panel: #181c22; --raised: #222831; --ink: #e6e9ed; --ink-2: #c5cbd3; --muted: #99a2ad;
  --hair: #29303a; --line: #3a424d; --field: #13171c; --primary: #e6e9ed; --on-primary: #101317; --primary-hover: #c9cfd6;
  --link: #8db6e6; --focus: #8db6e6; --good: #7cc79f; --good-soft: #17301f; --warn: #e2b862; --warn-soft: #33290f;
  --bad: #f0928b; --bad-soft: #3a1b19; --scrim: rgba(0, 0, 0, .55); --shadow: 0 10px 30px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 14px/22px var(--font); font-variant-numeric: lining-nums;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 600; color: var(--ink); }
h1 { font-size: 22px; line-height: 30px; }
h2 { font-size: 16px; line-height: 24px; }
h3 { font-size: 14px; line-height: 22px; }
p { margin: 0 0 12px; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden, [hidden] { display: none !important; }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.nil { color: var(--muted); }
svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.skip-link { position: absolute; inset-inline-start: 12px; top: -60px; z-index: 100; background: var(--primary); color: var(--on-primary);
  padding: 8px 14px; border-radius: var(--r-field); }
.skip-link:focus { top: 12px; }

/* ---- controls ---- */
button, .button {
  font: 500 14px/20px var(--font); display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px; padding: 8px 14px; border-radius: var(--r-field); border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap;
}
button:hover, .button:hover { background: var(--raised); text-decoration: none; }
button:disabled { opacity: .55; cursor: default; }
button.primary, .button.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
button.primary:hover, .button.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
button.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
button.ghost, .button.ghost { background: transparent; }
button.small, .button.small { min-height: 32px; padding: 5px 10px; font-size: 13px; }
button.wide { width: 100%; }
button.link { border: 0; background: none; color: var(--link); padding: 4px 0; min-height: 0; }
.danger-text { color: var(--bad) !important; }
button.add { gap: 6px; }
.icon-btn { min-height: 36px; width: 36px; padding: 0; border-color: transparent; background: transparent; }

input, select, textarea {
  font: 400 14px/20px var(--font); color: var(--ink); background: var(--field); border: 1px solid var(--line);
  border-radius: var(--r-field); padding: 9px 11px; min-height: 40px; width: 100%;
}
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--line) 60%, var(--ink)); }
input:disabled, select:disabled { background: var(--raised); color: var(--muted); }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; min-height: 0; padding: 0; margin: 0; accent-color: var(--primary); flex: none; }
input::placeholder { color: var(--muted); opacity: .8; }
input[aria-invalid=true] { border-color: var(--bad); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; margin: 0 0 14px; border: 0; padding: 0; }
.field > label, .field .label, .field legend, .field-head label { font-weight: 500; font-size: 13px; color: var(--ink-2); }
.field legend { padding: 0; margin-bottom: 6px; }
.field .value { padding: 2px 0; }
.value.strong { font-weight: 600; margin: 0 0 14px; }
.field-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.req { color: var(--bad); }
.hint { font-size: 12px; line-height: 18px; color: var(--muted); }
.field-error { font-size: 12px; line-height: 18px; color: var(--bad); }
.check { display: flex; align-items: center; gap: 10px; min-height: 36px; cursor: pointer; }
.checks { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.lang-tabs { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r-chip); overflow: hidden; }
.lang-tabs button { min-height: 24px; padding: 1px 8px; border: 0; border-radius: 0; font-size: 12px; background: transparent; color: var(--muted); }
.lang-tabs button + button { border-inline-start: 1px solid var(--line); }
.lang-tabs button[aria-selected=true] { background: var(--primary); color: var(--on-primary); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 16px; }
.form-grid .wide, .form-grid h3 { grid-column: 1 / -1; }
.form-grid h3 { margin: 6px 0 12px; }
.form-foot { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }
.narrow-form { max-width: 520px; }
.narrow-form h3 { margin: 18px 0 12px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }

.msg { border: 1px solid; border-inline-start-width: 3px; border-radius: var(--r-field); padding: 10px 12px; margin: 0 0 14px; font-size: 13px; }
.msg.bad { color: var(--bad); background: var(--bad-soft); }
.msg.good { color: var(--good); background: var(--good-soft); }
.msg button { margin-inline-start: 8px; }
.badge { display: inline-block; font-size: 12px; line-height: 18px; font-weight: 500; padding: 1px 8px; border-radius: var(--r-chip);
  background: var(--raised); color: var(--ink-2); white-space: nowrap; vertical-align: middle; }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }

/* ---- the shell ---- */
.topbar { display: none; }
.side {
  position: fixed; inset-block: 0; inset-inline-start: 0; width: var(--side); z-index: 40;
  display: flex; flex-direction: column; gap: 8px; padding: 16px 12px; overflow-y: auto;
  background: var(--panel); border-inline-end: 1px solid var(--hair);
}
body.signed-in main { margin-inline-start: var(--side); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); padding: 4px 6px 8px; min-width: 0; }
.brand:hover { text-decoration: none; }
.mark { width: 36px; height: 36px; border-radius: var(--r-field); background: var(--primary); color: var(--on-primary);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; flex: none; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-weight: 600; line-height: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-sub { font-size: 12px; line-height: 16px; color: var(--muted); }
.switch-shop { display: flex; align-items: center; gap: 8px; padding: 0 6px; color: var(--muted); }
.switch-shop select { min-height: 34px; padding: 5px 8px; font-size: 13px; }
.side nav { flex: 1; display: flex; flex-direction: column; gap: 14px; margin-top: 6px; }
.nav-title { font-size: 12px; font-weight: 500; color: var(--muted); padding: 0 10px 4px; }
.side nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--r-field);
  color: var(--ink-2); line-height: 20px; }
.side nav a:hover { background: var(--raised); color: var(--ink); text-decoration: none; }
.side nav a.on { background: var(--raised); color: var(--ink); font-weight: 600; }
.side nav a svg { color: var(--muted); }
.side nav a.on svg { color: var(--ink); }
.side-foot { border-top: 1px solid var(--hair); padding: 12px 6px 0; display: flex; flex-direction: column; gap: 8px; }
.who { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; direction: ltr; text-align: start; }
[dir=rtl] .who { text-align: end; }
.side-backdrop { display: none; }

main { padding: 24px 32px 48px; }
#app { max-width: 1400px; outline: none; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 0 0 20px; }

@media (max-width: 1100px) {
  body.signed-in main { margin-inline-start: 0; }
  .topbar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 30; height: 56px;
    padding: 0 12px; background: var(--panel); border-bottom: 1px solid var(--hair); }
  .topbar .brand { padding: 0; }
  .topbar .brand-sub { display: none; }
  .topbar .mark { width: 30px; height: 30px; font-size: 13px; }
  .menu-btn { width: 40px; height: 40px; min-height: 40px; padding: 0; border-color: var(--line); }
  .menu-btn svg { width: 20px; height: 20px; }
  .side { width: min(300px, 86vw); transform: translateX(-105%); transition: transform .2s ease; box-shadow: var(--shadow); }
  [dir=rtl] .side { transform: translateX(105%); }
  #bar.open .side { transform: none; }
  #bar.open .side-backdrop { display: block; position: fixed; inset: 0; background: var(--scrim); z-index: 35; }
  main { padding: 18px 16px 40px; }
}

/* ---- panels and the sign-in ---- */
.panel { background: var(--panel); border: 1px solid var(--hair); border-radius: var(--r-panel); padding: 20px; margin: 0 0 16px; }
.panel > h2 { margin-bottom: 12px; }
.panel.narrow { max-width: 620px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }

#login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
body.signed-in #login { display: none; }
.login-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--hair); border-radius: var(--r-panel); padding: 28px 24px 18px; }
.login-card h1 { margin: 14px 0 4px; }
.login-card form { margin-top: 18px; }
.login-card .link { margin-top: 10px; }
.login-mark { width: 44px; height: 44px; border-radius: var(--r-panel); background: var(--primary); color: var(--on-primary);
  display: flex; align-items: center; justify-content: center; }
.login-mark svg { width: 22px; height: 22px; }

/* ---- the dashboard ---- */
.dash { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 16px; align-items: start; }
.dash .panel { margin: 0; }
.facts { margin: 0 0 14px; display: grid; gap: 10px; }
.facts div { display: grid; grid-template-columns: 140px 1fr; gap: 12px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.sections { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.sections a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--hair); border-radius: var(--r-field); color: var(--ink); }
.sections a:hover { background: var(--raised); text-decoration: none; }
.sections .s-name { flex: 1; min-width: 0; }
.sections svg { color: var(--muted); }
.coming { max-width: 720px; }
.invites { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.invites li { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 12px; border: 1px solid var(--hair); border-radius: var(--r-field); }
.inv-name { display: flex; flex-direction: column; }
.inv-name .muted { font-size: 13px; }
.sub-head { margin: 20px 0 8px; }
.coming h2 { margin: 10px 0 8px; }
.shop-cards { display: grid; gap: 8px; margin-top: 12px; }
.shop-card { justify-content: flex-start; gap: 12px; padding: 12px; min-height: 60px; text-align: start; white-space: normal; }
.shop-card > span:last-child { display: flex; flex-direction: column; }
.shop-card .muted { font-size: 13px; font-weight: 400; }
@media (max-width: 900px) { .dash { grid-template-columns: 1fr; } }
@media (max-width: 520px) { .sections { grid-template-columns: 1fr; } .facts div { grid-template-columns: 110px 1fr; } }

/* ---- tabs ---- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--hair); margin: 0 0 16px; flex-wrap: wrap; }
.tabs button { border: 0; border-radius: 0; background: none; color: var(--muted); padding: 10px 12px; min-height: 42px;
  box-shadow: inset 0 -2px 0 transparent; }
.tabs button:hover { background: none; color: var(--ink); }
.tabs button[aria-selected=true] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--ink); }

/* ---- lists ---- */
.list-tools { display: flex; gap: 8px; margin: 4px 0 12px; }
.search { position: relative; display: flex; align-items: center; flex: 1; max-width: 360px; }
.search svg { position: absolute; inset-inline-start: 10px; color: var(--muted); pointer-events: none; }
.search input { padding-inline-start: 36px; }
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: 13px; line-height: 20px; }
table.list th { text-align: start; font-size: 12px; font-weight: 500; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--hair); white-space: nowrap; }
table.list th .sort { border: 0; background: none; padding: 0; min-height: 0; font: inherit; color: inherit; gap: 4px; }
table.list th[aria-sort=ascending] .sort::after { content: '↑'; }
table.list th[aria-sort=descending] .sort::after { content: '↓'; }
table.list td { padding: 10px; border-bottom: 1px solid var(--hair); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list .num { text-align: end; }
table.list td.acts { text-align: end; white-space: nowrap; }
table.list td.acts button + button { margin-inline-start: 4px; }
table.list .empty-row td { color: var(--muted); text-align: center; padding: 24px 10px; }
@media (max-width: 640px) {
  table.list thead { display: none; }
  table.list, table.list tbody, table.list tr, table.list td { display: block; width: 100%; }
  table.list tr { border: 1px solid var(--hair); border-radius: var(--r-field); padding: 6px 12px; margin-bottom: 8px; }
  table.list td { border: 0; padding: 4px 0; display: grid; grid-template-columns: 38% 1fr; gap: 10px; text-align: start; }
  table.list td::before { content: attr(data-label); color: var(--muted); font-size: 12px; }
  table.list td.acts { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-start; padding-top: 8px; }
  table.list td.acts::before { content: none; }
  table.list td.acts button + button { margin: 0; }
  table.list .num { text-align: start; }
  table.list .empty-row td { display: block; text-align: center; }
  table.list .empty-row td::before { content: none; }
  table.list tr.empty-row { border-style: dashed; }
}

/* the rights grid of a role */
table.rights { border-collapse: collapse; width: 100%; font-size: 13px; }
table.rights th, table.rights td { padding: 8px; border-bottom: 1px solid var(--hair); text-align: center; }
table.rights th[scope=row], table.rights thead th:first-child { text-align: start; font-weight: 500; }
table.rights thead th { font-size: 12px; font-weight: 500; color: var(--muted); }

/* ---- drawers, the confirm box, toasts ---- */
.drawer-wrap { position: fixed; inset: 0; z-index: 60; visibility: hidden; }
.drawer-wrap.open { visibility: visible; }
.drawer-backdrop { position: absolute; inset: 0; background: var(--scrim); opacity: 0; transition: opacity .2s ease; }
.drawer-wrap.open .drawer-backdrop { opacity: 1; }
.drawer { position: absolute; inset-block: 0; inset-inline-end: 0; width: min(480px, 100vw); background: var(--panel);
  display: flex; flex-direction: column; box-shadow: var(--shadow); transform: translateX(105%); transition: transform .22s ease; }
[dir=rtl] .drawer { transform: translateX(-105%); }
.drawer.wide { width: min(680px, 100vw); }
.drawer-wrap.open .drawer { transform: none; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 14px 20px; border-bottom: 1px solid var(--hair); }
[dir=rtl] .drawer-head { padding: 14px 20px 14px 16px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 20px 8px; }
.drawer-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--hair); }
body.drawer-open { overflow: hidden; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } .drawer, .drawer.wide { width: 100vw; } }

.modal-wrap { position: fixed; inset: 0; z-index: 90; background: var(--scrim); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--panel); border-radius: var(--r-panel); padding: 20px; max-width: 420px; width: 100%; box-shadow: var(--shadow); }
.modal p { margin-bottom: 18px; }

#toasts { position: fixed; inset-block-end: 16px; inset-inline-start: 16px; z-index: 95; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 32px); }
.toast { background: var(--primary); color: var(--on-primary); padding: 10px 14px; border-radius: var(--r-field); box-shadow: var(--shadow);
  font-size: 13px; transition: opacity .24s ease; max-width: 420px; }
.toast.bad { background: var(--bad); color: #fff; }
.toast.gone { opacity: 0; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
@media (pointer: coarse) { button, .button { min-height: 44px; } button.small { min-height: 38px; } .side nav a { padding-block: 10px; } }
