/* Shared tokens + components for every admin page (public/admin/*.html).
   Style "B - Glass": translucent blurred surfaces over a soft multi-radial
   background tinted with the brand green, iOS-system font stack, large
   radii. See umg-style-ref.html (.sB rules) - this is that direction,
   expanded from a phone-frame demo into real responsive page layout.
   Customer chat UI (public/css/style.css) is untouched and keeps the
   WhatsApp look - this file is admin-only. */

:root {
  --adm-bg: #EEF4F2;
  --adm-card: rgba(255, 255, 255, .55);
  --adm-sheet: rgba(255, 255, 255, .72);
  --adm-tx: #0B1A17;
  --adm-tx2: #5E6B68;
  --adm-tx3: #A9B3B0;
  --adm-sep: rgba(11, 26, 23, .10);
  --adm-fill: rgba(255, 255, 255, .55);
  --adm-seg-on: rgba(255, 255, 255, .95);
  --adm-accent: #128C7E;
  --adm-accent-ink: #FFFFFF;
  --adm-r: 20px;
  --adm-r-lg: 28px;

  --adm-role-owner: #FF9F0A;
  --adm-role-admin: #0A84FF;
  --adm-role-tester: #AF52DE;
  --adm-role-customer: #8E8E93;

  --adm-ok: #1F8A5B; --adm-ok-bg: rgba(31, 138, 91, .14);
  --adm-bad: #D7352B; --adm-bad-bg: rgba(215, 53, 43, .12);
  --adm-warn: #B7791F; --adm-warn-bg: rgba(183, 121, 31, .14);
  --adm-info: #0A6FB2; --adm-info-bg: rgba(10, 111, 178, .12);

  --adm-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Hebrew", "Heebo", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --adm-bg: #06100E;
    --adm-card: rgba(255, 255, 255, .08);
    --adm-sheet: rgba(28, 36, 34, .80);
    --adm-tx: #EEF5F3;
    --adm-tx2: #93A4A0;
    --adm-tx3: #4A5754;
    --adm-sep: rgba(255, 255, 255, .10);
    --adm-fill: rgba(255, 255, 255, .10);
    --adm-seg-on: rgba(255, 255, 255, .22);
    --adm-accent: #3CC4B0;
    --adm-accent-ink: #06100E;
    --adm-ok: #58C98B; --adm-ok-bg: rgba(88, 201, 139, .16);
    --adm-bad: #F2766B; --adm-bad-bg: rgba(242, 118, 107, .16);
    --adm-warn: #E6B35A; --adm-warn-bg: rgba(230, 179, 90, .16);
    --adm-info: #6CB6EC; --adm-info-bg: rgba(108, 182, 236, .16);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --adm-bg: #06100E;
  --adm-card: rgba(255, 255, 255, .08);
  --adm-sheet: rgba(28, 36, 34, .80);
  --adm-tx: #EEF5F3;
  --adm-tx2: #93A4A0;
  --adm-tx3: #4A5754;
  --adm-sep: rgba(255, 255, 255, .10);
  --adm-fill: rgba(255, 255, 255, .10);
  --adm-seg-on: rgba(255, 255, 255, .22);
  --adm-accent: #3CC4B0;
  --adm-accent-ink: #06100E;
  --adm-ok: #58C98B; --adm-ok-bg: rgba(88, 201, 139, .16);
  --adm-bad: #F2766B; --adm-bad-bg: rgba(242, 118, 107, .16);
  --adm-warn: #E6B35A; --adm-warn-bg: rgba(230, 179, 90, .16);
  --adm-info: #6CB6EC; --adm-info-bg: rgba(108, 182, 236, .16);
}

* { box-sizing: border-box; }
.hidden { display: none !important; }
html { direction: rtl; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--adm-font);
  color: var(--adm-tx);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(120% 60% at 90% 0%, rgba(18, 140, 126, .35), transparent 60%),
    radial-gradient(90% 50% at 0% 40%, rgba(120, 190, 255, .30), transparent 60%),
    radial-gradient(80% 50% at 80% 100%, rgba(255, 190, 120, .25), transparent 60%),
    var(--adm-bg);
  background-attachment: fixed;
}
button { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--adm-accent); outline-offset: 2px; }

/* Glass surface, shared by every card/list/sheet/segmented-control. */
.adm-glass {
  background: var(--adm-card);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  border: .5px solid rgba(255, 255, 255, .55);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5), 0 6px 20px rgba(0, 0, 0, .05);
}
:root:not([data-theme="light"]) .adm-glass { border-color: rgba(255, 255, 255, .14); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08); }
:root[data-theme="dark"] .adm-glass { border-color: rgba(255, 255, 255, .14); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08); }
/* Fallback where backdrop-filter is unsupported: an opaque-enough surface
   instead of a see-through, low-contrast one. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .adm-glass { background: color-mix(in srgb, var(--adm-card) 94%, var(--adm-bg)); }
}

/* ---------- Header + nav ---------- */
.adm-header {
  padding: calc(14px + env(safe-area-inset-top, 0px)) 20px 10px;
  max-width: 1200px; margin: 0 auto;
}
.adm-header-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.adm-brand { font-size: clamp(22px, 3vw, 30px); font-weight: 700; letter-spacing: -0.02em; margin: 0; }
.adm-brand small { font-weight: 400; color: var(--adm-tx2); font-size: 14px; margin-inline-start: 8px; }
.adm-header-actions { display: flex; gap: 8px; align-items: center; }

.adm-btn {
  font: inherit;
  border: none;
  border-radius: 12px;
  padding: 8px 14px;
  cursor: pointer;
  background: var(--adm-accent);
  color: var(--adm-accent-ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.adm-btn:hover { filter: brightness(1.06); }
.adm-btn-ghost { background: var(--adm-fill); color: var(--adm-tx); border: .5px solid rgba(255, 255, 255, .5); }
:root:not([data-theme="light"]) .adm-btn-ghost { border-color: rgba(255, 255, 255, .14); }
.adm-btn-danger { background: var(--adm-bad); color: #fff; }
.adm-btn-small { padding: 6px 12px; font-size: 13px; border-radius: 10px; }
.adm-btn-block { width: 100%; justify-content: center; }
.adm-btn[disabled] { opacity: .5; cursor: default; }

.adm-nav {
  display: inline-flex;
  gap: 2px;
  margin-top: 12px;
  padding: 2px;
  border-radius: 14px;
  background: var(--adm-fill);
  max-width: 100%;
  overflow-x: auto;
}
.adm-navlink {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--adm-tx2);
  text-decoration: none;
  padding: 7px 16px;
  border-radius: 12px;
  white-space: nowrap;
}
.adm-navlink[aria-current="page"] { background: var(--adm-seg-on); color: var(--adm-tx); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); font-weight: 600; }

.adm-main { max-width: 1200px; margin: 0 auto; padding: 16px 20px 64px; display: grid; gap: 16px; }
.adm-gate { background: var(--adm-card); border-radius: var(--adm-r); padding: 40px 24px; text-align: center; font-size: 16px; }

/* ---------- KPIs ---------- */
.adm-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 760px) { .adm-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.adm-kpi {
  font: inherit;
  text-align: start;
  border: none;
  border-radius: var(--adm-r);
  padding: 14px 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.adm-kpi.active { outline: 2px solid var(--adm-accent); outline-offset: -2px; }
.adm-kpi-num { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.adm-kpi-label { color: var(--adm-tx2); font-size: 12.5px; }
.adm-kpi-note { font-size: 11.5px; color: var(--adm-warn); }
.adm-meter { height: 5px; background: var(--adm-fill); border-radius: 3px; overflow: hidden; margin-top: 2px; }
.adm-meter > span { display: block; height: 100%; background: var(--adm-warn); border-radius: 3px; }

/* ---------- Legend ---------- */
.adm-legend { display: flex; gap: 8px 18px; flex-wrap: wrap; font-size: 12.5px; color: var(--adm-tx2); align-items: center; }
.adm-legend .adm-ricon { width: 20px; height: 20px; }
.adm-legend .adm-ricon svg { width: 11px; height: 11px; }

/* ---------- Filters ---------- */
.adm-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.adm-seg {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border-radius: 16px;
  background: var(--adm-fill);
  overflow-x: auto;
  max-width: 100%;
}
.adm-seg-btn {
  font: inherit;
  font-size: 13px;
  border: none;
  background: transparent;
  color: var(--adm-tx2);
  padding: 6px 14px;
  border-radius: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.adm-seg-btn[aria-pressed="true"] { background: var(--adm-seg-on); color: var(--adm-tx); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }
.adm-search {
  flex: 1 1 220px;
  min-width: 0;
  border: .5px solid rgba(255, 255, 255, .55);
  background: var(--adm-fill);
  color: var(--adm-tx);
  border-radius: 999px;
  padding: 8px 16px;
  font: inherit;
}
:root:not([data-theme="light"]) .adm-search { border-color: rgba(255, 255, 255, .14); }
.adm-search::placeholder { color: var(--adm-tx3); }

/* ---------- List / table ---------- */
.adm-list-wrap { border-radius: var(--adm-r); overflow: hidden; }
.adm-list-head, .adm-row {
  display: grid;
  grid-template-columns: minmax(0, 2fr) 0.8fr 0.7fr 0.8fr 0.9fr 0.7fr 0.9fr 0.7fr 16px;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
}
.adm-row-meta { display: none; color: var(--adm-tx2); font-size: 12px; margin-top: 1px; }
.adm-list-head {
  font-size: 12px;
  color: var(--adm-tx2);
  font-weight: 500;
}
.adm-list-head button {
  font: inherit;
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 0;
  text-align: start;
  width: 100%;
}
.adm-list-head button[aria-sort="descending"]::after { content: " ▾"; }
.adm-list-head button[aria-sort="ascending"]::after { content: " ▴"; }
.adm-row {
  cursor: pointer;
  position: relative;
  background: transparent;
}
.adm-row + .adm-row::before {
  content: "";
  position: absolute; top: 0; inset-inline-start: 14px; inset-inline-end: 14px;
  height: .5px; background: var(--adm-sep);
}
.adm-row:hover, .adm-row:focus-visible { background: var(--adm-fill); }
.adm-row.sel { background: var(--adm-info-bg); }
.adm-cell-email { display: flex; align-items: center; gap: 8px; min-width: 0; }
.adm-email { font-weight: 500; direction: ltr; unicode-bidi: plaintext; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.adm-cell-num { font-variant-numeric: tabular-nums; }
.adm-cell-soft { color: var(--adm-tx2); }
.adm-chev { color: var(--adm-tx3); font-size: 16px; justify-self: end; }
.adm-empty { padding: 40px 0; text-align: center; color: var(--adm-tx2); }

@media (max-width: 760px) {
  .adm-list-head { display: none; }
  .adm-row {
    grid-template-columns: minmax(0, 1fr) 16px;
    padding: 10px 12px;
  }
  .adm-row [data-col]:not([data-col="email"]) { display: none; }
  .adm-row-meta { display: block; }
}

.adm-ricon {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; flex: none; color: #fff;
}
.adm-ricon svg { width: 16px; height: 16px; }
.adm-ricon-owner { background: var(--adm-role-owner); }
.adm-ricon-admin { background: var(--adm-role-admin); }
.adm-ricon-tester { background: var(--adm-role-tester); }
.adm-ricon-customer { background: var(--adm-role-customer); }

.adm-pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 500;
  border-radius: 999px; padding: 2px 9px;
  white-space: nowrap;
}
.adm-pill .adm-ricon { width: 16px; height: 16px; }
.adm-pill .adm-ricon svg { width: 9px; height: 9px; }
.adm-pill-ok { background: var(--adm-ok-bg); color: var(--adm-ok); }
.adm-pill-bad { background: var(--adm-bad-bg); color: var(--adm-bad); }
.adm-pill-warn { background: var(--adm-warn-bg); color: var(--adm-warn); }
.adm-pill-info { background: var(--adm-info-bg); color: var(--adm-info); }
.adm-pill-plain { background: var(--adm-fill); color: var(--adm-tx2); }
.adm-pill-role-owner { background: var(--adm-warn-bg); color: var(--adm-warn); }
.adm-pill-role-admin { background: var(--adm-info-bg); color: var(--adm-info); }
.adm-pill-role-tester { background: rgba(175, 82, 222, .14); color: #9A3FCB; }
:root:not([data-theme="light"]) .adm-pill-role-tester { color: #CE94EE; }
:root[data-theme="dark"] .adm-pill-role-tester { color: #CE94EE; }
.adm-pill-role-customer { background: var(--adm-fill); color: var(--adm-tx2); }
.adm-muted { color: var(--adm-tx2); font-size: 13px; }

/* ---------- Audit log card ---------- */
.adm-card { background: var(--adm-card); border-radius: var(--adm-r); padding: 16px; }
.adm-card h2 { margin: 0 0 10px; font-size: 15px; font-weight: 600; }
.adm-audit { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.adm-audit li { display: flex; gap: 10px; flex-wrap: wrap; font-size: 13px; align-items: baseline; }
.adm-audit time { color: var(--adm-tx2); font-variant-numeric: tabular-nums; min-width: 96px; }
.adm-audit b { font-weight: 600; }
.adm-load-more { text-align: center; }

/* ---------- Scrim + sheets ---------- */
.adm-scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 30; }
@media (prefers-reduced-motion: no-preference) {
  .adm-scrim { animation: adm-fade .15s ease-out; }
  @keyframes adm-fade { from { opacity: 0; } }
}

/* Detail sheet: side panel on desktop, bottom sheet on phones. */
.adm-sheet {
  position: fixed; z-index: 31;
  background: var(--adm-sheet);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border: .5px solid rgba(255, 255, 255, .6);
  display: flex; flex-direction: column;
  top: 0; bottom: 0; inset-inline-end: 0;
  width: min(460px, 100%);
  border-radius: 24px 0 0 24px;
  box-shadow: 0 0 30px rgba(0, 0, 0, .18);
}
:root:not([data-theme="light"]) .adm-sheet { border-color: rgba(255, 255, 255, .14); }
@media (max-width: 760px) {
  .adm-sheet {
    top: auto; inset-inline: 6px; bottom: 6px;
    width: auto; height: 86%;
    border-radius: 32px;
  }
}
@media (prefers-reduced-motion: no-preference) {
  .adm-sheet { animation: adm-slide .18s ease-out; }
  @keyframes adm-slide { from { transform: translateX(-16px); opacity: .6; } }
}
.adm-grab { width: 36px; height: 5px; border-radius: 3px; background: var(--adm-tx3); opacity: .6; margin: 10px auto 0; flex: none; }
.adm-sheet-head { padding: 10px 16px 0; display: grid; gap: 10px; flex: none; }
.adm-sheet-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.adm-sheet-title { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 600; min-width: 0; }
.adm-sheet-title .adm-email { direction: ltr; unicode-bidi: plaintext; }
.adm-sheet-close { border: none; background: transparent; font-size: 22px; cursor: pointer; color: var(--adm-tx2); line-height: 1; padding: 4px; }
.adm-sheet-pills { display: flex; gap: 6px; flex-wrap: wrap; }

.adm-tabs { display: flex; border-bottom: .5px solid var(--adm-sep); flex: none; margin-top: 8px; }
.adm-tab { flex: 1; border: none; background: none; padding: 10px; cursor: pointer; color: var(--adm-tx2); border-bottom: 2px solid transparent; font-size: 13.5px; }
.adm-tab[aria-selected="true"] { color: var(--adm-accent); border-bottom-color: var(--adm-accent); font-weight: 600; }
.adm-sheet-body { flex: 1; overflow-y: auto; padding: 16px; display: grid; gap: 14px; align-content: start; }

.adm-facts { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; }
.adm-facts dt { color: var(--adm-tx2); }
.adm-facts dd { margin: 0; font-variant-numeric: tabular-nums; }

.adm-group { background: var(--adm-fill); border-radius: 16px; overflow: hidden; }
.adm-act {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; flex-wrap: wrap;
  border-bottom: .5px solid var(--adm-sep);
}
.adm-act:last-child { border-bottom: none; }
.adm-act-txt { display: grid; gap: 1px; min-width: 0; flex: 1 1 160px; }
.adm-act-txt b { font-weight: 500; font-size: 13.5px; }
.adm-act-txt span { color: var(--adm-tx2); font-size: 12px; }
.adm-cap-row { display: flex; gap: 6px; align-items: center; }
.adm-cap-row input {
  width: 68px; border: .5px solid rgba(255, 255, 255, .55); border-radius: 10px;
  padding: 6px 8px; font: inherit; background: var(--adm-fill); color: var(--adm-tx);
  font-variant-numeric: tabular-nums;
}
.adm-role-sel {
  font: inherit; border: .5px solid rgba(255, 255, 255, .55); border-radius: 10px;
  padding: 6px 8px; background: var(--adm-fill); color: var(--adm-tx);
}
.adm-locked { color: var(--adm-tx2); font-size: 12.5px; padding: 10px 12px; }

.adm-secret {
  background: var(--adm-ok-bg); color: var(--adm-ok); border-radius: 14px; padding: 12px;
  display: grid; gap: 8px; font-size: 13px;
}
.adm-secret code {
  font-size: 17px; letter-spacing: .07em; direction: ltr; font-family: Consolas, 'Courier New', monospace;
  color: var(--adm-tx); background: var(--adm-fill); padding: 6px 10px; border-radius: 8px;
  justify-self: start; user-select: all;
}

.adm-orders { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.adm-orders li { background: var(--adm-fill); border-radius: 14px; padding: 10px 12px; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.adm-orders b { font-variant-numeric: tabular-nums; }

.adm-chat { background: var(--adm-fill); border-radius: 16px; padding: 10px; display: grid; gap: 6px; }
.adm-chat-note { font-size: 12px; color: var(--adm-tx2); text-align: center; }
.adm-bub { max-width: 85%; padding: 6px 10px 4px; border-radius: 12px; font-size: 13.5px; line-height: 1.45; background: var(--adm-card); }
.adm-bub small { display: block; text-align: end; color: var(--adm-tx2); font-size: 11px; }
.adm-bub.u { justify-self: start; }
.adm-bub.b { justify-self: end; background: var(--adm-accent); color: var(--adm-accent-ink); }

/* ---------- Confirm sheet ---------- */
.adm-confirm-sheet {
  position: fixed; z-index: 32;
  inset-inline: 10px; bottom: 10px;
  margin-inline: auto; max-width: 420px;
  background: var(--adm-sheet);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border: .5px solid rgba(255, 255, 255, .6);
  border-radius: 24px;
  padding: 8px 18px 18px;
  display: grid; gap: 12px;
}
:root:not([data-theme="light"]) .adm-confirm-sheet { border-color: rgba(255, 255, 255, .14); }
.adm-confirm-title { font-weight: 600; font-size: 15px; text-align: center; padding-top: 6px; }
.adm-confirm-body { color: var(--adm-tx2); font-size: 13.5px; text-align: center; line-height: 1.5; }
.adm-confirm-actions { display: grid; gap: 8px; }
.adm-btn-primary { background: var(--adm-accent); color: var(--adm-accent-ink); }
@media (prefers-reduced-motion: no-preference) {
  .adm-confirm-sheet { animation: adm-pop .15s ease-out; }
  @keyframes adm-pop { from { transform: translateY(8px); opacity: 0; } }
}

/* ---------- Toast ---------- */
.adm-toast {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  background: var(--adm-tx);
  color: var(--adm-bg);
  padding: 10px 18px;
  border-radius: 999px;
  z-index: 60;
  font-size: 13.5px;
}
.adm-toast.error { background: var(--adm-bad); color: #fff; }
