/* ─── RMS Portal — Shared Stylesheet ──────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #070b1d;
  --surface:  #101a3a;
  --border:   rgba(255,255,255,0.1);
  --text:     #e8ecf4;
  --muted:    #8b9dc4;
  --accent:   #5271ff;   /* overridden per-client via JS */
  --green:    #22c55e;
  --red:      #ef4444;
  --blue:     #4c6ef5;
  --purple:   #a855f7;
  --header-h: 58px;
  --nav-h:    62px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: linear-gradient(160deg, #05080f 0%, #1a2560 35%, #2e45a8 65%, #3352c8 100%);
  background-attachment: scroll;
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ─── Header ──────────────────────────────────────────────────── */
.p-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: rgba(5, 8, 15, 0.72);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255,255,255,0.07);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.1);
  z-index: 200;
}
.p-header-inner {
  max-width: 960px;
  margin: 0 auto;
  height: 100%;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.p-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.p-biz {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.p-sub-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  letter-spacing: 0.4px;
  white-space: nowrap;
  flex-shrink: 0;
}
.p-sub-badge.ok  { background: rgba(34,197,94,0.18); color: var(--green); }
.p-sub-badge.off { background: rgba(239,68,68,0.16); color: var(--red); }

/* Brand logo in header */
.p-brand-logo {
  height: 34px;
  width: auto;
  max-width: 80px;
  object-fit: contain;
  border-radius: 5px;
  flex-shrink: 0;
}

/* Hamburger button */
.p-ham {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
  transition: border-color 0.18s;
}
.p-ham:hover { border-color: rgba(255,255,255,0.3); }
.p-ham span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--muted);
  border-radius: 2px;
  transition: transform 0.22s, opacity 0.22s, background 0.18s;
}
.p-ham:hover span { background: var(--text); }
.p-ham.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.p-ham.open span:nth-child(2) { opacity: 0; }
.p-ham.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* Hamburger dropdown */
.p-ham-menu {
  display: none;
  position: fixed;
  top: calc(var(--header-h) + 6px);
  right: 16px;
  background: #0e1848;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.12), 0 20px 60px rgba(0,0,0,0.6);
  min-width: 190px;
  z-index: 300;
}
.p-ham-menu.open { display: block; }
.p-ham-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  font-family: inherit;
  transition: background 0.14s, color 0.14s;
  text-align: left;
}
.p-ham-item:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.p-ham-item.is-active { color: var(--blue); }
.p-logout {
  border-top: 1px solid var(--border);
  color: var(--red);
}
.p-logout:hover { background: rgba(239,68,68,0.1); color: var(--red); }

/* ─── Bottom Nav ──────────────────────────────────────────────── */
.p-bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: rgba(5, 8, 15, 0.82);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255,255,255,0.12);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
  display: flex;
  z-index: 200;
}
.p-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.18s;
  padding: 8px 0;
  -webkit-tap-highlight-color: transparent;
}
.p-nav-item svg { transition: stroke 0.18s; }
.p-nav-item:hover { color: var(--text); }
.p-nav-item.active { color: var(--blue); }
.p-nav-item.active svg { stroke: var(--blue); }

/* ─── Page Content Wrapper ────────────────────────────────────── */
.portal-content {
  padding-top: calc(var(--header-h) + 24px);
  padding-bottom: calc(var(--nav-h) + 24px);
  max-width: 720px;
  margin: 0 auto;
  padding-left: 20px;
  padding-right: 20px;
}
@media (min-width: 640px) {
  .portal-content { padding-left: 32px; padding-right: 32px; }
}

/* ─── Section header ──────────────────────────────────────────── */
.p-section-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}
.p-section-sub {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 24px;
  line-height: 1.5;
}

/* ─── Cards ───────────────────────────────────────────────────── */
.p-card {
  background: rgba(255,255,255,0.055);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.14), 0 4px 32px rgba(0,0,0,0.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.p-card-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  margin-bottom: 18px;
}

/* ─── Summary stat cards ──────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
@media (min-width: 560px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
}
.stat-card {
  background: rgba(255,255,255,0.055);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  padding: 18px 16px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.14), 0 4px 20px rgba(0,0,0,0.3);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: 14px 14px 0 0;
  background: var(--border);
}
.stat-card.blue::before  { background: var(--blue); }
.stat-card.green::before { background: var(--green); }
.stat-card.gold::before  { background: var(--accent); }
.stat-card.red::before   { background: var(--red); }
.stat-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 8px;
}
.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -1px;
  line-height: 1;
  margin-bottom: 3px;
}
.stat-sub { font-size: 11px; color: var(--muted); }
.stat-card.blue  .stat-value { color: var(--blue); }
.stat-card.green .stat-value { color: var(--green); }
.stat-card.gold  .stat-value { color: var(--accent); }
.stat-card.red   .stat-value { color: var(--red); }

/* ─── Customer list / table ───────────────────────────────────── */
.p-list { list-style: none; }
.p-list-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.p-list-row:last-child { border-bottom: none; }
.p-list-name { font-size: 14px; font-weight: 600; color: var(--text); }
.p-list-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.p-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.p-badge.manual  { background: rgba(59,130,246,0.18);  color: var(--blue); }
.p-badge.qr      { background: rgba(168,85,247,0.18);  color: var(--purple); }
.p-badge.sms     { background: rgba(34,197,94,0.18);   color: var(--green); }
.p-badge.email   { background: rgba(82,113,255,0.18);   color: var(--accent); }

/* ─── Forms ───────────────────────────────────────────────────── */
.p-form-group { margin-bottom: 18px; }
.p-form-group:last-child { margin-bottom: 0; }
.p-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.p-input {
  width: 100%;
  padding: 12px 14px;
  background: rgba(255,255,255,0.05);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  color: var(--text);
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s, background 0.2s;
}
.p-input:focus  { border-color: var(--blue); background: rgba(255,255,255,0.08); }
.p-input.error  { border-color: var(--red) !important; }
.p-input::placeholder { color: rgba(123,138,170,0.6); }
.p-field-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 5px;
}
.p-or-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0;
  color: var(--muted);
  font-size: 12px;
}
.p-or-divider::before, .p-or-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Checkbox row */
.p-check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}
.p-check-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
  cursor: pointer;
}
.p-check-row label {
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
}

/* ─── Buttons ─────────────────────────────────────────────────── */
.p-btn {
  display: block;
  width: 100%;
  padding: 13px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.18s, transform 0.1s;
  font-family: inherit;
  text-align: center;
  text-decoration: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.18), 0 4px 16px rgba(76,110,245,0.35);
}
.p-btn:hover    { opacity: 0.88; }
.p-btn:active   { opacity: 0.8; transform: scale(0.99); }
.p-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.p-btn.ghost {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  color: var(--muted);
  font-weight: 600;
}
.p-btn.ghost:hover { background: rgba(255,255,255,0.1); color: var(--text); }
.p-btn.danger {
  background: var(--red);
  color: #fff;
}

.p-back-link {
  display: inline-block;
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  background: none;
  border: none;
  font-family: inherit;
}
.p-back-link:hover { color: var(--text); }

/* ─── Alerts ──────────────────────────────────────────────────── */
.p-error {
  background: rgba(239,68,68,0.12);
  border: 1px solid rgba(239,68,68,0.3);
  color: #fca5a5;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  margin-top: 12px;
  line-height: 1.5;
}
.p-success {
  background: rgba(34,197,94,0.12);
  border: 1px solid rgba(34,197,94,0.3);
  color: #86efac;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  margin-top: 12px;
  line-height: 1.5;
}

/* ─── Spinner ─────────────────────────────────────────────────── */
.p-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: p-spin 0.7s linear infinite;
  margin: 0 auto;
}
@keyframes p-spin { to { transform: rotate(360deg); } }

/* ─── Shimmer skeleton ────────────────────────────────────────── */
.shimmer {
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.09) 50%, rgba(255,255,255,0.04) 75%);
  background-size: 200% 100%;
  animation: p-shimmer 1.4s infinite;
  border-radius: 6px;
  color: transparent !important;
}
@keyframes p-shimmer { to { background-position: -200% 0; } }

/* ─── Plan cards ──────────────────────────────────────────────── */
.plan-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
@media (max-width: 480px) {
  .plan-grid { grid-template-columns: 1fr; }
}
.plan-card {
  background: rgba(255,255,255,0.055);
  border: 1.5px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  padding: 22px 20px;
  transition: border-color 0.2s;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.14), 0 4px 28px rgba(0,0,0,0.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.plan-card.current { border-color: var(--blue); }
.plan-name  { font-size: 16px; font-weight: 800; color: var(--text); margin-bottom: 4px; }
.plan-price { font-size: 26px; font-weight: 800; color: var(--blue); letter-spacing: -1px; margin-bottom: 4px; }
.plan-freq  { font-size: 12px; color: var(--muted); margin-bottom: 16px; }
.plan-features { list-style: none; }
.plan-features li {
  font-size: 13px;
  color: var(--muted);
  padding: 4px 0;
  display: flex;
  align-items: flex-start;
  gap: 7px;
}
.plan-features li::before {
  content: '✓';
  color: var(--green);
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}
.plan-current-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  background: rgba(82,113,255,0.14);
  padding: 3px 9px;
  border-radius: 20px;
  margin-bottom: 12px;
}

/* ─── Toggle switch (shared) ──────────────────────────────────── */
.ds-toggle {
  position: relative;
  display: inline-flex;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
  cursor: pointer;
}
.ds-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.ds-toggle-slider {
  position: absolute;
  inset: 0;
  background: #c0392b;
  box-shadow: none;
  border-radius: 26px;
  transition: background 0.2s;
}
.ds-toggle-slider::before {
  content: '';
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.35);
}
.ds-toggle input:checked + .ds-toggle-slider {
  background: #22c55e;
}
.ds-toggle input:checked + .ds-toggle-slider::before {
  transform: translateX(22px);
}
.ds-toggle-label {
  font-size: 12px;
  font-weight: 700;
  min-width: 26px;
  color: var(--muted);
}
