/* PRIeSIM — design system (LIGHT, sipas brendit zyrtar) */
@import url('https://fonts.googleapis.com/css2?family=Hanken+Grotesk:wght@400;500;600;700;800&family=Saira+Condensed:wght@600;700;800;900&display=swap');

:root {
  --bg: #F4F7FB;
  --bg-soft: #EDF2F8;
  --card: #FFFFFF;
  --card-2: #F5F9FD;
  --text: #0E2438;
  --muted: #5B6B7C;
  --brand: #0F497C;
  --brand-2: #2E86D6;
  --brand-3: #7DB9EC;
  --ok: #15A06B;
  --danger: #C0392B;
  --line: #E7EDF3;
  --radius: 18px;
  --shadow: 0 18px 44px -30px rgba(8,30,52,.4);
  --font: 'Hanken Grotesk', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --display: 'Saira Condensed', var(--font);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; overscroll-behavior-y: none; }
@supports (-webkit-touch-callout: none) {
  input:not([type="checkbox"]):not([type="radio"]), select, textarea { font-size: 16px !important; }
}
:where(input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
  scroll-margin-top: calc(var(--safe-top) + 78px);
  scroll-margin-bottom: calc(var(--safe-bottom) + 120px);
}
/* Overscroll poshtë = ngjyra e footer-it navy (jo e bardhë) në mobile. */
html { background: #0A2C4D; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
h1, h2, h3 { line-height: 1.15; letter-spacing: -.5px; }

.container { max-width: 1080px; margin: 0 auto; padding: 0 1.3rem; }
/* padding-block: vetëm lart/poshtë — mos e prish padding-un anësor të .container-it */
.section { padding-block: 2.2rem; }
.row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.spacer { flex: 1; }
.h-sub { color: var(--muted); margin-top: .3rem; }

.brand { font-weight: 800; letter-spacing: .3px; font-size: 1.4rem; color: var(--brand); }
.brand span { color: var(--brand-2); }
.brand-logo { display: inline-flex; align-items: center; gap: .55rem; text-decoration: none; }
.brand-logo img { height: 26px; display: block; }
.brand-logo:hover { text-decoration: none; }
.brand-divider { width: 1.5px; height: 26px; background: var(--brand); transform: skewX(-11deg); opacity: .5; }
.brand-esim { font-family: var(--display); font-weight: 800; font-size: 24px; transform: skewX(-11deg); letter-spacing: -.5px; }
.brand-esim .e { color: var(--brand-2); } .brand-esim .s { color: var(--brand); }
/* Wordmark PRIeSIM (logo i ri) */
.wordmark { font-family: var(--display); font-weight: 800; font-style: italic; font-size: 1.5rem; letter-spacing: -.5px; color: var(--brand); line-height: 1; }
.wordmark .e { color: var(--brand-2); }
.wordmark.on-dark { color: #fff; } .wordmark.on-dark .e { color: var(--brand-3); }
.admin-tag { font-size: .68rem; font-weight: 800; color: var(--brand-2); border: 1px solid var(--line); border-radius: 999px; padding: .12rem .5rem; text-transform: uppercase; letter-spacing: .5px; }
.logo-card { display: block; margin: 0 auto 1.1rem; height: 30px; }

/* ── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  border: 1px solid transparent; border-radius: 12px; padding: .8rem 1.2rem;
  font-family: inherit; font-size: 1rem; font-weight: 700; cursor: pointer; transition: .15s;
  background: var(--bg-soft); color: var(--text);
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: #0c3a63; }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--brand); }
.btn-ghost:hover { background: var(--card-2); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem;
}

.center-page {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  padding: calc(1.5rem + var(--safe-top)) 1.5rem calc(1.5rem + var(--safe-bottom));
}
.pay-card { width: 100%; max-width: 400px; text-align: center; }
.pay-amount { font-size: 2.4rem; font-weight: 800; margin: .6rem 0 .25rem; }
.pay-actions { display: grid; gap: .6rem; margin-top: 1.4rem; }
.msg { min-height: 1.4rem; margin-top: .8rem; color: var(--danger); }

/* ── Nav (light, sticky) ───────────────────────────────── */
.nav {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(12px);
  background: rgba(255,255,255,.86);
  border-bottom: 1px solid var(--line);
}
.nav .container { display: flex; align-items: center; gap: 1rem; height: 62px; max-width: 1200px; }
.nav a.link { color: #3C4F62; font-weight: 600; }
.nav a.link:hover { color: var(--brand); text-decoration: none; }
.nav-links { display: flex; gap: 1.2rem; align-items: center; font-size: 15px; }
.nav-admin .nav-links a.link.active { color: var(--brand); font-weight: 700; }
.admin-back, .admin-login-back { display: none; }
.nav-burger { display: none; width: 42px; height: 42px; align-items: center; justify-content: center;
  border: 1px solid var(--line); background: #fff; color: var(--brand); border-radius: 11px; cursor: pointer; flex: none; }
@media (max-width: 760px) {
  .nav .container { position: relative; }
  .nav-burger { display: inline-flex; }
  .nav-links { display: none; position: absolute; top: 100%; left: 0; right: 0;
    background: #fff; border-bottom: 1px solid var(--line); flex-direction: column; align-items: stretch;
    gap: 0; padding: 8px 18px 14px; box-shadow: 0 22px 34px -22px rgba(8,30,52,.35); }
  .nav-links.open { display: flex; }
  .nav-links a.link { padding: 13px 4px; border-bottom: 1px solid #F0F3F7; }

  /* Admini në WKWebView shtrihet edge-to-edge: header-i duhet të fillojë nën status bar. */
  .nav-admin {
    padding-top: var(--safe-top);
    background: rgba(255,255,255,.96);
  }
  .nav-admin .container { flex-wrap: wrap; height: auto; padding-top: 10px; padding-bottom: 7px; }
  .nav-admin .brand-logo { min-width: 0; }
  .nav-admin .brand-logo img { height: 25px !important; }
  .nav-admin .wordmark { font-size: 1.22rem !important; }
  .nav-admin .spacer { display: none; }
  .nav-admin .admin-back {
    display: inline-flex; align-items: center; justify-content: center; gap: 5px;
    min-height: 38px; margin-left: auto; padding: 0 12px 0 10px;
    border: 1px solid #D6E4F0; border-radius: 999px;
    background: #F2F7FB; color: var(--brand); font-size: 13px; font-weight: 800;
    text-decoration: none; flex: none;
  }
  .nav-admin .admin-back:active { transform: scale(.97); }
  .nav-admin .nav-burger { display: none !important; }
  .nav-admin .nav-links {
    display: flex !important; position: static; order: 3; width: 100%;
    flex-flow: row nowrap; align-items: center; gap: 8px;
    background: transparent; border: none; box-shadow: none;
    overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
    padding: 9px 1.3rem 2px; margin: 6px -1.3rem 0; border-top: 1px solid var(--line);
  }
  .nav-admin .nav-links::-webkit-scrollbar { display: none; }
  .nav-admin .nav-links a.link {
    flex: 0 0 auto;
    white-space: nowrap; border: 1px solid var(--line); border-radius: 999px;
    padding: 7px 13px; font-size: 13px; background: #fff; color: var(--brand); font-weight: 600;
  }
  .nav-admin .nav-links a.link.active { background: var(--brand); color: #fff; border-color: var(--brand); }

  .admin-login-back {
    display: inline-flex; align-items: center; gap: 6px; position: fixed;
    top: calc(var(--safe-top) + 14px); left: 16px; z-index: 10;
    min-height: 40px; padding: 0 13px 0 10px; border: 1px solid var(--line);
    border-radius: 999px; background: rgba(255,255,255,.92); color: var(--brand);
    font-size: 13px; font-weight: 800; text-decoration: none; box-shadow: var(--shadow);
  }
}

/* ── Hero (generic, for inner pages) ──────────────────── */
.hero { padding: 2.6rem 0 1rem; }
.hero h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); margin: 0; }

/* ── Trust / networks / footer ─────────────────────────── */
.trust-row { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: center; margin-top: 1.2rem; color: var(--muted); font-size: .92rem; }
.from-price { font-family: var(--display); font-weight: 800; color: #fff; background: var(--brand); padding: .3rem .85rem; border-radius: 999px; font-size: 1rem; }
.networks { display: flex; flex-wrap: wrap; gap: .55rem; }
.net-chip { border: 1px solid var(--line); background: #fff; color: var(--muted); border-radius: 999px; padding: .4rem .85rem; font-size: .9rem; font-weight: 600; }
.footer { border-top: 1px solid var(--line); padding: 1.6rem 0 2.4rem; margin-top: 1rem; }

/* ── Grids & cards ─────────────────────────────────────── */
.grid { display: grid; gap: 1rem; }
.grid-regions { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid-packages { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

.region-card { cursor: pointer; text-align: left; transition: .18s; display: block; color: inherit; }
.region-card:hover { transform: translateY(-4px); border-color: var(--brand-3); text-decoration: none; box-shadow: 0 22px 44px -26px rgba(8,30,52,.35); }
.region-emoji { font-size: 2.2rem; }
.region-card h3 { margin: .6rem 0 .2rem; }
.tag { display: inline-block; font-size: .72rem; font-weight: 800; color: var(--brand-2); background: rgba(46,134,214,.1); border-radius: 999px; padding: .18rem .65rem; }

.pkg { display: flex; flex-direction: column; gap: .5rem; transition: .18s; }
.pkg:hover { transform: translateY(-4px); border-color: var(--brand-3); box-shadow: 0 22px 44px -26px rgba(8,30,52,.35); }
.pkg .data { font-family: var(--display); font-size: 2rem; font-weight: 800; color: var(--brand); }
.pkg .meta { color: var(--muted); font-size: .9rem; }
.pkg .price { font-family: var(--display); font-size: 1.5rem; font-weight: 800; color: var(--brand); }
.pkg .foot { margin-top: auto; }

.empty { text-align: center; color: var(--muted); padding: 2rem; }

/* Loading elegant: spinner rrethor + tekst i zbutur (zëvendëson tekstin e thatë kudo) */
.loading { text-align: center; color: var(--muted); padding: 2.4rem 2rem; font-size: .95rem; }
.loading::before {
  content: ''; display: block; width: 30px; height: 30px; margin: 0 auto 12px;
  border-radius: 50%; border: 3px solid #E3EAF2; border-top-color: var(--brand);
  animation: pe-spin .75s linear infinite;
}
@keyframes pe-spin { to { transform: rotate(360deg); } }

/* ── Smoothness globale (web) ─────────────────────────── */
@view-transition { navigation: auto; }                    /* tranzicion i butë mes faqeve (Chrome) */
::view-transition-old(root) { animation: pe-fadeout .14s ease both; }
::view-transition-new(root) { animation: pe-fadein .18s ease both; }
@keyframes pe-fadeout { to { opacity: 0; } }
@keyframes pe-fadein { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { ::view-transition-old(root), ::view-transition-new(root) { animation: none; } }
/* iOS: tranzicionet cross-document FIKEN — WKWebView flash-on të ZI mes snapshot-eve.
   Anti-zoom: inputet <16px e bëjnë iOS-in të zmadhojë faqen në fokus. */
@supports (-webkit-touch-callout: none) {
  @view-transition { navigation: none; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
  input:not([type=checkbox]):not([type=radio]), select, textarea { font-size: 16px !important; }
}
@media (display-mode: standalone) {
  ::view-transition { background: #F4F7FB; }
  html { background: #F4F7FB; }
}

html { scroll-behavior: smooth; }
body.modal-open { overflow: hidden; }
::selection { background: rgba(61,139,217,.25); }
.btn:active { transform: scale(.98); }
.region-card:hover, .pkg:hover { transform: translateY(-3px); box-shadow: 0 18px 38px -22px rgba(8,30,52,.45); }
.region-card:active, .pkg:active { transform: translateY(-1px) scale(.99); }
a.link { transition: color .15s; }

/* Hyrje e butë për përmbajtjen që rendërohet nga JS */
@keyframes pe-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.fade-up { animation: pe-up .24s ease both; }

/* ── Checkout / summary (legacy) ──────────────────────── */
.summary-row { display: flex; justify-content: space-between; padding: .55rem 0; border-bottom: 1px dashed var(--line); }
.summary-row:last-child { border-bottom: 0; }
.summary-total { font-family: var(--display); font-size: 1.4rem; font-weight: 800; color: var(--brand); }

/* ── Forms ─────────────────────────────────────────────── */
.field { display: block; margin-bottom: 1rem; }
.field label { display: block; margin-bottom: .35rem; color: var(--muted); font-size: .9rem; font-weight: 600; }
.field input, .field select {
  width: 100%; padding: .8rem .9rem; border-radius: 12px;
  border: 1px solid var(--line); background: #fff; color: var(--text); font-size: 1rem; font-family: inherit;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15,73,124,.1); }
.form-card { width: 100%; max-width: 420px; }

/* ── Badges ───────────────────────────────────────────── */
.badge { display: inline-block; padding: .2rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 800; }
.badge-green { background: rgba(21,160,107,.12); color: var(--ok); }
.badge-amber { background: rgba(245,166,35,.15); color: #B9791A; }
.badge-red { background: rgba(192,57,43,.12); color: var(--danger); }
.badge-gray { background: rgba(91,107,124,.12); color: var(--muted); }

/* ── Table ─────────────────────────────────────────────── */
.table-wrap {
  width: 100%; max-width: 100%; min-width: 0; overflow-x: auto;
  overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line); border-radius: var(--radius); background: #fff;
}
table.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.tbl th, table.tbl td { padding: .75rem .9rem; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.tbl th { color: var(--muted); font-weight: 700; background: var(--card-2); }
table.tbl tr:last-child td { border-bottom: 0; }

/* ── KPI ──────────────────────────────────────────────── */
.kpis { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.kpi .v { font-family: var(--display); font-size: 2rem; font-weight: 800; color: var(--brand); }
.kpi .l { color: var(--muted); font-size: .9rem; }

.toolbar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }

/* ── Admin · Klientët ─────────────────────────────────── */
.users-page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 1rem; margin-bottom: 1rem;
}
.users-title-block { min-width: 0; }
.users-title-block h1 { margin: 0; }
.users-title-block .h-sub { margin-bottom: 0; }
.users-toolbar {
  display: flex; align-items: center; justify-content: flex-end;
  gap: .65rem; width: min(100%, 520px); min-width: 0;
}
.users-search {
  flex: 1 1 260px; width: 100%; min-width: 0; margin: 0;
  padding: .8rem .9rem; border: 1px solid var(--line); border-radius: 12px;
  background: #fff; color: var(--text); font-family: inherit;
}
.users-search:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15,73,124,.1);
}
.users-export { flex: none; white-space: nowrap; }
.users-table-wrap { margin-top: 1rem; }
.users-modal-title { min-width: 0; flex: 1; }
.users-modal-title h2 { margin: 0; overflow-wrap: anywhere; }
.users-modal-title .muted { overflow-wrap: anywhere; }
.users-modal-actions { display: flex; gap: 8px; align-items: center; flex: none; }
.users-modal-actions #mEdit { padding: 8px 14px; }
.user-edit-form {
  display: block; margin-bottom: 8px; padding: 16px;
  border: 1px solid #E3E9F0; border-radius: 12px; background: #F7FAFD;
}
.user-edit-form[hidden] { display: none; }
.user-edit-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px;
}
.user-edit-label {
  min-width: 0; color: #5B6B7C; font-size: 12.5px; font-weight: 700;
}
.user-edit-optional { font-weight: 400; }
.user-edit-grid .field {
  width: 100%; max-width: 100%; min-width: 0; margin: 5px 0 0;
  padding: .8rem .9rem; border: 1px solid var(--line); border-radius: 12px;
  background: #fff; color: var(--text); font-family: inherit;
}
.user-edit-grid .field:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15,73,124,.1);
}
.user-edit-notify {
  display: flex; align-items: center; gap: 8px; min-width: 0;
  margin-top: 26px; color: #5B6B7C; font-size: 12.5px; font-weight: 700;
}
.user-edit-notify input { width: auto; flex: none; margin: 0; }
.user-edit-actions {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 14px;
}
.user-edit-actions .btn { padding: 10px 20px; }
.user-edit-actions #eMsg { min-width: 0; font-size: 13px; overflow-wrap: anywhere; }
.user-detail-table-wrap table { min-width: 580px; }

/* ── WhatsApp + toast ──────────────────────────────────── */
.wa-fab {
  position: fixed; right: 1.1rem; bottom: 1.1rem; z-index: 45;
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: #25d366; color: #fff; box-shadow: 0 12px 26px rgba(8,30,52,.28); transition: transform .15s;
}
.wa-fab:hover { transform: scale(1.08); text-decoration: none; }
.toast {
  position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%);
  background: #0E2438; color: #fff; padding: .7rem 1.1rem;
  border-radius: 12px; box-shadow: var(--shadow); opacity: 0; transition: .2s; z-index: 60;
}
.toast.show { opacity: 1; }

/* ── Modal ─────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 70; display: flex; align-items: flex-start; justify-content: center;
  background: rgba(8,30,52,.5); backdrop-filter: blur(3px); padding: 4vh 1rem; overflow-y: auto;
}
.modal {
  background: #fff; border-radius: var(--radius); box-shadow: 0 30px 70px -20px rgba(8,30,52,.55);
  width: 100%; max-width: 680px; padding: 1.6rem;
}
.modal-head { display: flex; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; }
.modal-close {
  margin-left: auto; border: 1px solid var(--line); background: #fff; color: var(--muted);
  width: 36px; height: 36px; border-radius: 10px; cursor: pointer; font-size: 1.1rem; flex: none;
}
.modal-close:hover { background: var(--card-2); }
.minigrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .8rem; margin: 1rem 0; }
.minigrid .b { background: var(--card-2); border: 1px solid var(--line); border-radius: 12px; padding: .7rem .9rem; }
.minigrid .b .v { font-weight: 800; font-size: 1.05rem; color: var(--brand); }
.minigrid .b .l { color: var(--muted); font-size: .8rem; }

@media (max-width: 760px) {
  body.admin-users-page { width: 100%; max-width: 100%; overflow-x: hidden; overflow-x: clip; }
  .admin-users-page .users-section {
    width: 100%; max-width: 100%; min-width: 0;
    padding-block: 1.35rem calc(1.6rem + var(--safe-bottom));
    padding-inline: 1rem;
  }
  .users-page-head {
    display: grid; grid-template-columns: minmax(0, 1fr);
    align-items: stretch; gap: .85rem; margin-bottom: .85rem;
  }
  .users-title-block { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; }
  .users-title-block h1 { font-size: clamp(1.75rem, 8vw, 2.1rem); }
  .users-title-block .h-sub { flex: none; margin: 0; font-size: .88rem; white-space: nowrap; }
  .users-toolbar {
    display: grid; grid-template-columns: minmax(0, 1fr) auto;
    width: 100%; max-width: none; gap: .5rem;
  }
  .users-search { min-height: 44px; padding: .68rem .8rem; }
  .users-export { min-height: 44px; padding: .68rem .85rem; font-size: .9rem; }

  /* Tabela kryesore bëhet listë kartash; kështu faqja vetë nuk lëviz anash. */
  .users-table-wrap {
    overflow: visible; border: 0; border-radius: 0; background: transparent;
  }
  table.users-table { display: block; width: 100%; font-size: .9rem; }
  .users-table thead { display: none; }
  .users-table tbody {
    display: grid; grid-template-columns: minmax(0, 1fr); gap: .75rem; width: 100%;
  }
  .users-table tbody tr[data-id] {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%; min-width: 0; padding: .95rem;
    border: 1px solid var(--line); border-radius: 16px;
    background: #fff; box-shadow: var(--shadow);
  }
  .users-table tbody tr[data-id]:active { transform: scale(.995); }
  table.users-table tbody tr[data-id] td {
    display: block; min-width: 0; padding: .55rem .45rem;
    border: 0; white-space: normal; overflow-wrap: anywhere;
  }
  table.users-table tbody tr[data-id] td::before {
    content: attr(data-label); display: block; margin-bottom: .12rem;
    color: var(--muted); font-size: .7rem; font-weight: 800;
    letter-spacing: .025em; text-transform: uppercase;
  }
  table.users-table tbody tr[data-id] td:first-child {
    grid-column: 1 / -1; margin: -.1rem -.05rem .2rem; padding: .35rem .45rem .75rem;
    border-bottom: 1px solid var(--line);
  }
  table.users-table tbody tr[data-id] td:first-child::before { display: none; }
  table.users-table tbody tr:not([data-id]) {
    display: block; padding: 1.2rem; border: 1px solid var(--line);
    border-radius: 16px; background: #fff;
  }
  table.users-table tbody tr:not([data-id]) td {
    display: block; width: 100%; padding: 0; border: 0; white-space: normal;
  }

  /* Modal-i respekton notch/home-indicator dhe scrollon vetëm vertikalisht. */
  .users-modal-overlay {
    width: 100%; max-width: 100%; height: 100vh; height: 100dvh;
    padding: calc(var(--safe-top) + 10px) 10px calc(var(--safe-bottom) + 10px);
    overflow: hidden;
  }
  .users-modal {
    width: 100%; max-width: 100%; min-width: 0;
    max-height: calc(100vh - var(--safe-top) - var(--safe-bottom) - 20px);
    max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 20px);
    padding: 1rem; border-radius: 16px; overflow-x: hidden; overflow-y: auto;
    overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  }
  .users-modal-head {
    display: grid; grid-template-columns: minmax(0, 1fr) auto;
    align-items: start; gap: .65rem; min-width: 0;
  }
  .users-modal-title h2 { font-size: 1.25rem; }
  .users-modal-title .muted { font-size: .85rem; }
  .users-modal-actions { gap: 6px; }
  .users-modal-actions #mEdit {
    min-height: 36px; padding: 6px 9px; border-radius: 9px; font-size: .8rem;
  }
  .users-modal .modal-close { width: 36px; height: 36px; }
  .user-edit-form { width: 100%; min-width: 0; padding: .85rem; }
  .user-edit-grid { grid-template-columns: minmax(0, 1fr); gap: .75rem; }
  .user-edit-notify {
    min-height: 44px; margin-top: 0; padding: .65rem .75rem;
    border: 1px solid var(--line); border-radius: 12px; background: #fff;
  }
  .user-edit-actions {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch; gap: .6rem;
  }
  .user-edit-actions .btn { width: 100%; min-width: 0; padding: .72rem .8rem; }
  .user-edit-actions #eMsg { grid-column: 1 / -1; }
  .users-modal .minigrid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
  .users-modal .minigrid .b { min-width: 0; padding: .65rem .7rem; }
  .users-modal .minigrid .v { font-size: .93rem; overflow-wrap: anywhere; }
  .users-modal .user-detail-table-wrap {
    width: 100%; max-width: 100%; min-width: 0;
    overflow-x: auto; overflow-y: hidden;
  }
}

@media (max-width: 390px) {
  .users-toolbar { grid-template-columns: minmax(0, 1fr); }
  .users-export { width: 100%; }
  .users-table tbody tr[data-id] { padding: .8rem; }
  .users-modal { padding: .85rem; }
}
