:root {
  --bg: #e8f0ef;
  --ink: #0f2430;
  --muted: #5a7380;
  --line: #d3e0e2;
  --card: #ffffff;
  --brand: #0a7c74;
  --brand-2: #06635d;
  --brand-soft: #e4f6f3;
  --accent: #d97706;
  --ok: #0f7a3c;
  --warn: #9a6b00;
  --err: #b42318;
  --shadow: 0 8px 24px rgba(15, 36, 48, 0.07);
  --radius: 14px;
  --sidebar: #063f3c;
  --sidebar-2: #0a5852;
}
* { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
html, body {
  margin: 0;
  max-width: 100%;
  overflow-x: hidden;
}
body {
  color: var(--ink);
  font-family: "Plus Jakarta Sans", "Segoe UI", sans-serif;
  background:
    radial-gradient(1000px 420px at 0% -5%, rgba(10, 124, 116, 0.16) 0%, transparent 55%),
    radial-gradient(800px 360px at 100% 0%, rgba(217, 119, 6, 0.12) 0%, transparent 50%),
    linear-gradient(180deg, #edf4f3 0%, var(--bg) 40%);
  min-height: 100vh;
  min-height: 100dvh;
}
a { color: var(--brand-2); text-decoration: none; }
.shell {
  display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh;
  width: 100%; max-width: 100%;
}
.shell > * { min-width: 0; }
.sidebar-backdrop { display: none; }
.sidebar {
  background: linear-gradient(185deg, var(--sidebar-2) 0%, var(--sidebar) 70%);
  color: #e8fffb;
  padding: 26px 18px;
  box-shadow: inset -1px 0 0 rgba(255,255,255,.06);
}
.brand {
  font-size: 19px; font-weight: 800; letter-spacing: -.02em;
  padding: 4px 8px 18px; border-bottom: 1px solid rgba(255,255,255,.12);
}
.brand small {
  display: block; opacity: .72; font-weight: 500; font-size: 11px;
  margin-top: 6px; letter-spacing: .04em; text-transform: uppercase;
}
.nav { margin-top: 20px; display: grid; gap: 4px; }
.nav a {
  color: #d7f5f0;
  padding: 11px 14px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 13.5px;
  line-height: 1.25;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background .15s ease, transform .15s ease;
}
.nav a.active {
  background: rgba(255,255,255,.16);
  box-shadow: inset 3px 0 0 #7ee0d4;
}
.nav a:hover { background: rgba(255,255,255,.1); }
.nav-ico {
  width: 1em;
  height: 1em;
  flex: 0 0 1em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: .85;
  color: inherit;
}
.nav-ico svg {
  width: 1em;
  height: 1em;
  display: block;
  stroke: currentColor;
}
.nav-label { min-width: 0; line-height: 1.25; }
.main { padding: 24px 28px 40px; width: 100%; max-width: 1280px; min-width: 0; overflow-x: hidden; }
.top {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: rgba(255,255,255,.82); border: 1px solid var(--line); border-radius: 16px;
  padding: 16px 18px; box-shadow: var(--shadow); backdrop-filter: blur(8px);
  flex-wrap: nowrap;
  position: relative;
  z-index: 200; /* keep bell dropdown above Chart.js / sales cards */
  overflow: visible;
}
body.modal-open .top,
body.modal-open .bell-wrap,
body.modal-open .bell-panel {
  z-index: 1;
}
.top h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; font-weight: 800; }
.top p, .top-sub { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.top-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; flex-wrap: nowrap; position: relative; z-index: 1; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 999px; padding: 9px 18px;
  background: linear-gradient(180deg, #0d8f86 0%, var(--brand) 100%);
  color: #fff; font-weight: 700; cursor: pointer;
  width: auto; margin-top: 0; font-family: inherit; font-size: 13px;
  letter-spacing: -.01em;
  box-shadow: 0 1px 0 rgba(255,255,255,.22) inset, 0 6px 14px rgba(10, 124, 116, .22);
  transition: transform .12s ease, box-shadow .15s ease, filter .15s ease;
}
.btn:hover { filter: brightness(1.05); box-shadow: 0 1px 0 rgba(255,255,255,.22) inset, 0 8px 18px rgba(10, 124, 116, .28); }
.btn:active { transform: translateY(1px) scale(.98); }
.btn.secondary {
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  box-shadow: 0 1px 0 rgba(255,255,255,.2) inset, 0 6px 14px rgba(37, 99, 235, .22);
}
.btn.secondary:hover { filter: brightness(1.05); }
.btn.ghost {
  background: #fff; color: var(--brand-2); border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(15, 36, 48, .04);
}
.btn.ghost:hover { border-color: #9ec9c4; background: var(--brand-soft); filter: none; }
.btn.danger {
  background: linear-gradient(180deg, #ef4444 0%, var(--err) 100%);
  box-shadow: 0 1px 0 rgba(255,255,255,.18) inset, 0 6px 14px rgba(180, 35, 24, .2);
}
.btn.sm { padding: 6px 12px; font-size: 12px; border-radius: 999px; box-shadow: none; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; align-items: center; }
.grid { display: grid; gap: 16px; margin-top: 18px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.cards-2 { grid-template-columns: 1.15fr 1fr; }
.cards-3 { grid-template-columns: repeat(3, 1fr); }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); max-width: 100%; min-width: 0;
}
.grid > * { min-width: 0; }
.card h3 {
  margin: 0 0 10px; font-size: 15px; font-weight: 750; letter-spacing: -.01em;
  display: flex; align-items: center; gap: 8px;
}
.card h3::before {
  content: ""; width: 4px; height: 16px; border-radius: 4px; background: var(--brand); flex-shrink: 0;
}
.muted { color: var(--muted); font-size: 13px; line-height: 1.45; }
.kpi-value { font-size: 28px; font-weight: 800; margin-top: 6px; letter-spacing: -.03em; color: var(--ink); }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
label { display: block; margin-top: 10px; font-size: 12px; font-weight: 700; color: #3d5a68; }
input, select, textarea {
  width: 100%; margin-top: 6px; padding: 11px 12px; border-radius: 12px;
  border: 1px solid #c5d5da; background: #fff; font-family: inherit; font-size: 14px; color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(10, 124, 116, 0.18);
}
form.card > button[type=submit], .modal form > button[type=submit] { width: 100%; margin-top: 14px; }
.table-wrap {
  display: block;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  border-radius: 10px; border: 1px solid #e6edf2;
  max-width: 100%; width: 100%;
  background: #fff;
}
.card > .table-wrap { margin: 0; width: 100%; max-width: 100%; }
.card { overflow: hidden; } /* keep side-scroll inside table-wrap, not the page */
/* Desktop: fill the card */
table.data-table,
.table-wrap > table {
  width: 100% !important;
  min-width: 100%;
  max-width: 100%;
  border-collapse: collapse; border-spacing: 0;
  table-layout: fixed;
}
th, td {
  text-align: left; padding: 7px 8px;
  border-bottom: 1px solid #eef2f5;
  font-size: 12px; vertical-align: middle; color: #1f2937;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 0; /* critical with table-layout:fixed so long text ellipsizes */
}
th {
  color: #6b7c8a; text-transform: uppercase; font-size: 9.5px; letter-spacing: .06em;
  background: #f5f8fa; font-weight: 700; position: sticky; top: 0; z-index: 1;
  border-bottom: 1px solid #e6edf2;
  max-width: none;
}
tr:nth-child(even) td { background: transparent; }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td, .table-wrap tbody tr:hover td { background: #f4faf9; }

/* Actions: fixed narrow column, no overflow that triggers side-scroll */
td.row-actions, th.row-actions {
  width: 78px;
  max-width: 78px;
  white-space: nowrap;
  text-align: right;
  overflow: hidden;
  padding-left: 4px; padding-right: 8px;
  vertical-align: middle;
}
td.row-actions.row-actions-wide, th.row-actions.row-actions-wide {
  width: 96px; max-width: 96px;
}
td.col-created, th.col-created {
  width: 96px; max-width: 96px; white-space: nowrap; font-variant-numeric: tabular-nums;
}
td.col-phone, th.col-phone { width: 15%; }
td.col-role, th.col-role { width: 15%; }
td.col-num, th.col-num { width: 72px; max-width: 72px; text-align: center; }
td.col-money, th.col-money { width: 118px; max-width: 118px; font-variant-numeric: tabular-nums; }
td.col-token, th.col-token { width: 36%; }
td.col-msg, th.col-msg { width: 38%; }
td.col-status, th.col-status { width: 88px; max-width: 88px; }
td.col-reason, th.col-reason { width: 18%; }
td.col-id, th.col-id { width: 52px; max-width: 52px; }
td.col-meter, th.col-meter { width: 18%; }

/* Accounts */
.accounts-table th:first-child,
.accounts-table td:first-child { width: 28%; }
.accounts-table th.col-role,
.accounts-table td.col-role { width: 16%; }
.accounts-table th.col-phone,
.accounts-table td.col-phone { width: 16%; }
.accounts-table th.col-created,
.accounts-table td.col-created { width: 96px; max-width: 96px; }
.accounts-table th.row-actions,
.accounts-table td.row-actions { width: 72px; max-width: 72px; }

/* Landlords */
.landlords-table th:first-child,
.landlords-table td:first-child { width: 26%; }
.landlords-table th.col-phone,
.landlords-table td.col-phone { width: 14%; }
.landlords-table th.col-money,
.landlords-table td.col-money { width: 120px; max-width: 120px; }
.landlords-table th.row-actions,
.landlords-table td.row-actions { width: 96px; max-width: 96px; }

/* Meter registry */
.meters-table th.col-id,
.meters-table td.col-id { width: 56px; max-width: 56px; }
.meters-table th.col-meter,
.meters-table td.col-meter { width: 20%; }
.meters-table th.col-num,
.meters-table td.col-num { width: 80px; max-width: 80px; }
.meters-table th.row-actions,
.meters-table td.row-actions { width: 72px; max-width: 72px; }

/* SMS logs — single-line clip (never display:-webkit-box on td) */
.sms-log-table th:first-child,
.sms-log-table td:first-child { width: 16%; }
.sms-log-table th.col-status,
.sms-log-table td.col-status { width: 72px; max-width: 72px; }
.sms-log-table th.col-reason,
.sms-log-table td.col-reason { width: 18%; }
.sms-log-table th.col-msg,
.sms-log-table td.col-msg { width: auto; }
.sms-log-table th.col-created,
.sms-log-table td.col-created { width: 92px; max-width: 92px; }
.sms-log-table th.row-actions,
.sms-log-table td.row-actions { width: 44px; max-width: 44px; }
.sms-log-table td.col-reason,
.sms-log-table td.col-msg,
.sms-log-table td.cell-stack {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Withdrawals */
.withdrawals-table th.col-id,
.withdrawals-table td.col-id { width: 44px; max-width: 44px; }
.withdrawals-table th.col-money,
.withdrawals-table td.col-money { width: 100px; max-width: 100px; }
.withdrawals-table th.col-status,
.withdrawals-table td.col-status { width: 78px; max-width: 78px; }
.withdrawals-table th.col-phone,
.withdrawals-table td.col-phone { width: 12%; }
.withdrawals-table th.col-created,
.withdrawals-table td.col-created { width: 92px; max-width: 92px; }
.withdrawals-table th.row-actions,
.withdrawals-table td.row-actions { width: 44px; max-width: 44px; }
.mpesa-till-table th.row-actions,
.mpesa-till-table td.row-actions { width: 120px; max-width: 140px; white-space: nowrap; }
.mpesa-till-table form.inline-action { display: inline-flex; margin: 0; }
.mpesa-till-table form.inline-action .btn { margin: 0; }

/* Reports money grids */
.reports-table th.col-money,
.reports-table td.col-money { width: 130px; max-width: 130px; }
.reports-table th.row-actions,
.reports-table td.row-actions { width: 44px; max-width: 44px; }

/* Activity log */
.activity-log-table th.col-created,
.activity-log-table td.col-created { width: 100px; max-width: 100px; }
.activity-log-table th:nth-child(2),
.activity-log-table td:nth-child(2) { width: 16%; }
.activity-log-table th:nth-child(3),
.activity-log-table td:nth-child(3) { width: 18%; }
.activity-log-table th:nth-child(4),
.activity-log-table td:nth-child(4) { width: 12%; }
.act-log-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin-top: 8px;
}
.act-log-grid > div { display: grid; gap: 4px; min-width: 0; }
.act-log-grid .span-2 { grid-column: 1 / -1; }
.act-log-grid span.muted { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.act-log-grid strong {
  font-size: 14px; font-weight: 700; color: #111827;
  overflow-wrap: anywhere; word-break: break-word; white-space: normal;
}
.act-log-ip strong {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 15px; letter-spacing: .02em;
  padding: 8px 10px; background: #f5f8fa; border-radius: 8px; border: 1px solid #e6edf2;
}

.cell-clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-stack { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-stack .person-sub {
  display: inline;
  margin-left: 4px;
  margin-top: 0;
}
.cell-stack .person-sub::before { content: "· "; }
.person-cell {
  display: inline-flex; align-items: center; gap: 8px; min-width: 0; width: 100%; max-width: 100%;
}
.person-avatar {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 11px; letter-spacing: -.02em;
}
.person-avatar.tone-a { background: #f59e0b; }
.person-avatar.tone-b { background: #ea580c; }
.person-avatar.tone-c { background: #0d9488; }
.person-avatar.tone-d { background: #2563eb; }
.person-avatar.tone-e { background: #7c3aed; }
.person-avatar.tone-f { background: #db2777; }
.person-meta { display: flex; flex-direction: column; gap: 0; min-width: 0; overflow: hidden; flex: 1; }
.person-name {
  font-size: 12px; font-weight: 700; color: #111827; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.person-sub {
  font-size: 10.5px; color: #8a9aa6; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cell-mono { font-variant-numeric: tabular-nums; color: #334155; }
.cell-muted { color: #8a9aa6; font-size: 11px; white-space: nowrap; }
/* Latest tokens on dashboard — clip long tokens instead of wrapping */
.tokens-table th.col-token,
.tokens-table td.col-token { width: 42%; white-space: nowrap; }
.tokens-table th.col-phone,
.tokens-table td.col-phone { width: 22%; }
.tokens-table th.col-num,
.tokens-table td.col-num { width: 72px; max-width: 72px; }

@media (max-width: 720px) {
  .tokens-table th.col-phone,
  .tokens-table td.col-phone { width: 28%; }
  .tokens-table th.col-token,
  .tokens-table td.col-token { width: 48%; }
}
.crumbs {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-top: 12px; font-size: 13px; font-weight: 700; color: var(--muted);
}
.crumbs a { color: var(--brand-2); }
.crumbs-sep { opacity: .45; }
.hierarchy-hint {
  margin-top: 14px; padding: 12px 14px; font-size: 13px;
  background: linear-gradient(180deg, #f3fbf9 0%, #fff 100%);
}
.hierarchy-hint a { font-weight: 800; }
.alert {
  margin-top: 16px; padding: 12px 16px; border-radius: 12px; font-weight: 600; font-size: 14px;
  border: 1px solid transparent;
}
.alert.ok { background: #e6f8ee; color: #0d6a36; border-color: #b7e8c8; }
.alert.err { background: #ffece9; color: #8f1d14; border-color: #f5c4bc; }
.alert.warn { background: #fff8e6; color: #7a5b00; border-color: #f0d78c; }
.test-system-banner {
  position: sticky; top: 0; z-index: 1000;
  background: #b42318; color: #fff; text-align: center;
  font-weight: 700; font-size: 13px; padding: 7px 12px; letter-spacing: .02em;
}

/* ===== Auth / login ===== */
.auth-screen {
  min-height: 100vh;
  width: 100%;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 0;
  background:
    radial-gradient(900px 480px at 12% 10%, rgba(14, 165, 155, 0.35) 0%, transparent 55%),
    radial-gradient(700px 420px at 90% 85%, rgba(180, 110, 30, 0.22) 0%, transparent 50%),
    linear-gradient(145deg, #043833 0%, #0a5c55 42%, #0d6b7a 100%);
}
.auth-screen-inner {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 20px 40px;
}
.auth-stage {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 400px);
  gap: 28px 48px;
  align-items: center;
}
.auth-brand {
  color: #f3fffc;
  padding: 12px 8px;
  animation: authRise .55s ease both;
}
.auth-kicker {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #9be8dc;
}
.auth-brand-name {
  margin: 0;
  font-size: clamp(2rem, 4.5vw, 3.1rem);
  font-weight: 800;
  letter-spacing: -.04em;
  line-height: 1.05;
  color: #fff;
  text-shadow: 0 10px 30px rgba(0,0,0,.18);
}
.auth-brand-tag {
  margin: 16px 0 0;
  max-width: 28ch;
  font-size: 16px;
  line-height: 1.5;
  color: rgba(232, 255, 251, .86);
  font-weight: 500;
}
.auth-panel {
  background: rgba(255,255,255,.97);
  border: 1px solid rgba(255,255,255,.55);
  border-radius: 20px;
  padding: 28px 26px 24px;
  box-shadow: 0 24px 50px rgba(2, 28, 26, .28);
  animation: authRise .55s ease .08s both;
}
.auth-title {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.02em;
  color: #0f2430;
}
.auth-lead {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}
.auth-form label {
  display: block;
  margin: 12px 0 6px;
  font-size: 12px;
  font-weight: 700;
  color: #4b6570;
}
.auth-form input {
  width: 100%;
  border: 1px solid #d3e0e2;
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  font-size: 14px;
  background: #f7fbfb;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.auth-form input:focus {
  outline: 0;
  border-color: #0a7c74;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(10, 124, 116, .16);
}
.auth-submit {
  width: 100%;
  margin-top: 18px;
  padding: 12px 18px;
  font-size: 15px;
  border-radius: 12px;
}
.auth-foot {
  margin: 16px 0 0;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
}
.auth-foot a { color: var(--brand-2); }
.auth-foot a:hover { text-decoration: underline; }
.auth-panel .alert { margin: 0 0 14px; }
@keyframes authRise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (max-width: 820px) {
  .auth-stage { grid-template-columns: 1fr; gap: 18px; }
  .auth-brand { text-align: center; padding: 8px 4px 0; }
  .auth-brand-tag { margin-left: auto; margin-right: auto; }
  .auth-brand-name { font-size: 2rem; }
}
@media (max-width: 520px) {
  .auth-screen-inner { padding: 18px 14px 28px; }
  .auth-panel { padding: 22px 18px 18px; border-radius: 16px; }
}

.auth-wrap { max-width: 440px; margin: 10vh auto; }
.auth-wrap .card { padding: 22px; }
.hero-panel {
  border-radius: 16px; padding: 22px 24px; color: #fff;
  background: linear-gradient(135deg, #0a7c74 0%, #0f6a8a 55%, #c97810 120%);
  box-shadow: var(--shadow);
}
.hero-panel h2 { margin: 0 0 8px; font-size: 22px; letter-spacing: -.02em; }
.hero-panel p { margin: 0 0 10px; opacity: .95; line-height: 1.5; }
.hero-panel .btn { background: #fff; color: var(--brand-2); }
.hero-panel .btn.secondary { background: rgba(255,255,255,.18); color: #fff; border: 1px solid rgba(255,255,255,.35); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 4px; }
.hero-actions .btn { margin: 0; }
.token {
  font-family: ui-monospace, Consolas, monospace; letter-spacing: 0.5px; background: #f0f7ff;
  border: 1px dashed #9db7d8; border-radius: 8px; padding: 3px 6px; font-size: 11px;
  display: inline-block; max-width: 100%; white-space: normal; word-break: break-all; line-height: 1.35;
}
.filters {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px;
  margin-top: 14px; padding: 14px; background: rgba(255,255,255,.75);
  border: 1px solid var(--line); border-radius: 12px;
}
.meter-pick-wrap { display: flex; flex-direction: column; gap: 8px; }
.meter-pick-q { margin: 0; }
.live-scope {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 20px; /* uniform space between search filters and table card */
}
.live-scope > .filters { margin-top: 0; margin-bottom: 0; }
.live-scope > .card { margin-top: 0 !important; }
.filter-item label { margin-top: 0; }
.filter-actions { display: flex; gap: 8px; align-items: end; }
.pager {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line);
}
.pager-info { color: var(--muted); font-size: 13px; }
.pager-links { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pager-links a {
  min-width: 32px; height: 32px; padding: 0 10px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); font-weight: 700; font-size: 13px;
}
.pager-links a:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.pager-current {
  min-width: 36px; height: 36px; padding: 0 10px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 12px; background: var(--brand); color: #fff; font-weight: 800; font-size: 13px;
  box-shadow: 0 6px 14px rgba(10, 124, 116, .22);
}
.tabs {
  display: flex; gap: 4px; margin-top: 16px; flex-wrap: wrap;
  padding: 5px; background: rgba(255,255,255,.85); border: 1px solid rgba(15,36,48,.08); border-radius: 999px;
  width: fit-content; max-width: 100%;
  box-shadow: 0 8px 20px rgba(15, 36, 48, .05);
}
.tabs a, .tabs .tab {
  padding: 8px 14px; border-radius: 999px; border: 0;
  background: transparent; font-weight: 700; font-size: 13px; color: var(--muted);
  transition: background .15s ease, color .15s ease, transform .12s ease;
}
.tabs a.active, .tabs .tab.active {
  background: linear-gradient(180deg, #0d8f86 0%, var(--brand) 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(10, 124, 116, .25);
}
.tabs a:not(.active):hover { background: var(--brand-soft); color: var(--brand-2); }
.bell-wrap { position: relative; z-index: 210; }
.bell-btn {
  position: relative; width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; font-size: 18px; flex-shrink: 0;
}
.bell-count {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; border-radius: 999px;
  background: var(--err); color: #fff; font-size: 11px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 4px;
}
.bell-panel {
  display: none; position: absolute; right: 0; top: 48px; width: min(420px, calc(100vw - 24px)); max-height: 440px; overflow: auto;
  background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  z-index: 220;
}
.bell-panel.open { display: block; }
.bell-panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 14px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 1;
}
.bell-panel-head strong { font-size: 14px; }
.bell-close {
  width: 32px; height: 32px; border: 0; border-radius: 8px; background: #f3f6f8;
  font-size: 20px; line-height: 1; cursor: pointer; color: var(--ink);
}
.bell-item {
  padding: 12px 14px; border-bottom: 1px solid var(--line);
  display: block; color: inherit; text-decoration: none;
  border-left: 3px solid transparent;
}
a.bell-item:hover { background: #f4f8f8; }
.bell-item.is-error { border-left-color: #ef4444; background: #fff8f7; }
.bell-item.is-error:hover { background: #ffefed; }
.bell-item.is-ok { border-left-color: #10b981; }
.bell-item.is-warn { border-left-color: #f59e0b; }
.bell-item strong {
  display: block; font-size: 13px;
  overflow-wrap: anywhere; word-break: break-word;
  white-space: normal;
}
.bell-item.is-error strong { color: #b91c1c; }
.bell-item.is-ok strong { color: #047857; }
.bell-msg {
  overflow-wrap: anywhere; word-break: break-word;
  white-space: normal; font-size: 12.5px; line-height: 1.45; margin-top: 4px;
  color: #334155;
}
.bell-item span { color: var(--muted); font-size: 12px; display: block; margin-top: 6px; }
.bell-cta { color: var(--brand) !important; font-weight: 700; }
.bell-foot { padding: 10px 14px; }
.modal-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(15, 36, 48, .48); z-index: 1000;
  align-items: center; justify-content: center; padding: 16px;
}
.modal-backdrop.open { display: flex; }
.modal {
  width: min(560px, 100%); max-height: 90vh; overflow: auto;
  background: #fff; border-radius: 16px; padding: 20px; box-shadow: 0 20px 50px rgba(15,36,48,.2);
}
.modal h3 { margin: 0 0 8px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
/* Never set display:flex on td/th — that breaks table layout and leaves a gap after buttons */
form.row-actions,
div.row-actions,
span.row-actions {
  display: inline-flex; gap: 5px; flex-wrap: nowrap; align-items: center; justify-content: flex-end;
}
td.row-actions > form,
td.row-actions > a,
td.row-actions > button {
  display: inline-flex;
  vertical-align: middle;
  margin: 0 0 0 5px;
}
td.row-actions > form:first-child,
td.row-actions > a:first-child,
td.row-actions > button:first-child { margin-left: 0; }
td.row-actions form { display: inline-flex; margin: 0 0 0 5px; }
.action-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; padding: 0; margin: 0;
  border: 1.5px solid #cbd5e1; border-radius: 50%;
  background: #fff; color: #64748b; cursor: pointer;
  line-height: 1; text-decoration: none; flex-shrink: 0;
  box-shadow: none;
  transition: background .12s ease, border-color .12s ease, color .12s ease, transform .1s ease;
}
.action-btn svg { width: 12px; height: 12px; display: block; }
.action-btn:hover { transform: translateY(-1px); background: #f8fafc; }
.action-btn:active { transform: scale(.96); }
.action-btn.is-edit { border-color: #60a5fa; color: #2563eb; }
.action-btn.is-edit:hover { background: #eff6ff; }
.action-btn.is-danger { border-color: #f87171; color: #dc2626; }
.action-btn.is-danger:hover { background: #fef2f2; }
.action-btn.is-primary { border-color: #5eead4; color: #0f766e; }
.action-btn.is-primary:hover { background: #f0fdfa; }
.action-btn.is-warn { border-color: #fbbf24; color: #d97706; }
.action-btn.is-warn:hover { background: #fffbeb; }
.action-btn.is-info { border-color: #7dd3fc; color: #0284c7; }
.action-btn.is-info:hover { background: #f0f9ff; }
.action-btn.is-ghost { border-color: #cbd5e1; color: #64748b; }
.action-btn-wide {
  width: auto; min-height: 28px; padding: 0 10px; gap: 5px; border-radius: 999px;
  font-size: 12px; font-weight: 700;
}
.role-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 999px;
  background: #e8f8ef; color: #166534; font-size: 10.5px; font-weight: 700;
  border: 0; white-space: nowrap; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis;
}
.role-pill.pill-teal { background: #d1fae5; color: #065f46; }
.role-pill.pill-green { background: #e8f8ef; color: #166534; }
.role-pill.pill-blue { background: #e0f2fe; color: #075985; }
.role-pill.pill-amber { background: #fef3c7; color: #92400e; }
.role-pill.pill-slate { background: #eef2f7; color: #475569; }
.badge {
  display: inline-block; border-radius: 999px; padding: 3px 8px; font-size: 11px; font-weight: 700;
  background: #e8f8ef; color: #166534;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle;
}
.badge.ok { background: #e8f8ef; color: #166534; }
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.err { background: #fee2e2; color: #b91c1c; }

/* ===== Settings layout ===== */
.settings-intro {
  margin-top: 18px; margin-bottom: 4px;
}
.settings-intro h2 {
  margin: 0; font-size: 20px; letter-spacing: -.02em; font-weight: 800;
}
.settings-intro p {
  margin: 6px 0 0; color: var(--muted); font-size: 14px; max-width: 62ch;
}
.settings-stack {
  display: flex; flex-direction: column; gap: 16px; margin-top: 16px;
}
.settings-split {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
.settings-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.settings-panel-head {
  padding: 18px 20px 14px;
  background: linear-gradient(180deg, #f5fbfa 0%, #fff 100%);
  border-bottom: 1px solid var(--line);
}
.settings-kicker {
  display: inline-block;
  font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  color: var(--brand); margin-bottom: 4px;
}
.settings-panel-head h3 {
  margin: 0; font-size: 17px; font-weight: 800; letter-spacing: -.02em;
}
.settings-panel-head h3::before { display: none; }
.settings-panel-head p {
  margin: 6px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; max-width: 70ch;
}
.settings-body { padding: 18px 20px 8px; }
.settings-side-action {
  padding: 0 20px 18px;
  display: flex; gap: 8px; flex-wrap: wrap;
}
.settings-side-action .btn { width: auto; }
.settings-divider {
  height: 1px; background: var(--line); margin: 4px 20px;
}
.form-section-label {
  font-size: 11px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase;
  color: #6a8490; margin: 6px 0 10px; padding-top: 6px;
}
.form-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px;
}
.form-grid .field label { margin-top: 0; }
.form-grid .field.span-2 { grid-column: 1 / -1; }
.form-actions {
  display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0 10px;
}
.form-actions .btn { width: auto; min-width: 120px; }
.check-row {
  display: flex; align-items: center; gap: 10px; margin-top: 12px;
  font-size: 13px; font-weight: 600; color: var(--ink); cursor: pointer;
}
.check-row input {
  width: 16px; height: 16px; margin: 0; accent-color: var(--brand); flex-shrink: 0;
}
.rights-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 16px;
  padding: 16px;
}
.role-pick { display: flex; flex-direction: column; gap: 6px; }
.role-pick a {
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 12px; border-radius: 10px;
  background: #fff; border: 1px solid var(--line);
  text-decoration: none; color: var(--ink); font-weight: 700; font-size: 13px;
}
.role-pick a small { font-weight: 500; color: var(--muted); font-size: 11px; }
.role-pick a.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.role-pick a.active small { color: rgba(255,255,255,.85); }
.rights-panel { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.perm-group { margin: 0 0 16px; }
.perm-group h4 { margin: 0 0 8px; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--brand-2); }
.perm-list { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 16px; }
.perm-list label {
  display: flex; gap: 8px; align-items: flex-start;
  font-size: 13px; font-weight: 500; cursor: pointer; padding: 6px 0;
}
.perm-list input { width: 16px; height: 16px; margin-top: 2px; accent-color: var(--brand); flex-shrink: 0; }
.pricing-example {
  margin: 12px 0 0; padding: 12px 14px; border-radius: 10px;
  background: var(--brand-soft); font-size: 13px; color: var(--ink); line-height: 1.5;
}
.property-pricing .settings-body { padding-top: 0; }
.meter-pick-list {
  max-height: 220px; overflow-y: auto; margin: 10px 0 14px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
.modal-wide { max-width: 560px; }
.meter-assign-panel { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
@media (max-width: 900px) {
  .rights-layout { grid-template-columns: 1fr; padding: 12px; }
  .role-pick { flex-direction: row; flex-wrap: wrap; }
  .role-pick a { flex: 1 1 calc(50% - 6px); }
  .perm-list { grid-template-columns: 1fr; }
}
.time-now {
  margin: 0 0 10px; font-size: 13px; color: var(--muted);
  padding: 10px 12px; background: var(--brand-soft); border-radius: 10px;
}
.time-now strong { color: var(--ink); }

.tabs-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  flex-wrap: nowrap;
  -webkit-overflow-scrolling: touch;
}
.tabs-scroll a { white-space: nowrap; flex-shrink: 0; }
.dash-analytics {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) 260px;
  gap: 18px;
  align-items: stretch;
  margin: 16px 0 20px;
  position: relative;
  z-index: 1;
}
.sales-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px 20px 16px;
  box-shadow: var(--shadow);
  min-width: 0;
  position: relative;
  z-index: 1;
}
.sales-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.sales-title { display: flex; align-items: center; gap: 10px; }
.sales-title h3 { margin: 0; font-size: 18px; letter-spacing: -.02em; }
.sales-kicker {
  margin: 0 0 2px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.sales-ico {
  width: 36px; height: 36px; border-radius: 12px; flex-shrink: 0;
  background:
    linear-gradient(180deg, rgba(255,255,255,.18), transparent 40%),
    linear-gradient(135deg, #0a7c74, #14b8a6);
  box-shadow: 0 6px 14px rgba(10,124,116,.25);
  position: relative;
}
.sales-ico::after {
  content: "";
  position: absolute; left: 8px; right: 8px; bottom: 9px; height: 10px;
  border-bottom: 2px solid rgba(255,255,255,.9);
  border-left: 2px solid rgba(255,255,255,.9);
  transform: skewX(-18deg);
}
.sales-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sales-toggles, .sales-ranges { display: flex; gap: 6px; flex-wrap: wrap; }
.chart-type-btn, .sales-ranges a {
  border: 1px solid var(--line);
  background: #f7fbfb;
  color: var(--ink);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}
.chart-type-btn.active { background: #2563eb; color: #fff; border-color: #2563eb; }
.sales-ranges a.active { background: #f59e0b; color: #fff; border-color: #f59e0b; }
.sales-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 14px 0 10px;
  color: var(--muted);
  font-size: 13px;
}
.sales-meta strong { color: #d97706; font-size: 16px; font-weight: 800; }
.sales-chart-wrap {
  height: 280px;
  position: relative;
  background: linear-gradient(180deg, #f8fcfc 0%, #fff 70%);
  border-radius: 14px;
  padding: 8px 4px 0;
}
.dash-summary { display: flex; flex-direction: column; gap: 10px; }
.summary-box {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 13px 12px 13px 14px;
  box-shadow: var(--shadow);
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.summary-box:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(15,36,48,.1);
  border-color: #bcd4d2;
}
.summary-icon {
  width: 38px; height: 38px; border-radius: 12px; flex-shrink: 0;
}
.summary-copy { min-width: 0; flex: 1; display: grid; gap: 1px; }
.summary-label { font-size: 12px; font-weight: 700; color: var(--muted); }
.summary-value { font-size: 18px; font-weight: 800; letter-spacing: -.02em; }
.summary-sub { font-size: 11px; color: var(--muted); }
.summary-chevron {
  color: #9ab0b6; font-size: 20px; font-weight: 700; line-height: 1;
  flex-shrink: 0; margin-left: 4px; align-self: center;
}
.summary-box.tone-green .summary-icon { background: #dcfce7; }
.summary-box.tone-yellow .summary-icon { background: #fef3c7; }
.summary-box.tone-pink .summary-icon { background: #fce7f3; }
.summary-box.tone-blue .summary-icon { background: #dbeafe; }
.summary-box.tone-orange .summary-icon { background: #ffedd5; }
.dash-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 18px;
}
.dash-strip > div, .dash-strip > a {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
}
.dash-strip > a:hover { border-color: var(--brand); }
.dash-strip span { display: block; color: var(--muted); font-size: 12px; font-weight: 600; }
.dash-strip strong { display: block; margin-top: 4px; font-size: 16px; font-weight: 800; }
.wallet-toolbar { margin: 16px 0 0; }
.withdraw-panel { margin-top: 14px; }
.withdraw-panel[hidden], .wallet-toolbar .btn[hidden] { display: none; }
.finder-hits { margin: 6px 0 8px; display: flex; flex-direction: column; gap: 6px; }
.finder-hit {
  text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 10px;
  padding: 10px 12px; cursor: pointer;
}
.finder-hit:hover { border-color: var(--brand); background: #f4f8f8; }
.finder-hit strong { display: block; font-size: 14px; }
.finder-hit span { color: var(--muted); font-size: 12px; }
.finder-modes { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 10px; }
.finder-mode {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 6px 12px; font-size: 13px; font-weight: 700; cursor: pointer; color: var(--ink);
}
.finder-mode.is-on { background: var(--brand); border-color: var(--brand); color: #fff; }
.finder-picked-prop {
  margin: 8px 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f4f8f8;
  border: 1px solid var(--line);
}
.finder-picked-prop strong { display: block; }
.finder-picked-prop span { color: var(--muted); font-size: 13px; }
.finder-picked-prop .linkish {
  border: 0; background: none; color: var(--brand); font-weight: 700; padding: 0; cursor: pointer;
}
.stk-inline { display: flex; gap: 8px; align-items: center; }
.stk-inline input { flex: 1; }
.stk-inline .btn { width: auto; min-width: 0; flex-shrink: 0; }
.withdraw-dest {
  margin-top: 8px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #f4f8f8;
  border: 1px solid var(--line);
}
.withdraw-steps {
  margin: 0 0 12px;
  padding-left: 20px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
}
.withdraw-steps li { margin: 0 0 6px; }
.otp-timer {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #f4f8f8;
  font-size: 14px;
  font-weight: 700;
}
.otp-timer.is-live { border-color: var(--brand); background: #e7f6f2; }
.otp-timer.is-expiring { border-color: #fdba74; background: #fff7ed; }
.otp-timer.is-expired { border-color: #fca5a5; background: #fef2f2; color: #991b1b; }
.withdraw-dest strong { display: block; font-size: 18px; letter-spacing: .02em; }
.withdraw-dest span { display: block; margin-top: 6px; color: var(--muted); font-size: 13px; line-height: 1.4; }
.withdraw-process { margin-bottom: 0; border: 1px solid var(--brand); }
.wd-row-focus td { background: #e7f6f2; }
.dash-alert {
  display: block;
  margin: 0 0 16px;
  padding: 14px 16px;
  border-radius: 14px;
  background: #fff7ed;
  border: 1px solid #fdba74;
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
}
.dash-alert:hover { border-color: #f97316; }
@media (max-width: 1100px) {
  .dash-strip { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 980px) {
  .dash-analytics { grid-template-columns: 1fr; }
  .dash-summary { display: grid; grid-template-columns: 1fr 1fr; }
  .dash-strip { grid-template-columns: 1fr 1fr; }
}
.dash-head {
  display: flex; align-items: center; justify-content: flex-end; gap: 12px; flex-wrap: wrap;
  margin-top: 14px; margin-bottom: 2px;
}
.dash-clock {
  display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 0; background: transparent; border: 0; box-shadow: none; font-weight: 600;
}
.dash-clock-cal {
  width: 18px; height: 18px; border: 1.5px solid #8aa0ad; border-radius: 4px; position: relative; flex-shrink: 0;
}
.dash-clock-cal::before {
  content: ""; position: absolute; left: 3px; right: 3px; top: 5px; height: 1.5px; background: #8aa0ad;
}
.dash-clock-cal::after {
  content: ""; position: absolute; width: 2px; height: 4px; background: #8aa0ad; top: -2px; left: 4px;
  box-shadow: 7px 0 0 #8aa0ad;
}
.dash-clock-date {
  color: #5d7380; font-size: 14px; font-weight: 600;
}
.dash-clock-time {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 86px; padding: 6px 12px; border-radius: 999px;
  background: #16a34a; color: #fff; font-size: 13px; font-weight: 800;
  font-variant-numeric: tabular-nums; letter-spacing: .02em;
}
.top-left { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.top-title { min-width: 0; overflow: hidden; }
.nav-toggle {
  display: none;
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; font-size: 20px; flex-shrink: 0; line-height: 1;
}

@media (max-width: 1100px) {
  .cards-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 980px) {
  .shell {
    display: block;
    width: 100%;
    max-width: 100%;
  }
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: min(280px, 86vw);
    z-index: 80; transform: translateX(-110%); transition: transform .2s ease;
    overflow: auto; box-shadow: none; padding: 18px 14px;
  }
  body.nav-open .sidebar { transform: translateX(0); box-shadow: 8px 0 30px rgba(0,0,0,.25); }
  .sidebar-backdrop {
    display: block; position: fixed; inset: 0; background: rgba(15,36,48,.45);
    z-index: 75; opacity: 0; pointer-events: none; transition: opacity .2s ease;
  }
  body.nav-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  .brand { padding-bottom: 12px; }
  .nav { grid-template-columns: 1fr; }
  .cards-2, .cards-3, .settings-split { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .field.span-2 { grid-column: auto; }
  .main {
    display: block;
    padding: 10px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
  }

  /* One compact header row: menu | title | bell + logout */
  .top {
    padding: 10px 12px;
    align-items: center;
    gap: 8px;
    width: 100%;
    max-width: 100%;
    flex-direction: row;
    flex-wrap: nowrap;
  }
  .top-left {
    width: auto;
    flex: 1;
    min-width: 0;
    align-items: center;
    gap: 8px;
  }
  .top-title { min-width: 0; overflow: hidden; }
  .top h1 {
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .top-sub { display: none; }
  .top-actions {
    width: auto;
    max-width: none;
    flex-shrink: 0;
    flex-wrap: nowrap;
    gap: 6px;
    justify-content: flex-end;
  }
  .btn-logout {
    padding: 8px 10px;
    font-size: 12px;
    white-space: nowrap;
  }
  .bell-btn, .nav-toggle { width: 38px; height: 38px; }

  /* Notifications stay fully on screen */
  .bell-panel {
    position: fixed;
    left: 10px;
    right: 10px;
    top: 64px;
    width: auto !important;
    max-width: none;
    max-height: min(70vh, 460px);
    z-index: 250;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .bell-msg, .bell-item strong, .bell-item {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .tabs, .tabs-sub, .tabs-scroll {
    width: 100%; max-width: 100%;
    overflow-x: auto; flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  .tabs a, .tabs-sub a, .tabs-scroll a {
    white-space: nowrap; flex-shrink: 0;
    padding: 8px 12px; font-size: 12px;
  }
  .toolbar {
    gap: 8px; width: 100%;
    display: flex; flex-wrap: wrap;
  }
  .toolbar .btn {
    flex: 0 1 auto;
    width: auto;
    min-width: 0;
    padding: 9px 12px;
    font-size: 12.5px;
    white-space: nowrap;
  }
  .toolbar form { display: inline-flex; margin: 0; }
  .filters { grid-template-columns: 1fr; width: 100%; max-width: 100%; padding: 10px; }
  .filter-actions { grid-column: 1 / -1; }
  .filter-actions .btn { width: auto; }
  .table-wrap { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 0; }
  .person-cell { max-width: 160px; gap: 6px; }
  .person-avatar { width: 26px; height: 26px; font-size: 11px; }
  .person-name { font-size: 12px; }
  .action-btn { width: 30px; height: 30px; }
  .action-btn svg { width: 13px; height: 13px; }
  .hierarchy-hint { font-size: 12px; padding: 10px 12px; }
  .toolbar .btn { padding: 8px 12px; font-size: 12.5px; }
  .kpi-value { font-size: 20px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
  .hero-panel { padding: 16px; overflow-wrap: anywhere; }
  .hero-panel h2 { font-size: 18px; }
  .hero-panel .btn, .hero-actions .btn {
    display: inline-flex;
    width: auto;
    margin: 0;
    padding: 9px 12px;
    font-size: 12.5px;
  }
  .modal {
    width: min(100%, 560px);
    max-width: calc(100vw - 20px);
    padding: 14px;
  }
  .modal-actions { flex-wrap: wrap; }
  .modal-actions .btn { flex: 1 1 auto; }
  .form-actions { display: flex; flex-direction: column; gap: 8px; }
  .form-actions .btn, .settings-side-action .btn { width: 100%; min-width: 0; }
  .settings-side-action { flex-direction: column; }
  .settings-panel, .settings-body, .card { max-width: 100%; }
  form.row-actions,
  div.row-actions,
  span.row-actions { gap: 6px; }
  .dash-head { justify-content: flex-end; margin-top: 10px; }
  .dash-clock { justify-content: flex-end; max-width: 100%; gap: 6px; flex-wrap: wrap; }
  .dash-clock-date { font-size: 11px; max-width: 100%; }
  .dash-clock-time { min-width: 72px; padding: 5px 10px; font-size: 12px; }
  .token { word-break: break-all; white-space: normal; }
  input, select, textarea { max-width: 100%; font-size: 16px; }
  .pager { gap: 8px; }
  .pager-links { width: 100%; }
}

@media (max-width: 560px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .auth-wrap { margin: 4vh 12px; max-width: none; width: auto; }
  .auth-screen-inner { padding: 16px 12px 24px; }
  .pager { flex-direction: column; align-items: flex-start; }
  .main { padding: 8px; }
  .card { padding: 12px; }
  table { min-width: 0; font-size: 12px; }
  th, td { padding: 8px 6px; }
  .top h1 { font-size: 15px; }
  .btn-logout { padding: 8px 9px; }
  .person-cell { max-width: 160px; }
  .role-pill { font-size: 10px; padding: 2px 6px; }
  .tabs { border-radius: 14px; width: 100%; }
  .tabs a, .tabs .tab { padding: 8px 10px; font-size: 12px; }
  .filters { gap: 8px; padding: 10px; }
  .modal { padding: 12px; border-radius: 14px; }
  .btn { min-height: 40px; }
}

@media (min-width: 981px) and (max-width: 1200px) {
  .shell { grid-template-columns: 220px minmax(0, 1fr); }
  .main { padding: 18px 20px 32px; }
}

.wallet-statement-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.wallet-statement-head h3 { margin: 0; }
.wallet-statement-filter select {
  min-width: 180px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
}
.statement-table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.statement-table .money-in { color: var(--ok); font-weight: 600; }
.statement-table .money-out { color: var(--err); font-weight: 600; }
.wallet-fee-preview {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--brand-soft);
  border: 1px solid #c6ebe4;
  font-size: 14px;
}
.wallet-fee-notice {
  margin-top: 8px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #f4f8f8;
  border: 1px solid var(--line);
  font-size: 14px;
}
.wallet-fee-notice.ok {
  background: var(--brand-soft);
  border-color: #c6ebe4;
}
.wallet-fee-notice.err {
  background: #fdecec;
  border-color: #f3c0bc;
}
.wallet-fee-notice .fee-line { margin: 0 0 4px; }
.wallet-fee-notice .fee-line.remain { margin-top: 8px; font-weight: 600; }
.wallet-fee-notice .fee-warn { color: var(--err); font-weight: 600; margin-top: 6px; }
.fee-tier-table input {
  width: 100%;
  min-width: 90px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
}
.fee-tier-table td { vertical-align: middle; }

/* =========================================================
   Device modules: phone · tablet/iPad · desktop
   ========================================================= */

/* Shared: never bleed sideways */
img, canvas, svg, video { max-width: 100%; height: auto; }
.card, .settings-panel, .hero-panel, .live-scope, .filters, .table-wrap, .modal {
  max-width: 100%;
}
.main, .shell, .auth-screen { max-width: 100vw; }

/* ----- Desktop (default / large) ----- */
@media (min-width: 1201px) {
  .main { padding: 24px 28px 40px; max-width: 1280px; }
  .shell { grid-template-columns: 248px minmax(0, 1fr); }
}

/* ----- Compact desktop / large tablet landscape ----- */
@media (min-width: 981px) and (max-width: 1200px) {
  .shell { grid-template-columns: 212px minmax(0, 1fr); }
  .main { padding: 16px 18px 28px; max-width: 100%; }
  .dash-analytics { grid-template-columns: minmax(0, 1.5fr) 220px; gap: 14px; }
  .sales-chart-wrap { height: 240px; }
  .filters { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
}

/* ----- Tablet / iPad (portrait + small landscape) ----- */
@media (min-width: 641px) and (max-width: 980px) {
  .main {
    padding: 12px 14px 28px;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }
  .top { padding: 12px 14px; border-radius: 14px; }
  .top h1 { font-size: 18px; }
  .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 12px;
    padding: 12px;
  }
  .filter-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .dash-analytics { grid-template-columns: 1fr; }
  .dash-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sales-chart-wrap { height: 260px; }
  .settings-split { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid .field.span-2 { grid-column: 1 / -1; }
  .table-wrap {
    border-radius: 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }
  table.data-table,
  .table-wrap > table {
    width: max-content !important;
    min-width: 720px !important;
    max-width: none !important;
    table-layout: auto;
  }
  th, td { max-width: none; }
  .modal { width: min(560px, calc(100vw - 32px)); }
  .toolbar .btn { min-height: 40px; }
  .nav a { padding: 12px 14px; font-size: 14px; min-height: 44px; display: flex; align-items: center; }
}

/* ----- Phone ----- */
@media (max-width: 640px) {
  .main {
    padding: 8px 8px 24px;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    padding-left: max(8px, env(safe-area-inset-left));
    padding-right: max(8px, env(safe-area-inset-right));
  }
  .top {
    position: sticky;
    top: 0;
    z-index: 60;
    margin-bottom: 8px;
    padding: 8px 10px;
    padding-top: max(8px, env(safe-area-inset-top));
    border-radius: 12px;
  }
  body.modal-open .top { z-index: 1; }
  .top h1 { font-size: 15px; }
  .nav-toggle, .bell-btn {
    width: 42px; height: 42px; min-width: 42px;
  }
  .btn, .auth-submit, .toolbar .btn, .filter-actions .btn {
    min-height: 44px;
  }
  .action-btn { width: 34px; height: 34px; }
  .filters {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px;
    border-radius: 12px;
  }
  .kpis, .dash-summary, .dash-strip, .cards-2, .cards-3 {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .dash-strip > div, .dash-strip > a { padding: 10px; }
  .dash-strip strong { font-size: 14px; }
  .summary-value { font-size: 16px; }
  .sales-card { padding: 14px; border-radius: 14px; }
  .sales-chart-wrap { height: 220px; }
  .sales-card-head { gap: 8px; }
  .chart-type-btn, .sales-ranges a { padding: 6px 10px; font-size: 12px; }
  .card { padding: 12px; border-radius: 12px; }
  .settings-panel { border-radius: 12px; }
  .settings-body { padding: 12px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .field.span-2 { grid-column: auto; }
  .modal-backdrop {
    padding: 8px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    align-items: flex-end;
  }
  .modal {
    width: 100%;
    max-width: 100%;
    max-height: min(92vh, 100%);
    border-radius: 16px 16px 12px 12px;
    padding: 14px;
  }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; }
  .tabs, .tabs-sub, .tabs-scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar, .tabs-scroll::-webkit-scrollbar { display: none; }
  .pager { flex-direction: column; align-items: stretch; gap: 8px; }
  .pager-links { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
  .hero-panel { padding: 14px; border-radius: 14px; }
  .hero-actions { width: 100%; }
  .hero-actions .btn { flex: 1 1 auto; justify-content: center; }
  .wallet-statement-head { flex-direction: column; align-items: stretch; }
  .wallet-statement-filter select { width: 100%; min-width: 0; }
  .fee-tier-table { font-size: 12px; }
  .fee-tier-table input { min-width: 0; }
  .stk-inline { flex-direction: column; }
  .stk-inline .btn { width: 100%; }

  /* Card fits phone; table scrolls sideways so no columns are lost */
  .card { overflow: hidden; }
  .table-wrap {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    touch-action: pan-x pan-y;
  }
  table.data-table,
  .table-wrap > table {
    width: max-content !important;
    min-width: 640px !important;
    max-width: none !important;
    table-layout: auto;
  }
  th, td {
    max-width: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 8px 10px;
    font-size: 12px;
  }
  td.col-msg, th.col-msg,
  td.col-token, th.col-token {
    max-width: 220px;
  }
  .sidebar {
    width: min(300px, 88vw);
    padding-top: max(18px, env(safe-area-inset-top));
    padding-bottom: max(18px, env(safe-area-inset-bottom));
  }
  .bell-panel {
    top: max(56px, calc(env(safe-area-inset-top) + 48px));
    left: 8px; right: 8px;
  }
}

/* Very small phones */
@media (max-width: 380px) {
  .kpis, .dash-summary, .dash-strip { grid-template-columns: 1fr; }
  .btn-logout { font-size: 0; padding: 8px 10px; }
  .btn-logout::before { content: "🚪"; font-size: 16px; }
  .top h1 { font-size: 14px; }
}

/* iPad Pro / large tablet landscape keep usable sidebar drawer if needed */
@media (min-width: 981px) and (max-width: 1100px) and (pointer: coarse) {
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; }
}

/* Touch: larger hit targets without breaking desktop mouse UI */
@media (pointer: coarse) {
  .nav a { min-height: 44px; }
  .action-btn { width: 32px; height: 32px; }
  .tabs a, .tabs .tab { min-height: 40px; display: inline-flex; align-items: center; }
  input, select, textarea { font-size: 16px; } /* avoid iOS zoom */
}

/* System version secret link */
.system-version-link {
  display: inline-flex;
  align-items: center;
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: default;
  text-align: left;
}
.system-version-link:focus { outline: 2px solid rgba(10,124,116,.35); outline-offset: 1px; }

/* Secret System Controls modal */
.secret-controls-modal {
  width: min(920px, 96vw);
  max-height: min(92vh, 900px);
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.secret-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  background: #1f2937;
  color: #fff;
}
.secret-head-title { display: flex; gap: 12px; align-items: flex-start; }
.secret-head-title strong { display: block; font-size: 17px; }
.secret-head-title small { display: block; margin-top: 4px; color: #9ca3af; font-size: 12px; }
.secret-shield {
  width: 36px; height: 36px; border-radius: 10px;
  background: rgba(255,255,255,.08);
  display: inline-flex; align-items: center; justify-content: center;
}
.secret-close {
  border: 0; background: transparent; color: #fff; font-size: 28px; line-height: 1;
  cursor: pointer; padding: 0 4px;
}
.secret-tabs {
  display: flex; flex-wrap: wrap; gap: 4px;
  padding: 10px 12px 0; border-bottom: 1px solid var(--line); background: #f8fafc;
}
.secret-tab {
  border: 0; background: transparent; color: #2563eb; font: inherit; font-weight: 600;
  font-size: 13px; padding: 10px 12px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.secret-tab svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.secret-tab.is-on { color: var(--ink); border-bottom-color: #2563eb; background: #fff; border-radius: 8px 8px 0 0; }
.secret-body { padding: 16px 18px 20px; overflow: auto; }
.secret-pane { display: none; }
.secret-pane.is-on { display: block; }
.secret-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  align-items: start;
  margin-bottom: 14px;
}
.secret-toggle { font-weight: 600; display: inline-flex; gap: 8px; align-items: center; padding-top: 28px; }
.secret-status-box {
  background: #f3f4f6; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
}
.secret-alert {
  border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; font-size: 14px; line-height: 1.45;
}
.secret-alert.warn { background: #fff8e6; border: 1px solid #f0d78c; color: #7a5b00; }
.secret-alert.danger { background: #fdecea; border: 1px solid #f0b4ad; color: #8a1f16; }
.secret-alert.muted-box { background: #f3f4f6; border: 1px solid var(--line); color: var(--muted); }
.secret-cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.secret-cat {
  text-align: left; cursor: pointer;
  border: 1px solid #f0b4ad; background: #fff; border-radius: 10px; padding: 12px;
  color: var(--ink); font: inherit;
}
.secret-cat strong { display: block; color: #b42318; margin-bottom: 4px; }
.secret-cat span { display: block; color: var(--muted); font-size: 12px; line-height: 1.35; }
.secret-cat.is-on, .secret-cat:hover { background: #fff5f4; box-shadow: 0 0 0 1px #b42318 inset; }
.secret-confirm-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
  align-items: end;
  margin-top: 8px;
}
.secret-confirm-row .btn { white-space: nowrap; }
.err-text { color: #b42318; font-weight: 700; }
.btn.warn-outline {
  background: #fff; color: #9a6b00; border: 1px solid #e2b84a;
}
.btn.warn-outline:hover { background: #fff8e6; }
.secret-badge {
  display: inline-block; margin-left: 6px; padding: 2px 8px; border-radius: 999px;
  background: #111827; color: #fff; font-size: 11px; font-weight: 600;
}
.secret-users-table td, .secret-users-table th { font-size: 13px; }
.secret-log-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px;
}
.secret-log-actions { display: flex; flex-direction: column; gap: 10px; }
.inline-form { display: inline; margin: 0; }
@media (max-width: 720px) {
  .secret-confirm-row, .secret-log-grid { grid-template-columns: 1fr; }
  .secret-tabs { overflow-x: auto; flex-wrap: nowrap; }
}