/* Album Plus Admin v1.3.0 — mobile-first, no external fonts/CDNs (strict CSP). */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --border: #e3e7ef;
  --text: #1c2333;
  --muted: #6b7489;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-soft: #eef0ff;
  --sidebar: #151a2d;
  --sidebar-text: #aab2c8;
  --green: #15803d;   --green-soft: #dcfce7;
  --red: #b91c1c;     --red-soft: #fee2e2;
  --amber: #b45309;   --amber-soft: #fef3c7;
  --gray: #4b5563;    --gray-soft: #e5e7eb;
  --purple: #7e22ce;  --purple-soft: #f3e8ff;
  --blue: #1d4ed8;    --blue-soft: #dbeafe;
  --teal: #0f766e;    --teal-soft: #ccfbf1;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --touch: 40px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Tamil", sans-serif;
  font-size: 15px;
  color: var(--text);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
/* clip (not hidden): hidden would make body a scroll container and silently
   disable position: sticky on the top bar and the Confirm Renewal bar. */
html { overflow-x: clip; }
body { background: var(--bg); line-height: 1.45; overflow-x: clip; min-width: 0; }
body.no-scroll { overflow: hidden; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.55rem; margin: 0 0 .2rem; letter-spacing: -.01em; overflow-wrap: anywhere; }
h2 { font-size: 1.05rem; margin: 0; }
h3 { font-size: 1rem; margin: 0 0 .6rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .85em; }
.break, .break-words { overflow-wrap: anywhere; word-break: break-word; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.nowrap { white-space: nowrap; }
.min0 { min-width: 0; }
.ellipsis { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub { color: var(--muted); font-size: .82rem; }
.hint { color: var(--muted); font-size: .82rem; margin: .4rem 0 0; }
.text-warn { color: var(--amber); }
.icon { fill: currentColor; flex: none; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; min-width: 0; }
.sidebar {
  width: 240px; flex: none; background: var(--sidebar); color: var(--sidebar-text);
  position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 18px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; padding: 4px 8px 18px; }
.brand:hover { text-decoration: none; }
.brand strong { display: block; font-size: 1.02rem; }
.brand small { display: block; font-size: .75rem; color: var(--sidebar-text); }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, #6366f1, #a855f7); color: #fff; font-weight: 800;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a, .nav button {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 8px; min-height: var(--touch);
  color: var(--sidebar-text); font: inherit; font-size: .93rem; background: none; border: 0; cursor: pointer; width: 100%; text-align: left;
}
.nav a:hover, .nav button:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav a.active { background: var(--primary); color: #fff; }
.nav-logout { margin-top: 12px; border-top: 1px solid rgba(255, 255, 255, .08); padding-top: 12px; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 12px 24px; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 40;
}
.menu-btn { display: none; background: none; border: 0; padding: 8px; cursor: pointer; color: var(--text); min-width: var(--touch); min-height: var(--touch); }
.search-wrap { position: relative; flex: 1; max-width: 720px; min-width: 0; }
.quick-search {
  display: flex; align-items: center; gap: 8px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 10px; padding: 4px 4px 4px 12px; color: var(--muted);
}
.quick-search input { flex: 1; border: 0; background: transparent; padding: 7px 4px; font: inherit; outline: none; min-width: 0; color: var(--text); width: auto; box-shadow: none !important; }
.quick-search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.topbar-user { display: flex; align-items: center; gap: 6px; color: var(--muted); margin-left: auto; font-size: .9rem; flex: none; }
.content { padding: 24px; flex: 1; width: 100%; max-width: 1500px; min-width: 0; }
.footer { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 24px; color: var(--muted); font-size: .8rem; border-top: 1px solid var(--border); }
.sidebar-backdrop { display: none; }

/* Live search results */
.live-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 60; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 32px rgba(16, 24, 40, .18);
  max-height: 70vh; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
}
.live-results.loading { opacity: .75; }
.live-item { display: block; padding: 10px 14px; border-bottom: 1px solid var(--border); color: var(--text); }
.live-item:hover, .live-item.active { background: var(--primary-soft); text-decoration: none; }
.live-top { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.live-mobile { font-weight: 600; color: var(--primary-dark); }
.live-counts { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 5px; }
.live-empty { padding: 14px; color: var(--muted); }
.live-all { display: block; padding: 12px 14px; font-weight: 600; text-align: center; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head > div { min-width: 0; }
.page-head p { margin: 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.page-actions:empty { display: none; }
.crumbs { font-size: .85rem; color: var(--muted); margin: 0 0 4px !important; overflow-wrap: anywhere; }
.head-badges { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px !important; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px; min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card.narrow { max-width: 680px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head a { font-size: .87rem; }
.section-title { margin-bottom: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.grid-2 > .card, .grid-3 > .card { margin-bottom: 0; }
.empty { color: var(--muted); padding: 18px; text-align: center; margin: 0; }

/* Dashboard */
.income-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.income-card {
  background: linear-gradient(135deg, #312e81, #4f46e5); color: #fff; border-radius: var(--radius); padding: 16px;
  display: flex; flex-direction: column; gap: 4px; min-width: 0; box-shadow: var(--shadow);
}
a.income-card:hover { text-decoration: none; filter: brightness(1.07); }
.income-card .stat-label, .income-card .stat-hint { color: rgba(255, 255, 255, .8); }
.income-value { font-size: clamp(1.25rem, 2.2vw, 1.9rem); font-weight: 750; line-height: 1.15; overflow-wrap: anywhere; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px;
  display: flex; flex-direction: column; gap: 4px; color: var(--text); box-shadow: var(--shadow); min-width: 0;
  border-top: 4px solid var(--accent, var(--primary)); transition: transform .12s ease, box-shadow .12s ease;
}
.stat-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: 0 6px 16px rgba(16, 24, 40, .08); }
.stat-label { font-size: .78rem; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: .03em; overflow-wrap: anywhere; }
.stat-value { font-size: 1.9rem; font-weight: 750; line-height: 1.1; color: var(--accent, var(--text)); overflow-wrap: anywhere; }
.stat-hint { font-size: .78rem; color: var(--muted); overflow-wrap: anywhere; }
.c-green { --accent: var(--green); } .c-red { --accent: var(--red); } .c-amber { --accent: var(--amber); }
.c-gray { --accent: var(--gray); } .c-purple { --accent: var(--purple); } .c-blue { --accent: var(--blue); }
.c-teal { --accent: var(--teal); } .c-indigo { --accent: var(--primary); }
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.mini-list li:last-child { border-bottom: 0; }
.mini-main { display: flex; flex-direction: column; min-width: 0; }
.kv-list { list-style: none; margin: 0; padding: 0; }
.kv-list li { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: .9rem; }
.kv-list li:last-child { border-bottom: 0; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .72rem; font-weight: 700; letter-spacing: .04em; white-space: nowrap; }
.badge-active { background: var(--green-soft); color: var(--green); }
.badge-expired { background: var(--red-soft); color: var(--red); }
.badge-deactivated { background: var(--gray-soft); color: var(--gray); }
.badge-pending { background: var(--amber-soft); color: var(--amber); }
.badge-suspended { background: var(--purple-soft); color: var(--purple); }
.badge-soon { background: #ffedd5; color: #c2410c; }
.badge-muted { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); font-weight: 600; }
.count-pill { background: var(--primary-soft); color: var(--primary-dark); padding: 2px 10px; border-radius: 999px; font-size: .8rem; white-space: nowrap; }
.paid-pill { background: var(--teal-soft); color: var(--teal); padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.chips { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chip { background: var(--primary-soft); color: var(--primary-dark); padding: 3px 10px; border-radius: 999px; font-size: .82rem; }

/* Plan + remaining */
.plan { font-weight: 650; }
.plan-derived { color: var(--text); }
.plan-none { color: var(--muted); font-weight: 500; font-style: italic; }
.plan-note { color: var(--muted); font-size: .75rem; font-weight: 400; }
.remaining { font-weight: 650; }
.tone-active { color: var(--green); }
.tone-soon { color: #c2410c; }
.tone-expired { color: var(--red); }
.tone-suspended { color: var(--purple); }
.tone-pending { color: var(--amber); }
.tone-deactivated { color: var(--gray); }

/* PC ID with copy */
.pcid { display: inline-flex; align-items: flex-start; gap: 6px; max-width: 100%; flex-wrap: wrap; }
.pcid-value { word-break: break-all; overflow-wrap: anywhere; min-width: 0; line-height: 1.35; user-select: all; -webkit-user-select: all; }
.pcid-sm .pcid-value { font-size: .76rem; }
.col-pcid { min-width: 190px; max-width: 250px; }
.copy-btn {
  font: inherit; font-size: .74rem; font-weight: 650; padding: 3px 9px; border-radius: 6px; cursor: pointer; flex: none;
  border: 1px solid var(--border); background: var(--surface); color: var(--primary); min-height: 28px;
}
.copy-btn:hover { background: var(--primary-soft); }
.copy-btn.copied { background: var(--green-soft); color: var(--green); border-color: #bbf7d0; }

/* ---------- Buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 8px; min-height: 38px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: .9rem; font-weight: 600;
  cursor: pointer; white-space: nowrap; text-decoration: none !important; -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { padding: 5px 11px; font-size: .84rem; min-height: 34px; }
.btn-lg { padding: 12px 22px; font-size: 1rem; min-height: 48px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-success:hover { background: #166534; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #991b1b; }
.btn-secondary { background: var(--gray); border-color: var(--gray); color: #fff; }
.btn-ghost { background: transparent; }

label { display: flex; flex-direction: column; gap: 5px; font-size: .84rem; font-weight: 600; color: var(--muted); min-width: 0; }
input[type=text], input[type=search], input[type=password], input[type=email], input[type=number], input[type=date], select, textarea {
  font: inherit; font-size: .95rem; color: var(--text); padding: 9px 11px; border: 1px solid var(--border); min-height: 40px;
  border-radius: 8px; background: var(--surface); width: 100%; max-width: 100%; font-weight: 400; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea { resize: vertical; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; color: var(--text); min-height: var(--touch); }
label.check input { width: 20px; height: 20px; flex: none; }
fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px 14px; margin: 0; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
legend { font-weight: 700; font-size: .88rem; padding: 0 6px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.span-2 { grid-column: 1 / -1; }

.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filters label { min-width: 160px; flex: 0 1 auto; }
.filters label.check { min-width: 0; }
.filters .grow { flex: 1 1 260px; }
.filter-buttons { display: flex; gap: 8px; }
.filters.collapsed { display: none; }
.filters-toggle { margin-bottom: 14px; justify-content: space-between; }

.alert { padding: 11px 14px; border-radius: 10px; margin-bottom: 14px; font-size: .92rem; border: 1px solid transparent; overflow-wrap: anywhere; }
.alert-success { background: var(--green-soft); color: #14532d; border-color: #bbf7d0; }
.alert-error { background: var(--red-soft); color: #7f1d1d; border-color: #fecaca; }
.alert-warn { background: var(--amber-soft); color: #78350f; border-color: #fde68a; }
.alert-info { background: var(--blue-soft); color: #1e3a8a; border-color: #bfdbfe; }

/* ---------- Actions + "More" menu (tap, no hover) ---------- */
.actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }
.more { position: relative; }
.more > summary { list-style: none; }
.more > summary::-webkit-details-marker { display: none; }
.menu {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 70; min-width: 210px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 12px 32px rgba(16, 24, 40, .18); padding: 6px;
  display: flex; flex-direction: column;
}
.more.up .menu { top: auto; bottom: calc(100% + 4px); }
.more:not([open]) > .menu { display: none; }
.menu form { margin: 0; }
.menu-item {
  display: flex; align-items: center; width: 100%; min-height: 44px; padding: 10px 12px; border: 0; border-radius: 8px;
  background: none; font: inherit; font-size: .93rem; color: var(--text); text-align: left; cursor: pointer;
}
.menu-item:hover { background: var(--surface-2); text-decoration: none; }
.menu-item.danger { color: var(--red); }
.action-bar { padding: 12px 14px; }
.action-bar .actions { gap: 8px; }
.action-bar .btn { min-height: 42px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tbody tr:hover { background: #fafbff; }
.table tbody tr:last-child td { border-bottom: 0; }
.table a.sort { color: inherit; }
.list-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.per-page label { flex-direction: row; align-items: center; gap: 8px; }
.per-page select { width: auto; }
.pagination { display: flex; gap: 4px; flex-wrap: wrap; }
.page { padding: 7px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: .88rem; min-height: 38px; display: inline-flex; align-items: center; }
.page.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page.disabled, .page.gap { color: var(--muted); background: transparent; border-color: transparent; }
.mobile-only { display: none !important; }

/* License cards (mobile lists) */
.card-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 12px; }
.lcard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.lcard-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.lcard-head > div { min-width: 0; }
.lcard-name { font-weight: 700; font-size: 1.02rem; color: var(--text); overflow-wrap: anywhere; }
.lcard-mobile { font-weight: 650; white-space: nowrap; }
.lcard-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pc-tag { background: var(--text); color: #fff; font-size: .75rem; font-weight: 700; padding: 2px 9px; border-radius: 6px; }
.lcard-grid { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 6px 10px; margin: 0; font-size: .9rem; }
.lcard-grid dt { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; padding-top: 2px; }
.lcard-grid dd { margin: 0; min-width: 0; }
.lcard .actions .btn { min-height: 42px; }

/* ---------- Detail page ---------- */
.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 9px 14px; margin: 0; }
.kv dt { color: var(--muted); font-size: .84rem; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.kv-compact { grid-template-columns: 170px minmax(0, 1fr); }
.link-row { display: inline-flex; gap: 12px; margin-left: 10px; }
.sub-overview { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.ov { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ov-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 650; }
.ov-value { font-size: 1.05rem; overflow-wrap: anywhere; }
.pay-list { display: flex; flex-direction: column; }
.pay-row { display: grid; grid-template-columns: minmax(150px, 220px) minmax(0, 1fr) auto; gap: 8px 16px; padding: 12px 0; border-bottom: 1px solid var(--border); align-items: start; }
.pay-row:last-child { border-bottom: 0; }
.pay-row.is-void { opacity: .6; }
.pay-row.is-void strong { text-decoration: line-through; }
.pay-main { display: flex; flex-direction: column; gap: 2px; }
.pay-main strong { font-size: 1.1rem; }
.pay-detail { display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.void > summary { color: var(--red); font-size: .85rem; margin: 0; }
.void form { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; min-width: min(220px, 100%); }
.notes { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-size: .88rem; max-height: 260px; overflow-y: auto; margin-bottom: 12px; }
.note-form .row { display: flex; gap: 8px; flex-wrap: wrap; }
.note-form select { width: auto; flex: 0 1 auto; }
.note-form input { flex: 1 1 200px; width: auto; }
details > summary { cursor: pointer; font-weight: 600; color: var(--primary); margin: 12px 0 8px; min-height: 32px; display: flex; align-items: center; }
.form-toggle[open] > summary { margin-bottom: 12px; }
.summary-head { font-size: 1.05rem; color: var(--text) !important; margin-top: 0 !important; }
.add-admin form { display: grid; }
.small-head { font-size: .85rem; margin-top: 14px; }
.code { background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: 8px; overflow-x: auto; font-size: .8rem; margin: 8px 0 0; max-width: 100%; }
.activity { list-style: none; margin: 0; padding: 0; }
.activity > li { padding: 9px 0; border-bottom: 1px solid var(--border); font-size: .9rem; overflow-wrap: anywhere; }
.activity > li:last-child { border-bottom: 0; }
.changes { margin: 4px 0 0; padding-left: 16px; font-size: .82rem; color: var(--muted); overflow-wrap: anywhere; }
.changes strong { color: var(--text); }
.plain { margin: 0 0 14px; padding-left: 18px; }

/* ---------- Renewal page ---------- */
.plan-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.plan-option { position: relative; }
.plan-option input { position: absolute; opacity: 0; pointer-events: none; }
.plan-option span {
  display: flex; align-items: center; justify-content: center; text-align: center; min-height: 50px; padding: 8px;
  border: 2px solid var(--border); border-radius: 10px; font-weight: 700; font-size: .95rem; color: var(--text); background: var(--surface); cursor: pointer;
}
.plan-option input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; }
.plan-option input:focus-visible + span { box-shadow: 0 0 0 3px var(--primary-soft); }
.renew-extra { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; margin-bottom: 14px; }
.renew-extra > label { flex: 1 1 240px; }
.renew-extra > label.check { flex: 1 1 100%; }
.is-hidden { display: none !important; }
.new-expiry { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border: 2px solid var(--primary); border-radius: 12px; background: var(--primary-soft); margin-bottom: 12px; }
.new-expiry strong { font-size: 1.35rem; color: var(--primary-dark); }
.new-expiry.loading { opacity: .6; }
.new-expiry.warn { border-color: var(--amber); background: var(--amber-soft); }
.sticky-actions {
  position: sticky; bottom: 0; z-index: 30; display: flex; gap: 10px; justify-content: flex-end; align-items: center;
  background: rgba(255, 255, 255, .96); border: 1px solid var(--border); border-radius: 12px; padding: 12px;
  box-shadow: 0 -6px 18px rgba(16, 24, 40, .08); margin-bottom: 18px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}

/* ---------- Customers (grouped) ---------- */
.customer-list { display: flex; flex-direction: column; gap: 14px; margin-bottom: 18px; }
.customer { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; min-width: 0; }
.customer-head { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr) auto; gap: 14px; align-items: center; padding: 14px 18px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.c-main { display: flex; flex-direction: column; min-width: 0; }
.c-name { font-size: 1.05rem; overflow-wrap: anywhere; }
.c-mobile { min-width: 0; font-weight: 650; }
.c-counts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.customer .card-list { padding: 12px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 14px; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; scrollbar-width: thin; }
.tabs a { padding: 8px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--text); font-weight: 600; font-size: .9rem; white-space: nowrap; flex: none; min-height: 38px; display: inline-flex; align-items: center; }
.tabs a.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.tabs a:hover { text-decoration: none; }
.tab-count { display: inline-block; margin-left: 4px; padding: 0 7px; border-radius: 999px; background: rgba(0, 0, 0, .07); font-size: .78rem; }
.tabs a.active .tab-count { background: rgba(255, 255, 255, .22); }

/* ---------- Bars ---------- */
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) 44px; gap: 10px; align-items: center; color: var(--text); font-size: .88rem; }
.bar-row:hover { text-decoration: none; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-meter { width: 100%; height: 12px; }
.bar-num { text-align: right; font-weight: 700; }
meter.bar-meter { -webkit-appearance: none; appearance: none; background: var(--surface-2); border-radius: 6px; border: 1px solid var(--border); }
meter.bar-meter::-webkit-meter-bar { background: var(--surface-2); border: 0; border-radius: 6px; height: 12px; }
meter.bar-meter::-webkit-meter-optimum-value { background: var(--primary); border-radius: 6px; }
meter.bar-meter::-moz-meter-bar { background: var(--primary); border-radius: 6px; }

/* ---------- Release notes ---------- */
.rel-head { font-size: .78rem; letter-spacing: .08em; margin: 14px 0 6px; }
.rel-new { color: var(--green); } .rel-improved { color: var(--blue); } .rel-fixed { color: var(--amber); }
.rel-list { margin: 0; padding-left: 20px; }
.rel-list li { margin: 3px 0; }

/* ---------- Login ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(135deg, #151a2d 0%, #312e81 100%); }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: 16px; padding: 28px; box-shadow: 0 20px 50px rgba(0, 0, 0, .3); display: flex; flex-direction: column; gap: 12px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; }
.install-card { max-width: 520px; }
.brand-login { color: var(--text); padding: 0 0 6px; }
.brand-login small { color: var(--muted); }

/* ---------- Communications (v1.2.0) ---------- */
.status-dot { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; font-size: .82rem; letter-spacing: .02em; padding: 3px 10px; border-radius: 999px; white-space: normal; }
.dot-green { color: var(--green); background: var(--green-soft); }
.dot-red { color: var(--red); background: var(--red-soft); }
.dot-amber { color: var(--amber); background: var(--amber-soft); }
.dot-gray { color: var(--gray); background: var(--gray-soft); }
.status-line { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin: 0; }
.kv-status { grid-template-columns: 170px minmax(0, 1fr); }
.switch-row { min-width: 0; }
.switch { flex-direction: row; align-items: center; gap: 12px; cursor: pointer; color: var(--text); font-weight: 600; font-size: .93rem; min-height: 44px; position: relative; }
.switch input[type=checkbox] { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .slider { flex: none; width: 46px; height: 26px; border-radius: 999px; background: #cbd5e1; position: relative; transition: background .15s ease; }
.switch .slider::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s ease; }
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::after { transform: translateX(20px); }
.switch input:focus-visible + .slider { box-shadow: 0 0 0 3px var(--primary-soft); }
.switch-text { overflow-wrap: anywhere; }
.switch-row .hint { margin: 0 0 4px 58px; }
.sep { border: 0; border-top: 1px solid var(--border); margin: 4px 0; width: 100%; }
.stack-lg { display: flex; flex-direction: column; gap: 0; }
.stage-list { display: flex; flex-direction: column; gap: 8px; }
.stage-row { display: grid; grid-template-columns: repeat(2, minmax(0, 180px)); gap: 10px; }
.narrow-field { max-width: 360px; margin-top: 12px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.check-row { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.big-check { font-size: .95rem; }
.text-danger { color: var(--red); }
.comm-nav { margin-bottom: 14px; }
.comm-nav .tabs { margin-bottom: 0; }
.mobile-only-block { display: none; }
.test-grid { margin-bottom: 12px; }
.test-box { border: 1px solid var(--border); border-radius: 10px; padding: 14px; background: var(--surface-2); min-width: 0; }
.test-box h3 { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0; }
.test-inline { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); }
.copy-line { display: flex; gap: 8px; align-items: flex-start; background: #0f172a; color: #e2e8f0; border-radius: 8px; padding: 10px 12px; margin: 6px 0 10px; }
.copy-line code { flex: 1; min-width: 0; font-size: .8rem; line-height: 1.5; }
.steps { margin: 0 0 8px; padding-left: 20px; }
.steps li { margin: 6px 0; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-top: 12px; }
.stat-row > div { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.stat-row strong { font-size: 1.4rem; }
.wa-preview { white-space: pre-wrap; overflow-wrap: anywhere; background: #e7f8e9; color: #111b21; border-radius: 12px; padding: 14px 16px; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Tamil", sans-serif; margin: 0 0 12px; max-width: 520px; }
.email-preview { width: 100%; height: 640px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.template-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 18px; align-items: start; margin-bottom: 18px; }
.template-layout > .card { margin-bottom: 0; }
.tpl-links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.tpl-links a { display: flex; flex-direction: column; padding: 8px 10px; border-radius: 8px; color: var(--text); }
.tpl-links a:hover { background: var(--surface-2); text-decoration: none; }
.tpl-links a.active { background: var(--primary-soft); color: var(--primary-dark); font-weight: 600; }
.tpl-meta { font-size: .75rem; color: var(--muted); font-weight: 400; }
.var-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px 12px; }
.var-list li { display: flex; flex-direction: column; min-width: 0; }
.var-chip { font: inherit; font-family: ui-monospace, Consolas, monospace; font-size: .8rem; text-align: left; border: 1px solid var(--border); background: var(--surface-2); border-radius: 6px; padding: 4px 8px; cursor: pointer; color: var(--primary-dark); overflow-wrap: anywhere; }
.var-chip:hover { background: var(--primary-soft); }
.inner-grid { margin-bottom: 0; }
.msg-list { margin-bottom: 18px; }
.settings-comm .card-head { margin-bottom: 6px; }

/* ---------- v1.3.0: event switches, WhatsApp pause ---------- */
.event-grid { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin-bottom: 8px; }
.eg-head, .eg-row { display: grid; grid-template-columns: minmax(0, 1fr) 96px 96px; gap: 8px; align-items: center; padding: 8px 12px; }
.eg-head { background: var(--surface-2); font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
.eg-row { border-top: 1px solid var(--border); }
.eg-label { display: flex; flex-direction: column; min-width: 0; }
.eg-cell .switch { min-height: 36px; }
.eg-cell .switch-text:empty { display: none; }
.pause-banner { border: 2px solid var(--amber); background: var(--amber-soft); }
.pause-banner h2 { color: #92400e; margin-bottom: 6px; }
.btn-wrap { white-space: normal; text-align: center; max-width: 100%; }

/* ================= Responsive ================= */
@media (max-width: 1280px) {
  .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: 1fr; }
  .desktop-only { display: none !important; }
  .mobile-only { display: grid !important; }
  .card.flush:has(.card-list) { background: transparent; border: 0; box-shadow: none; overflow: visible; }
  .income-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .plan-grid { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
  .customer-head { grid-template-columns: minmax(0, 1fr) auto; }
  .c-counts { grid-column: 1 / -1; justify-content: flex-start; }
  .sub-overview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .template-layout { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 80; transform: translateX(-100%); transition: transform .2s ease; width: min(280px, 85vw); }
  .sidebar.open { transform: none; }
  .sidebar-backdrop.open { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 70; }
  .menu-btn { display: inline-flex; align-items: center; justify-content: center; }
  .topbar { padding: 8px 12px; gap: 8px; }
  .topbar-user { display: none; }
  .search-wrap { max-width: none; position: static; }
  /* Full-width results under the (sticky, so positioned) top bar */
  .live-results { left: 8px; right: 8px; top: calc(100% + 4px); }
  .quick-search button { display: none; }
  .content { padding: 16px; }
  .footer { padding: 14px 16px; }
  /* 16px inputs stop iOS Safari from zooming the page when a field is focused */
  input[type=text], input[type=search], input[type=password], input[type=email], input[type=number], input[type=date], select, textarea { font-size: 16px; min-height: 44px; }
  .btn { min-height: 42px; }
  .btn-sm { min-height: 40px; padding: 7px 12px; }
  .page { min-height: 42px; }
  .kv, .kv-compact { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
  .pay-row { grid-template-columns: minmax(0, 1fr) auto; }
  .pay-detail { grid-column: 1 / -1; grid-row: 2; }
  .pay-row > .void { grid-column: 1 / -1; grid-row: 3; }
  .void form { min-width: 0; }
}
@media (max-width: 700px) {
  h1 { font-size: 1.3rem; }
  .card { padding: 14px; }
  .page-head { margin-bottom: 14px; align-items: flex-start; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat-card { padding: 12px; }
  .stat-value { font-size: 1.5rem; }
  .income-grid { gap: 10px; }
  .income-card { padding: 12px; }
  .income-value { font-size: clamp(1.1rem, 5.2vw, 1.5rem); }
  .form-grid { grid-template-columns: 1fr; }
  .filters { gap: 10px; }
  .filters label, .filters .grow { flex: 1 1 100%; min-width: 0; }
  .filter-buttons { flex: 1 1 100%; }
  .filter-buttons .btn { flex: 1; }
  .customer-head { grid-template-columns: 1fr; gap: 6px; padding: 12px 14px; }
  .customer .card-list { padding: 10px; }
  .bar-row { grid-template-columns: 84px minmax(0, 1fr) 36px; }
  .sticky-actions { margin-left: -16px; margin-right: -16px; border-radius: 0; border-left: 0; border-right: 0; }
  .sticky-actions .btn { flex: 1; }
  .sticky-actions .btn-lg { flex: 2; }
  .btn-block-mobile { width: 100%; }
  .lcard .actions > .btn, .lcard .actions > form, .lcard .actions > .more { flex: 1 1 0; }
  .lcard .actions > form .btn, .lcard .actions .more > summary { width: 100%; }
  .action-bar .actions > * { flex: 1 1 calc(50% - 8px); }
  .action-bar .actions > form .btn, .action-bar .more > summary { width: 100%; }
  .list-footer { justify-content: center; }
  .link-row { display: flex; margin: 4px 0 0; }
  .comm-nav .desktop-tabs { display: none; }
  .mobile-only-block { display: flex; }
  .stage-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .switch-row .hint { margin-left: 0; }
  .copy-line { flex-direction: column; }
  .email-preview { height: 520px; }
  .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .var-list { grid-template-columns: 1fr; }
  .eg-head { display: none; }
  .eg-row { grid-template-columns: 1fr 1fr; }
  .eg-label { grid-column: 1 / -1; }
  .eg-cell { display: flex; align-items: center; gap: 8px; }
  .eg-cell::before { content: attr(data-label); font-size: .78rem; color: var(--muted); font-weight: 600; min-width: 64px; }
  /* Remaining generic tables (logs, settings) become stacked rows */
  .table.stack-mobile thead { display: none; }
  .table.stack-mobile, .table.stack-mobile tbody, .table.stack-mobile tr, .table.stack-mobile td { display: block; width: 100%; }
  .table.stack-mobile tr { border-bottom: 1px solid var(--border); padding: 8px 12px; }
  .table.stack-mobile td { border: 0; padding: 3px 0; display: flex; gap: 10px; overflow-wrap: anywhere; min-width: 0; }
  .table.stack-mobile td[data-label]::before { content: attr(data-label); flex: 0 0 84px; color: var(--muted); font-size: .76rem; text-transform: uppercase; padding-top: 2px; }
  .table.stack-mobile td > * { min-width: 0; }
}
@media (max-width: 380px) {
  .content { padding: 12px; }
  .sticky-actions { margin-left: -12px; margin-right: -12px; }
  .stat-grid { gap: 8px; }
  .stat-card { padding: 10px; }
  .stat-value { font-size: 1.3rem; }
  .stat-label { font-size: .7rem; }
  .income-grid { grid-template-columns: 1fr; }
  .lcard-grid { grid-template-columns: 74px minmax(0, 1fr); }
  .plan-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .brand-mark { width: 34px; height: 34px; }
}
