/* ============================================================
   idgen-bot admin — light Mini-App theme
   Telegram-style: bottom nav, white cards, soft background.
   ============================================================ */

:root {
  --bg:           #f3f5f9;
  --panel:        #ffffff;
  --panel-2:      #f7f8fb;
  --line:         #e7eaf2;
  --line-strong:  #d6dbe6;
  --text:         #1c2230;
  --text-strong:  #0c111a;
  --muted:        #6b7280;
  --accent:       #2f7ef7;     /* Telegram blue */
  --accent-soft:  #e5efff;
  --accent-strong:#1f63d8;
  --good:         #16a34a;
  --good-soft:    #dcfce7;
  --bad:          #dc2626;
  --bad-soft:     #fee2e2;
  --warn:         #d97706;
  --warn-soft:    #fef3c7;
  --shadow-sm:    0 1px 2px rgba(20, 24, 36, 0.06);
  --shadow-md:    0 4px 16px rgba(20, 24, 36, 0.08);
  --radius-sm:    8px;
  --radius-md:    12px;
  --radius-lg:    16px;

  --safe-bottom:  env(safe-area-inset-bottom, 0px);
}

/* Inside Telegram, themeParams provides matching values automatically. */
body.tg-active {
  --bg:    var(--tg-theme-bg-color, #f3f5f9);
  --panel: var(--tg-theme-secondary-bg-color, #ffffff);
  --text:  var(--tg-theme-text-color, #1c2230);
  --muted: var(--tg-theme-hint-color, #6b7280);
  --accent: var(--tg-theme-button-color, #2f7ef7);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 15px/1.45 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv02", "cv11", "ss01";
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}
.screen { min-height: 100vh; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--bad); }
code { font-family: ui-monospace, SFMono-Regular, "Cascadia Mono", Menlo, monospace; font-size: 12.5px; }
.flex-1 { flex: 1; }

button, input, select { font: inherit; color: inherit; }

button {
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: filter 0.1s, transform 0.06s;
  min-height: 40px;
}
button:hover { filter: brightness(1.05); }
button:active { transform: translateY(1px); }
button[disabled] { opacity: 0.45; cursor: not-allowed; }
button.ghost {
  background: var(--panel);
  color: var(--text);
  border-color: var(--line);
}
button.ghost:hover { background: var(--panel-2); }
button.good { background: var(--good); border-color: var(--good); }
button.danger { background: var(--bad); border-color: var(--bad); }
button > i[data-lucide], button svg { width: 16px; height: 16px; stroke-width: 2; }

input, select {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  transition: border-color 0.12s, box-shadow 0.12s;
  color: var(--text);
}
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder { color: #9aa1ad; }

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}
.input-with-icon i[data-lucide] {
  position: absolute;
  left: 11px;
  width: 16px;
  height: 16px;
  color: var(--muted);
  pointer-events: none;
}
.input-with-icon input { padding-left: 36px; width: 100%; }

/* ============================================================
   Login
   ============================================================ */
.login-card {
  max-width: 360px;
  margin: 18vh auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  text-align: center;
  box-shadow: var(--shadow-md);
}
.login-logo {
  width: 56px; height: 56px;
  margin: 0 auto 14px;
  border-radius: var(--radius-md);
  display: grid; place-items: center;
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft);
}
.login-logo i { width: 28px; height: 28px; color: var(--accent); }
.login-card h1 { margin: 0; font-size: 20px; font-weight: 600; color: var(--text-strong); }
.login-card p { margin: 6px 0 18px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card button { justify-content: center; }
.tg-login-slot { min-height: 48px; display: flex; justify-content: center; align-items: center; margin: 6px 0 4px; }
.tg-login-slot iframe { max-width: 100% !important; }
.login-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 18px 0 12px;
  color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
}
.login-divider::before, .login-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.login-card .muted.small { font-size: 11px; }

/* ============================================================
   App layout — top header + content + bottom nav
   ============================================================ */
header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
  /* For iOS notch */
  padding-top: max(12px, env(safe-area-inset-top));
}
.brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 600; color: var(--text-strong);
  letter-spacing: -0.01em;
}
.brand i { width: 20px; height: 20px; color: var(--accent); }
header nav { display: none; }   /* desktop top-tabs replaced by bottom nav */
.session-area {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
}
.session-area #role-badge { font-size: 11px; padding: 4px 9px; }
#view-as { font-size: 12px; padding: 6px 10px; max-width: 180px; }
.session-area #logout { padding: 7px 11px; min-height: 34px; }
.session-area #logout span { display: none; }
@media (min-width: 720px) {
  .session-area #logout span { display: inline; }
  #view-as { max-width: 240px; }
}

main {
  padding: 16px 16px calc(86px + var(--safe-bottom));
  max-width: 980px;
  margin: 0 auto;
}
@media (min-width: 720px) {
  main {
    max-width: 1180px;
    padding: 20px 24px calc(86px + var(--safe-bottom));
  }
}
@media (min-width: 1280px) {
  main {
    max-width: 1320px;
    padding: 24px 32px calc(86px + var(--safe-bottom));
  }
}
@media (min-width: 1600px) {
  main {
    max-width: 1440px;
    padding: 28px 40px calc(86px + var(--safe-bottom));
  }
}
.tab-content { display: none; animation: fadeIn 0.16s ease both; }
.tab-content.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.section-head h2 {
  margin: 0; font-size: 18px; font-weight: 600; color: var(--text-strong);
  display: flex; align-items: center; gap: 8px;
}
.section-head h2 i { width: 18px; height: 18px; color: var(--accent); }

/* Admin Pros tab */
.ap-list { display: grid; gap: 12px; }
.ap-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
}
.ap-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 14px; margin-bottom: 10px;
}
.ap-id { flex: 1; min-width: 0; }
.ap-name { font-weight: 600; font-size: 14px; color: var(--text-strong); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ap-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.ap-balance { text-align: right; }
.ap-balance .balance-value.negative { color: #b03333; }
.ap-balance .balance-value.muted { color: var(--muted); }
.ap-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  background: var(--panel-2);
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 10px;
}
.ap-stat { display: flex; flex-direction: column; gap: 2px; }
.ap-stat-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.ap-stat-value { font-size: 13px; color: var(--text-strong); font-weight: 500; }
.ap-receivers {
  font-size: 12px; color: var(--text); margin-bottom: 10px;
  background: var(--panel-2); padding: 8px; border-radius: 6px;
}
.ap-receivers > div { margin-bottom: 4px; }
.ap-receivers > div:last-child { margin-bottom: 0; }
.ap-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* Templates manager */
.templates-list { display: grid; gap: 8px; }
.tpl-row {
  display: grid;
  grid-template-columns: 24px 72px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transition: box-shadow 0.12s, background 0.12s;
}
.tpl-row:hover { background: var(--panel-2); }
.tpl-row-ghost { opacity: 0.4; background: var(--accent-soft); }
.tpl-row-hidden { opacity: 0.6; background: rgba(243,181,74,0.05); }
.tpl-row-hidden .tpl-name .tag.warn {
  background: rgba(243,181,74,0.2);
  color: #c98a14;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: 4px;
  vertical-align: middle;
}
.tpl-drag { color: var(--muted); cursor: grab; display: flex; align-items: center; justify-content: center; }
.tpl-drag:active { cursor: grabbing; }
.tpl-drag i { width: 16px; height: 16px; }
.tpl-thumb {
  width: 72px; height: 48px; object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel-2);
}
.tpl-thumb-empty {
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; color: var(--muted); text-align: center; line-height: 1.1;
}
.tpl-name { font-weight: 600; color: var(--text-strong); }
.tpl-flags { font-size: 11px; margin-top: 2px; }
.tpl-flags .warn { color: #c98a14; }
.tpl-actions { display: flex; gap: 4px; }
.tpl-actions button { padding: 6px 8px; }
.tpl-actions button i { width: 14px; height: 14px; }

.tpl-add-form, .tpl-edit-form { display: grid; gap: 10px; text-align: left; }
.tpl-add-form label, .tpl-edit-form label { display: grid; gap: 4px; font-size: 13px; color: var(--text); }
.tpl-add-form input, .tpl-edit-form input[type="file"], .tpl-edit-form textarea {
  font: inherit;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}
.tpl-edit-form textarea {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  resize: vertical;
  min-height: 220px;
}
.tpl-edit-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.tpl-add-form label small, .tpl-edit-form label small { color: var(--muted); font-size: 11px; }

/* Visual block editor */
#templates-editor { display: block; }
.ed-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 12px; flex-wrap: wrap;
}
.ed-head h3 { margin: 0; font-size: 15px; color: var(--text-strong); }
.ed-tabs { display: flex; gap: 4px; }
.ed-side-btn {
  padding: 6px 14px; font-size: 12px; font-weight: 600;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; cursor: pointer; transition: all 0.12s;
}
.ed-side-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.ed-actions { margin-left: auto; display: flex; gap: 6px; }
.ed-body { display: grid; grid-template-columns: 1fr 320px; gap: 14px; }
@media (max-width: 1080px) { .ed-body { grid-template-columns: 1fr; } }
.ed-canvas-wrap { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px; overflow: auto; max-height: 78vh; }
.ed-canvas { position: relative; }
.ed-stage { position: relative; margin: 0 auto; background: #fff; border: 1px solid var(--line); outline: none; }
.ed-stage:focus { outline: none; }
.ed-img { display: block; user-select: none; -webkit-user-drag: none; }
.ed-overlay {
  position: absolute;
  border: 2px solid rgba(47, 126, 247, 0.7);
  background: rgba(47, 126, 247, 0.10);
  cursor: move;
  display: flex; align-items: flex-start;
  font-size: 10px; line-height: 1.1;
  box-sizing: border-box;
}
.ed-overlay:hover { background: rgba(47,126,247,0.18); }
.ed-overlay.active { border-color: #f3b54a; border-width: 3px; background: rgba(243,181,74,0.18); z-index: 5; }
.ed-overlay-label {
  background: rgba(0,0,0,0.7); color: #fff; padding: 1px 4px; font-size: 10px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
  pointer-events: none;
  position: relative; z-index: 1;
}
.ed-overlay-media {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  pointer-events: none;
  opacity: 0.85;
}
/* Text block: render the sample lines as actual styled text in place, at
   the block's real fontSize / fontWeight / fill — scaled by the canvas
   scale so the editor matches the final ID 1:1. */
.ed-overlay.ed-text { background: transparent; border-color: transparent; }
.ed-overlay.ed-text:hover { border-color: rgba(43,187,110,0.55); background: rgba(43,187,110,0.06); }
.ed-overlay.ed-text.active { border-color: #f3b54a; background: rgba(243,181,74,0.10); }
.ed-text-content {
  position: absolute; inset: 0;
  pointer-events: none;
  font-family: Arial, Helvetica, sans-serif;
  overflow: visible;
}
.ed-text-line {
  position: absolute;
  left: 0;
  white-space: nowrap;
  pointer-events: none;
  /* drop-shadow for legibility over busy backgrounds (matches what users
     read on the actual card) */
  text-shadow: 0 0 2px rgba(255,255,255,0.6);
}
/* Preview mode — strip all editor chrome (borders, labels, handles) so the
   canvas matches what the final rendered ID will look like. */
.ed-stage.preview-mode .ed-overlay { border-color: transparent !important; background: transparent !important; }
.ed-stage.preview-mode .ed-overlay-label { display: none; }
.ed-stage.preview-mode .ed-handle { display: none !important; }
.ed-stage.preview-mode .ed-overlay-media { opacity: 1; }

#ed-preview.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Hidden-on-canvas row in the block list */
.ed-block-row.hidden-row { opacity: 0.45; }
.ed-block-row.hidden-row em { font-style: italic; font-size: 10px; color: var(--muted); }

/* Multi-select list in the property panel */
.ed-multi-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 200px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
}
.ed-multi-list li {
  padding: 4px 8px;
  font-size: 11px;
  border-bottom: 1px solid var(--line);
}
.ed-multi-list li:last-child { border-bottom: none; }
.ed-multi-list li code {
  font-size: 11px;
  background: transparent;
  padding: 0;
}

/* Resize handles — visible only on the active overlay. Eight tiny boxes
   anchored to the corners + mid-edges. Cursor reflects the drag axis. */
.ed-handle {
  position: absolute;
  width: 10px; height: 10px;
  background: #f3b54a;
  border: 1px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4);
  border-radius: 2px;
  display: none;
  z-index: 6;
}
.ed-overlay.active .ed-handle { display: block; }
.ed-h-nw { left: -5px;  top: -5px;  cursor: nwse-resize; }
.ed-h-n  { left: 50%;   top: -5px;  cursor: ns-resize; transform: translateX(-50%); }
.ed-h-ne { right: -5px; top: -5px;  cursor: nesw-resize; }
.ed-h-w  { left: -5px;  top: 50%;   cursor: ew-resize; transform: translateY(-50%); }
.ed-h-e  { right: -5px; top: 50%;   cursor: ew-resize; transform: translateY(-50%); }
.ed-h-sw { left: -5px;  bottom: -5px; cursor: nesw-resize; }
.ed-h-s  { left: 50%;   bottom: -5px; cursor: ns-resize; transform: translateX(-50%); }
.ed-h-se { right: -5px; bottom: -5px; cursor: nwse-resize; }

/* Image-replace buttons in the editor head — compact ghost variant. */
.ed-img-replaces { display: flex; gap: 4px; }
.ed-img-replaces .small {
  padding: 5px 9px;
  font-size: 11px;
}
.ed-img-replaces .small i { width: 13px; height: 13px; }

/* Quick-adjust tools (font size +/- / line gap +/-) above the property list */
.ed-quick-tools {
  display: flex; flex-direction: column; gap: 6px;
  padding: 8px;
  margin-bottom: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.ed-quick-row { display: flex; align-items: center; gap: 4px; }
.ed-quick-label { width: 36px; font-size: 11px; color: var(--muted); }
.ed-quick-tools .icon-only { padding: 3px 6px; min-width: 28px; }
.ed-quick-tools .icon-only i { width: 12px; height: 12px; }
.ed-quick-tools input { font-size: 12px; padding: 3px 5px; }
.ed-overlay.ed-text { border-color: rgba(43,187,110,0.7); background: rgba(43,187,110,0.12); }
.ed-overlay.ed-text:hover { background: rgba(43,187,110,0.20); }
.ed-overlay.ed-text.active { border-color: #f3b54a; background: rgba(243,181,74,0.20); }
.ed-overlay.ed-qr,
.ed-overlay.ed-photo,
.ed-overlay.ed-barcode { border-color: rgba(155,89,182,0.7); background: rgba(155,89,182,0.10); }
.ed-overlay.ed-qr.active,
.ed-overlay.ed-photo.active,
.ed-overlay.ed-barcode.active { border-color: #f3b54a; background: rgba(243,181,74,0.20); }

.ed-panel { display: flex; flex-direction: column; gap: 10px; max-height: 78vh; overflow: auto; }
.ed-panel-h { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 6px 0 4px; }
.ed-block-list { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px; }
.ed-block-row {
  display: grid;
  grid-template-columns: 60px 1fr auto;
  align-items: center; gap: 6px;
  padding: 5px 8px; border-radius: 4px; cursor: pointer; font-size: 12px;
}
.ed-block-row:hover { background: var(--panel); }
.ed-block-row.active { background: rgba(243,181,74,0.18); }
.ed-block-kind { font-size: 10px; padding: 1px 6px; border-radius: 3px; font-weight: 600; text-transform: uppercase; }
.ed-block-kind.kind-text    { background: rgba(43,187,110,0.18); color: var(--good); }
.ed-block-kind.kind-photo,
.ed-block-kind.kind-barcode,
.ed-block-kind.kind-qr,
.ed-block-kind.kind-region  { background: rgba(155,89,182,0.18); color: #8052b3; }
.ed-block-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-block-xy { font-size: 10px; }

.ed-props { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px; }
.ed-prop { display: grid; gap: 4px; margin-bottom: 8px; }
.ed-prop > span { font-size: 12px; color: var(--text); }
.ed-prop > span em { font-style: italic; font-size: 11px; }
.ed-prop input, .ed-prop textarea {
  font: inherit; font-size: 12px;
  padding: 5px 7px; border: 1px solid var(--line); border-radius: 4px;
  background: var(--panel);
}
.ed-prop textarea[data-type="fn"] { font-family: ui-monospace,Menlo,Consolas,monospace; }

/* Bot health chip (X8) — small status pill on the Dashboard heading. */
.health-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  user-select: none;
}
.health-chip .health-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--muted);
}
.health-chip.health-ok { color: var(--good); border-color: rgba(43,187,110,0.35); background: rgba(43,187,110,0.10); }
.health-chip.health-ok .health-dot { background: var(--good); box-shadow: 0 0 0 3px rgba(43,187,110,0.18); }
.health-chip.health-degraded { color: #c98a14; border-color: rgba(243,181,74,0.4); background: rgba(243,181,74,0.10); }
.health-chip.health-degraded .health-dot { background: #f3b54a; box-shadow: 0 0 0 3px rgba(243,181,74,0.18); }
.health-chip.health-down { color: #b03333; border-color: rgba(255,91,91,0.4); background: rgba(255,91,91,0.10); }
.health-chip.health-down .health-dot { background: #ff5b5b; box-shadow: 0 0 0 3px rgba(255,91,91,0.2); animation: hc-pulse 1.5s infinite; }
@keyframes hc-pulse { 0%,100% { box-shadow: 0 0 0 3px rgba(255,91,91,0.2); } 50% { box-shadow: 0 0 0 6px rgba(255,91,91,0.08); } }

/* ============================================================
   Bottom navigation (Telegram Mini App style)
   ============================================================ */
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--panel);
  border-top: 1px solid var(--line);
  display: flex;
  z-index: 10;
  padding-bottom: var(--safe-bottom);
  box-shadow: 0 -2px 12px rgba(20, 24, 36, 0.04);
}
.bottom-nav .nav-item {
  flex: 1 1 0;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  min-height: 56px;
  border-radius: 0;
  box-shadow: none;
}
.bottom-nav .nav-item i {
  width: 22px; height: 22px;
  stroke-width: 2;
  color: inherit;
}
.bottom-nav .nav-item:active { background: var(--panel-2); }
.bottom-nav .nav-item.active {
  color: var(--accent);
}
.bottom-nav .nav-item.active i {
  transform: scale(1.05);
  transition: transform 0.12s;
}

/* ============================================================
   Cards
   ============================================================ */
.cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (min-width: 720px) {
  .cards { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s, border-color 0.15s;
}
.card:active { transform: scale(0.99); }
.card .label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 500; }
.card .value { font-size: 22px; font-weight: 600; margin-top: 4px; color: var(--text-strong); letter-spacing: -0.02em; }
.card .sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.card.accent .value { color: var(--accent); }
.card.good .value { color: var(--good); }
.card.warn .value { color: var(--warn); }

/* Chart */
.chart-card {
  margin-top: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.chart-card h3 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  display: flex; align-items: center; gap: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.chart-card h3 i { width: 14px; height: 14px; color: var(--accent); }
.chart-wrap { position: relative; height: 240px; }
@media (min-width: 720px) { .chart-wrap { height: 280px; } }

/* ============================================================
   Toolbars + tables
   ============================================================ */
.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.toolbar select { min-width: 130px; }
.toolbar .input-with-icon { flex: 1; min-width: 200px; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  -webkit-overflow-scrolling: touch;
}
table { width: 100%; border-collapse: collapse; min-width: 560px; }
@media (min-width: 720px) {
  table { min-width: 0; }                  /* let columns auto-size on desktop */
}
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
@media (min-width: 1080px) {
  th, td { padding: 12px 14px; }            /* a little more breathing room */
}
th { color: var(--muted); font-weight: 500; background: var(--panel-2); position: sticky; top: 0; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
tbody tr:hover { background: var(--panel-2); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:active { background: var(--panel-2); }
td.right, th.right { text-align: right; }

.row-actions { display: flex; gap: 5px; justify-content: flex-end; flex-wrap: wrap; }
.row-actions button { padding: 5px 9px; font-size: 12px; min-height: 30px; }
.row-actions button > i { width: 14px; height: 14px; }
@media (max-width: 720px) {
  .row-actions button span { display: none; }
}

.pagination {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 12px;
  flex-wrap: wrap;
}
.pagination .info { color: var(--muted); margin-right: 8px; font-size: 13px; }
.pagination button { padding: 6px 12px; min-height: 32px; box-shadow: none; }

/* Tags */
.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
}
.tag.pending { color: var(--warn); border-color: var(--warn-soft); background: var(--warn-soft); }
.tag.approved { color: var(--good); border-color: var(--good-soft); background: var(--good-soft); }
.tag.rejected { color: var(--bad); border-color: var(--bad-soft); background: var(--bad-soft); }
.tag.auto { color: var(--accent); border-color: var(--accent-soft); background: var(--accent-soft); margin-left: 4px; }
.tag.admin-credit { color: var(--warn); border-color: var(--warn-soft); background: var(--warn-soft); margin-left: 4px; }

/* Toggle-pill row inside Swal dialogs (Credit/Deduct payment method) */
.method-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.method-pill {
  flex: 1 1 0;
  min-width: 80px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.method-pill:hover { border-color: var(--accent-soft); }
.method-pill.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

/* Receipt-details modal */
table.receipt-detail { width: 100%; border-collapse: collapse; font-size: 14px; }
table.receipt-detail th {
  width: 38%;
  text-align: left;
  font-weight: 500;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
table.receipt-detail td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  word-break: break-word;
}
table.receipt-detail tr:last-child th,
table.receipt-detail tr:last-child td { border-bottom: none; }

/* Broadcast: progress bar inside the Sent/Total cell */
.bc-bar {
  width: 100%;
  height: 4px;
  background: var(--panel-2);
  border-radius: 2px;
  margin-top: 4px;
  overflow: hidden;
}
.bc-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.4s ease;
}
.mini-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }

/* Broadcast: per-message card in the New-broadcast wizard */
.bc-msg {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  margin: 12px 0;
  background: var(--panel-2);
}
.bc-msg-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.tag.mode-prepaid { color: var(--accent); border-color: var(--accent-soft); background: var(--accent-soft); }
.tag.mode-postpaid { color: var(--warn); border-color: var(--warn-soft); background: var(--warn-soft); }
.tag.mode-counter { color: var(--muted); border-color: var(--line); }
.tag.role-superadmin { color: var(--accent); border-color: var(--accent-soft); background: var(--accent-soft); }
.tag.role-adminPro { color: var(--good); border-color: var(--good-soft); background: var(--good-soft); }
.tag.role-admin { color: var(--muted); border-color: var(--line); }
.tag.role-member { color: var(--muted); border-color: var(--line); }

/* ============================================================
   Card list (Users tab — phone-friendly)
   On wide screens we switch to the original table view.
   ============================================================ */
.card-list {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
}

/* Default: cards visible on phones, table hidden. */
.users-table-view { display: none; }
.users-cards-view { display: grid; }

/* Wide screens: table on, cards off. */
@media (min-width: 720px) {
  .users-cards-view { display: none; }
  .users-table-view { display: block; }
}

.empty {
  text-align: center;
  padding: 32px;
  color: var(--muted);
  background: var(--panel);
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
}

.user-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
}
.user-card:hover { border-color: var(--line-strong); }
.user-card:active { transform: scale(0.995); }

.user-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.avatar {
  flex: 0 0 auto;
  width: 42px; height: 42px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  background: var(--accent);   /* JS may override via inline style */
  letter-spacing: -0.02em;
}
.user-card-id {
  flex: 1; min-width: 0;
}
.user-card-name {
  font-weight: 600;
  color: var(--text-strong);
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
}
.user-card-sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.user-card-sub code { font-size: 11.5px; }
.user-card-balance {
  text-align: right;
  flex: 0 0 auto;
}
.balance-value {
  font-weight: 700;
  font-size: 20px;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--text-strong);
}
.balance-value.zero { color: var(--muted); }
.balance-value.positive { color: var(--good); }
.balance-label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 2px;
}

.user-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.meta-chip {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 500;
}
.meta-chip i { width: 12px; height: 12px; color: var(--muted); }
.meta-chip strong { color: var(--text); font-weight: 600; }
.meta-chip code { color: var(--text); font-size: 11px; }

.user-card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--line);
}
.user-card-actions.single {
  grid-template-columns: 1fr;
}
.user-card-actions button {
  min-height: 40px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  justify-content: center;
}
.user-card-actions button > i { width: 15px; height: 15px; }
.user-card-actions button span { display: inline; }
@media (max-width: 380px) {
  .user-card-actions:not(.single) { grid-template-columns: 1fr 1fr; }
}

/* Action sheet inside SweetAlert (mobile only) */
.action-sheet {
  display: grid;
  gap: 4px;
  text-align: left;
}
.sheet-btn {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  font-weight: 500;
  min-height: 48px;
  width: 100%;
  justify-content: flex-start;
  box-shadow: none;
}
.sheet-btn:hover { background: var(--panel-2); }
.sheet-btn > i:first-child { width: 18px; height: 18px; color: var(--accent); }
.sheet-btn .chev { margin-left: auto; width: 16px; height: 16px; color: var(--muted); }
.sheet-btn span { flex: 1; text-align: left; }

/* ============================================================
   Edit-user dialog form styling (rendered inside SweetAlert2)
   ============================================================ */
.ue-form { text-align: left; }
.ue-section { margin: 14px 0; }
.ue-section + .ue-section { margin-top: 16px; }
.ue-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}
.ue-label i { width: 14px; height: 14px; color: var(--accent); }
.ue-hint { color: var(--muted); font-size: 11.5px; margin-top: 4px; }

/* segmented control for payment mode */
.seg-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 3px;
}
.seg-control input[type="radio"] { display: none; }
.seg-control label {
  text-align: center;
  padding: 7px 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  transition: background 0.1s, color 0.1s;
}
.seg-control input[type="radio"]:checked + label {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
/* Compact variant — used inside section headers for period pickers. */
.seg-control.small {
  display: inline-grid;
  grid-template-columns: repeat(4, auto);
  padding: 2px;
  gap: 2px;
}
.seg-control.small label {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
/* Period-seg right-aligns inside the h3 — make h3 a flex row. */
.detail-section h3 { display: flex; align-items: center; gap: 8px; }

/* labeled-input row with suffix */
.input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 4px 4px 4px 10px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.input-row:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input-row input {
  flex: 1; min-width: 0;
  background: transparent;
  border: none;
  padding: 8px 0;
}
.input-row input:focus { box-shadow: none; }
.input-row .suffix {
  color: var(--muted);
  font-size: 12px;
  padding: 0 8px;
}

.ue-owner-select {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.ue-owner-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* iOS-style switch (for low-track toggle) */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.switch-row-label { font-size: 13px; color: var(--text); }
.switch-row-label small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.switch {
  position: relative;
  width: 42px; height: 24px;
  background: #d8dde6;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s;
  flex: 0 0 auto;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 20px; height: 20px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform 0.15s;
}
.switch input { display: none; }
.switch.on { background: var(--good); }
.switch.on::after { transform: translateX(18px); }
.switch.disabled { cursor: not-allowed; opacity: 0.5; }
.switch-row-label small em { font-style: italic; color: var(--accent); }

/* ============================================================
   User-detail "page"
   ============================================================ */
.detail-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px;
}
.detail-head h2 {
  margin: 0; font-size: 18px; font-weight: 600; color: var(--text-strong);
  display: flex; align-items: center; gap: 8px;
}
.detail-head h2 i { width: 18px; height: 18px; color: var(--accent); }
.icon-only {
  width: 38px; height: 38px;
  padding: 0;
  display: grid; place-items: center;
  border-radius: var(--radius-sm);
}
.icon-only > i { width: 18px; height: 18px; }

.detail-hero {
  display: flex; align-items: center; gap: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}
.avatar-lg {
  width: 56px; height: 56px;
  font-size: 22px;
  border-radius: 50%;
}
.detail-hero-id { flex: 1; min-width: 0; }
.detail-hero-name {
  font-weight: 600;
  color: var(--text-strong);
  font-size: 16px;
  display: flex; align-items: center; gap: 8px;
}
.detail-hero-sub {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}
.detail-hero-balance { text-align: right; }
.detail-hero-balance .balance-value { font-size: 24px; }

.detail-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 14px 0;
}
.detail-actions button {
  justify-content: center;
  min-height: 42px;
  font-size: 13px;
}
@media (max-width: 480px) {
  .detail-actions { grid-template-columns: 1fr 1fr; }
}

.detail-section {
  margin-top: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.detail-section h3 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex; align-items: center; gap: 8px;
}
.detail-section h3 i { width: 14px; height: 14px; color: var(--accent); }

.mini-list { display: grid; gap: 6px; }
.mini-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.mini-row-left { flex: 1; min-width: 0; }
.mini-row-title {
  font-weight: 500;
  font-size: 13px;
  color: var(--text);
}
.mini-row-sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mini-row-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex: none;
}
.mini-row-right .btn-link { font-size: 11px; padding: 4px 8px; min-height: 28px; }
.empty.small { padding: 18px; font-size: 13px; }

/* Audit-log rows */
.audit-list { display: grid; gap: 6px; }
.audit-row {
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.audit-row-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.audit-action {
  font-weight: 500;
  font-size: 13px;
  color: var(--text);
}
.audit-when {
  margin-left: auto;
  font-size: 12px;
}
.audit-row-sub {
  margin-top: 4px;
  font-size: 12px;
  word-break: break-word;
}
.audit-row-sub code {
  font-size: 11px;
  padding: 1px 5px;
}

/* Breakdown rows (Downloads summary tab) */
.breakdown-list { display: grid; gap: 6px; }
.breakdown-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 2fr auto;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.breakdown-label { font-size: 13px; color: var(--text); }
.breakdown-value { color: var(--text); font-size: 13px; }
.bar-wrap {
  height: 8px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.bar {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  min-width: 4px;
}
@media (max-width: 480px) {
  .breakdown-row { grid-template-columns: 1fr auto; }
  .breakdown-row .bar-wrap { grid-column: 1 / -1; }
}

/* Mini download summary (user-detail page) */
.download-mini-summary { display: grid; gap: 12px; }
.dmini-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.dmini-card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  text-align: center;
}
.dmini-label { color: var(--muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em; }
.dmini-value { font-size: 18px; font-weight: 600; color: var(--text-strong); margin-top: 2px; }
.dmini-section { display: flex; flex-direction: column; gap: 6px; }
.dmini-sub-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
.meta-chips { display: flex; flex-wrap: wrap; gap: 6px; }

.card .value .sub { color: var(--muted); font-size: 12px; margin-left: 4px; font-weight: 400; }

/* Settings form */
.settings-form {
  display: grid;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 18px;
  max-width: 520px;
  box-shadow: var(--shadow-sm);
}
.settings-form label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.settings-form label input,
.settings-form label select { color: var(--text); }
.settings-form label .hint { color: var(--muted); font-size: 11.5px; font-weight: 400; opacity: 0.85; }
.settings-form button { justify-self: start; margin-top: 4px; }
.settings-fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: grid;
  gap: 10px;
  margin: 0;
  background: var(--panel-2);
}
.settings-fieldset legend {
  padding: 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.field input[type="checkbox"] { width: auto; margin-right: 8px; vertical-align: middle; }

/* SweetAlert2 — match the light theme */
.swal2-popup {
  background: var(--panel) !important;
  color: var(--text) !important;
  border: 1px solid var(--line) !important;
  border-radius: var(--radius-lg) !important;
  font-family: "Inter", system-ui, -apple-system, sans-serif !important;
  box-shadow: var(--shadow-md) !important;
}
.swal2-title { color: var(--text-strong) !important; font-weight: 600 !important; }
.swal2-html-container { color: var(--muted) !important; }
.swal2-input, .swal2-textarea, .swal2-select {
  background: var(--panel) !important;
  color: var(--text) !important;
  border: 1px solid var(--line) !important;
  border-radius: var(--radius-sm) !important;
  box-shadow: none !important;
}
.swal2-input:focus, .swal2-textarea:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px var(--accent-soft) !important;
}
.swal2-confirm.swal2-styled {
  background: var(--accent) !important;
  color: #fff !important;
  border: 1px solid var(--accent) !important;
  border-radius: var(--radius-sm) !important;
}
.swal2-confirm.swal2-styled.danger {
  background: var(--bad) !important;
  border-color: var(--bad) !important;
}
.swal2-cancel.swal2-styled {
  background: var(--panel) !important;
  border: 1px solid var(--line) !important;
  color: var(--text) !important;
  border-radius: var(--radius-sm) !important;
}

/* Notyf in light theme */
.notyf__toast { color: #fff; }

/* Misc small screens tweaks */
@media (max-width: 420px) {
  .cards { grid-template-columns: 1fr; }
  .brand span { font-size: 14px; }
  main { padding-left: 12px; padding-right: 12px; }
}

/* ===== Grayscale toning editor ===== */
.grayscale-editor {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: start;
}
.grayscale-controls { display: flex; flex-direction: column; gap: 12px; }
.grayscale-controls label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.slider-row { display: flex; align-items: center; gap: 10px; }
.slider-row input[type=range] { flex: 1; }
.slider-num { width: 74px; flex: none; }
.grayscale-buttons { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.grayscale-preview { display: flex; flex-direction: column; gap: 12px; }
.gs-upload { cursor: pointer; }
.gs-upload .ghost { display: inline-flex; align-items: center; gap: 6px; }
.gs-preview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.gs-preview-grid figure { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.gs-preview-grid figcaption { font-size: 12px; color: var(--muted); text-align: center; }
.gs-preview-grid img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 120px;
}
@media (max-width: 720px) {
  .grayscale-editor { grid-template-columns: 1fr; }
}

.gs-toggle { flex-direction: row !important; align-items: flex-start; gap: 8px; }
.gs-toggle input[type=checkbox] { margin-top: 3px; flex: none; }

/* ===== Payments: receipt link button + mobile card layout ===== */
/* Anchor styled as a button (matches .ghost buttons in the action row). */
a.btn-link {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 9px; min-height: 30px; font-size: 12px;
  border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--panel); color: var(--text);
  text-decoration: none; box-sizing: border-box;
}
a.btn-link:hover { background: var(--panel-2); }
a.btn-link > i { width: 14px; height: 14px; }

/* Payments must always fit the screen — never scroll horizontally.
   Desktop/tablet: keep the table but let every cell wrap instead of nowrap, so
   columns shrink to fit the viewport. */
#tab-payments .table-wrap { overflow-x: hidden; }
#payments-table { min-width: 0; width: 100%; }
#payments-table th, #payments-table td {
  white-space: normal; word-break: break-word; overflow-wrap: anywhere;
}
#payments-table code { word-break: break-all; white-space: normal; }

/* On phones, turn the table into stacked cards. */
@media (max-width: 720px) {
  #payments-table thead { display: none; }
  /* display:block (NOT width:100%) — block elements already fill the width, and
     adding width:100% on top of the card's horizontal margin overflows. */
  #payments-table, #payments-table tbody, #payments-table tr, #payments-table td { display: block; }
  #payments-table tr {
    border: 1px solid var(--line); border-radius: 12px;
    margin: 10px 0; background: var(--panel); box-shadow: var(--shadow-sm);
    overflow: hidden;
  }
  #payments-table td {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 14px;
    white-space: normal; word-break: break-word; text-align: right;
    border-bottom: 1px solid var(--line); padding: 9px 13px;
  }
  #payments-table td:last-child { border-bottom: none; }
  #payments-table td::before {
    content: attr(data-label); color: var(--muted);
    font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
    font-weight: 600; flex: none; text-align: left; padding-top: 2px;
  }
  /* Action row: buttons row, no label, show button text. */
  #payments-table td.row-actions { justify-content: flex-end; flex-wrap: wrap; gap: 6px; }
  #payments-table td.row-actions::before { display: none; }
  #payments-table td.row-actions button span,
  #payments-table td.row-actions a.btn-link span { display: inline; }
  #payments-table td.row-actions button,
  #payments-table td.row-actions a.btn-link { flex: 1 1 auto; justify-content: center; min-height: 36px; }
  /* Content must wrap inside the card, never force a scroll. */
  #payments-table td > code, #payments-table td code { word-break: break-all; white-space: normal; min-width: 0; }
  #payments-table td > * { min-width: 0; max-width: 100%; }
  #tab-payments .table-wrap { border: none; box-shadow: none; background: transparent; }
}
