:root {
  --bg: #f6f8fb; --card: #ffffff; --ink: #0f172a; --muted: #64748b;
  --line: #e5e9f0; --line-soft: #eef2f7; --field-bg: #ffffff;
  --subtle: #f8fafc; --subtle-2: #f9fbff;
  --primary: #2563eb; --primary-dark: #1d4ed8; --primary-soft: #eaf1ff;
  --primary-ink: #ffffff; --danger: #dc2626; --danger-soft: #fef2f2;
  --ok-bg: #dcfce7; --ok-ink: #166534;
  --topbar-bg: rgba(255,255,255,.86); --glow: rgba(37,99,235,.16);
  --radius: 12px; --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.04);
  --shadow: 0 4px 16px rgba(15,23,42,.08);
  --shadow-lg: 0 12px 40px rgba(15,23,42,.14);
}
html[data-theme="dark"] {
  --bg: #0b1220; --card: #131c2e; --ink: #e6edf6; --muted: #93a1b5;
  --line: #24314a; --line-soft: #1c2740; --field-bg: #0f1729;
  --subtle: #172236; --subtle-2: #17233a;
  --primary: #3b82f6; --primary-dark: #2563eb; --primary-soft: #16294a;
  --danger: #ef4444; --danger-soft: #2a1517;
  --ok-bg: #14532d; --ok-ink: #bbf7d0;
  --topbar-bg: rgba(19,28,46,.88); --glow: rgba(59,130,246,.28);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow: 0 6px 20px rgba(0,0,0,.45);
  --shadow-lg: 0 14px 44px rgba(0,0,0,.55);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { overflow-x: hidden; }   /* never allow horizontal scroll */
body {
  margin: 0;
  font-family: "Segoe UI", "Noto Kufi Arabic", Tahoma, system-ui, -apple-system, sans-serif;
  font-size: 15px; line-height: 1.55; letter-spacing: .1px;
  background:
    radial-gradient(1200px 400px at 100% -10%, var(--primary-soft) 0%, rgba(0,0,0,0) 55%),
    var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  transition: background .2s, color .2s;
}
a { color: var(--primary); text-decoration: none; }
h1 { font-size: 23px; font-weight: 700; margin: 0 0 4px; letter-spacing: -.2px; }
h2 { font-size: 16px; font-weight: 650; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* ---------- header + tabs ---------- */
.topbar {
  display: flex; align-items: center; gap: 18px;
  background: var(--topbar-bg); backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 10px 22px; position: sticky; top: 0; z-index: 30; box-shadow: var(--shadow-sm);
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink);
  font-weight: 750; font-size: 15px; white-space: nowrap; }
.brand-mark {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), #4f46e5); color: #fff;
  font-weight: 800; font-size: 17px; box-shadow: 0 2px 8px rgba(37,99,235,.35);
}
.brand-text { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }

/* Nav container + hamburger (hamburger hidden on desktop) */
.nav-wrap { display: flex; align-items: center; gap: 18px; flex: 1 1 auto; min-width: 0; }
.hamburger {
  display: none; width: 42px; height: 42px; min-height: 42px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font-size: 20px; cursor: pointer; margin-inline-start: auto;
}

/* Segmented tab bar: hugs its content, scrolls horizontally when space is tight. */
.tabs {
  display: flex; align-items: center; gap: 2px; flex: 0 1 auto; min-width: 0;
  overflow-x: auto; scrollbar-width: none;
  background: var(--subtle); border: 1px solid var(--line);
  border-radius: 999px; padding: 4px;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative; display: inline-flex; align-items: center; gap: 7px;
  color: var(--muted); font-weight: 600; font-size: 14px;
  padding: 8px 15px; border-radius: 999px; white-space: nowrap;
  transition: background .18s, color .18s, box-shadow .18s;
}
.tab .tab-ico { font-size: 14.5px; line-height: 1; }
.tab:hover { color: var(--ink); background: var(--card); }
.tab.active { color: var(--primary-dark); background: var(--card); box-shadow: var(--shadow-sm); }
html[data-theme="dark"] .tab.active { color: #dbe8ff; }

/* Settings sub-navigation (general / users / password) */
.subnav {
  display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 22px;
  border-bottom: 1px solid var(--line); padding-bottom: 14px;
}
.subtab {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  color: var(--muted); font-weight: 600; font-size: 14px; transition: all .15s;
}
.subtab:hover { background: var(--subtle); color: var(--ink); }
.subtab.active { background: var(--primary-soft); color: var(--primary-dark);
  border-color: var(--primary); }
html[data-theme="dark"] .subtab.active { color: #dbe8ff; }

.topnav-right { display: flex; align-items: center; gap: 8px; margin-inline-start: auto; }
.pill {
  font-size: 13px; font-weight: 600; color: var(--ink);
  padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); transition: border-color .15s, background .15s, color .15s;
}
.pill:hover { border-color: var(--primary); background: var(--subtle); }
.pill.logout:hover { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.lang, .icon-btn {
  display: grid; place-items: center; min-width: 34px; height: 34px; padding: 0 9px;
  border: 1px solid var(--line); border-radius: 999px; color: var(--primary);
  font-weight: 700; font-size: 14px; background: var(--card); cursor: pointer;
}
.icon-btn { font-size: 16px; }
.lang:hover, .icon-btn:hover { background: var(--primary-soft); border-color: var(--primary); }

/* ---------- layout ---------- */
.content { max-width: 1120px; margin: 26px auto 60px; padding: 0 20px; }
.page-head { display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { position: relative; padding-inline-start: 14px; }
.page-head h1::before {
  content: ""; position: absolute; inset-inline-start: 0; top: 50%;
  transform: translateY(-50%); width: 5px; height: 22px; border-radius: 3px;
  background: linear-gradient(180deg, var(--primary), #6366f1);
}
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; margin-bottom: 18px; box-shadow: var(--shadow-sm); }
.card h2 { padding-bottom: 12px; border-bottom: 1px solid var(--line-soft); }

/* ---------- forms / fields ---------- */
label { color: var(--muted); }
input, select, textarea {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  font: inherit; font-size: 14.5px; background: var(--field-bg); color: var(--ink);
  min-height: 40px; transition: border-color .15s, box-shadow .15s; max-width: 100%;
}
textarea { min-height: 80px; line-height: 1.5; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .7; }
input:hover, select:hover, textarea:hover { border-color: var(--primary); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3.5px var(--glow);
}
select {
  appearance: none; -webkit-appearance: none; padding-inline-end: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}
html[dir="rtl"] select { background-position: left 11px center; }
input[type=color] { padding: 3px; width: 46px; height: 40px; min-height: 40px; cursor: pointer; }
input[type=file] { border: 1px dashed var(--line); background: var(--subtle); padding: 9px 12px; cursor: pointer; }
input[type=checkbox] { min-height: 0; width: 16px; height: 16px; accent-color: var(--primary); }

/* ---------- buttons ---------- */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--card); color: var(--ink); cursor: pointer; font: inherit; font-weight: 600;
  font-size: 14px; min-height: 40px; transition: all .15s; white-space: nowrap;
}
button:hover, .btn:hover { border-color: var(--primary); background: var(--subtle); }
button:active, .btn:active { transform: translateY(1px); }
button.primary, .btn.primary, a.primary.btn, .primary.btn {
  background: var(--primary); color: var(--primary-ink); border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(37,99,235,.28);
}
button.primary:hover, .btn.primary:hover, a.primary.btn:hover, .primary.btn:hover {
  background: var(--primary-dark); border-color: var(--primary-dark); color: #fff;
}
button.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
button.danger:hover { background: #b91c1c; border-color: #b91c1c; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- dashboard ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { display: flex; align-items: center; gap: 14px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px;
  box-shadow: var(--shadow-sm); transition: transform .15s, box-shadow .15s, border-color .15s; }
a.stat { text-decoration: none; color: inherit; }
a.stat:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-ico { font-size: 24px; width: 46px; height: 46px; display: grid; place-items: center;
  border-radius: 12px; background: var(--primary-soft); flex: none; }
.stat .value { font-size: 28px; font-weight: 750; letter-spacing: -.5px; line-height: 1.1; }
.stat .label { color: var(--muted); font-size: 13px; }

/* Headline current rate, e.g. "1 USD = 5,500 SDG" */
.hero-rate {
  display: block; text-align: center; margin-bottom: 20px; padding: 22px 20px;
  border-radius: var(--radius); color: #fff; text-decoration: none;
  background: linear-gradient(135deg, var(--primary), #4f46e5);
  box-shadow: 0 8px 26px rgba(37,99,235,.32); transition: transform .15s, box-shadow .15s;
}
.hero-rate:hover { transform: translateY(-2px); box-shadow: 0 12px 32px rgba(37,99,235,.42); }
.hero-label { font-size: 13px; font-weight: 600; opacity: .9; letter-spacing: .3px; }
.hero-value { font-size: 34px; font-weight: 800; letter-spacing: -.5px; margin: 6px 0 2px;
  font-variant-numeric: tabular-nums; direction: ltr; }
.hero-date { font-size: 12px; opacity: .8; }

.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.panel { margin-bottom: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-head h2 { margin: 0; }
.rate-list { display: flex; flex-direction: column; gap: 12px; }
.rate-row { display: grid; grid-template-columns: 90px 1fr auto; align-items: center; gap: 12px; font-size: 14px; }
.rate-pair b { color: var(--ink); }
.bar-track { height: 8px; background: var(--subtle); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--primary), #6366f1); }
.rate-val { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- toolbar ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-bottom: 16px; }
/* A toolbar sitting directly on the page (not nested in a card) reads as a
   proper filter bar rather than loose controls. */
.content > .toolbar {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow-sm); align-items: flex-end;
}
.toolbar label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.toolbar .check { flex-direction: row; align-items: center; gap: 7px; }
form.stack { display: flex; flex-direction: column; gap: 6px; }
form.stack label { font-size: 12.5px; color: var(--muted); font-weight: 600; margin-top: 10px; }
form.inline { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 0; }
.row-gap { display: flex; gap: 10px; margin-top: 16px; }

/* ---------- file-type buttons + drag & drop ---------- */
.toolbar .spacer { flex: 1 1 auto; }
.icon-lead { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.icon-lead .ico { flex: 0 0 auto; }   /* the badge never shrinks or wraps */
.ico { display: inline-flex; align-items: center; gap: 2px; min-width: 40px; height: 22px;
  padding: 0 7px; border-radius: 5px; font-size: 10.5px; font-weight: 800;
  letter-spacing: .3px; color: #fff; background: var(--muted); justify-content: center; }
.ico.xls { background: #16794a; }              /* Excel green (export) */
.ico.xls.up { background: #b45309; }           /* amber = import/upload, distinct */
.ico.pdf { background: #b3261e; }              /* PDF red */
.ico .dir { font-style: normal; font-size: 12px; font-weight: 900; line-height: 1; }
/* File-input label styled exactly like the other .btn buttons — the extra
   specificity beats `.toolbar label { flex-direction: column }` so the badge
   sits BESIDE the text (one row), not above it. */
.toolbar .file-btn, .file-btn {
  display: inline-flex; flex-direction: row; align-items: center; gap: 8px;
  white-space: nowrap; position: relative; cursor: pointer;
}
.file-btn input[type=file] {
  position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer;
}

/* ---- bulk selection ---- */
.sel-cell { width: 42px; text-align: center; }
.rowsel, #selAll { width: 18px; height: 18px; min-height: 18px; accent-color: var(--primary); cursor: pointer; }
table.grid tbody tr:has(.rowsel:checked) td { background: var(--primary-soft); }
.bulkbar {
  position: sticky; top: 64px; z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--primary);
  border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.bulk-count { font-weight: 700; margin-inline-end: auto; }
.bulk-count b { color: var(--primary-dark); font-size: 16px; }
.linkish { border: none; background: none; color: var(--muted); font-size: 18px;
  cursor: pointer; padding: 4px 8px; min-height: 0; border-radius: 8px; }
.linkish:hover { background: var(--subtle); color: var(--ink); }
#bulkMsg { margin-bottom: 14px; }

/* Actions "sheet" — a robust modal listing the bulk actions (works on every
   device/orientation; no fragile dropdown positioning). */
#actionsBtn .caret { font-size: 11px; display: inline-block; }
.action-sheet { max-width: 380px; }
.sheet-list { display: flex; flex-direction: column; gap: 3px; margin-top: 12px; }
.menu-item {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: start;
  padding: 13px 14px; border: 1px solid transparent; background: none; border-radius: 10px;
  color: var(--ink); font: inherit; font-size: 15px; font-weight: 600;
  cursor: pointer; min-height: 0; white-space: nowrap; text-decoration: none;
}
.menu-item:hover { background: var(--subtle); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-soft); }
.menu-sep { height: 1px; background: var(--line-soft); margin: 5px 2px; }
.bm-field { margin: 10px 0 4px; }
.bm-field select, .bm-field input { width: 100%; }

.drag-handle { cursor: grab; color: var(--muted); font-size: 17px; text-align: center;
  user-select: none; }
.drag-handle:active { cursor: grabbing; }
tr.dragging { opacity: .45; background: var(--primary-soft); }
tr[draggable="true"] { transition: opacity .12s; }
.auto-tag { font-size: 10.5px; font-weight: 700; color: var(--primary-dark);
  background: var(--primary-soft); border-radius: 5px; padding: 1px 6px; margin-inline-start: 5px; }

/* ---------- tables ---------- */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.grid { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
table.grid.mini { box-shadow: none; }
table.grid th { background: var(--subtle); color: var(--muted); text-align: start; padding: 11px 14px;
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; border-bottom: 1px solid var(--line); }
table.grid td { border-top: 1px solid var(--line-soft); padding: 11px 14px; font-size: 14px; vertical-align: middle; }
table.grid tbody tr:nth-child(even) td { background: var(--subtle); }   /* zebra striping */
table.grid tbody tr:hover td { background: var(--subtle-2); }
td.actions, .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.actions form { display: inline-flex; gap: 4px; align-items: center; margin: 0; }

/* ---------- chips / badges / alerts ---------- */
.chip { color: #fff; padding: 3px 11px; border-radius: 999px; font-size: 12px; font-weight: 600;
  display: inline-block; box-shadow: inset 0 0 0 1px rgba(255,255,255,.15); }
.badge { padding: 3px 11px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.ok { background: var(--ok-bg); color: var(--ok-ink); }
.badge.off { background: var(--danger-soft); color: var(--danger); }
.alert { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--line);
  padding: 11px 14px; border-radius: var(--radius-sm); margin: 12px 0; font-size: 14px; }
code { background: var(--subtle); padding: 2px 7px; border-radius: 6px; font-size: 13px; }

.flash { padding: 12px 16px; border-radius: var(--radius-sm); margin: 0 0 16px; font-size: 14px;
  font-weight: 600; box-shadow: var(--shadow-sm); }
.flash.success { background: var(--ok-bg); color: var(--ok-ink); border: 1px solid var(--ok-ink); }
.flash.error { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger); }

/* ---------- auth ---------- */
.auth-card { max-width: 400px; margin: 9vh auto; box-shadow: var(--shadow-lg); border: 1px solid var(--line); padding: 30px 30px 26px; }
.auth-card h1 { text-align: center; }
.auth-card > .muted { text-align: center; margin: 0 0 18px; }
.auth-card form { display: flex; flex-direction: column; gap: 6px; }
.auth-card label { font-size: 12.5px; font-weight: 600; margin-top: 10px; }
.auth-card input { min-height: 44px; }
.auth-card button.primary { margin-top: 16px; min-height: 46px; font-size: 15px; }
.auth-card .small { text-align: center; margin-top: 16px; }

/* ---------- responsive ---------- */
/* ---------- help / contact modal ---------- */
.help-btn { width: 100%; margin-top: 14px; justify-content: center; font-weight: 600; }
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center;
  justify-content: center; padding: 18px; background: rgba(15,23,42,.55);
  backdrop-filter: blur(3px);
}
.modal-backdrop[hidden] { display: none; }
.modal {
  position: relative; width: 100%; max-width: 420px; background: var(--card);
  color: var(--ink); border: 1px solid var(--line); border-radius: 16px;
  padding: 26px 24px 22px; box-shadow: var(--shadow-lg);
  animation: cpm-pop .16s ease-out;
}
@keyframes cpm-pop { from { transform: translateY(8px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal h2 { margin: 0 0 6px; font-size: 19px; }
.modal-x {
  position: absolute; inset-inline-end: 12px; top: 12px; width: 34px; height: 34px;
  min-height: 34px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--muted); cursor: pointer; font-size: 15px;
}
.modal-x:hover { color: var(--ink); background: var(--subtle); }
.contact-list { display: flex; flex-direction: column; gap: 10px; margin: 16px 0 6px; }
.contact {
  display: flex; align-items: center; gap: 14px; padding: 13px 15px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--subtle);
  color: var(--ink); text-decoration: none; transition: border-color .15s, transform .1s;
}
a.contact:hover { border-color: var(--primary); transform: translateY(-1px); }
.contact-ico { display: grid; place-items: center; width: 44px; height: 44px; flex: none;
  border-radius: 12px; font-size: 20px; background: var(--card); }
.contact-ico.wa { background: #e7f8ee; }
.contact-body { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.contact-body b { font-size: 13px; color: var(--muted); font-weight: 600; }
.contact-body span { font-weight: 700; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }

/* ======================================================================
   MOBILE / TABLET  — a portrait, app-like layout: hamburger menu, big
   touch targets, stacked "card" tables, and zero horizontal scrolling.
   ====================================================================== */
@media (max-width: 860px) {
  .topbar { padding: 10px 14px; gap: 10px; flex-wrap: wrap; position: sticky; }
  .brand-text { display: none; }
  .hamburger { display: grid; place-items: center; }

  /* The whole menu collapses behind the hamburger. */
  .nav-wrap {
    display: none; order: 3; flex-basis: 100%; flex-direction: column;
    align-items: stretch; gap: 6px; padding: 8px 2px 4px;
  }
  .topbar.open .nav-wrap { display: flex; }

  .tabs { flex-direction: column; align-items: stretch; gap: 4px;
    background: transparent; border: none; border-radius: 0; padding: 0; overflow: visible; }
  .tab { width: 100%; justify-content: flex-start; padding: 14px 16px; font-size: 16px;
    border-radius: 12px; }
  .tab.active { box-shadow: none; background: var(--primary-soft); }
  .tab .tab-ico { font-size: 18px; width: 24px; text-align: center; }

  .topnav-right { margin: 6px 0 0; gap: 10px; flex-wrap: wrap; }
  .topnav-right .pill, .topnav-right .lang, .topnav-right .icon-btn {
    flex: 1 1 auto; min-height: 46px; font-size: 15px; justify-content: center; }
  .topnav-right .logout { flex-basis: 100%; }

  .content { padding: 0 14px; margin: 16px auto 40px; }
  .page-head { align-items: flex-start; gap: 8px; }
  h1 { font-size: 20px; }
  .page-head h1::before { height: 19px; }

  .cards { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat { padding: 15px; }
  .hero-value { font-size: 26px; }

  .subnav { gap: 6px; overflow-x: auto; flex-wrap: nowrap; }
  .subtab { flex: 0 0 auto; padding: 11px 15px; font-size: 14px; }

  /* Bigger, thumb-friendly controls and full-width primary actions. */
  input, select, textarea, button, .btn { min-height: 46px; font-size: 16px; }
  .toolbar { gap: 10px; }
  .content > .toolbar { padding: 14px; }
  .toolbar > form.inline, .toolbar > .btn, .toolbar > .file-btn { width: 100%; }
  .toolbar .inline input { flex: 1 1 auto; }
  .row-gap { flex-direction: column; align-items: stretch; }
  .row-gap .btn, .row-gap button { width: 100%; }

  /* --- stacked "card" tables: no horizontal scroll, header becomes labels --- */
  table.grid { display: block; border: none; box-shadow: none; background: transparent; }
  table.grid thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.grid tbody { display: block; }
  table.grid tr { display: block; margin-bottom: 12px; border: 1px solid var(--line);
    border-radius: 12px; overflow: hidden; background: var(--card); box-shadow: var(--shadow-sm); }
  table.grid tr:nth-child(even) td, table.grid tbody tr:hover td { background: transparent; }
  table.grid td { display: flex; align-items: center; justify-content: space-between; gap: 14px;
    padding: 11px 14px; border: none; border-bottom: 1px solid var(--line-soft); text-align: end; }
  table.grid td:last-child { border-bottom: none; }
  table.grid td::before { content: attr(data-label); font-weight: 700; color: var(--muted);
    text-align: start; flex: 0 0 auto; }
  table.grid td.actions { flex-wrap: wrap; justify-content: flex-start; }
  table.grid td.actions::before { flex-basis: 100%; margin-bottom: 4px; }
  table.grid td.actions .btn, table.grid td.actions button { flex: 1 1 auto; }
  table.grid td.drag-handle { display: none; }   /* drag is a desktop feature */
  table.grid td .inline input[type=color] { min-height: 40px; }
}
@media (max-width: 860px) {
  .bulkbar { position: static; }
  #actionsBtn { min-height: 44px; }
  .sel-cell { width: auto; }
  /* the select-checkbox stays visible and tappable in stacked card rows */
  table.grid td.sel-cell { justify-content: flex-start; }
  table.grid td.sel-cell::before { content: none; }
}
@media (max-width: 420px) { .cards { grid-template-columns: 1fr; } }
@media (min-width: 861px) and (max-width: 1024px) {
  .tab { padding: 8px 11px; font-size: 13.5px; }
}
@media print { .topbar { display: none; } .content { margin: 0; } }
