:root {
  --bg: #111318;
  --card: #1a1d24;
  --card-hover: #1f232c;
  --border: #2a2f3a;
  --text: #e8eaed;
  --muted: #8b929e;
  --red: #e4002b;
  --red-hover: #c40025;
  --green: #22c55e;
  --yellow: #eab308;
  --blue: #3b82f6;
  --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Cairo", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

.hidden { display: none !important; }

.layout {
  max-width: 1480px;
  margin: 0 auto;
  padding: 0 16px 32px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 0;
  flex-wrap: wrap;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  width: 44px;
  height: 44px;
  background: var(--red);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.9rem;
}

.header h1 { font-size: 1.15rem; font-weight: 700; line-height: 1.2; }
.header p { font-size: 0.8rem; color: var(--muted); }

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.search {
  padding: 9px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  width: 160px;
}

.search:focus {
  outline: none;
  border-color: var(--red);
}

/* Buttons */
.btn {
  padding: 9px 16px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-red { background: var(--red); color: #fff; }
.btn-red:hover:not(:disabled) { background: var(--red-hover); }
.btn-red:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--card); }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }

.btn-spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  flex-shrink: 0;
}
#sync-all-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
#sync-all-btn .btn-spinner {
  border-color: rgba(255,255,255,0.25);
  border-top-color: var(--text);
}
@keyframes spin { to { transform: rotate(360deg); } }

.sync-all-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.sync-all-box {
  background: #1a1d24;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 32px;
  text-align: center;
  max-width: 320px;
}
.sync-all-spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto 16px;
  border: 3px solid rgba(255,255,255,0.15);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.sync-all-box p { margin: 0 0 8px; }
.sync-all-box .small { margin-bottom: 0; font-size: 0.8rem; }

/* Main */
.main { flex: 1; }

.summary-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.875rem;
  color: var(--muted);
  flex-wrap: wrap;
}

.summary-item strong {
  color: var(--text);
  font-size: 1.1rem;
  margin-left: 4px;
}

.summary-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
}

/* Lines table */
.table-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.table-scroll {
  overflow-x: auto;
}

.lines-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  min-width: 1200px;
}

.lines-table thead {
  background: #1e4d8c;
}

.lines-table th {
  padding: 12px 10px;
  text-align: center;
  font-weight: 700;
  font-size: 0.78rem;
  color: #fff;
  white-space: nowrap;
  border-left: 1px solid rgba(255,255,255,0.12);
}

.lines-table th:first-child { border-left: none; }

.lines-table th.sortable {
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.lines-table th.sortable:hover {
  background: #2563a8;
}

.lines-table th.sortable.sorted {
  background: #1a3d6e;
}

.lines-table tbody tr {
  background: #2a2f38;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}

.lines-table tbody tr:hover { background: #323844; }
.lines-table tbody tr.syncing { opacity: 0.6; pointer-events: none; }

.lines-table td {
  padding: 12px 10px;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
}

.col-name { font-weight: 700; }
.col-phone { font-family: inherit; color: var(--text); }
.col-renewal { color: var(--blue); font-weight: 600; }
.col-sync { color: var(--muted); font-size: 0.78rem; }
.col-days { font-weight: 600; }

.pkg-badge {
  display: inline-block;
  padding: 4px 10px;
  background: rgba(34,197,94,0.18);
  color: var(--green);
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ops-wrap { position: relative; }

.btn-ops {
  padding: 6px 12px;
  border: 1px solid #4a90c4;
  border-radius: 6px;
  background: rgba(59,130,246,0.15);
  color: #7ec8ff;
  font-family: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  white-space: nowrap;
}

.btn-ops:hover, .btn-ops.open {
  background: rgba(59,130,246,0.28);
  color: #fff;
}

.usage-bar-wrap {
  width: 100%;
  min-width: 90px;
  height: 22px;
  background: #1a1d24;
  border-radius: 4px;
  overflow: hidden;
}

.usage-bar {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  min-width: 36px;
  border-radius: 4px;
  transition: width 0.4s ease;
}

.usage-bar.low { background: var(--green); }
.usage-bar.mid { background: var(--yellow); color: #1a1d24; }
.usage-bar.high { background: var(--red); }

.sync-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-weight: 800;
  font-size: 0.85rem;
}

.sync-icon.sync-ok { background: rgba(34,197,94,0.2); color: var(--green); }
.sync-icon.sync-err { background: rgba(239,68,68,0.2); color: #f87171; }
.sync-icon.sync-wait { background: rgba(234,179,8,0.2); color: var(--yellow); }
.sync-icon.sync-never { background: #2a2f3a; color: var(--muted); font-size: 0.75rem; }

/* Account cards (legacy) */
.accounts-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.line-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.line-card:hover {
  border-color: #3a4050;
  background: var(--card-hover);
}

.line-card.syncing { opacity: 0.6; pointer-events: none; }

.line-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.line-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.line-avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #2a2f3a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.line-name {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.line-phone {
  font-size: 0.8rem;
  color: var(--muted);
  direction: ltr;
  text-align: right;
}

.line-menu-wrap {
  position: relative;
  flex-shrink: 0;
}

.btn-dots {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.btn-dots:hover, .btn-dots.open {
  background: #2a2f3a;
  color: var(--text);
}

.dropdown {
  position: fixed;
  min-width: 180px;
  background: #22262e;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  z-index: 1000;
  overflow: hidden;
}

.dropdown button {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: none;
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  text-align: right;
  cursor: pointer;
}

.dropdown button:hover { background: #2a2f3a; }
.dropdown button.danger { color: #f87171; }
.dropdown hr { border: none; border-top: 1px solid var(--border); margin: 0; }

.line-meta {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.meta-item label {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
  margin-bottom: 2px;
}

.meta-item span {
  font-size: 0.85rem;
  font-weight: 600;
}

.meta-item .green { color: var(--green); }
.meta-item .package {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.line-bottom {
  display: flex;
  align-items: center;
  gap: 12px;
}

.progress-track {
  flex: 1;
  height: 6px;
  background: #2a2f3a;
  border-radius: 99px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.4s ease;
}

.progress-fill.low { background: var(--green); }
.progress-fill.mid { background: var(--yellow); }
.progress-fill.high { background: var(--red); }

.pct-label {
  font-size: 0.8rem;
  color: var(--muted);
  direction: ltr;
  min-width: 36px;
  text-align: left;
}

.status-dot {
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 99px;
  font-weight: 600;
  white-space: nowrap;
}

.status-dot.ok { background: rgba(34,197,94,0.15); color: var(--green); }
.status-dot.err { background: rgba(239,68,68,0.15); color: #f87171; }
.status-dot.wait { background: rgba(234,179,8,0.15); color: var(--yellow); }
.status-dot.never { background: #2a2f3a; color: var(--muted); }

/* Empty */
.empty {
  text-align: center;
  padding: 60px 20px;
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.empty-icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty h2 { font-size: 1.1rem; margin-bottom: 6px; }
.empty p { color: var(--muted); font-size: 0.875rem; margin-bottom: 20px; }

/* Detail */
.back-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.875rem;
  cursor: pointer;
  padding: 0;
  margin-bottom: 16px;
}
.back-btn:hover { color: var(--text); }

.detail-head {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.detail-top {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.detail-avatar {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: var(--red);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
}

.detail-info h2 { font-size: 1.2rem; }
.detail-info p { color: var(--muted); direction: ltr; text-align: right; }

.detail-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.detail-stat-box {
  text-align: center;
  padding: 12px;
  background: var(--bg);
  border-radius: 8px;
}

.detail-stat-box .val {
  font-size: 1.3rem;
  font-weight: 800;
  direction: ltr;
}

.detail-stat-box .val.green { color: var(--green); }
.detail-stat-box .val.warn { color: var(--yellow); }
.detail-stat-box .lbl { font-size: 0.72rem; color: var(--muted); margin-top: 2px; }

.we-bonus {
  position: relative;
  overflow: hidden;
  margin: 18px 0 8px;
  padding: 18px;
  border-radius: 14px;
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(228, 0, 43, 0.22), transparent 55%),
    linear-gradient(180deg, #22181c 0%, #18151a 100%);
  border: 1px solid rgba(228, 0, 43, 0.35);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  animation: we-bonus-in 0.45s ease both;
}
.we-bonus::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 12px;
  bottom: 12px;
  width: 3px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ff4d6d, var(--red));
}
.we-bonus-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.we-bonus-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #ff2a4d, #b00020);
  box-shadow: 0 8px 18px rgba(228, 0, 43, 0.28);
  flex-shrink: 0;
  position: relative;
}
.we-bonus-mark-we {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #fff;
  line-height: 1;
}
.we-bonus-mark-plus {
  position: absolute;
  inset-inline-end: -4px;
  bottom: -4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #111318;
  border: 1px solid rgba(228, 0, 43, 0.55);
  color: #fda4af;
  font-size: 0.72rem;
  font-weight: 800;
  display: grid;
  place-items: center;
}
.we-bonus-name {
  font-size: 1rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.01em;
}
.we-bonus-caption {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 2px;
}
.we-bonus-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: stretch;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 14px 12px;
}
.we-bonus-divider {
  width: 1px;
  background: linear-gradient(180deg, transparent, rgba(255,255,255,0.12), transparent);
}
.we-bonus-metric {
  text-align: center;
  min-width: 0;
}
.we-bonus-metric-label {
  font-size: 0.72rem;
  color: #b7bec9;
  margin-bottom: 6px;
}
.we-bonus-metric-value {
  font-size: 1.55rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.we-bonus-metric-value.soft { color: #fecaca; }
.we-bonus-metric-unit {
  margin-top: 4px;
  font-size: 0.72rem;
  color: var(--muted);
}
.we-bonus-foot {
  display: flex;
  justify-content: flex-start;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
  font-size: 0.7rem;
  color: #8b929e;
}
@keyframes we-bonus-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (max-width: 520px) {
  .we-bonus { padding: 16px 14px 14px; }
  .we-bonus-metric-value { font-size: 1.28rem; }
  .we-bonus-foot { flex-direction: column; gap: 4px; }
}

.detail-actions { margin-top: 16px; }

.section-label {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 10px;
}

.quotas-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  align-items: stretch;
}

/* Quota card */
.quota-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  min-width: 0;
  height: 100%;
}

.quota-card.expired { opacity: 0.7; }

.quota-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.quota-name {
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1.35;
  flex: 1;
  min-width: 0;
}

.quota-tag {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 99px;
}

.quota-tag.active { background: rgba(34,197,94,0.15); color: var(--green); }
.quota-tag.done { background: rgba(239,68,68,0.15); color: #f87171; }

.quota-bar-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.quota-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 0;
}

.quota-stat {
  text-align: center;
  padding: 8px;
  background: var(--bg);
  border-radius: 6px;
}

.quota-stat .v { font-weight: 700; direction: ltr; font-size: 0.95rem; }
.quota-stat .l { font-size: 0.68rem; color: var(--muted); }

.quota-dates {
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.quota-dates div { display: flex; justify-content: space-between; }

/* Overlay / Dialog */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.dialog {
  background: #1a1d24;
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
}

.dialog-sm { max-width: 380px; }
.dialog-lg { max-width: 560px; }

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

@media (max-width: 520px) {
  .form-grid-2 { grid-template-columns: 1fr; }
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 0;
}

.dialog-head h2 { font-size: 1.05rem; }

.dialog-close {
  width: 32px; height: 32px;
  border: none;
  background: #2a2f3a;
  color: var(--muted);
  border-radius: 8px;
  font-size: 1.2rem;
  cursor: pointer;
  line-height: 1;
}
.dialog-close:hover { color: var(--text); }

.dialog form, .dialog > .delete-msg { padding: 16px 20px 20px; }

.field {
  display: block;
  margin-bottom: 14px;
}

.field span {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 5px;
}

.field small { font-weight: 400; }

.field input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
}

.field input:focus {
  outline: none;
  border-color: var(--red);
}

.field textarea,
.field select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
}

.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--red);
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge.ok { background: rgba(34,197,94,0.15); color: #86efac; }
.badge.warn { background: rgba(251,191,36,0.15); color: #fcd34d; }

.captcha-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.captcha-row img {
  display: block;
  min-width: 180px;
  min-height: 52px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  object-fit: contain;
}

.captcha-auto {
  font-size: 0.85rem;
  color: var(--green);
  margin-bottom: 8px;
  padding: 8px 12px;
  background: rgba(34, 197, 94, 0.1);
  border-radius: 8px;
}

/* Remain visual bar */
.remain-visual {
  margin-bottom: 10px;
}

.remain-visual.compact { margin-bottom: 8px; }

.remain-visual-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  margin-bottom: 5px;
}

.remain-visual-top .green { color: var(--green); font-weight: 700; }
.remain-visual-top .green.big-num { font-size: 1.4rem; }
.remain-visual-top .muted { color: var(--muted); }

.progress-track.tall { height: 10px; }
.progress-track.thin { height: 4px; margin-top: 6px; }

.remain-visual.big {
  padding: 14px;
  background: var(--bg);
  border-radius: 10px;
  margin-bottom: 16px;
}

.days-expiry {
  font-size: 0.78rem;
  color: var(--blue, #3b82f6);
  margin-top: 6px;
  font-weight: 600;
}

.days-expiry.warn { color: var(--yellow); }

.warn-text { color: var(--yellow) !important; }

.package-sub { font-size: 0.85rem; color: var(--muted); margin-top: 4px; }

.empty-hint {
  text-align: center;
  color: var(--muted);
  padding: 24px;
}

.sync-time { font-size: 0.78rem; color: var(--muted); flex: 1; }

a.btn { text-decoration: none; display: inline-flex; }

.error {
  padding: 10px 12px;
  background: rgba(239,68,68,0.12);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: 8px;
  color: #fca5a5;
  font-size: 0.85rem;
  margin-bottom: 12px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 20px 20px;
}

.delete-msg {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
  padding: 16px 20px 0;
}

.footer {
  text-align: center;
  padding: 20px 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

@media (max-width: 600px) {
  .header { flex-direction: column; align-items: stretch; }
  .header-left { justify-content: stretch; }
  .search { flex: 1; width: auto; min-width: 0; }
  .line-meta { grid-template-columns: 1fr 1fr; }
  .summary-bar { gap: 10px; }
  .summary-divider { display: none; }
  .detail-stats { grid-template-columns: repeat(2, 1fr); }
  .quotas-list { grid-template-columns: 1fr; }
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; min-height: auto; border-left: none; border-bottom: 1px solid var(--border); }
  .sidebar-nav { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; }
  .sidebar-link { padding: 8px 10px; font-size: 0.8rem; }
}

/* ===== SaaS App Shell ===== */
.app-shell {
  display: flex;
  min-height: 100vh;
  max-width: none;
  margin: 0;
  padding: 0;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--card);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.sidebar-brand strong { display: block; font-size: 0.95rem; }
.sidebar-brand small { color: var(--muted); font-size: 0.72rem; }

.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 4px; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
}

.sidebar-link:hover { background: var(--card-hover); color: var(--text); }
.sidebar-link.active { background: rgba(228, 0, 43, 0.15); color: #fff; }
.sidebar-link.small { font-size: 0.8rem; padding: 8px 12px; }
.sidebar-link .icon { width: 1.2em; text-align: center; }

.nav-badge {
  margin-inline-start: auto;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--red, #e4002b);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-user { font-size: 0.8rem; color: var(--muted); padding: 0 12px; }
.trial-badge {
  font-size: 0.75rem;
  background: rgba(234, 179, 8, 0.15);
  color: var(--yellow);
  padding: 6px 10px;
  border-radius: 6px;
  text-align: center;
}

.sidebar-logout {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 8px;
  font-family: inherit;
  cursor: pointer;
  font-size: 0.8rem;
}
.sidebar-logout:hover { background: var(--card-hover); color: var(--text); }

.btn-logout {
  color: var(--muted);
  border-color: var(--border);
}
.btn-logout:hover {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.08);
}

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.app-header h1 { font-size: 1.25rem; font-weight: 700; }
.app-header p { font-size: 0.85rem; color: var(--muted); margin-top: 2px; }
.app-header-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.app-content { padding: 20px 24px 32px; flex: 1; }

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 16px;
}
.panel h3 { margin-bottom: 8px; font-size: 1rem; }

.dash-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.dash-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.dash-val { font-size: 1.6rem; font-weight: 700; color: var(--green); }
.dash-lbl { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }
.dash-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

/* Auth pages */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}
.auth-card.wide { max-width: 480px; }

.auth-brand {
  text-align: center;
  padding: 28px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.auth-brand .logo { margin: 0 auto 12px; }
.auth-brand h1 { font-size: 1.2rem; }
.auth-brand p { color: var(--muted); font-size: 0.85rem; }

.auth-form { padding: 24px; }
.auth-form h2 { font-size: 1.05rem; margin-bottom: 16px; }
.auth-remember {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 14px;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.auth-remember input {
  width: 18px;
  height: 18px;
  accent-color: var(--red);
  flex-shrink: 0;
  cursor: pointer;
}
.auth-switch { text-align: center; margin-top: 16px; font-size: 0.85rem; color: var(--muted); }
.auth-switch a { color: var(--red); text-decoration: none; }
.btn-block { width: 100%; }

/* Plans */
.plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.plan-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.plan-card h3 { font-size: 1.1rem; margin-bottom: 8px; }
.plan-price { font-size: 1.4rem; font-weight: 700; color: var(--green); margin-bottom: 8px; }
.plan-price small { font-size: 0.75rem; color: var(--muted); font-weight: 400; }
.plan-features { list-style: none; margin: 12px 0 16px; font-size: 0.85rem; color: var(--muted); }
.plan-features li { padding: 4px 0; }
.plan-features li::before { content: "✓ "; color: var(--green); }

.trial-expired-page { display: flex; align-items: center; justify-content: center; min-height: 60vh; }
.trial-box {
  text-align: center;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px 24px;
}
.trial-box h1 { font-size: 1.3rem; margin: 12px 0; }
.trial-box p { color: var(--muted); margin-bottom: 20px; }
.trial-box .btn { margin: 4px; }

/* Wide enough that the actions column keeps its buttons on one line — the
   table scrolls inside .table-scroll rather than stacking every row 5 high. */
.admin-table { min-width: 1150px; }
.admin-actions { display: flex; flex-wrap: nowrap; gap: 4px; justify-content: center; }
.admin-actions .btn { flex-shrink: 0; }
.admin-actions .danger { color: #fca5a5; border-color: rgba(239,68,68,0.4); }

.impersonation-banner {
  position: sticky;
  top: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: linear-gradient(90deg, #7c2d12, #b45309);
  color: #fff;
  font-size: 0.92rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.impersonation-banner .btn { background: rgba(255,255,255,0.15); color: #fff; border-color: rgba(255,255,255,0.35); }
.impersonation-banner .btn:hover { background: rgba(255,255,255,0.25); }
.admin-shell .sidebar { background: #141820; }

/* ===== Subscriber Dashboard ===== */
.dash-page { display: flex; flex-direction: column; gap: 16px; }

.dash-welcome-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  background: linear-gradient(135deg, rgba(228,0,43,0.12), rgba(59,130,246,0.08));
  border: 1px solid rgba(228,0,43,0.2);
  border-radius: 14px;
  padding: 20px 24px;
}

.dash-welcome-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.dash-avatar {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: var(--red);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.dash-welcome-left h2 { font-size: 1.15rem; margin-bottom: 4px; }

.dash-welcome-right {
  min-width: 200px;
  flex: 1;
  max-width: 320px;
}

.sub-pill {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 10px;
}

.sub-pill.trial { background: rgba(234,179,8,0.15); color: var(--yellow); border: 1px solid rgba(234,179,8,0.3); }
.sub-pill.active { background: rgba(34,197,94,0.15); color: var(--green); border: 1px solid rgba(34,197,94,0.3); }
.sub-pill.expired { background: rgba(239,68,68,0.12); color: #fca5a5; border: 1px solid rgba(239,68,68,0.3); }

.trial-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.dash-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.dash-stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: border-color 0.2s, transform 0.2s;
}

.dash-stat-card:hover {
  border-color: rgba(255,255,255,0.12);
  transform: translateY(-2px);
}

.dash-stat-icon { font-size: 1.6rem; line-height: 1; }

.dash-stat-card .dash-val {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.dash-stat-card.accent-green .dash-val { color: var(--green); }
.dash-stat-card.accent-blue .dash-val { color: var(--blue); }
.dash-stat-card.accent-yellow .dash-val { color: var(--yellow); }
.dash-stat-card.accent-red .dash-val { color: #f87171; font-size: 1.1rem; }

.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.dash-panel { margin-top: 0 !important; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.panel-head h3 { margin: 0; font-size: 0.95rem; }

.dash-alerts { display: flex; flex-direction: column; gap: 8px; }

.dash-alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.85rem;
  transition: opacity 0.15s;
}

.dash-alert:hover { opacity: 0.85; }
.dash-alert-warn { background: rgba(234,179,8,0.1); border: 1px solid rgba(234,179,8,0.25); color: var(--yellow); }
.dash-alert-err { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.25); color: #fca5a5; }
.dash-alert-info { background: rgba(56,189,248,0.1); border: 1px solid rgba(56,189,248,0.25); color: #7dd3fc; }
.dash-alert-arrow { opacity: 0.6; font-size: 0.8rem; }

.sub-info-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 0.875rem;
}

.sub-info-row span { color: var(--muted); }
.sub-info-row:last-child { border-bottom: none; }

.dash-lines-table { min-width: 700px; }
.dash-lines-table th { font-size: 0.78rem; }

.usage-bar-wrap.compact { height: 18px; min-width: 80px; }
.usage-bar-wrap.compact .usage-bar { font-size: 0.65rem; line-height: 18px; }

@media (max-width: 900px) {
  .dash-grid { grid-template-columns: 1fr; }
  .dash-welcome-card { flex-direction: column; align-items: flex-start; }
  .dash-welcome-right { max-width: none; width: 100%; }
}

.auth-form select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
}

/* ===== PWA install banner ================================================ */

.pwa-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--card);
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.35);
  animation: pwa-slide-up 0.28s ease-out;
}

@keyframes pwa-slide-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.pwa-banner-icon img {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: block;
}

.pwa-banner-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pwa-banner-text strong { font-size: 0.9rem; }

.pwa-banner-text span {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.5;
}

.pwa-banner-text b { color: var(--text); font-weight: 600; }
.pwa-banner .ios-share { color: var(--blue); }

.pwa-banner-action { flex-shrink: 0; padding: 8px 18px; font-size: 0.85rem; }

.pwa-banner-close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 6px;
  line-height: 1;
}

.pwa-banner-close:hover { color: var(--text); }

/* ===== WhatsApp activation =============================================== */

.btn-whatsapp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #25d366;
  color: #062e14;
  border: none;
  font-weight: 700;
}

.btn-whatsapp:hover { background: #1fb855; }

.pay-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.pay-price {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.pay-price .amount { font-size: 2.4rem; font-weight: 800; color: var(--red); line-height: 1; }
.pay-price .unit { color: var(--muted); font-size: 0.9rem; }

.pay-calc {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.pay-calc label { font-size: 0.85rem; color: var(--muted); }

.pay-calc input {
  width: 80px;
  padding: 8px 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  text-align: center;
}

.pay-calc .total { margin-inline-start: auto; font-size: 1.1rem; font-weight: 700; }
.pay-calc .total b { color: var(--green); }

.pay-steps { display: flex; flex-direction: column; gap: 10px; }

.pay-step {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.6;
}

.pay-step .num {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== Line quota meter ================================================== */

.quota-meter {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.quota-meter-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.85rem;
}

.quota-meter-top strong { font-size: 1rem; }
.quota-meter-top .muted { font-size: 0.78rem; }
.quota-meter.is-full .progress-fill { background: var(--red); }

/* .progress-track carries flex:1 for its usual row layout; inside this column
   container that resolves flex-basis to 0 and collapses the bar. */
.quota-meter .progress-track {
  flex: none;
  height: 8px;
}

/* ===== Push toggle ======================================================= */

.push-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.push-row .push-text { flex: 1; min-width: 200px; }
.push-row .push-text strong { display: block; font-size: 0.9rem; margin-bottom: 4px; }
.push-row .push-text span { font-size: 0.78rem; color: var(--muted); line-height: 1.6; }

.push-state {
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}

.push-state.on { color: var(--green); border-color: rgba(34, 197, 94, 0.4); }

/* ===== Mobile app shell ==================================================
   These live at the end on purpose. The older @media (max-width: 600px)
   block sits above the .app-shell / .sidebar definitions, so its rules lose
   to them on source order and never applied on a phone. */

@media (max-width: 700px) {
  .app-shell {
    flex-direction: column;
    /* Status bar is translucent in standalone mode — keep content clear of it. */
    padding-top: env(safe-area-inset-top);
  }

  .sidebar {
    width: 100%;
    height: auto;
    min-height: 0;
    position: static;
    border-left: none;
    border-bottom: 1px solid var(--border);
    padding: 10px 12px;
    gap: 8px;
  }

  .sidebar-brand {
    padding: 2px 4px 10px;
    margin-bottom: 0;
  }

  .sidebar-nav {
    flex: none;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }

  .sidebar-nav::-webkit-scrollbar { display: none; }

  .sidebar-link {
    flex-direction: column;
    gap: 3px;
    flex-shrink: 0;
    padding: 8px 12px;
    font-size: 0.7rem;
    text-align: center;
    white-space: nowrap;
    position: relative;
  }

  .sidebar-link .icon { font-size: 1.05rem; }

  /* Tabs stack icon over label here, so the count rides the corner instead. */
  .nav-badge {
    position: absolute;
    top: 2px;
    inset-inline-end: 4px;
    margin-inline-start: 0;
    min-width: 16px;
    padding: 0 4px;
    font-size: 0.62rem;
  }

  /* Account links and logout belong in a row under the tabs, not a column. */
  .sidebar-footer {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
  }

  /* initAppLayout injects a logout button into the header too — one is enough. */
  .app-header .btn-logout { display: none; }

  .sidebar-footer .sidebar-user { font-size: 0.78rem; margin-inline-end: auto; }
  .sidebar-footer .sidebar-link.small { padding: 5px 9px; font-size: 0.7rem; flex-direction: row; }
  .sidebar-logout { width: auto; padding: 5px 12px; font-size: 0.72rem; }

  .app-main { min-width: 0; }

  .app-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .app-content {
    padding: 14px 12px;
    /* Room for the fixed install banner plus the home indicator. */
    padding-bottom: calc(120px + env(safe-area-inset-bottom));
  }

  .panel { padding: 16px 14px; }

  .pay-card { padding: 18px 14px; }
  .pay-price .amount { font-size: 2rem; }
  .pay-calc { gap: 10px; }
  .pay-calc .total { width: 100%; margin-inline-start: 0; }

  /* Wide tables must scroll inside their own box, never the page. */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Stack the toggle under its description instead of squeezing beside it. */
  .push-row { flex-direction: column; align-items: stretch; }
  .push-row .push-text { min-width: 0; }
  .push-row .btn { width: 100%; }
}

/* ===== Admin toolbar, pills, activation dialog =========================== */

.admin-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

#subs-summary { margin-bottom: 18px; }

.admin-toolbar .search { width: 260px; flex: 0 1 260px; }

.admin-toolbar select {
  padding: 9px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
}

.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}

.pill.ok    { background: rgba(34, 197, 94, 0.16); color: var(--green); border-color: rgba(34, 197, 94, 0.35); }
.pill.warn  { background: rgba(234, 179, 8, 0.16); color: var(--yellow); border-color: rgba(234, 179, 8, 0.35); }
.pill.err   { background: rgba(239, 68, 68, 0.16); color: #f87171; border-color: rgba(239, 68, 68, 0.35); }
.pill.info  { background: rgba(59, 130, 246, 0.16); color: var(--blue); border-color: rgba(59, 130, 246, 0.35); }
.pill.muted { background: rgba(255, 255, 255, 0.05); color: var(--muted); border-color: var(--border); }

.activate-total {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 14px;
  margin: 4px 0 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: var(--muted);
}

.activate-total strong {
  margin-inline-start: auto;
  font-size: 1.25rem;
  color: var(--green);
}

.activate-total small { font-size: 0.75rem; }

.field-hint {
  display: block;
  margin-top: 5px;
  font-size: 0.75rem;
  color: var(--muted);
}

/* Locked nav entry for customers without an active subscription. */
.sidebar-link.locked {
  opacity: 0.55;
  cursor: pointer;
}

.sidebar-link.locked:hover {
  opacity: 0.8;
  background: var(--card-hover);
}

/* ===== Admin ops health panel ============================================= */

.admin-ops-panel { margin-bottom: 18px; }

.admin-ops-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.admin-ops-sub { margin: 4px 0 0; font-size: 0.85rem; }

.admin-ops-badge {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
  border: 1px solid transparent;
}

.admin-ops-badge-ok { background: rgba(34,197,94,0.15); color: var(--green); border-color: rgba(34,197,94,0.35); }
.admin-ops-badge-warn { background: rgba(234,179,8,0.15); color: var(--yellow); border-color: rgba(234,179,8,0.35); }
.admin-ops-badge-err { background: rgba(239,68,68,0.15); color: #fca5a5; border-color: rgba(239,68,68,0.35); }
.admin-ops-badge-info { background: rgba(59,130,246,0.12); color: #93c5fd; border-color: rgba(59,130,246,0.3); }

.admin-ops-alerts { margin-bottom: 14px; }
.admin-ops-alert { cursor: default; }
.admin-ops-alert:hover { opacity: 1; }

.admin-ops-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.admin-ops-metric {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
}

.admin-ops-metric strong { font-size: 1.05rem; }

.admin-telemetry-panel { margin-bottom: 18px; }

.admin-telemetry-highlight {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.admin-telemetry-kpi {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-telemetry-kpi-ok { border-color: rgba(34,197,94,0.35); background: rgba(34,197,94,0.06); }
.admin-telemetry-kpi-warn { border-color: rgba(234,179,8,0.35); background: rgba(234,179,8,0.06); }
.admin-telemetry-kpi-err { border-color: rgba(239,68,68,0.35); background: rgba(239,68,68,0.06); }
.admin-telemetry-kpi-info { border-color: var(--border); background: var(--bg); }

.admin-telemetry-kpi strong { font-size: 1.35rem; }
.admin-telemetry-kpi small { color: var(--muted); font-size: 0.78rem; }

.admin-telemetry-split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 8px;
}

.admin-telemetry-split h4 { margin: 0 0 8px; font-size: 0.85rem; }

.admin-settings-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}

.admin-ops-details summary {
  cursor: pointer;
  font-weight: 600;
  margin-bottom: 8px;
  user-select: none;
}

.admin-ops-table { min-width: 720px; margin-top: 8px; }
.admin-ops-err { max-width: 320px; font-size: 0.82rem; color: var(--muted); word-break: break-word; }
.admin-ops-updated { margin: 10px 0 0; font-size: 0.78rem; }

/* ===== Admin tasks panel ================================================== */

.admin-tasks-panel { margin-bottom: 18px; border-color: rgba(228, 0, 43, 0.25); }

.admin-tasks-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.admin-tasks-sub { margin: 4px 0 0; font-size: 0.85rem; }

.admin-tasks-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-tasks-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(228, 0, 43, 0.15);
  color: var(--red);
  font-weight: 700;
  font-size: 0.95rem;
}

.admin-tasks-table { min-width: 760px; }
.admin-tasks-err { max-width: 280px; font-size: 0.82rem; color: var(--muted); word-break: break-word; }
.admin-tasks-empty { padding: 12px 0; margin: 0; }

/* ===== Admin ops health panel (continued) ================================= */

.broadcast-delivery { display: flex; flex-direction: column; gap: 8px; }
.broadcast-option {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1.45;
}
.broadcast-option input { margin-top: 4px; flex-shrink: 0; }
.broadcast-status.ok { color: var(--ok, #16a34a); font-weight: 600; }
.broadcast-status.error { color: var(--err, #dc2626); font-weight: 600; }
.admin-phone-cell {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.btn-xs {
  padding: 2px 8px;
  font-size: 0.75rem;
  line-height: 1.4;
}
.wa-send-inline { white-space: nowrap; }

/* Manual sync hidden by default — shown when line needs captcha/session refresh */
.manual-sync-ui { display: none !important; }
.manual-sync-ui.show-sync { display: inline-flex !important; }
body.admin-impersonating .manual-sync-ui { display: none !important; }

.admin-impersonation-only { display: none !important; }
body.admin-impersonating .admin-impersonation-only { display: inline-flex !important; }
body.admin-impersonating .dropdown .admin-impersonation-only {
  display: block !important;
  width: 100%;
  text-align: right;
}
