/* ==========================================================================
   إدارة الاشتراكات - design system
   Tokens follow a validated neutral/blue/status palette; light + dark.
   ========================================================================== */

:root {
  color-scheme: light;
  --bg: #f4f3ef;
  --surface: #fcfcfb;
  --surface-2: #f3f2ee;
  --surface-3: #e9e8e2;
  --hover: rgba(11, 11, 11, .035);
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #7a7873;
  --line: #e4e3dc;
  --line-strong: #c9c8bf;
  --border: rgba(11, 11, 11, .09);

  --primary: #2a78d6;
  --primary-hover: #256abf;
  --primary-ink: #ffffff;
  --primary-soft: #e6effb;
  --primary-text: #1c5cab;

  --good: #0ca30c;
  --good-ink: #006300;
  --good-soft: #e3f4e3;
  --bad: #d03b3b;
  --bad-ink: #a52a2a;
  --bad-soft: #fbe8e8;
  --warn: #eda100;
  --warn-ink: #7d5200;
  --warn-soft: #fdf0d2;
  --brand: #eda100;

  --series: #2a78d6;
  --grid: #e4e3dc;
  --axis: #c3c2b7;

  --sidebar: #141413;
  --sidebar-2: #1f1f1d;
  --sidebar-ink: #b4b3aa;
  --sidebar-strong: #f0efec;

  --mark: #fde8a1;
  --av-s: 65%; --av-bg: 90%; --av-ink: 28%;

  --shadow-sm: 0 1px 2px rgba(11, 11, 11, .05);
  --shadow-md: 0 8px 24px rgba(11, 11, 11, .08);
  --shadow-lg: 0 28px 70px rgba(11, 11, 11, .28);
  --radius: 16px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d0d0d; --surface: #1a1a19; --surface-2: #232321; --surface-3: #2c2c2a;
    --hover: rgba(255, 255, 255, .04);
    --ink: #f0efec; --ink-2: #c3c2b7; --muted: #8f8d86;
    --line: #2c2c2a; --line-strong: #3d3d3a; --border: rgba(255, 255, 255, .10);
    --primary: #3987e5; --primary-hover: #5598e7; --primary-soft: rgba(57, 135, 229, .16); --primary-text: #86b6ef;
    --good: #0ca30c; --good-ink: #4cc24c; --good-soft: rgba(12, 163, 12, .16);
    --bad: #e66767; --bad-ink: #f08a8a; --bad-soft: rgba(230, 103, 103, .15);
    --warn: #fab219; --warn-ink: #fab219; --warn-soft: rgba(250, 178, 25, .14);
    --series: #3987e5; --grid: #2c2c2a; --axis: #383835;
    --sidebar: #101010; --sidebar-2: #1a1a19;
    --mark: rgba(250, 178, 25, .32);
    --av-s: 35%; --av-bg: 24%; --av-ink: 82%;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, .45);
    --shadow-lg: 0 28px 70px rgba(0, 0, 0, .7);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0d0d; --surface: #1a1a19; --surface-2: #232321; --surface-3: #2c2c2a;
  --hover: rgba(255, 255, 255, .04);
  --ink: #f0efec; --ink-2: #c3c2b7; --muted: #8f8d86;
  --line: #2c2c2a; --line-strong: #3d3d3a; --border: rgba(255, 255, 255, .10);
  --primary: #3987e5; --primary-hover: #5598e7; --primary-soft: rgba(57, 135, 229, .16); --primary-text: #86b6ef;
  --good: #0ca30c; --good-ink: #4cc24c; --good-soft: rgba(12, 163, 12, .16);
  --bad: #e66767; --bad-ink: #f08a8a; --bad-soft: rgba(230, 103, 103, .15);
  --warn: #fab219; --warn-ink: #fab219; --warn-soft: rgba(250, 178, 25, .14);
  --series: #3987e5; --grid: #2c2c2a; --axis: #383835;
  --sidebar: #101010; --sidebar-2: #1a1a19;
  --mark: rgba(250, 178, 25, .32);
  --av-s: 35%; --av-bg: 24%; --av-ink: 82%;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, .45);
  --shadow-lg: 0 28px 70px rgba(0, 0, 0, .7);
}

/* ---------- reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: 'Cairo', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased;
}
body.modal-open { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4, p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
bdi { unicode-bidi: isolate; }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
.ic { display: inline-block; flex: none; vertical-align: middle; }
.ic-slot { display: inline-grid; place-items: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.ltr { direction: ltr; text-align: left; }
[hidden] { display: none !important; }
::-webkit-search-cancel-button { display: none; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 268px minmax(0, 1fr); min-height: 100vh; }
.main { min-width: 0; display: flex; flex-direction: column; }
.view { padding: 8px 28px 64px; width: 100%; max-width: 1500px; margin-inline: auto; outline: none; }
.view-inner { animation: rise .35s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.sidebar {
  position: sticky; top: 0; height: 100vh; background: var(--sidebar); color: var(--sidebar-ink);
  display: flex; flex-direction: column; gap: 22px; padding: 20px 14px; z-index: 60;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px; }
.brand-logo {
  width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; flex: none;
  background: linear-gradient(145deg, #f7b81f, #e08a00); color: #1b1300; box-shadow: 0 6px 18px rgba(237, 161, 0, .35);
}
.brand-text { display: grid; line-height: 1.25; min-width: 0; }
.brand-text strong { color: var(--sidebar-strong); font-size: 16px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-text small { color: var(--sidebar-ink); font-size: 12px; }
.nav { display: grid; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px; color: var(--sidebar-ink);
  font-weight: 600; transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--sidebar-2); color: var(--sidebar-strong); }
.nav-item.active { background: var(--sidebar-2); color: var(--sidebar-strong); box-shadow: inset -3px 0 0 var(--brand); }
.nav-item.active .ic { color: var(--brand); }
.nav-count { margin-inline-start: auto; font-style: normal; font-size: 12px; background: rgba(255, 255, 255, .08); color: var(--sidebar-strong); border-radius: 99px; padding: 1px 9px; }
.sidebar-foot { margin-top: auto; display: grid; gap: 10px; }
.foot-note { font-size: 12px; line-height: 1.6; color: #77756e; padding-inline: 6px; }

.topbar {
  position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 10px; height: 68px; padding-inline: 28px;
  background: var(--bg); border-bottom: 1px solid transparent;
}
@supports (background: color-mix(in srgb, red, blue)) {
  .topbar { background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(12px); }
}
.page-title { font-size: 20px; font-weight: 800; letter-spacing: -.2px; }
.topbar-spacer { flex: 1; }
.scrim { display: none; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 18px;
  border-radius: 12px; font-weight: 700; font-size: 14.5px; white-space: nowrap; border: 1px solid transparent;
  transition: background .15s, border-color .15s, transform .1s, box-shadow .15s, opacity .15s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; }
.btn-sm { height: 34px; padding: 0 12px; border-radius: 10px; font-size: 13.5px; }
.btn-primary { background: var(--primary); color: var(--primary-ink); box-shadow: 0 4px 14px color-mix(in srgb, var(--primary) 35%, transparent); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-ghost { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-soft { background: var(--primary-soft); color: var(--primary-text); }
.btn-soft:hover:not(:disabled) { filter: brightness(.97); }
.btn-text { color: var(--primary-text); height: 34px; padding: 0 10px; }
.btn-text:hover { background: var(--primary-soft); }
.btn-danger { background: var(--bad); color: #fff; box-shadow: 0 4px 14px color-mix(in srgb, var(--bad) 35%, transparent); }
.btn-danger:hover:not(:disabled) { filter: brightness(.93); }
.btn-danger-soft { background: var(--bad-soft); color: var(--bad-ink); }
.btn-danger-soft:hover:not(:disabled) { filter: brightness(.96); }
.btn-good-soft { background: var(--good-soft); color: var(--good-ink); }
.icon-btn {
  width: 38px; height: 38px; border-radius: 11px; display: inline-grid; place-items: center; color: var(--ink-2); flex: none;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn.danger:hover { background: var(--bad-soft); color: var(--bad-ink); }
.link-btn { display: inline-flex; align-items: center; gap: 4px; color: var(--primary-text); font-weight: 700; font-size: 13.5px; }
.link-btn:hover { text-decoration: underline; }
.only-mobile, .only-mobile-flex { display: none; }

/* ---------- sync chip ---------- */
.sync-chip {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 99px; font-size: 13px; font-weight: 700;
  background: var(--surface); border: 1px solid var(--border); color: var(--ink-2); white-space: nowrap;
}
.sync-chip .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.sync-chip[data-state="online"] .dot { background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 25%, transparent); }
.sync-chip[data-state="syncing"] .dot, .sync-chip[data-state="connecting"] .dot { background: var(--primary); animation: pulse 1s infinite; }
.sync-chip[data-state="offline"] .dot, .sync-chip[data-state="auth"] .dot { background: var(--warn); }
.sync-chip[data-state="error"] .dot { background: var(--bad); }
@keyframes pulse { 50% { opacity: .35; } }
.sync-card { width: 100%; height: auto; padding: 11px 12px; border-radius: 12px; background: var(--sidebar-2); border-color: rgba(255, 255, 255, .06); color: var(--sidebar-strong); justify-content: flex-start; white-space: normal; text-align: start; }
.set-card header .sync-chip { margin-inline-start: auto; }

/* ---------- page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 4px 0 18px; }
.page-h { font-size: 24px; font-weight: 800; letter-spacing: -.3px; }
.page-sub { color: var(--ink-2); font-size: 14px; max-width: 640px; }
.head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.month-nav { display: inline-flex; align-items: center; gap: 2px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; padding: 2px; height: 42px; }
.month-btn { white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; border-radius: 10px; font-weight: 700; min-width: 168px; justify-content: center; }
.month-btn:hover { background: var(--surface-2); }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; padding: 18px 20px 6px; }
.card-head h3 { font-size: 16px; font-weight: 800; }
.card-head .sub { font-size: 12.5px; color: var(--muted); }

.tone-primary { --tone: var(--primary); --tone-soft: var(--primary-soft); --tone-ink: var(--primary-text); }
.tone-good { --tone: var(--good); --tone-soft: var(--good-soft); --tone-ink: var(--good-ink); }
.tone-bad, .tone-danger { --tone: var(--bad); --tone-soft: var(--bad-soft); --tone-ink: var(--bad-ink); }
.tone-warn { --tone: var(--warn); --tone-soft: var(--warn-soft); --tone-ink: var(--warn-ink); }
.tone-muted { --tone: var(--muted); --tone-soft: var(--surface-3); --tone-ink: var(--ink-2); }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin-bottom: 14px; }
.stat {
  position: relative; display: grid; gap: 2px; text-align: start; padding: 18px 18px 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); transition: transform .15s var(--ease), box-shadow .15s, border-color .15s;
}
button.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat.on { border-color: var(--tone); box-shadow: 0 0 0 3px var(--tone-soft); }
.stat-ic { position: absolute; inset-block-start: 16px; inset-inline-end: 16px; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--tone-soft); color: var(--tone-ink); }
.stat-label { font-size: 13.5px; color: var(--ink-2); font-weight: 600; padding-inline-end: 52px; }
.stat-value { font-size: 36px; line-height: 1.15; font-weight: 800; letter-spacing: -.5px; margin-top: 2px; }
.stat .bar { display: block; height: 6px; border-radius: 99px; background: var(--good-soft); overflow: hidden; margin: 8px 0 2px; }
.stat .bar i { display: block; height: 100%; background: var(--good); border-radius: 99px; transition: width .5s var(--ease); }
.stat-sub { font-size: 12.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.delta { font-weight: 700; color: var(--muted); }
.delta.up { color: var(--good-ink); }
.delta.down { color: var(--bad-ink); }

/* ---------- insights: chart + late list ---------- */
.insights { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 14px; margin-bottom: 14px; }
.chart-card #chart { padding: 10px 20px 18px; }
.chart { display: flex; gap: 10px; height: 212px; padding-top: 22px; }
.y-axis { position: relative; width: 30px; margin-bottom: 30px; flex: none; }
.y-axis span { position: absolute; inset-inline: 0; transform: translateY(50%); font-size: 11.5px; color: var(--muted); text-align: end; font-variant-numeric: tabular-nums; }
.plot { position: relative; flex: 1; min-width: 0; }
.gl-wrap { position: absolute; inset: 0 0 30px 0; }
.gl { position: absolute; inset-inline: 0; height: 1px; background: var(--grid); }
.gl.base { bottom: 0; background: var(--axis); }
.cols { position: absolute; inset: 0; display: flex; }
.col { flex: 1; display: flex; flex-direction: column; align-items: center; border-radius: 8px; transition: background .15s; }
.col:hover, .col:focus-visible { background: var(--hover); }
.col-bar { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.col .bar { position: relative; display: block; width: min(24px, 56%); min-height: 2px; background: var(--series); border-radius: 4px 4px 0 0; opacity: .45; transition: height .5s var(--ease), opacity .15s; }
.col.sel .bar, .col:hover .bar, .col:focus-visible .bar { opacity: 1; }
.col .val { position: absolute; inset-inline: -12px; bottom: calc(100% + 4px); text-align: center; font-style: normal; font-size: 12.5px; font-weight: 700; color: var(--ink); opacity: 0; transition: opacity .15s; }
.col.sel .val, .col:hover .val { opacity: 1; }
.col-label { height: 30px; display: grid; place-items: center; font-size: 12px; color: var(--ink-2); font-weight: 600; }
.col.sel .col-label { color: var(--ink); }
.tip {
  position: fixed; z-index: 400; pointer-events: none; opacity: 0; transition: opacity .12s; display: grid; gap: 2px; padding: 8px 12px;
  background: var(--ink); color: var(--surface); border-radius: 10px; font-size: 12.5px; box-shadow: var(--shadow-md); white-space: nowrap;
}
.tip b { font-size: 13px; }
.mini-table { width: calc(100% - 0px); border-collapse: collapse; font-size: 13.5px; }
.mini-table th { text-align: start; color: var(--muted); font-weight: 600; font-size: 12px; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.mini-table td { padding: 9px 6px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }

.late-list { padding: 8px 12px 14px; display: grid; gap: 2px; }
.late-row { width: 100%; display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 12px; text-align: start; transition: background .15s; }
.late-row:hover { background: var(--hover); }
.late-main { display: grid; line-height: 1.3; min-width: 0; flex: 1; }
.late-main b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.late-main small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.late-badge { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 99px; background: var(--surface-3); color: var(--ink-2); white-space: nowrap; }
.late-badge.warm { background: var(--warn-soft); color: var(--warn-ink); }
.late-badge.hot { background: var(--bad-soft); color: var(--bad-ink); }
.late-empty { display: grid; justify-items: center; gap: 4px; text-align: center; padding: 34px 10px; color: var(--good-ink); }
.late-empty small { color: var(--muted); }

/* ---------- list card: toolbar, filters ---------- */
.list-card { overflow: clip; }
.toolbar { display: flex; gap: 10px; padding: 16px 20px 12px; align-items: center; }
.search { position: relative; flex: 1; display: flex; align-items: center; min-width: 0; }
.search > .ic { position: absolute; inset-inline-start: 14px; color: var(--muted); pointer-events: none; }
.search input {
  width: 100%; height: 46px; padding-inline: 44px 56px; border: 1px solid var(--line-strong); border-radius: 13px; background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.clear-q { position: absolute; inset-inline-end: 8px; width: 30px; height: 30px; }
.search .kbd { position: absolute; inset-inline-end: 12px; font-family: inherit; font-size: 12px; padding: 1px 8px; border-radius: 6px; border: 1px solid var(--line-strong); color: var(--muted); background: var(--surface-2); pointer-events: none; }
.search input:not(:placeholder-shown) ~ .kbd, .search input:focus ~ .kbd { display: none; }

.filters { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: flex-end; padding: 2px 20px 14px; }
.f-segs { display: flex; flex-wrap: wrap; gap: 12px; }
.f-selects { display: flex; flex-wrap: wrap; gap: 12px; flex: 1 1 540px; }
.f-selects .select { flex: 1 1 130px; }
.f-selects .select select { width: 100%; min-width: 0; }
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 13px; background: var(--surface-2); border: 1px solid var(--line); }
.seg-btn { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px; border-radius: 10px; font-weight: 700; font-size: 13.5px; color: var(--ink-2); transition: background .15s, color .15s; }
.seg-btn em { font-style: normal; font-size: 11.5px; padding: 1px 7px; border-radius: 99px; background: var(--surface-3); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.seg-btn:hover { color: var(--ink); }
.seg-btn.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.seg-btn.on em { background: var(--primary-soft); color: var(--primary-text); }
.select { display: grid; gap: 3px; font-size: 12px; color: var(--muted); font-weight: 600; }
.select select, .input-date {
  height: 40px; min-width: 150px; padding: 0 12px; padding-inline-start: 34px; border: 1px solid var(--line-strong); border-radius: 11px; background-color: var(--surface);
  appearance: none; -webkit-appearance: none; color: var(--ink); 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='%23898781' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left 10px center;
}
.input-date { background-image: none; padding-inline-start: 12px; font-family: inherit; }
.select select:focus, .input-date:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 0 20px 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px 0 8px; border-radius: 99px; background: var(--primary-soft); color: var(--primary-text); font-size: 12.5px; font-weight: 700; }
.chip:hover { filter: brightness(.96); }
.chip-clear { font-size: 12.5px; font-weight: 700; color: var(--muted); padding: 4px 8px; border-radius: 8px; }
.chip-clear:hover { color: var(--bad-ink); }

.bulkbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0 20px 12px; padding: 10px 14px; border-radius: 13px; background: var(--primary-soft); border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent); animation: rise .2s var(--ease); }
.bulk-info { display: flex; align-items: center; gap: 10px; color: var(--primary-text); font-weight: 700; }
.bulk-info b { font-size: 17px; }
.bulk-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; border-top: 1px solid var(--line); }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 900px; }
.tbl th { text-align: start; font-size: 12.5px; font-weight: 700; color: var(--muted); padding: 11px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; user-select: none; }
.tbl th.sortable { cursor: pointer; }
.tbl th.sortable:hover, .tbl th.sorted { color: var(--ink); }
.sort-ind { font-size: 9px; margin-inline-start: 6px; color: var(--primary-text); }
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover { background: var(--hover); }
.tbl tbody tr.sel { background: var(--primary-soft); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.c-sel { width: 46px; padding-inline-end: 0 !important; }
.c-act { width: 1%; white-space: nowrap; }
.name-btn { display: flex; align-items: center; gap: 12px; text-align: start; max-width: 280px; }
.nm { display: grid; line-height: 1.3; min-width: 0; }
.nm b { font-weight: 700; font-size: 14.5px; }
.nm small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.name-btn:hover .nm b { color: var(--primary-text); }
.c-phone a { font-variant-numeric: tabular-nums; color: var(--ink-2); font-weight: 600; display: inline-block; unicode-bidi: isolate; }
.c-phone a:hover { color: var(--primary-text); }
.c-addr { color: var(--ink-2); max-width: 260px; }
.c-last { white-space: nowrap; line-height: 1.3; }
.c-last b { display: block; font-size: 13.5px; font-weight: 600; }
.c-last small { color: var(--muted); font-size: 12px; }
.dash { color: var(--muted); }
.row-actions { display: inline-flex; gap: 2px; opacity: .75; transition: opacity .15s; }
.tbl tr:hover .row-actions, .row-actions:focus-within { opacity: 1; }

.avatar { width: var(--s, 40px); height: var(--s, 40px); border-radius: 50%; display: inline-grid; place-items: center; flex: none; font-weight: 800; font-size: calc(var(--s, 40px) * .42); background: hsl(var(--h) var(--av-s) var(--av-bg)); color: hsl(var(--h) 55% var(--av-ink)); }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 99px; font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.badge-meter { background: var(--primary-soft); color: var(--primary-text); }
.badge-breaker { background: var(--warn-soft); color: var(--warn-ink); }

.status-btn { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 99px; font-weight: 700; font-size: 13px; transition: filter .15s, transform .1s; white-space: nowrap; }
button.status-btn:hover { filter: brightness(.95); }
button.status-btn:active { transform: scale(.97); }
.status-btn.paid { background: var(--good-soft); color: var(--good-ink); }
.status-btn.unpaid { background: var(--bad-soft); color: var(--bad-ink); }
.status-btn.na { background: var(--surface-3); color: var(--muted); font-weight: 600; }
.c-status { white-space: nowrap; }
.st-sub { display: block; margin-top: 3px; font-size: 11.5px; color: var(--muted); padding-inline-start: 4px; }
.st-sub.late { color: var(--bad-ink); font-weight: 600; }

.chk { position: relative; display: inline-grid; place-items: center; cursor: pointer; }
.chk input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chk span { width: 19px; height: 19px; border-radius: 6px; border: 1.6px solid var(--line-strong); background: var(--surface); display: grid; place-items: center; transition: background .12s, border-color .12s; }
.chk input:checked + span, .chk input:indeterminate + span { background: var(--primary); border-color: var(--primary); }
.chk input:checked + span::after { content: ''; width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px); }
.chk input:indeterminate + span::after { content: ''; width: 9px; height: 2px; background: #fff; border-radius: 2px; }
.chk input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- pager ---------- */
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 20px; border-top: 1px solid var(--line); }
.pager:empty { display: none; }
.pager-info { font-size: 13.5px; color: var(--ink-2); }
.pager-info b { color: var(--ink); font-variant-numeric: tabular-nums; }
.pager-nav { display: flex; gap: 4px; align-items: center; }
.pg { min-width: 36px; height: 36px; padding: 0 8px; border-radius: 10px; display: inline-grid; place-items: center; font-weight: 700; font-size: 13.5px; color: var(--ink-2); border: 1px solid transparent; font-variant-numeric: tabular-nums; transition: background .12s; }
.pg:hover:not(:disabled):not(.active) { background: var(--surface-3); color: var(--ink); }
.pg.active { background: var(--primary); color: #fff; }
.pg:disabled { opacity: .35; }
.pg-gap { color: var(--muted); padding: 0 4px; }
.pager-size { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.pager-size select { height: 36px; min-width: 76px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); }

/* ---------- empty states ---------- */
.empty { display: grid; justify-items: center; gap: 8px; text-align: center; padding: 56px 20px; }
.empty h3 { font-size: 18px; font-weight: 800; }
.empty p { color: var(--ink-2); max-width: 420px; }
.empty-art { width: 76px; height: 76px; border-radius: 24px; display: grid; place-items: center; margin-bottom: 6px; background: linear-gradient(145deg, #f7b81f, #e08a00); color: #1b1300; box-shadow: 0 10px 30px rgba(237, 161, 0, .3); }
.empty-art.muted { background: var(--surface-3); color: var(--muted); box-shadow: none; }
.empty-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 10px; }

/* ---------- forms ---------- */
.form { display: grid; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: grid; gap: 6px; align-content: start; min-width: 0; border: 0; padding: 0; margin: 0; }
.field > label, .field > legend { font-size: 13.5px; font-weight: 700; color: var(--ink); padding: 0; }
.field b { color: var(--bad); }
.opt { font-weight: 500; color: var(--muted); font-size: 12px; }
.input {
  width: 100%; height: 44px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; padding: 10px 14px; resize: vertical; line-height: 1.6; }
textarea.code { font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; font-size: 12.5px; line-height: 1.5; text-align: left; }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.input:disabled { background: var(--surface-2); color: var(--muted); }
.input-btn { display: flex; align-items: center; gap: 10px; text-align: start; cursor: pointer; font-weight: 600; }
.input-btn:hover { border-color: var(--ink-2); }
.input-group { position: relative; }
.input-group .input { padding-inline-end: 38px; }
.input-group i { position: absolute; inset-inline-end: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-style: normal; font-weight: 700; pointer-events: none; }
.field.invalid .input { border-color: var(--bad); box-shadow: 0 0 0 4px var(--bad-soft); }
.err { color: var(--bad-ink); font-size: 12.5px; font-weight: 600; min-height: 0; }
.err:empty { display: none; }
.hint { color: var(--warn-ink); font-size: 12.5px; font-weight: 600; display: flex; gap: 6px; align-items: center; }
.hint:empty { display: none; }
.form-actions { display: flex; gap: 10px; align-items: center; }
.form-actions.wrap { flex-wrap: wrap; }

.type-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.type-card { position: relative; cursor: pointer; }
.type-card input { position: absolute; opacity: 0; inset: 0; }
.type-card-body { display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: center; padding: 12px 14px; border: 1.5px solid var(--line-strong); border-radius: 14px; background: var(--surface); transition: border-color .15s, background .15s, box-shadow .15s; }
.type-card-body .ic { grid-row: span 2; color: var(--muted); }
.type-card-body b { font-size: 15px; }
.type-card-body small { color: var(--muted); font-size: 12px; }
.type-card input:checked + .type-card-body { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 3px var(--primary-soft); }
.type-card input:checked + .type-card-body .ic { color: var(--primary-text); }
.type-card input:focus-visible + .type-card-body { outline: 2px solid var(--primary); outline-offset: 2px; }

.pay-box { display: grid; gap: 14px; padding: 16px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line); }
.pay-head { display: flex; align-items: center; gap: 8px; color: var(--ink-2); }
.pay-box .input { background: var(--surface); }
.switch-row { position: relative; display: flex; align-items: center; gap: 12px; cursor: pointer; padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line-strong); transition: border-color .15s, background .15s; }
.switch-row.on { border-color: var(--good); background: var(--good-soft); }
.switch-row.compact { padding: 8px 12px; height: 44px; }
.switch-row input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch { width: 44px; height: 26px; border-radius: 99px; background: var(--line-strong); position: relative; flex: none; transition: background .18s; }
.switch::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .18s var(--ease); }
.switch-row input:checked ~ .switch { background: var(--good); }
.switch-row input:checked ~ .switch::after { transform: translateX(-18px); }
.switch-row input:focus-visible ~ .switch { outline: 2px solid var(--primary); outline-offset: 2px; }
.switch-label { display: grid; line-height: 1.3; }
.switch-label small { color: var(--muted); font-size: 12px; }
.switch-row.on .switch-label small { color: var(--good-ink); font-weight: 600; }
.start-field { padding-top: 4px; }

.note { display: flex; gap: 12px; padding: 12px 14px; border-radius: 13px; font-size: 13.5px; line-height: 1.65; margin-top: 14px; }
.note .ic { margin-top: 2px; }
.note-info { background: var(--primary-soft); color: var(--primary-text); }
.lead { line-height: 1.7; margin-bottom: 12px; }

/* ---------- modal / drawer ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(12, 12, 11, .5); backdrop-filter: blur(3px); animation: fade .18s ease both; }
.modal-backdrop.out { animation: fadeout .18s ease both; }
@keyframes fade { from { opacity: 0; } }
@keyframes fadeout { to { opacity: 0; } }
.modal:focus { outline: none; }
.modal { width: min(560px, 100%); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow-lg); animation: pop .26s var(--ease) both; overflow: hidden; }
.modal-backdrop.out .modal { animation: popout .18s ease both; }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.97); } }
@keyframes popout { to { opacity: 0; transform: translateY(8px) scale(.98); } }
.modal-sm { width: min(440px, 100%); }
.modal-lg { width: min(540px, 100%); }
.modal-head { display: flex; align-items: center; gap: 14px; padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.modal-ic { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; flex: none; background: var(--tone-soft, var(--primary-soft)); color: var(--tone-ink, var(--primary-text)); }
.modal-titles { flex: 1; min-width: 0; }
.modal-titles h2 { font-size: 18px; font-weight: 800; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; }
.modal-titles p { font-size: 13px; color: var(--muted); }
.modal-body { padding: 18px 20px; overflow-y: auto; flex: 1; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); flex-direction: row-reverse; }
.modal.is-busy { opacity: .8; pointer-events: none; }
.confirm-text { line-height: 1.7; }
.modal.tone-danger .modal-ic { background: var(--bad-soft); color: var(--bad-ink); }

.modal-backdrop.is-drawer { padding: 0; justify-content: flex-end; align-items: stretch; }
.is-drawer .modal { width: min(520px, 100vw); height: 100dvh; max-height: none; border-radius: 0 22px 22px 0; border-width: 0 1px 0 0; animation: slide .3s var(--ease) both; }
.modal-backdrop.out.is-drawer .modal { animation: slideout .18s ease both; }
@keyframes slide { from { opacity: 0; transform: translateX(-40px); } }
@keyframes slideout { to { opacity: 0; transform: translateX(-30px); } }

.sub-card { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.sub-card-main { display: grid; line-height: 1.5; flex: 1; min-width: 0; }
.muted-line { display: flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 13px; }
.muted-line .ic { color: var(--muted); }
.del-list { display: grid; gap: 8px; padding: 12px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.del-row { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.del-more { color: var(--muted); font-size: 13px; padding-inline-start: 4px; }

.changes { display: grid; gap: 6px; }
.changes li { display: grid; grid-template-columns: 1fr; gap: 2px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); font-size: 13.5px; }
.c-label { font-weight: 700; color: var(--ink-2); font-size: 12.5px; }
.c-from { color: var(--bad-ink); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--bad-ink) 50%, transparent); }
.c-to { color: var(--good-ink); font-weight: 700; }
.c-arrow { display: none; }
.changes li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.changes .c-label { flex-basis: 100%; }
.changes .c-arrow { display: inline-flex; color: var(--muted); }

/* ---------- drawer content ---------- */
.drawer-body { display: grid; gap: 18px; }
.d-top { display: flex; align-items: center; gap: 16px; }
.d-id h3 { font-size: 20px; font-weight: 800; line-height: 1.3; }
.d-badges { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 4px; }
.since { font-size: 12.5px; color: var(--muted); }
.d-contact { display: grid; gap: 4px; padding: 6px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line); }
.d-line { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 11px; font-weight: 600; color: var(--ink-2); }
a.d-line:hover { background: var(--surface-3); color: var(--primary-text); }
.d-line .ic { color: var(--muted); }
.note-line { font-weight: 500; align-items: flex-start; }
.d-actions { display: flex; gap: 10px; }
.d-actions .btn { flex: 1; }
.d-pay-head { display: flex; justify-content: space-between; align-items: center; }
.d-pay-head h4, .d-hist h4, .snap-title { font-size: 15px; font-weight: 800; }
.year-nav { display: inline-flex; align-items: center; gap: 4px; }
.year-nav strong { min-width: 48px; text-align: center; font-variant-numeric: tabular-nums; }
.d-pay-sum { display: flex; justify-content: space-between; align-items: baseline; margin-top: 6px; font-size: 13.5px; color: var(--ink-2); }
.d-pay-sum b { color: var(--ink); }
.pct { font-weight: 800; font-size: 18px; color: var(--ink); }
.d-pay .bar { height: 7px; border-radius: 99px; background: var(--surface-3); margin: 6px 0 14px; overflow: hidden; }
.d-pay .bar i { display: block; height: 100%; border-radius: 99px; background: var(--good); transition: width .4s var(--ease); }
.m-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.m-tile { display: grid; gap: 2px; justify-items: center; padding: 10px 6px; border-radius: 13px; border: 1.5px solid var(--line); background: var(--surface); transition: transform .12s, border-color .15s, background .15s; text-align: center; }
.m-tile:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--line-strong); }
.m-tile .m-name { font-weight: 700; font-size: 13.5px; }
.m-tile .m-state { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; }
.m-tile .m-amt { font-size: 11.5px; color: var(--muted); min-height: 17px; }
.m-tile.paid { background: var(--good-soft); border-color: transparent; color: var(--good-ink); }
.m-tile.paid .m-amt { color: var(--good-ink); }
.m-tile.unpaid { background: var(--bad-soft); border-color: transparent; color: var(--bad-ink); }
.m-tile.future { color: var(--muted); border-style: dashed; }
.m-tile.na { opacity: .45; background: var(--surface-2); border-style: dashed; }
.m-tile.now { box-shadow: 0 0 0 2px var(--primary); }
.hint-line { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.mini-hist { display: grid; gap: 4px; margin: 10px 0 8px; }
.mini-hist li { display: flex; align-items: flex-start; gap: 10px; padding: 8px 4px; font-size: 13.5px; }
.mini-hist li > div { flex: 1; min-width: 0; display: grid; line-height: 1.4; }
.mini-hist small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-hist time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.mh-ic { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; flex: none; background: var(--tone-soft); color: var(--tone-ink); }

/* ---------- history timeline ---------- */
.timeline { border-top: 1px solid var(--line); }
.tl-day { position: sticky; top: 68px; z-index: 2; padding: 9px 20px; font-size: 12.5px; font-weight: 800; color: var(--ink-2); background: var(--surface-2); border-bottom: 1px solid var(--line); }
.tl-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--line); transition: background .12s; }
.tl-item:hover { background: var(--hover); }
.tl-item.is-reverted { opacity: .62; }
.tl-ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--tone-soft); color: var(--tone-ink); }
.tl-main { min-width: 0; display: grid; gap: 5px; }
.tl-top { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.tl-verb { font-size: 14.5px; }
.tl-name { font-weight: 700; color: var(--primary-text); }
button.tl-name:hover { text-decoration: underline; }
.tl-name.gone { color: var(--ink-2); }
.tag { font-size: 11.5px; font-weight: 700; padding: 1px 9px; border-radius: 99px; background: var(--surface-3); color: var(--ink-2); }
.tl-detail { display: flex; flex-wrap: wrap; gap: 6px; }
.chg { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 3px 10px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--line); }
.chg em { font-style: normal; color: var(--muted); font-weight: 600; }
.chg s { color: var(--bad-ink); text-decoration-color: color-mix(in srgb, var(--bad-ink) 45%, transparent); }
.chg b { color: var(--good-ink); }
.chg .ic { color: var(--muted); }
.chg.plain { color: var(--ink-2); background: transparent; border-color: transparent; padding-inline: 0; margin-inline-end: 8px; }
.chg.more { color: var(--muted); }
.tl-time { display: flex; gap: 6px; align-items: center; font-size: 12.5px; color: var(--muted); }
.tl-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.reverted { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; color: var(--good-ink); padding: 0 6px; max-width: 220px; line-height: 1.3; }
.reverted.off { color: var(--muted); font-weight: 600; }
.snap { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.snap-head, .snap-row { display: grid; grid-template-columns: 110px 1fr 1fr; gap: 10px; padding: 9px 14px; align-items: start; }
.snap-head { background: var(--surface-2); color: var(--muted); font-size: 12.5px; border-bottom: 1px solid var(--line); }
.snap-row { border-bottom: 1px solid var(--line); font-size: 13.5px; }
.snap-row:last-child { border-bottom: 0; }
.snap-row > span:first-child { color: var(--muted); font-weight: 600; }
.snap-row.diff { background: var(--warn-soft); }
.snap-row.diff .snap-from { color: var(--bad-ink); }
.snap-row.diff .snap-to { color: var(--good-ink); font-weight: 700; }
.snap-title { margin: 16px 0 8px; }
.small-note { font-size: 12px; margin-top: 12px; }

/* ---------- settings ---------- */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 480px), 1fr)); gap: 14px; align-items: start; }
.set-card { padding: 20px; display: grid; gap: 16px; }
.set-card > header { display: flex; align-items: center; gap: 14px; }
.set-card h3 { font-size: 16px; font-weight: 800; }
.set-card header p { font-size: 13px; color: var(--muted); }
.set-ic { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; flex: none; background: var(--primary-soft); color: var(--primary-text); }
.fb-msg { padding: 10px 14px; border-radius: 12px; font-size: 13.5px; font-weight: 600; background: var(--warn-soft); color: var(--warn-ink); }
.fb-msg.bad { background: var(--bad-soft); color: var(--bad-ink); }
.howto { border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; background: var(--surface-2); font-size: 13.5px; }
.howto summary { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 700; list-style: none; }
.howto summary::-webkit-details-marker { display: none; }
.howto ol { margin: 12px 0; padding-inline-start: 20px; display: grid; gap: 6px; line-height: 1.7; }
.howto code { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; background: var(--surface-3); padding: 1px 6px; border-radius: 6px; }
.howto pre { margin: 0 0 12px; padding: 12px 14px; border-radius: 12px; background: #141413; color: #d9d8cf; font-size: 12px; line-height: 1.6; overflow-x: auto; }
.warn-line { display: flex; gap: 8px; align-items: flex-start; color: var(--warn-ink); font-weight: 600; line-height: 1.6; }
.sep { border: 0; border-top: 1px solid var(--line); margin: 0; }
.file-pill { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 13px; font-size: 13.5px; line-height: 1.55; }
.file-pill > span { flex: 1; }
.file-pill.ok { background: var(--good-soft); color: var(--good-ink); }
.file-pill.warn { background: var(--warn-soft); color: var(--warn-ink); }
.file-pill.bad { background: var(--bad-soft); color: var(--bad-ink); }
.file-pill.off { background: var(--surface-2); color: var(--ink-2); }
.radio-card { display: flex; gap: 12px; padding: 12px 14px; border: 1.5px solid var(--line-strong); border-radius: 14px; cursor: pointer; margin-bottom: 10px; align-items: flex-start; }
.radio-card:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.radio-card span { display: grid; line-height: 1.5; }
.radio-card small { color: var(--muted); font-size: 12.5px; }
.radio-card input { margin-top: 5px; accent-color: var(--primary); }

/* ---------- popover (month picker) ---------- */
.popover { position: fixed; z-index: 500; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 10px; width: 282px; animation: pop .18s var(--ease) both; }
.mp-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 2px 8px; }
.mp-head strong { font-size: 16px; font-variant-numeric: tabular-nums; }
.mp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.mp-m { height: 42px; border-radius: 11px; font-weight: 600; font-size: 13px; color: var(--ink-2); line-height: 1.2; padding: 0 4px; }
.mp-m:hover { background: var(--surface-3); color: var(--ink); }
.mp-m.cur { box-shadow: inset 0 0 0 1.5px var(--line-strong); }
.mp-m.sel { background: var(--primary); color: #fff; }
.mp-foot { display: flex; justify-content: center; padding-top: 8px; }

/* ---------- toast ---------- */
#toast-root { position: fixed; inset-inline: 0; bottom: 22px; z-index: 600; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding-inline: 16px; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; min-width: 280px; max-width: min(520px, 100%); padding: 11px 12px 11px 8px; border-radius: 14px; background: var(--ink); color: var(--surface); box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(14px) scale(.98); transition: opacity .22s, transform .26s var(--ease); }
.toast.in { opacity: 1; transform: none; }
.toast-ic { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; flex: none; background: var(--good); color: #fff; margin-inline-start: 4px; }
.toast-error .toast-ic { background: var(--bad); }
.toast-info .toast-ic { background: var(--primary); }
.toast-msg { flex: 1; font-size: 14px; font-weight: 600; line-height: 1.45; }
.toast-act { font-weight: 800; font-size: 13.5px; padding: 6px 12px; border-radius: 9px; background: rgba(255, 255, 255, .14); color: inherit; }
.toast-act:hover { background: rgba(255, 255, 255, .24); }
.toast-x { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; opacity: .6; }
.toast-x:hover { opacity: 1; background: rgba(255, 255, 255, .12); }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .insights { grid-template-columns: 1fr; }
}
@media (max-width: 1000px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: 280px; height: 100dvh; transform: translateX(100%); transition: transform .28s var(--ease); box-shadow: var(--shadow-lg); }
  .app.nav-open .sidebar { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 50; background: rgba(12, 12, 11, .5); opacity: 0; pointer-events: none; transition: opacity .25s; }
  .app.nav-open .scrim { opacity: 1; pointer-events: auto; }
  .only-mobile { display: inline-grid; }
  .only-mobile-flex { display: inline-flex; }
  .topbar, .view { padding-inline: 16px; }
  .topbar { height: 60px; }
  .chip-compact .sync-label { display: none; }
  .chip-compact { padding: 0 11px; }
  .btn-label { display: none; }
  #addBtn { padding: 0 14px; }
}
@media (max-width: 860px) {
  .filters { display: none; }
  .filters.open { display: flex; }
  .filters .seg { width: 100%; overflow-x: auto; }
  .f-segs { width: 100%; }
  .f-segs .seg { flex: 1; }
  .filters .select { flex: 1 1 140px; }
  .filters .select select, .input-date { width: 100%; min-width: 0; }
  .toolbar { padding-inline: 14px; }
  .filters, .chips { padding-inline: 14px; }
  .bulkbar { margin-inline: 14px; }

  .tbl { min-width: 0; display: block; }
  .tbl thead { display: none; }
  .tbl tbody { display: grid; gap: 10px; padding: 12px 14px; }
  .tbl tr { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; grid-template-areas: "sel name status" ". phone type" ". addr addr" ". last act"; gap: 6px 10px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
  .tbl tbody tr:hover { background: var(--surface); }
  .tbl tbody tr.sel { background: var(--primary-soft); }
  .tbl td { padding: 0; border: 0; }
  .tbl .c-sel { grid-area: sel; width: auto; padding: 0 !important; }
  .tbl .c-name { grid-area: name; min-width: 0; }
  .tbl .c-status { grid-area: status; text-align: end; }
  .tbl .c-phone { grid-area: phone; }
  .tbl .c-type { grid-area: type; justify-self: end; }
  .tbl .c-addr { grid-area: addr; max-width: none; font-size: 13.5px; }
  .tbl .c-last { grid-area: last; }
  .tbl .c-act { grid-area: act; width: auto; justify-self: end; }
  .row-actions { opacity: 1; }
  .st-sub { padding: 0; text-align: end; }
  .name-btn { max-width: none; }
  .pager { justify-content: center; }
  .pager-info { width: 100%; text-align: center; order: 3; }
  .tl-item { grid-template-columns: auto minmax(0, 1fr); }
  .tl-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .tl-day { top: 60px; }
}
@media (max-width: 640px) {
  .grid-2, .type-cards { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 14px; }
  .stat-value { font-size: 28px; }
  .stat-ic { width: 34px; height: 34px; inset-block-start: 12px; inset-inline-end: 12px; }
  .stat-label { padding-inline-end: 40px; font-size: 12.5px; }
  .page-h { font-size: 21px; }
  .head-actions { width: 100%; }
  .month-nav { flex: 1 1 100%; }
  .head-actions .btn { flex: 1; }
  .month-btn { flex: 1; min-width: 0; }
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal, .modal-sm, .modal-lg, .modal-xl { width: 100%; max-height: 92dvh; border-radius: 22px 22px 0 0; }
  .is-drawer .modal { width: 100%; height: 94dvh; border-radius: 22px 22px 0 0; align-self: flex-end; }
  .modal-backdrop.is-drawer { align-items: flex-end; }
  .m-grid { grid-template-columns: repeat(3, 1fr); }
  .snap-head, .snap-row { grid-template-columns: 84px 1fr 1fr; padding-inline: 10px; }
  .toast { min-width: 0; width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
@media print {
  .sidebar, .topbar, .toolbar, .filters, .bulkbar, .pager, .row-actions, .c-sel, .chart-card, .late-card { display: none !important; }
  .app { display: block; }
  body { background: #fff; }
}

/* ==========================================================================
   Login page (gate)
   ========================================================================== */
.gate { position: fixed; inset: 0; z-index: 800; display: none; place-items: center; padding: 20px; overflow-y: auto; background: var(--bg); }
html.gating .gate { display: grid; }
html.gating .app, html.gating #modal-root { visibility: hidden; }
html.gating body { overflow: hidden; }
.gate-blobs { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }
.gate-blobs i { position: absolute; width: 520px; height: 520px; border-radius: 50%; filter: blur(90px); opacity: .55; }
.gate-blobs i:first-child { background: #f7b81f; inset-block-start: -180px; inset-inline-start: -120px; opacity: .35; }
.gate-blobs i:last-child { background: var(--primary); inset-block-end: -200px; inset-inline-end: -140px; opacity: .3; }
.gate-card {
  position: relative; width: min(420px, 100%); padding: 30px 28px 26px; border-radius: 24px; background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow-lg); animation: pop .4s var(--ease) both;
}
.gate-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.gate-brand strong { display: block; font-size: 17px; font-weight: 800; line-height: 1.25; }
.gate-brand small { color: var(--muted); font-size: 12.5px; }
.gate-head h2 { font-size: 24px; font-weight: 800; letter-spacing: -.3px; }
.gate-head p { color: var(--ink-2); font-size: 14px; margin: 4px 0 18px; line-height: 1.7; }
.gate-form { display: grid; gap: 14px; }
.gate-loading { display: grid; justify-items: center; gap: 14px; padding: 34px 0 18px; color: var(--ink-2); }
.input-icon { position: relative; display: flex; align-items: center; }
.input-icon > span[data-icon] { position: absolute; inset-inline-start: 13px; color: var(--muted); pointer-events: none; display: grid; }
.input-icon .input { padding-inline-start: 42px; padding-inline-end: 42px; direction: ltr; text-align: left; height: 48px; }
.input-icon .input::placeholder { color: var(--muted); }
.eye { cursor: pointer; position: absolute; inset-inline-end: 6px; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: var(--muted); }
.eye:hover { background: var(--surface-3); color: var(--ink); }
.btn-block { width: 100%; height: 48px; font-size: 15.5px; }
.link-btn.center { justify-content: center; width: 100%; }
.gate-msg { padding: 10px 14px; border-radius: 12px; font-size: 13.5px; font-weight: 600; line-height: 1.6; background: var(--surface-2); color: var(--ink-2); }
.gate-msg.bad { background: var(--bad-soft); color: var(--bad-ink); }
.gate-msg.ok { background: var(--good-soft); color: var(--good-ink); }
.gate-foot { text-align: center; color: var(--muted); font-size: 12.5px; line-height: 1.7; margin-top: 2px; }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--line-strong); border-top-color: var(--primary); animation: spin .8s linear infinite; display: inline-block; }
.spinner.sm { width: 16px; height: 16px; border-width: 2.5px; border-color: rgba(255, 255, 255, .45); border-top-color: #fff; }
.spinner[hidden] { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* signed-in user card (sidebar) */
.user-card { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 12px; background: var(--sidebar-2); border: 1px solid rgba(255, 255, 255, .06); }
.user-info { display: grid; min-width: 0; flex: 1; line-height: 1.3; }
.user-info b { color: var(--sidebar-strong); font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: start; }
.user-info small { color: var(--sidebar-ink); font-size: 11.5px; }
.user-card .icon-btn { color: var(--sidebar-ink); width: 34px; height: 34px; }
.user-card .icon-btn:hover { background: rgba(255, 255, 255, .08); color: var(--sidebar-strong); }

/* ==========================================================================
   Excel import dialog
   ========================================================================== */
.modal-xl { width: min(960px, 100%); }
.drop { display: grid; justify-items: center; gap: 10px; padding: 38px 20px; border: 2px dashed var(--line-strong); border-radius: 18px; background: var(--surface-2); text-align: center; transition: border-color .15s, background .15s; outline: none; }
.drop:hover, .drop:focus-visible, .drop.over { border-color: var(--primary); background: var(--primary-soft); }
.drop.busy { opacity: .6; pointer-events: none; }
.drop-ic { width: 60px; height: 60px; border-radius: 18px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-text); }
.drop b { font-size: 16px; }
.imp-help { margin-top: 18px; display: grid; gap: 8px; }
.imp-help h4, .imp-h { font-size: 14.5px; font-weight: 800; margin: 0; }
.imp-help p { color: var(--ink-2); font-size: 13.5px; line-height: 1.75; }
.imp-cols { display: flex; flex-wrap: wrap; gap: 8px; }
.imp-cols .chip { cursor: default; }
.chip.req { background: var(--warn-soft); color: var(--warn-ink); }
.imp-file { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.imp-file > div { display: grid; line-height: 1.35; flex: 1; min-width: 140px; }
.imp-file small { color: var(--muted); font-size: 12.5px; }
.imp-file-ic { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--good-soft); color: var(--good-ink); }
.imp-file .select select { min-width: 160px; }
.check-row { display: flex; align-items: center; gap: 10px; margin: 14px 2px 4px; cursor: pointer; font-weight: 600; font-size: 14px; }
.check-row input { width: 18px; height: 18px; accent-color: var(--primary); }
.imp-h { margin: 16px 0 10px; }
.imp-map { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 12px; }
.imp-field { display: grid; gap: 5px; font-size: 13px; font-weight: 700; }
.imp-field b { color: var(--bad); }
.imp-field select { height: 42px; padding: 0 12px; padding-inline-start: 34px; border: 1px solid var(--line-strong); border-radius: 11px; background-color: var(--surface); width: 100%; appearance: none; -webkit-appearance: none; 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='%23898781' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left 10px center; font-weight: 500; }
.imp-field select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.imp-field small { color: var(--muted); font-size: 12px; font-weight: 500; min-height: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.imp-opts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: start; }
.imp-opts .seg { width: 100%; }
.imp-opts .seg-btn { flex: 1; justify-content: center; }
.imp-stats { display: flex; flex-wrap: wrap; gap: 8px; }
.imp-stat { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 99px; font-size: 13px; font-weight: 600; background: var(--surface-3); color: var(--ink-2); }
.imp-stat b { font-size: 15px; font-variant-numeric: tabular-nums; }
.imp-stat.good { background: var(--good-soft); color: var(--good-ink); }
.imp-stat.warn { background: var(--warn-soft); color: var(--warn-ink); }
.imp-stat.bad { background: var(--bad-soft); color: var(--bad-ink); }
.imp-warns { display: grid; gap: 4px; margin: 10px 0 0; }
.imp-warns li { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--warn-ink); font-weight: 600; }
.imp-table-wrap { margin-top: 12px; overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
.imp-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 640px; }
.imp-table th { text-align: start; padding: 9px 12px; font-size: 12px; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.imp-table td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.imp-table tr:last-child td { border-bottom: 0; }
.imp-table tr.st-invalid td, .imp-table tr.st-dupfile td { opacity: .62; }
.pay-ok { color: var(--good-ink); font-weight: 600; }
.badge-st { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; white-space: nowrap; background: var(--surface-3); color: var(--ink-2); }
.badge-st.good { background: var(--good-soft); color: var(--good-ink); }
.badge-st.warn { background: var(--warn-soft); color: var(--warn-ink); }
.badge-st.bad { background: var(--bad-soft); color: var(--bad-ink); }
@media (max-width: 860px) {
  .imp-map, .imp-opts { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .imp-map, .imp-opts { grid-template-columns: 1fr; }
  .gate-card { padding: 24px 20px 20px; }
}

/* ==========================================================================
   Roles, users page, dashboard columns
   ========================================================================== */
.role-badge { display: inline-flex; align-items: center; padding: 3px 12px; border-radius: 99px; font-size: 12.5px; font-weight: 800; background: var(--tone-soft, var(--surface-3)); color: var(--tone-ink, var(--ink-2)); white-space: nowrap; }
.role-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-bottom: 14px; }
.role-card { padding: 16px 18px; display: grid; gap: 8px; border-top: 3px solid var(--tone, var(--line-strong)); }
.role-card header { display: flex; align-items: center; justify-content: space-between; }
.role-card header small { color: var(--muted); font-weight: 600; font-size: 12px; }
.role-card p { color: var(--ink-2); font-size: 13.5px; line-height: 1.7; }

.utbl { width: 100%; border-collapse: collapse; min-width: 680px; }
.utbl th { text-align: start; font-size: 12.5px; font-weight: 700; color: var(--muted); padding: 11px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.utbl td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.utbl tbody tr:last-child td { border-bottom: 0; }
.utbl tbody tr:hover { background: var(--hover); }
.u-id { display: flex; align-items: center; gap: 12px; min-width: 0; }
.u-id > div { display: grid; line-height: 1.35; min-width: 0; }
.u-id small { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; text-align: start; }
.me-tag { font-style: normal; font-size: 11px; font-weight: 700; background: var(--primary-soft); color: var(--primary-text); padding: 1px 8px; border-radius: 99px; margin-inline-start: 6px; }
.role-select { height: 38px; padding: 0 12px; padding-inline-start: 32px; border: 1px solid var(--line-strong); border-radius: 10px; background-color: var(--surface); appearance: none; -webkit-appearance: none; cursor: pointer; font-weight: 700; min-width: 130px;
  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='%23898781' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left 10px center; }
.role-select:disabled { opacity: .6; cursor: not-allowed; }
.role-select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.switch-row.mini { padding: 4px 10px 4px 12px; height: 38px; width: fit-content; }
.u-date { color: var(--ink-2); white-space: nowrap; font-size: 13.5px; }
.u-act { width: 1%; white-space: nowrap; }
.perm-card { margin-top: 14px; }
.perm-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 520px; }
.perm-table th { text-align: center; padding: 10px 14px; font-size: 12.5px; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--line); }
.perm-table th:first-child, .perm-table td:first-child { text-align: start; }
.perm-table td { text-align: center; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.perm-table tr:last-child td { border-bottom: 0; }
.perm-yes { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--good-soft); color: var(--good-ink); }
.perm-no { color: var(--line-strong); font-weight: 800; }

.pass-row { display: flex; gap: 8px; align-items: stretch; }
.pass-row .input-icon { flex: 1; }
.pass-row .btn { height: 48px; }
.role-pick { display: grid; gap: 8px; }
.role-opt { position: relative; cursor: pointer; }
.role-opt input { position: absolute; opacity: 0; inset: 0; }
.role-opt-body { display: grid; gap: 2px; padding: 11px 14px; border: 1.5px solid var(--line-strong); border-radius: 13px; background: var(--surface); transition: border-color .15s, background .15s; }
.role-opt-body b { font-size: 14.5px; }
.role-opt-body small { color: var(--muted); font-size: 12.5px; line-height: 1.6; }
.role-opt input:checked + .role-opt-body { border-color: var(--tone, var(--primary)); background: var(--tone-soft, var(--primary-soft)); }
.role-opt input:focus-visible + .role-opt-body { outline: 2px solid var(--primary); outline-offset: 2px; }
.note-ok { background: var(--good-soft); color: var(--good-ink); }
.cred { display: grid; gap: 6px; margin-top: 12px; padding: 12px 14px; border-radius: 13px; background: var(--surface-2); border: 1px solid var(--line); }
.cred > div { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; font-size: 14px; }
.cred span { color: var(--muted); }
.cred b { font-family: ui-monospace, Consolas, monospace; font-size: 14px; word-break: break-all; }
.steps { margin: 4px 0 12px; padding-inline-start: 20px; display: grid; gap: 4px; color: var(--ink-2); font-size: 13.5px; line-height: 1.7; }
.rules-box { font-size: 12px; line-height: 1.55; min-height: 220px; }
.modal-lg .rules-box { min-height: 300px; }

/* dashboard columns: manager dialog */
.cm { display: grid; gap: 14px; }
.cm-list { display: grid; gap: 10px; }
.cm-row { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); }
.cm-main { display: grid; grid-template-columns: 1fr 170px; gap: 10px; }
.cm-row .input { background: var(--surface); height: 42px; }
.cm-tools { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.cm-btns { display: inline-flex; gap: 2px; }
.cm-empty { display: grid; justify-items: center; gap: 4px; padding: 26px 10px; text-align: center; color: var(--muted); border: 1.5px dashed var(--line-strong); border-radius: 14px; }
.cm-empty b { color: var(--ink); }
.check-row.sm { margin: 0; font-size: 13.5px; font-weight: 600; }
.icon-btn:disabled { opacity: .3; pointer-events: none; }

/* custom columns in the table / form / drawer */
.f-cf { display: contents; }
.c-cx { color: var(--ink-2); white-space: nowrap; font-size: 13.5px; }
.c-cx .yes { display: inline-flex; align-items: center; gap: 4px; color: var(--good-ink); font-weight: 700; }
.cx-grid { margin-top: -2px; }
.cx-field .switch-row { height: 44px; }
.d-extra { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.d-kv { display: grid; gap: 1px; padding: 9px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); min-width: 0; }
.d-kv span { color: var(--muted); font-size: 12px; font-weight: 600; }
.d-kv b { font-size: 14px; overflow-wrap: anywhere; }
.imp-cx { max-width: 220px; }
.imp-cx .chg { display: inline-flex; margin: 0 0 2px; }

/* blocked-account page (inside the login card) */
.gate-blocked { display: grid; gap: 12px; justify-items: stretch; text-align: center; }
.gb-icon { width: 60px; height: 60px; border-radius: 18px; display: grid; place-items: center; margin: 0 auto 2px; background: var(--warn-soft); color: var(--warn-ink); }
.gate-blocked h2 { font-size: 21px; font-weight: 800; }
.gate-blocked > p { color: var(--ink-2); font-size: 14px; line-height: 1.75; }
.gb-who { color: var(--muted) !important; font-size: 13px !important; }
.gb-rules { display: grid; gap: 8px; text-align: start; }
.gb-rules .btn { justify-self: start; }
.gb-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 4px; }
.gate-card:has(.gate-blocked:not([hidden]) .gb-rules:not([hidden])) { width: min(560px, 100%); }

@media (max-width: 860px) {
  .tbl .c-cx { grid-column: 2 / -1; font-size: 13px; white-space: normal; }
  .tbl .c-cx::before { content: attr(data-label) ': '; color: var(--muted); font-weight: 600; }
  .d-extra { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .cm-main { grid-template-columns: 1fr; }
  .pass-row { flex-direction: column; }
  .pass-row .btn { height: 42px; }
}

/* import: columns of the file suggested as new dashboard columns */
.imp-new { display: grid; gap: 8px; }
.imp-newcol { display: grid; grid-template-columns: minmax(150px, 1.1fr) minmax(150px, 1.2fr) 150px; gap: 8px 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-2); transition: opacity .15s; }
.imp-newcol .input { height: 40px; background: var(--surface); }
.imp-newcol small { grid-column: 1 / -1; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.imp-newcol.off { opacity: .55; }
.imp-newcol .check-row { margin: 0; font-weight: 700; }
@media (max-width: 640px) { .imp-newcol { grid-template-columns: 1fr; } }

/* big-list loading states */
.boot-loading { display: grid; justify-items: center; gap: 12px; padding: 90px 20px; color: var(--ink-2); }
.sync-banner { position: relative; display: flex; align-items: center; gap: 10px; margin-bottom: 16px; border-radius: var(--radius); padding: 12px 20px; background: var(--primary-soft); color: var(--primary-text); font-size: 13.5px; font-weight: 600; overflow: hidden; }
.sync-banner b { font-variant-numeric: tabular-nums; }
.sync-banner .indeterminate { position: absolute; inset-inline: 0; bottom: 0; height: 3px; background: linear-gradient(90deg, transparent, var(--primary), transparent); background-size: 40% 100%; background-repeat: no-repeat; animation: slide-bar 1.2s linear infinite; }
@keyframes slide-bar { from { background-position: 140% 0; } to { background-position: -40% 0; } }
.spinner.sm.dark { border-color: color-mix(in srgb, var(--primary) 30%, transparent); border-top-color: var(--primary); }
.hist-more { display: grid; justify-items: center; gap: 6px; padding: 14px 20px 18px; border-top: 1px solid var(--line); }
.hist-more small { font-size: 12.5px; }
.hist-more[hidden] { display: none; }
.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 8px; }
.kv-grid .kv { display: grid; gap: 1px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.kv-grid .kv span { color: var(--muted); font-size: 12px; font-weight: 600; }
.kv-grid .kv b { font-size: 15px; font-variant-numeric: tabular-nums; }

/* ==========================================================================
   Features: switches, smart billing, collector mode, WhatsApp
   ========================================================================== */
.btn-good { background: var(--good); color: #fff; box-shadow: 0 4px 14px color-mix(in srgb, var(--good) 32%, transparent); }
.btn-good:hover:not(:disabled) { filter: brightness(.93); }
.insights.one { grid-template-columns: minmax(0, 1fr); }
.insights[hidden], .stats[hidden], .f-selects[hidden], .chart-card[hidden], .late-card[hidden] { display: none; }
.st-sub.due { color: var(--primary-text); font-weight: 600; }
.st-sub.need { color: var(--warn-ink); font-weight: 600; }
.nav-item[hidden] { display: none; }

/* ---------- settings: feature switches / pricing / WhatsApp texts ---------- */
.set-wide { grid-column: 1 / -1; }
.feat-count { margin-inline-start: auto; font-size: 12.5px; font-weight: 700; padding: 4px 12px; border-radius: 99px; background: var(--good-soft); color: var(--good-ink); white-space: nowrap; }
.feat-count.has { background: var(--warn-soft); color: var(--warn-ink); }
.feat-group { display: grid; gap: 10px; }
.feat-group h4 { font-size: 14px; font-weight: 800; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.feat-group h4 small { color: var(--muted); font-weight: 500; font-size: 12.5px; }
.feat-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 8px; }
.feat-row { height: auto; align-items: flex-start; }
.feat-row .switch { margin-top: 2px; }
.feat-row .switch-label b { display: flex; align-items: center; gap: 6px; }
.feat-row:not(.on) { background: var(--surface-2); }
.feat-row:not(.on) .switch-label b { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }
.pk-rows { display: grid; gap: 8px; margin-bottom: 8px; }
.pk-row { display: grid; grid-template-columns: 1fr minmax(110px, 170px) auto; gap: 8px; align-items: center; }
.wa-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.wa-ph { cursor: pointer; direction: ltr; font-size: 12.5px; }
.wa-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 14px; }
.wa-text { line-height: 1.75; resize: vertical; min-height: 110px; }
.wa-prev, .rq-msg { white-space: pre-wrap; margin-top: 8px; padding: 11px 14px; border-radius: 14px 14px 14px 4px; background: #dcf8c6; color: #0b2a12; font-size: 13.5px; line-height: 1.75; }
:root[data-theme="dark"] .wa-prev, :root[data-theme="dark"] .rq-msg { background: #1f3a2a; color: #e6f5e8; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .wa-prev, :root:not([data-theme="light"]) .rq-msg { background: #1f3a2a; color: #e6f5e8; } }

/* ---------- subscriber drawer ---------- */
.d-share { display: flex; gap: 10px; flex-wrap: wrap; }
.d-share .btn { flex: 1; min-width: 150px; }
.d-bill { display: grid; gap: 10px; padding: 14px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line); }
.d-bill-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.d-bill-head h4 { font-size: 14px; font-weight: 800; }
.bill-amount { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.bill-amount span { color: var(--muted); font-weight: 600; font-size: 13px; }
.bill-amount b { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.bill-amount.none b { color: var(--muted); }
.bill-note { margin: 0; color: var(--muted); font-size: 13px; }
.bill-table { font-size: 12.5px; }

/* ---------- reading dialog ---------- */
.reading { display: grid; gap: 14px; }
.reading-ctx { display: flex; align-items: center; gap: 12px; }
.reading-ctx small { display: block; color: var(--muted); }
.reading-prev { display: flex; align-items: baseline; gap: 10px; padding: 10px 14px; border-radius: 12px; background: var(--surface-2); color: var(--muted); font-weight: 600; }
.reading-prev b { color: var(--ink); font-size: 20px; font-variant-numeric: tabular-nums; }
.big-input { font-size: 24px; font-weight: 800; height: 56px; text-align: center; }
.reading-calc { padding: 12px 14px; border-radius: 12px; background: var(--surface-2); display: flex; gap: 14px; align-items: center; justify-content: space-between; min-height: 50px; font-weight: 700; }
.reading-calc.good { background: var(--good-soft); color: var(--good-ink); }
.reading-calc.bad { background: var(--bad-soft); color: var(--bad-ink); justify-content: flex-start; }
.reading-calc .rc-amt b { font-size: 20px; }
.reading-calc small { font-weight: 500; color: var(--muted); }

/* ---------- reminder queue ---------- */
.rq { display: grid; gap: 14px; }
.rq-top { display: grid; gap: 8px; font-size: 14px; }
.rq-next { border: 1px solid var(--line); border-radius: 16px; padding: 12px; background: var(--surface-2); }
.rq-next-h { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rq-msg { font-family: inherit; margin: 10px 0 0; }
.rq-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 36vh; overflow: auto; }
.rq-list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; border: 1px solid var(--line); }
.rq-list li.done { opacity: .55; }
.rq-list li.recent { opacity: .75; }
.rq-who { flex: 1; min-width: 0; display: grid; }
.rq-who b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rq-who small { color: var(--muted); font-size: 12px; }
.rq-ok { color: var(--good-ink); display: inline-flex; }
.tone { font-size: 11.5px; font-weight: 700; padding: 2px 9px; border-radius: 99px; white-space: nowrap; background: var(--surface-3); }
.tone.tone-good { background: var(--good-soft); color: var(--good-ink); }
.tone.tone-warn { background: var(--warn-soft); color: var(--warn-ink); }
.tone.tone-bad { background: var(--bad-soft); color: var(--bad-ink); }

/* ---------- receipt picture ---------- */
.doc { display: grid; justify-items: center; }
.doc-wait { padding: 70px; }
.doc-img { max-width: 100%; max-height: 62vh; border-radius: 18px; box-shadow: var(--shadow-md); }

/* ---------- collector mode ---------- */
.round { max-width: 780px; margin: 0 auto; display: grid; gap: 14px; }
.round-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.round-head .month-nav { flex: 1 1 auto; justify-content: space-between; }
.cashbox { border-radius: 20px; padding: 14px 16px; background: linear-gradient(145deg, #f7b81f, #e08a00); color: #1b1300; box-shadow: 0 10px 28px rgba(237, 161, 0, .28); }
.cash-main { display: flex; align-items: center; gap: 14px; }
.cash-ic { width: 46px; height: 46px; border-radius: 14px; background: rgba(27, 19, 0, .12); display: grid; place-items: center; flex: none; }
.cash-main small { display: block; font-weight: 700; opacity: .75; }
.cash-main b { font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.2; }
.cash-n { margin-inline-start: auto; text-align: center; }
.cash-n b { font-size: 24px; display: block; }
.cash-mine { margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(27, 19, 0, .18); font-size: 13px; font-weight: 600; }
.round-tabs { display: flex; }
.round-tabs .seg-btn { flex: 1; justify-content: center; height: 44px; font-size: 15px; }
.round-tools { display: grid; gap: 10px; }
.round-tools .seg { display: flex; }
.round-tools .seg .seg-btn { flex: 1; justify-content: center; }
@media (min-width: 700px) { .round-tools { grid-template-columns: 1fr auto auto; align-items: end; } }
.rlist { display: grid; gap: 10px; }
.rg { display: flex; align-items: center; gap: 8px; margin: 12px 2px 0; padding: 6px 0; font-size: 14px; font-weight: 800; color: var(--ink-2); position: sticky; top: 60px; z-index: 2; background: var(--bg); }
.rg em { margin-inline-start: auto; font-style: normal; font-size: 12px; color: var(--muted); font-weight: 700; }
.rc { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 14px; border-radius: 18px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.rc.is-paid, .rc.rd.has { background: var(--good-soft); border-color: transparent; }
.rc-info { display: grid; gap: 4px; min-width: 0; align-content: start; }
.rc-name { font-size: 16px; }
.rc-addr { color: var(--muted); font-size: 13px; }
.rc-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.rc-chip { font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 99px; background: var(--surface-3); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.rc-chip.soft { background: var(--primary-soft); color: var(--primary-text); }
.rc-contact { display: flex; gap: 6px; margin-top: 4px; }
.rc-act { display: grid; gap: 6px; align-content: center; min-width: 142px; }
.rc-pay { height: 54px; font-size: 16px; font-weight: 800; border-radius: 16px; }
.rc-sub { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.rc-paid { display: flex; align-items: center; gap: 8px; justify-content: center; color: var(--good-ink); font-weight: 800; font-size: 16px; }
.rd-act { min-width: 200px; }
.rd-in { height: 50px; font-size: 21px; font-weight: 800; text-align: center; }
.rd-in.bad { border-color: var(--bad); }
.rd-calc { font-size: 13px; font-weight: 700; color: var(--good-ink); display: flex; gap: 6px; align-items: center; justify-content: center; min-height: 20px; }
.rd-calc .bad, .bad { color: var(--bad-ink); }
.rd-more { justify-self: center; }
@media (max-width: 560px) { .rc { grid-template-columns: 1fr; } .rc-act { min-width: 0; } .rg { top: 56px; } }

.sum-top { display: grid; gap: 4px; justify-items: center; text-align: center; padding: 16px; border-radius: 16px; background: var(--surface-2); }
.sum-top span { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 700; }
.sum-top b { font-size: 34px; font-weight: 800; }
.sum-top small { color: var(--muted); }
.sum-by, .sum-list { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 6px; }
.sum-by li, .sum-list li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 12px; background: var(--surface-2); }
.sum-by li span, .sum-list li span { flex: 1; min-width: 0; display: grid; }
.sum-by li em { font-style: normal; color: var(--muted); font-size: 12.5px; }
.sum-list time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.sum-list small { color: var(--muted); font-size: 12px; }

/* ==========================================================================
   Responsive hardening (phones 320px -> ultrawide): nothing may force the page wider than the screen,
   touch targets are finger sized, dialogs fit, cards stack cleanly.
   ========================================================================== */
@supports (overflow-x: clip) { html { overflow-x: clip; } }
:root { --pad-x: 28px; }
@media (max-width: 1000px) { :root { --pad-x: 16px; } }
@media (max-width: 380px) { :root { --pad-x: 12px; } }     /* safety net: the page itself never scrolls sideways */
.main, .view, .view-inner, .card, .set-card, .list-card, .toolbar, .filters, .insights > *, .stats > *, .settings-grid > * { min-width: 0; }
.set-card { grid-template-columns: minmax(0, 1fr); }
.set-card > * { min-width: 0; }
.input, textarea.input, select.input { max-width: 100%; }
.form-actions { flex-wrap: wrap; }
.sidebar { overflow-y: auto; overscroll-behavior: contain; }
.stat-sub, .stat-label, .late-main, .nm { overflow-wrap: anywhere; }
.col { min-width: 0; }
.col-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.sort-ind { font-size: 11px; }
.rg { top: 68px; }
.gate { place-items: normal; justify-items: center; }
.gate-card { margin-block: auto; }
.gate { overflow-x: hidden; }

/* notches / rounded corners (landscape phones): keep content off the cut-outs */
.topbar, .view { padding-inline: max(var(--pad-x, 28px), env(safe-area-inset-left), env(safe-area-inset-right)); }
#toast-root { padding-bottom: env(safe-area-inset-bottom); }
.modal-foot { padding-bottom: max(14px, env(safe-area-inset-bottom)); }

/* ---------- users page ---------- */
.perm-card .table-wrap, #uWrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 760px) {
  #uWrap { overflow: visible; }
  .utbl, .utbl tbody { display: block; width: 100%; }
  .utbl thead { display: none; }
  .utbl tbody { display: grid; gap: 10px; padding: 12px 14px; }
  .utbl tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "id id" "role active" "date act"; gap: 10px 12px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
  .utbl td { padding: 0; border: 0; min-width: 0; }
  .utbl td:nth-child(1) { grid-area: id; }
  .utbl td:nth-child(2) { grid-area: role; }
  .utbl td:nth-child(3) { grid-area: active; justify-self: end; }
  .utbl td:nth-child(4) { grid-area: date; }
  .utbl td:nth-child(5) { grid-area: act; width: auto; justify-self: end; }
  .utbl .role-select { width: 100%; }
  .utbl tbody tr:hover { background: var(--surface); }
  .role-cards { grid-template-columns: 1fr; }
}

/* ---------- tablets and phones ---------- */
@media (max-width: 860px) {
  #tableWrap { overflow: visible; }
  /* the action icons (view / reading / reminder / receipt / edit / delete) get their own row, right under the details */
  .tbl tr { grid-template-areas: "sel name status" ". phone type" ". addr addr" ". last last" ". act act"; }
  .tbl .c-phone a { white-space: nowrap; }
  .tbl .c-act { width: 100%; justify-self: stretch; }
  .tbl .row-actions { width: 100%; justify-content: flex-end; flex-wrap: wrap; }
}
@media (max-width: 520px) {
  /* narrow phones: name on top, status + type under it, so nothing is squeezed into a sliver */
  .tbl tr { grid-template-columns: 24px minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "sel name name" ". status type" ". phone phone" ". addr addr" ". last last" ". act act"; }
  .tbl .c-status { justify-self: start; text-align: start; }
  .tbl .st-sub { text-align: start; padding-inline-start: 6px; }
  .tbl .c-type { justify-self: end; }
  .tbl tbody { padding-inline: 10px; }
  .table-wrap, .list-card { border-radius: 16px; }
  .toolbar { padding: 12px; }
  .filters, .chips { padding-inline: 12px; }
  .bulkbar { margin-inline: 12px; }
  .bulk-actions { width: 100%; display: flex; flex-wrap: wrap; gap: 8px; }
  .bulk-actions .btn { flex: 1 1 auto; }
  .pager { padding-inline: 12px; }
  .pager-nav { flex-wrap: wrap; justify-content: center; }
  .head-actions .btn { height: 40px; padding-inline: 10px; font-size: 13.5px; }
  .d-share .btn { min-width: 0; }
  .chart { gap: 6px; }
  .y-axis { width: 24px; }
  .col-label { font-size: 11px; }
  .col .val { inset-inline: -6px; font-size: 11.5px; }
  .pk-row { grid-template-columns: minmax(0, 1fr) auto; }
  .pk-row > :first-child { grid-column: 1 / -1; }
  .rc { padding: 12px; }
  .cash-main b { font-size: 24px; }
  .round-tabs .seg-btn { padding-inline: 8px; }
}
@media (max-width: 380px) {
  .topbar { gap: 6px; }
  .stats { gap: 8px; }
  .stat { padding: 12px; }
  .stat-value { font-size: 25px; }
  .stat-label { font-size: 12px; padding-inline-end: 34px; }
  .stat-ic { width: 30px; height: 30px; inset-block-start: 10px; inset-inline-end: 10px; }
  .page-h { font-size: 19px; }
  .seg-btn { padding-inline: 9px; font-size: 13px; }
  .gate { padding: 12px; }
  .gate-card { padding: 22px 16px 18px; }
}

/* ---------- dialogs ---------- */
@media (max-width: 640px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .modal-foot { flex-wrap: wrap; gap: 8px; padding-inline: 14px; }
  .modal-foot .btn { flex: 1 1 calc(50% - 8px); min-width: 0; padding-inline: 10px; }
  .modal-foot .btn-primary, .modal-foot .btn-danger { order: -1; flex-basis: 100%; }
  .modal-body { padding-inline: 16px; }
  .modal-head { padding-inline: 16px; }
  .m-grid { gap: 6px; }
}
/* short screens (phones on their side): dialogs use the whole height, headers shrink */
@media (max-height: 520px) {
  .topbar { height: 52px; }
  .modal, .modal-sm, .modal-lg, .modal-xl { max-height: 96dvh; }
  .is-drawer .modal { height: 96dvh; }
  .modal-head { padding-block: 10px; }
  .modal-foot { padding-block: 8px; }
  .gate-card { padding-block: 16px; }
  .doc-img { max-height: 48vh; }
  .rg, .tl-day { top: 52px; }
}

/* ---------- touch: finger sized targets, no zoom-on-focus ---------- */
@media (pointer: coarse), (max-width: 1000px) {
  .btn-sm { height: 38px; }
  .icon-btn { width: 40px; height: 40px; }
  .status-btn { height: 36px; }
  .link-btn { min-height: 38px; padding-inline: 4px; }
  .tl-name { display: inline-flex; align-items: center; min-height: 38px; }
  .chip, .chip-clear { min-height: 36px; }
  .c-phone a { display: inline-flex; align-items: center; min-height: 36px; }
  .name-btn { min-height: 44px; }
  .seg-btn { height: 38px; }
  .nav-item { min-height: 46px; }
}
@media (max-width: 1000px) {
  .input, .search input, .select select, .input-date, .role-select, .pager-size select, .rd-in, .big-input { font-size: 16px; }
  .rg { top: 60px; }
  .tl-day { top: 60px; }
}
@media (max-width: 1000px) and (max-height: 520px) { .rg, .tl-day { top: 52px; } }

/* ---------- very large screens ---------- */
@media (min-width: 1800px) {
  body { font-size: 16px; }
  .view { max-width: 1680px; }
}
@media (min-width: 2200px) {
  .view { max-width: 1900px; }
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* topbar on the narrowest phones: the title may be cut with an ellipsis instead of pushing the buttons off the screen */
.page-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 380px) {
  .page-title { font-size: 17px; }
  .topbar .icon-btn { width: 36px; }
  .topbar #addBtn { padding: 0 10px; }
  .chip-compact { padding: 0 9px; }
}
/* long button labels wrap instead of overflowing their box */
.d-share .btn { white-space: normal; height: auto; min-height: 42px; padding-block: 8px; line-height: 1.35; }
@media (max-width: 520px) {
  .btn { max-width: 100%; }
  .form-actions .btn, .modal-foot .btn, .gb-actions .btn, .head-actions .btn { white-space: normal; height: auto; min-height: 42px; padding-block: 8px; line-height: 1.35; text-align: center; }
}

.chip-compact { min-width: 38px; justify-content: center; }

@media (max-width: 640px) { .modal-foot .btn:not(.btn-primary):not(.btn-danger) { flex: 1 1 0; min-width: 72px; } }

/* ---------- tables: contain absolutely positioned bits, cards up to tablet landscape ---------- */
/* a visually-hidden heading inside a scrolling table used to escape the scroller and widen the whole page */
.table-wrap { position: relative; }
.seg-btn { white-space: nowrap; }

@media (max-width: 1100px) {
  #tableWrap { overflow: visible; }
  .tbl { min-width: 0; display: block; }
  .tbl thead { display: none; }
  .tbl tbody { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 12px 14px; }
  .tbl tr { display: grid; grid-template-columns: 24px minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "sel name name" ". status type" ". phone phone" ". addr addr" ". last last" ". act act"; gap: 6px 10px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
  .tbl tbody tr:hover { background: var(--surface); }
  .tbl tbody tr.sel { background: var(--primary-soft); }
  .tbl td { padding: 0; border: 0; }
  .tbl .c-sel { grid-area: sel; width: auto; padding: 0 !important; }
  .tbl .c-name { grid-area: name; min-width: 0; }
  .tbl .c-status { grid-area: status; justify-self: start; text-align: start; }
  .tbl .c-phone { grid-area: phone; }
  .tbl .c-type { grid-area: type; justify-self: end; }
  .tbl .c-addr { grid-area: addr; max-width: none; font-size: 13.5px; }
  .tbl .c-last { grid-area: last; }
  .tbl .c-act { grid-area: act; width: 100%; justify-self: stretch; }
  .tbl .c-cx { grid-column: 2 / -1; font-size: 13px; white-space: normal; }
  .tbl .c-cx::before { content: attr(data-label) ': '; color: var(--muted); font-weight: 600; }
  .tbl .row-actions { width: 100%; justify-content: flex-end; flex-wrap: wrap; }
  .tbl .c-phone a { white-space: nowrap; }
  .tbl .st-sub { text-align: start; padding: 0 6px 0 0; }
  .row-actions { opacity: 1; }
  .name-btn { max-width: none; }
}
/* roomy screens that still use cards (tablets): two cards per row */
@media (min-width: 561px) and (max-width: 1100px) {
  .tbl tbody { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
}

/* ---------- collector mode on bigger screens: two columns of cards ---------- */
.round-tools .seg { min-width: max-content; }
@media (min-width: 720px) {
  .round { max-width: 1040px; }
  .rlist { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .rlist > .rg, .rlist > .empty { grid-column: 1 / -1; }
}
@media (min-width: 1500px) {
  .round { max-width: 1280px; }
  .rlist { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
