/* ============================================================
   Platform Admin Panel — Light Theme Design System
   Professional SaaS administration interface
   Version: 1.0 — Full redesign from dark to light
============================================================ */

/* ============================================================
   PLATFORM TOKENS (light theme override)
   Base tokens from app.css are reused; these extend/override.
============================================================ */
:root {
  /* ── Brand Palette (shared with all interfaces) ── */
  --color-primary:  #0E3A5F;
  --color-accent:   #FF8A00;
  --color-sky:      #3B82F6;
  --color-light:    #F1F7FD;

  /* Platform sidebar — light */
  --p-sb-bg:         #FFFFFF;
  --p-sb-border:     #E8ECF0;
  --p-sb-text:       #718096;
  --p-sb-hover:      #F7F8FA;
  --p-sb-active-bg:  rgba(14,58,95,.06);
  --p-sb-width:      256px;

  /* Platform surfaces */
  --p-bg:            #F1F7FD;
  --p-surface:       #FFFFFF;
  --p-border:        #E8ECF0;
  --p-border-light:  #F1F5F9;

  /* Platform text */
  --p-text:          #1a202c;
  --p-text-2:        #4a5568;
  --p-text-muted:    #718096;
  --p-text-faint:    #A0AEC0;

  --p-topbar-h:      60px;
}

/* ============================================================
   RESET & BASE (platform scope)
============================================================ */
.p-root {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--p-bg);
  color: var(--p-text);
  min-height: 100vh;
  display: flex;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   PLATFORM SIDEBAR
============================================================ */
.p-sidebar {
  width: var(--p-sb-width);
  flex-shrink: 0;
  background: var(--p-sb-bg);
  border-right: 1px solid var(--p-sb-border);
  min-height: 100vh;
  height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform .28s ease;
  z-index: 200;
  scrollbar-width: thin;
  scrollbar-color: var(--p-border) transparent;
}

/* Brand row */
.p-brand {
  height: var(--p-topbar-h);
  padding: 0 20px;
  display: flex; align-items: center; gap: 11px;
  border-bottom: 1px solid var(--p-sb-border);
  flex-shrink: 0;
  text-decoration: none;
}
.p-brand-icon {
  width: 34px; height: 34px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 900; font-size: .92rem; color: #fff;
  /* background set inline via primary color */
}
.p-brand-texts { line-height: 1.15; min-width: 0; }
.p-brand-name {
  display: block;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: .88rem; font-weight: 800; color: var(--p-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.p-brand-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .58rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase;
  border-radius: 4px; padding: 2px 7px; margin-top: 2px;
  /* colors set inline */
}
.p-brand-badge::before {
  content: '';
  width: 5px; height: 5px; border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 5px #22c55e;
  flex-shrink: 0;
}

/* Nav */
.p-nav {
  padding: 8px 12px;
  flex: 1;
  display: flex; flex-direction: column; gap: 1px;
}
.p-nav-section {
  font-size: .59rem; font-weight: 800; letter-spacing: .1em;
  text-transform: uppercase; color: var(--p-text-faint);
  padding: 14px 8px 5px;
  display: flex; align-items: center; gap: 8px;
}
.p-nav-section::after {
  content: ''; flex: 1; height: 1px; background: var(--p-border);
}
.p-nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 8px;
  font-size: .83rem; font-weight: 500; color: var(--p-sb-text);
  cursor: pointer; transition: all .16s;
  text-decoration: none; position: relative;
}
.p-nav-item:hover {
  background: var(--p-sb-hover);
  color: var(--p-text);
}
.p-nav-item.active {
  background: var(--p-sb-active-bg);
  color: var(--primary);
  font-weight: 600;
}
.p-nav-item.active::before {
  content: ''; position: absolute; left: -12px; top: 20%; bottom: 20%;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--primary);
}
.p-nav-icon {
  width: 16px; height: 16px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--p-text-faint); transition: color .16s;
}
.p-nav-icon svg { width: 15px; height: 15px; }
.p-nav-item:hover .p-nav-icon { color: var(--p-text-muted); }
.p-nav-item.active .p-nav-icon { color: var(--primary); }

.p-nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff; font-size: .6rem; font-weight: 800;
  padding: 2px 6px; border-radius: 100px; line-height: 1.4;
}

/* User card */
.p-sidebar-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--p-sb-border);
  flex-shrink: 0;
}
.p-user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px;
  border-radius: 9px;
  background: var(--p-bg);
  border: 1px solid var(--p-border);
}
.p-user-avatar {
  width: 32px; height: 32px; border-radius: 8px;
  color: #fff; font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: .72rem; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  /* background set inline */
}
.p-user-info { flex: 1; min-width: 0; }
.p-user-name {
  font-size: .79rem; font-weight: 600; color: var(--p-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.p-user-role { font-size: .63rem; color: var(--p-text-faint); margin-top: 1px; }
.p-logout-btn {
  width: 28px; height: 28px; border-radius: 7px;
  background: transparent; border: 1px solid var(--p-border);
  display: flex; align-items: center; justify-content: center;
  color: var(--p-text-muted); cursor: pointer; transition: all .16s;
  flex-shrink: 0; text-decoration: none;
}
.p-logout-btn:hover {
  background: var(--danger-bg);
  border-color: var(--danger-bd);
  color: var(--danger);
}
.p-logout-btn svg { width: 13px; height: 13px; }

/* Mobile overlay */
.p-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 190;
}
.p-overlay.show { display: block; }

/* ============================================================
   MAIN AREA
============================================================ */
.p-main {
  flex: 1; display: flex; flex-direction: column;
  min-width: 0; background: var(--p-bg);
}

/* ============================================================
   TOPBAR
============================================================ */
.p-topbar {
  height: var(--p-topbar-h);
  background: var(--p-surface);
  border-bottom: 1px solid var(--p-border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
  position: sticky; top: 0; z-index: 100;
  gap: 16px;
  box-shadow: 0 1px 0 var(--p-border), 0 2px 8px rgba(0,0,0,.03);
}
.p-topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }

.p-menu-btn {
  width: 34px; height: 34px; border-radius: 8px;
  background: transparent; border: 1px solid var(--p-border);
  display: flex; align-items: center; justify-content: center;
  color: var(--p-text-muted); cursor: pointer; transition: all .15s;
  flex-shrink: 0; display: none;
}
.p-menu-btn:hover { background: var(--p-bg); color: var(--p-text); }
.p-menu-btn svg { width: 16px; height: 16px; }

/* Breadcrumb */
.p-breadcrumb { display: flex; align-items: center; gap: 5px; min-width: 0; }
.p-breadcrumb-root {
  font-size: .78rem; font-weight: 500; color: var(--p-text-muted);
  flex-shrink: 0; text-decoration: none; transition: color .14s;
}
.p-breadcrumb-root:hover { color: var(--primary); }
.p-breadcrumb-sep { color: var(--p-text-faint); flex-shrink: 0; display: flex; align-items: center; }
.p-breadcrumb-sep svg { width: 12px; height: 12px; }
.p-breadcrumb-page {
  font-size: .78rem; font-weight: 600; color: var(--p-text-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.p-topbar-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.p-topbar-btn {
  width: 34px; height: 34px; border-radius: 8px;
  background: transparent; border: 1px solid var(--p-border);
  display: flex; align-items: center; justify-content: center;
  color: var(--p-text-muted); cursor: pointer; transition: all .15s;
  text-decoration: none; position: relative; flex-shrink: 0;
}
.p-topbar-btn:hover {
  background: var(--p-bg); color: var(--p-text);
  border-color: var(--p-text-faint);
}
.p-topbar-btn svg { width: 15px; height: 15px; }
.p-topbar-btn .notif-dot {
  position: absolute; top: 6px; right: 6px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--danger); border: 1.5px solid var(--p-surface);
}

.p-view-site {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 8px;
  background: transparent; border: 1px solid var(--p-border);
  font-size: .76rem; font-weight: 600; color: var(--p-text-muted);
  cursor: pointer; transition: all .15s; text-decoration: none; white-space: nowrap;
}
.p-view-site:hover {
  border-color: var(--primary); color: var(--primary); background: var(--primary-light);
}
.p-view-site svg { width: 12px; height: 12px; }

/* Admin pill — pill button in topbar */
.p-admin-pill {
  display: flex; align-items: center; gap: 7px;
  padding: 4px 10px 4px 4px; border-radius: 100px;
  background: var(--p-bg); border: 1px solid var(--p-border);
  cursor: pointer; transition: all .15s; text-decoration: none;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.p-admin-pill:hover { background: var(--p-border-light); border-color: var(--p-text-faint); }
.p-admin-pill-av {
  width: 26px; height: 26px; border-radius: 50%;
  color: #fff; font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 900; font-size: .64rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.p-admin-pill-name {
  font-size: .77rem; font-weight: 600; color: var(--p-text-2);
  max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ============================================================
   PLATFORM CONTENT
============================================================ */
.p-content {
  flex: 1; padding: 28px 28px 40px; overflow-x: hidden;
}

/* Page header */
.p-page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  flex-wrap: wrap; gap: 14px; margin-bottom: 28px;
}
.p-page-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1.35rem; font-weight: 800; color: var(--p-text);
  letter-spacing: -.025em; line-height: 1.2;
}
.p-page-sub { font-size: .81rem; color: var(--p-text-muted); margin-top: 4px; line-height: 1.5; }

/* ── Customer / entity detail hero header ── */
.p-entity-header {
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: 14px;
  padding: 20px 24px 0;
  margin-bottom: 4px;
}
.p-entity-breadcrumb {
  display: flex; align-items: center; gap: 5px;
  font-size: .76rem; color: var(--p-text-muted);
  margin-bottom: 12px;
}
.p-entity-breadcrumb svg { width: 11px; height: 11px; flex-shrink: 0; opacity: .6; }
.p-entity-breadcrumb a {
  color: var(--p-text-muted); text-decoration: none; transition: color .14s;
}
.p-entity-breadcrumb a:hover { color: var(--primary); text-decoration: underline; }

.p-entity-meta {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 14px; padding-bottom: 16px;
  border-bottom: 1px solid var(--p-border-light);
}
.p-entity-left { display: flex; flex-direction: column; gap: 8px; }
.p-entity-title-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.p-entity-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1.4rem; font-weight: 800; color: var(--p-text);
  letter-spacing: -.025em; line-height: 1.1;
}
.p-entity-sub {
  font-size: .8rem; color: var(--p-text-muted);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.p-entity-sub-sep { color: var(--p-border); user-select: none; }
.p-entity-actions {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex-shrink: 0;
}

/* Tab navigation — sits at bottom of hero header */
.p-entity-tabs {
  display: flex; gap: 0; flex-wrap: nowrap;
  overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none;
  margin-top: 4px;
}
.p-entity-tabs::-webkit-scrollbar { display: none; }
.p-entity-tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 11px 16px; font-size: .8rem; font-weight: 600;
  color: var(--p-text-muted); cursor: pointer; transition: all .15s;
  text-decoration: none; background: transparent; border: none;
  font-family: 'Inter', sans-serif;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px; white-space: nowrap; flex-shrink: 0;
  position: relative;
}
.p-entity-tab:hover { color: var(--p-text-2); background: var(--p-bg); border-radius: 8px 8px 0 0; }
.p-entity-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: transparent;
}
.p-entity-tab .p-tab-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 100px; font-size: .67rem; font-weight: 700; line-height: 1;
  background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-bd);
}
.p-entity-tab.active .p-tab-count {
  background: var(--primary-light); color: var(--primary); border-color: var(--primary-mid);
}

/* ============================================================
   PLATFORM STAT CARDS
============================================================ */
.p-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.p-stat-card {
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: 14px;
  padding: 20px;
  display: flex; align-items: flex-start; gap: 14px;
  transition: all .18s;
  position: relative; overflow: hidden;
}
.p-stat-card:hover {
  box-shadow: 0 6px 20px rgba(0,0,0,.07);
  border-color: var(--primary-mid);
}
.p-stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--primary); opacity: 0; transition: opacity .18s;
}
.p-stat-card:hover::before { opacity: 1; }
.p-stat-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.p-stat-icon svg { width: 20px; height: 20px; }
.p-stat-info .val {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1.85rem; font-weight: 900; color: var(--p-text);
  line-height: 1; letter-spacing: -.03em;
}
.p-stat-info .lbl { font-size: .74rem; color: var(--p-text-muted); margin-top: 5px; }
.p-stat-info .sub {
  font-size: .72rem; color: var(--success); margin-top: 4px;
  display: flex; align-items: center; gap: 3px;
}
.p-stat-info .sub.warn   { color: var(--warning); }
.p-stat-info .sub.danger { color: var(--danger); }
.p-stat-info .sub.neutral{ color: var(--p-text-muted); }

/* ============================================================
   PLATFORM CARDS
============================================================ */
.p-card {
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: 14px;
  padding: 22px;
  margin-bottom: 20px;
}
.p-card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; flex-wrap: wrap; gap: 10px;
}
.p-card-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: .9rem; font-weight: 800; color: var(--p-text);
  display: flex; align-items: center; gap: 8px;
}
.p-card-title svg { width: 15px; height: 15px; color: var(--primary); }
.p-card-sub { font-size: .78rem; color: var(--p-text-muted); margin-top: 2px; }

/* ============================================================
   PLATFORM TABLES
============================================================ */
.p-tbl-wrap { overflow-x: auto; border-radius: 10px; }
.p-tbl {
  width: 100%; border-collapse: collapse;
  font-size: .83rem; min-width: 520px;
}
.p-tbl thead tr { background: var(--p-bg); }
.p-tbl th {
  text-align: left; padding: 10px 14px;
  font-size: .68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--p-text-muted);
  border-bottom: 1.5px solid var(--p-border);
  white-space: nowrap;
}
.p-tbl td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--p-border-light);
  vertical-align: middle;
  color: var(--p-text-2);
}
.p-tbl tr:last-child td { border-bottom: none; }
.p-tbl tbody tr { transition: background .14s; }
.p-tbl tbody tr:hover td { background: var(--p-bg); }
.p-tbl td strong { color: var(--p-text); font-weight: 600; }

/* ============================================================
   PLATFORM BADGES
============================================================ */
.p-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 100px;
  font-size: .68rem; font-weight: 700;
  letter-spacing: .02em; white-space: nowrap;
}
.p-badge::before {
  content: ''; width: 5px; height: 5px;
  border-radius: 50%; background: currentColor; opacity: .7; flex-shrink: 0;
}
.p-b-green  { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-bd); }
.p-b-blue   { background: var(--info-bg);    color: var(--info);    border: 1px solid var(--info-bd); }
.p-b-amber  { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-bd); }
.p-b-red    { background: var(--danger-bg);  color: var(--danger);  border: 1px solid var(--danger-bd); }
.p-b-gray   { background: #F3F4F6; color: #6B7280; border: 1px solid #E5E7EB; }
.p-b-purple { background: #F3E8FF; color: #7C3AED; border: 1px solid #E9D5FF; }
.p-b-navy   { background: var(--primary-light); color: var(--primary); border: 1px solid var(--primary-mid); }

/* ============================================================
   PLATFORM BUTTONS
============================================================ */
.p-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px;
  font-family: 'Inter', sans-serif; font-size: .8rem; font-weight: 600;
  cursor: pointer; border: 1px solid transparent; transition: all .15s ease;
  text-decoration: none; white-space: nowrap; line-height: 1.4;
  letter-spacing: .01em;
}
.p-btn:active { transform: scale(.97); }
.p-btn svg { width: 13px; height: 13px; flex-shrink: 0; }
.p-btn:disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }

.p-btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 1px 3px rgba(14,58,95,.2), 0 1px 2px rgba(14,58,95,.12);
}
.p-btn-primary:hover {
  background: #1a5080;
  border-color: #1a5080;
  box-shadow: 0 4px 12px rgba(14,58,95,.28);
  transform: translateY(-1px);
  color: #fff;
}

.p-btn-outline {
  background: var(--p-surface);
  border-color: var(--p-border);
  color: var(--p-text-2);
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.p-btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

/* Suspend / destructive solid button */
.p-btn-danger {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
  box-shadow: 0 1px 3px rgba(220,38,38,.25);
}
.p-btn-danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
  box-shadow: 0 4px 10px rgba(220,38,38,.28);
  transform: translateY(-1px);
  color: #fff;
}

/* Soft danger (used for less-destructive inline actions) */
.p-btn-danger-soft {
  background: var(--danger-bg);
  border-color: var(--danger-bd);
  color: var(--danger);
}
.p-btn-danger-soft:hover {
  background: #fee2e2;
  border-color: #f87171;
}

.p-btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--p-text-muted);
}
.p-btn-ghost:hover { background: var(--p-bg); color: var(--p-text); border-color: var(--p-border); }

.p-btn-success {
  background: var(--success-bg);
  border-color: var(--success-bd);
  color: var(--success);
}
.p-btn-success:hover { background: #d1fae5; border-color: #6ee7b7; }

.p-btn-warning {
  background: var(--warning-bg);
  border-color: var(--warning-bd);
  color: #92400e;
}
.p-btn-warning:hover { background: #fef3c7; }

/* Sizes */
.p-btn-sm {
  padding: 5px 12px;
  font-size: .75rem;
  border-radius: 7px;
  gap: 5px;
}
.p-btn-sm svg { width: 12px; height: 12px; }
.p-btn-lg { padding: 10px 20px; font-size: .875rem; border-radius: 9px; }
.p-btn-icon { padding: 7px; border-radius: 8px; }
.p-btn-block { width: 100%; justify-content: center; }

/* Loading state */
.p-btn-loading { pointer-events: none; }
.p-btn-loading::after {
  content: '';
  width: 12px; height: 12px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin .65s linear infinite;
  margin-left: 4px;
  display: inline-block;
}

/* ============================================================
   PLATFORM FORMS
============================================================ */
.p-form-group { margin-bottom: 16px; }
.p-form-label {
  display: block; font-size: .77rem; font-weight: 600;
  color: var(--p-text-2); margin-bottom: 6px; letter-spacing: .01em;
}
.p-form-label .required { color: var(--danger); margin-left: 2px; }
.p-form-control {
  width: 100%; padding: 9px 13px;
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: var(--radius);
  font-family: 'Inter', sans-serif;
  font-size: .875rem; color: var(--p-text);
  outline: none; transition: border-color .16s, box-shadow .16s;
}
.p-form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.p-form-control::placeholder { color: var(--p-text-faint); }
.p-form-control:disabled { background: var(--p-bg); color: var(--p-text-muted); cursor: not-allowed; }
select.p-form-control { cursor: pointer; }
textarea.p-form-control { resize: vertical; min-height: 80px; line-height: 1.6; }
.p-form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.p-form-row-2 { grid-template-columns: 1fr 1fr; }
.p-form-hint { font-size: .73rem; color: var(--p-text-muted); margin-top: 5px; }
.p-form-error { font-size: .73rem; color: var(--danger); margin-top: 5px; }
.p-input-group { display: flex; gap: 8px; }
.p-input-group .p-form-control { flex: 1; }

/* Switch (platform) */
.p-switch-label {
  display: flex; align-items: center; gap: 9px;
  cursor: pointer; font-size: .83rem; font-weight: 500; color: var(--p-text-2);
  user-select: none;
}
.p-switch { position: relative; width: 40px; height: 22px; flex-shrink: 0; }
.p-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.p-switch-track {
  position: absolute; inset: 0; background: #d1d5db;
  border-radius: 11px; transition: .22s;
}
.p-switch-track::before {
  content: ''; position: absolute;
  width: 16px; height: 16px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%;
  transition: .22s; box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.p-switch input:checked + .p-switch-track { background: var(--primary); }
.p-switch input:checked + .p-switch-track::before { transform: translateX(18px); }

/* ============================================================
   PLATFORM PAGINATION
============================================================ */
.p-pagination { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 18px; align-items: center; }
.p-page-link {
  padding: 6px 11px; border-radius: 7px;
  font-size: .78rem; font-weight: 500;
  border: 1px solid var(--p-border); color: var(--p-text-2);
  background: var(--p-surface); cursor: pointer; transition: all .14s;
  text-decoration: none;
}
.p-page-link:hover { border-color: var(--primary); color: var(--primary); }
.p-page-link.active {
  background: var(--primary); color: #fff; border-color: var(--primary);
  box-shadow: 0 2px 6px rgba(14,58,95,.22);
}
.p-page-link.disabled { opacity: .4; pointer-events: none; }
.p-page-info { font-size: .77rem; color: var(--p-text-muted); padding: 6px 8px; }

/* ============================================================
   PLATFORM EMPTY STATE
============================================================ */
.p-empty {
  text-align: center; padding: 52px 24px;
}
.p-empty-icon {
  width: 60px; height: 60px; border-radius: 16px;
  background: var(--p-bg); border: 1.5px dashed var(--p-border);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px; color: var(--p-text-faint);
}
.p-empty-icon svg { width: 26px; height: 26px; }
.p-empty-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: .95rem; font-weight: 800; color: var(--p-text); margin-bottom: 6px;
}
.p-empty p { font-size: .83rem; color: var(--p-text-muted); line-height: 1.6; max-width: 300px; margin: 0 auto; }

/* ============================================================
   PLATFORM ALERTS
============================================================ */
.p-alert {
  border-radius: var(--radius); padding: 12px 16px; font-size: .83rem;
  margin-bottom: 18px; display: flex; align-items: flex-start; gap: 10px; line-height: 1.55;
}
.p-alert svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 1px; }
.p-alert-success { background: var(--success-bg); border: 1px solid var(--success-bd); color: #065f46; }
.p-alert-danger  { background: var(--danger-bg);  border: 1px solid var(--danger-bd);  color: #991b1b; }
.p-alert-warning { background: var(--warning-bg); border: 1px solid var(--warning-bd); color: #92400e; }
.p-alert-info    { background: var(--info-bg);    border: 1px solid var(--info-bd);    color: #1e40af; }

/* ============================================================
   PLATFORM MODALS
============================================================ */
.p-modal-overlay {
  position: fixed; inset: 0; z-index: 800;
  background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; visibility: hidden; transition: all .22s;
}
.p-modal-overlay.show { opacity: 1; visibility: visible; }
.p-modal {
  background: var(--p-surface);
  border-radius: 18px;
  padding: 28px;
  width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 32px 80px rgba(0,0,0,.16);
  border: 1px solid var(--p-border);
  transform: scale(.96) translateY(8px); transition: transform .22s;
}
.p-modal-overlay.show .p-modal { transform: scale(1) translateY(0); }
.p-modal-sm  { max-width: 440px; }
.p-modal-lg  { max-width: 720px; }
.p-modal-xl  { max-width: 940px; }
.p-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px; padding-bottom: 14px;
  border-bottom: 1px solid var(--p-border-light);
}
.p-modal-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1rem; font-weight: 800; color: var(--p-text);
}
.p-modal-subtitle { font-size: .78rem; color: var(--p-text-muted); margin-top: 2px; }
.p-modal-close {
  width: 30px; height: 30px; border-radius: 7px;
  background: var(--p-bg); border: 1px solid var(--p-border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--p-text-muted); transition: all .16s; flex-shrink: 0;
}
.p-modal-close:hover { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-bd); }
.p-modal-close svg { width: 13px; height: 13px; }
.p-modal-body { margin-bottom: 22px; }
.p-modal-footer {
  display: flex; gap: 10px; justify-content: flex-end;
  padding-top: 16px; border-top: 1px solid var(--p-border-light);
}

/* ============================================================
   PLATFORM TOASTS
============================================================ */
.p-toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 1000; pointer-events: none;
}
.p-toast {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px;
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,.12);
  min-width: 300px; max-width: 400px;
  pointer-events: all;
  animation: toastIn .28s ease both;
  border-left-width: 3px;
}
.p-toast.closing { animation: toastOut .22s ease both; }
.p-toast.success { border-left-color: var(--success); }
.p-toast.error   { border-left-color: var(--danger); }
.p-toast.warning { border-left-color: var(--warning); }
.p-toast.info    { border-left-color: var(--info); }
.p-toast-icon { flex-shrink: 0; margin-top: 1px; }
.p-toast-icon svg { width: 15px; height: 15px; }
.p-toast.success .p-toast-icon { color: var(--success); }
.p-toast.error   .p-toast-icon { color: var(--danger); }
.p-toast.warning .p-toast-icon { color: var(--warning); }
.p-toast.info    .p-toast-icon { color: var(--info); }
.p-toast-content { flex: 1; min-width: 0; }
.p-toast-title   { font-size: .84rem; font-weight: 700; color: var(--p-text); margin-bottom: 2px; }
.p-toast-msg { font-size: .79rem; color: var(--p-text-muted); line-height: 1.5; }
.p-toast-close { cursor: pointer; color: var(--p-text-faint); transition: color .16s; flex-shrink: 0; }
.p-toast-close:hover { color: var(--p-text); }
.p-toast-close svg { width: 13px; height: 13px; }

/* ============================================================
   PLATFORM FILTER TABS
============================================================ */
.p-filter-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.p-filter-tab {
  padding: 6px 14px; border-radius: 8px; font-size: .77rem; font-weight: 600;
  border: 1px solid var(--p-border); color: var(--p-text-muted);
  background: var(--p-surface); cursor: pointer; transition: all .15s;
  text-decoration: none;
}
.p-filter-tab:hover { background: var(--p-bg); color: var(--p-text); }
.p-filter-tab.active {
  background: var(--primary-light);
  border-color: var(--primary-mid);
  color: var(--primary);
}

/* ============================================================
   PLATFORM SEARCH INPUT
============================================================ */
.p-search-wrap { position: relative; display: inline-flex; align-items: center; }
.p-search-wrap svg {
  position: absolute; left: 11px;
  color: var(--p-text-faint); width: 14px; height: 14px; pointer-events: none;
}
.p-search-input {
  padding: 8px 12px 8px 34px;
  background: var(--p-surface); border: 1px solid var(--p-border);
  border-radius: var(--radius); font-family: 'Inter', sans-serif;
  font-size: .82rem; color: var(--p-text); outline: none; transition: all .16s;
  min-width: 220px;
}
.p-search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.p-search-input::placeholder { color: var(--p-text-faint); }

/* ============================================================
   PLATFORM DETAIL ROWS
============================================================ */
.p-detail-row { display: flex; padding: 10px 0; border-bottom: 1px solid var(--p-border-light); }
.p-detail-row:last-child { border-bottom: none; }
.p-detail-lbl { font-size: .77rem; color: var(--p-text-muted); width: 38%; flex-shrink: 0; }
.p-detail-val { font-size: .83rem; color: var(--p-text-2); font-weight: 500; flex: 1; }

/* ============================================================
   PLATFORM TIMELINE
============================================================ */
.p-timeline { display: flex; flex-direction: column; }
.p-timeline-item {
  display: flex; gap: 14px; padding: 14px 0;
  border-bottom: 1px solid var(--p-border-light);
}
.p-timeline-item:last-child { border-bottom: none; }
.p-timeline-dot {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-light); border: 1px solid var(--primary-mid);
  margin-top: 2px;
}
.p-timeline-dot svg { width: 13px; height: 13px; color: var(--primary); }
.p-timeline-content { flex: 1; min-width: 0; }
.p-timeline-action { font-size: .83rem; font-weight: 600; color: var(--p-text); }
.p-timeline-desc { font-size: .78rem; color: var(--p-text-muted); margin-top: 2px; line-height: 1.55; }
.p-timeline-meta {
  font-size: .71rem; color: var(--p-text-faint); margin-top: 4px;
  display: flex; gap: 12px; flex-wrap: wrap;
}

/* ============================================================
   STATUS BREAKDOWN CHIPS
============================================================ */
.p-status-chips { display: flex; flex-wrap: wrap; gap: 10px; }
.p-status-chip {
  display: flex; flex-direction: column; align-items: center;
  padding: 14px 18px; border-radius: 12px;
  background: var(--p-surface); border: 1px solid var(--p-border);
  min-width: 88px; transition: all .18s; cursor: default;
}
.p-status-chip:hover { box-shadow: var(--shadow); border-color: var(--p-text-faint); }
.p-status-chip-num {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1.5rem; font-weight: 900; color: var(--p-text); line-height: 1;
}
.p-status-chip-lbl { font-size: .65rem; color: var(--p-text-muted); margin-top: 5px; text-align: center; }

/* ============================================================
   PLAN CARDS
============================================================ */
.p-plan-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; margin-bottom: 24px; }
.p-plan-card {
  background: var(--p-surface); border: 1px solid var(--p-border);
  border-radius: 14px; padding: 22px; transition: all .2s;
  position: relative;
}
.p-plan-card:hover { box-shadow: var(--shadow-md); border-color: var(--primary-mid); }
.p-plan-card.featured { border-color: var(--primary-mid); }
.p-plan-card.featured::before {
  content: 'Featured'; position: absolute; top: -1px; right: 14px;
  background: var(--primary); color: #fff;
  font-size: .6rem; font-weight: 800; letter-spacing: .06em;
  padding: 3px 10px; border-radius: 0 0 8px 8px;
}
.p-plan-name {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1rem; font-weight: 800; color: var(--p-text); margin-bottom: 6px;
}
.p-plan-price {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1.6rem; font-weight: 900; color: var(--p-text);
  line-height: 1; margin: 10px 0; letter-spacing: -.03em;
}
.p-plan-price span { font-size: .82rem; font-weight: 500; color: var(--p-text-muted); }
.p-plan-meta { font-size: .75rem; color: var(--p-text-muted); line-height: 1.7; }

/* ============================================================
   PLATFORM SETTINGS TABS
============================================================ */
.p-settings-tabs {
  display: flex; gap: 0; flex-wrap: nowrap;
  overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--p-border);
  padding-bottom: 0; background: var(--p-surface);
}
.p-settings-tabs::-webkit-scrollbar { display: none; }
.p-settings-tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 11px 16px; font-size: .8rem; font-weight: 600;
  color: var(--p-text-muted); cursor: pointer; transition: all .15s;
  text-decoration: none; border: none; background: transparent;
  font-family: 'Inter', sans-serif;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px; white-space: nowrap; flex-shrink: 0;
}
.p-settings-tab:hover { color: var(--p-text-2); }
.p-settings-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.p-settings-tab svg { width: 14px; height: 14px; flex-shrink: 0; }

/* Tab panel show/hide */
.p-tab-panel { display: none; }
.p-tab-panel.active { display: block; }

/* ============================================================
   MESSAGE CARDS
============================================================ */
.p-msg-card {
  background: var(--p-surface); border: 1px solid var(--p-border);
  border-radius: 12px; padding: 18px; margin-bottom: 10px;
  transition: all .18s;
}
.p-msg-card:hover { box-shadow: var(--shadow); border-color: var(--p-text-faint); }
.p-msg-card.msg-new { border-left: 3px solid var(--info); }
.p-msg-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 10px; margin-bottom: 8px;
}
.p-msg-sender { font-size: .88rem; font-weight: 700; color: var(--p-text); }
.p-msg-email { font-size: .74rem; color: var(--p-text-muted); }
.p-msg-subject { font-size: .85rem; font-weight: 600; color: var(--p-text-2); margin-bottom: 5px; }
.p-msg-preview {
  font-size: .8rem; color: var(--p-text-muted); line-height: 1.6;
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}
.p-msg-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 12px; flex-wrap: wrap; gap: 8px;
}
.p-msg-date { font-size: .72rem; color: var(--p-text-faint); }

/* ============================================================
   MINI BARS (inline sparkline)
============================================================ */
.p-mini-bars { display: flex; align-items: flex-end; gap: 3px; height: 40px; }
.p-mini-bar {
  flex: 1; border-radius: 3px 3px 0 0; min-width: 4px;
  background: var(--primary-light);
  transition: background .18s;
}
.p-mini-bar:hover { background: var(--primary); }

/* ============================================================
   QUICK METRICS ROW
============================================================ */
.p-metrics-row { display: flex; flex-direction: column; gap: 8px; }
.p-metric-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-radius: 10px;
  background: var(--p-bg); border: 1px solid var(--p-border);
}
.p-metric-label { font-size: .82rem; font-weight: 600; color: var(--p-text-2); }
.p-metric-sub { font-size: .72rem; color: var(--p-text-muted); margin-top: 1px; }
.p-metric-val {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1.1rem; font-weight: 800;
}

/* ============================================================
   RESPONSIVE
============================================================ */
@media (max-width: 1024px) {
  .p-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
    z-index: 200;
    height: 100vh;
  }
  .p-sidebar.open { transform: translateX(0); }
  .p-menu-btn { display: flex !important; }
  .p-view-site { display: none; }
}

@media (max-width: 768px) {
  .p-content { padding: 16px; }
  .p-topbar { padding: 0 16px; }
  .p-stat-grid { grid-template-columns: 1fr 1fr; }
  .p-form-row, .p-form-row-2 { grid-template-columns: 1fr; }
  .p-plan-grid { grid-template-columns: 1fr; }
  .p-modal { padding: 20px; }
  .p-settings-tab span { display: none; }
}

@media (max-width: 480px) {
  .p-stat-grid { grid-template-columns: 1fr; }
  .p-page-title { font-size: 1.15rem; }
}

/* ============================================================
   UTILITY CLASSES
============================================================ */
.p-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.p-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
@media (max-width: 768px) {
  .p-grid-2, .p-grid-3 { grid-template-columns: 1fr; }
}
.p-text-muted { color: var(--p-text-muted); }
.p-text-small { font-size: .78rem; }
.p-text-tiny  { font-size: .72rem; }
.p-fw-600 { font-weight: 600; }
.p-fw-700 { font-weight: 700; }
.p-truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ============================================================
   PLATFORM DROPDOWNS
   (app.css not loaded on platform pages — define here)
============================================================ */
.dropdown { position: relative; display: inline-block; }

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0,0,0,.10);
  min-width: 190px;
  z-index: 400;
  padding: 6px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity .16s ease, transform .16s ease, visibility .16s;
  pointer-events: none;
}
.dropdown-menu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

/* Left-opening variant — opens to the left instead of right */
.dropdown-menu-left {
  right: auto;
  left: 0;
}

/* For table rows at the right edge, always open left-anchored to button */
.col-shrink .dropdown-menu {
  right: 0;
  left: auto;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: .82rem;
  font-weight: 500;
  color: var(--p-text-2);
  cursor: pointer;
  transition: background .14s, color .14s;
  text-decoration: none;
  white-space: nowrap;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  font-family: 'Inter', sans-serif;
}
.dropdown-item:hover {
  background: var(--p-bg);
  color: var(--primary);
}
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: var(--danger-bg); color: var(--danger); }

/* SVG icons inside dropdown items — must be constrained */
.dropdown-item svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: .65;
}
.dropdown-item:hover svg { opacity: 1; }
.dropdown-item.danger svg { opacity: .8; }

.dropdown-sep {
  height: 1px;
  background: var(--p-border-light);
  margin: 5px 6px;
}

/* Button inside dropdown trigger */
.dropdown > .p-btn svg,
.dropdown > button svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

/* Platform topbar user pill dropdown */
.p-topbar-right .dropdown-menu {
  min-width: 170px;
}

/* ============================================================
   ANIMATIONS
============================================================ */
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px) scale(.95); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0) scale(1); }
  to   { opacity: 0; transform: translateX(20px) scale(.95); }
}

/* ============================================================
   SIDEBAR — improved active state + hover polish
============================================================ */
.p-nav {
  padding: 6px 10px;
}
.p-nav-item {
  padding: 7px 10px; border-radius: 7px;
  font-size: .82rem;
}
.p-nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}
.p-nav-item.active::before {
  left: -10px;
}

/* ============================================================
   PAGE HEADER — action button group
============================================================ */
.p-page-actions {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}

/* ============================================================
   STAT CARDS — tighter refinement
============================================================ */
.p-stat-card {
  border-radius: 12px;
  padding: 18px 20px;
}
.p-stat-icon {
  width: 40px; height: 40px; border-radius: 10px;
}
.p-stat-icon svg { width: 18px; height: 18px; }
.p-stat-info .val {
  font-size: 1.7rem;
}

/* ============================================================
   CARDS — subtle improvements
============================================================ */
.p-card {
  border-radius: 12px;
  padding: 20px 22px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.p-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}

/* ============================================================
   CUSTOMER VIEW — tab content spacing
============================================================ */
.p-tab-content {
  padding-top: 20px;
}

/* ============================================================
   ENTITY HEADER — responsive
============================================================ */
@media (max-width: 768px) {
  .p-entity-header { padding: 16px 16px 0; border-radius: 10px; }
  .p-entity-title { font-size: 1.15rem; }
  .p-entity-actions { width: 100%; }
  .p-entity-tab { padding: 10px 12px; font-size: .76rem; }
  .p-settings-tab { padding: 10px 12px; font-size: .76rem; }
  .p-content { padding: 16px 16px 32px; }
}
@media (max-width: 480px) {
  .p-entity-title { font-size: 1.05rem; }
  .p-btn-sm { padding: 5px 10px; font-size: .72rem; }
}

/* ============================================================
   IMPROVED DROPDOWNS — slightly tighter
============================================================ */
.dropdown-menu {
  border-radius: 10px;
  box-shadow: 0 4px 24px rgba(0,0,0,.1), 0 1px 4px rgba(0,0,0,.06);
  padding: 5px;
}
.dropdown-item {
  border-radius: 7px;
  padding: 8px 11px;
  font-size: .81rem;
}

/* ============================================================
   TABLE — small enhancements
============================================================ */
.p-tbl th {
  font-size: .67rem;
  letter-spacing: .08em;
  padding: 9px 14px;
  background: #F8FAFC;
}
.p-tbl td { padding: 11px 14px; }

/* ============================================================
   DETAIL ROW — better label contrast
============================================================ */
.p-detail-lbl {
  font-weight: 500;
  font-size: .76rem;
  color: var(--p-text-muted);
  min-width: 130px;
}
.p-detail-val {
  font-size: .84rem;
  color: var(--p-text-2);
}

/* ============================================================
   SETTINGS TABS — in context of entity header (no card)
============================================================ */
.p-entity-header .p-settings-tabs {
  margin-bottom: 0;
  border-bottom: none;
  background: transparent;
}

/* ============================================================
   MISC POLISH
============================================================ */
/* Give modal close button keyboard focus ring */
.p-modal-close:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
/* Better form focus ring */
.p-form-control:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
/* Badge size variants */
.p-badge-sm {
  font-size: .64rem; padding: 2px 7px;
}
/* Separator */
.p-divider {
  height: 1px; background: var(--p-border); margin: 16px 0;
}

/* ============================================================
   ENTITY HEADER — tab row border fix
   The entity header card provides the bottom border for tabs.
============================================================ */
.p-entity-header {
  /* ensure the tab underlines align flush with the card bottom */
  overflow: hidden;
}
.p-entity-header > .p-settings-tabs {
  /* border-bottom is on the card, tabs sit inside it */
  border-bottom: 1px solid var(--p-border);
  margin-left: -24px;
  margin-right: -24px;
  padding-left: 24px;
  padding-right: 24px;
}
@media (max-width: 768px) {
  .p-entity-header > .p-settings-tabs {
    margin-left: -16px;
    margin-right: -16px;
    padding-left: 16px;
    padding-right: 16px;
  }
}


/* ============================================================
   MOBILE RESPONSIVE — platform.css additions
   All rules inside @media queries. Desktop unchanged.
   ============================================================ */

/* ── Overflow base ── */
@media (max-width: 767px) {
  .p-root { overflow-x: hidden; }
  .p-main { overflow-x: hidden; min-width: 0; }
}

/* ── Sidebar: off-canvas drawer ── */
@media (max-width: 1023px) {
  .p-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    height: 100vh;
    transform: translateX(-100%);
    z-index: 300;
    transition: transform 0.26s ease, box-shadow 0.26s ease;
  }
  .p-sidebar.open {
    transform: translateX(0);
    box-shadow: 6px 0 28px rgba(0,0,0,0.18);
  }
  .p-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.42);
    z-index: 290;
    cursor: pointer;
  }
  .p-overlay.show { display: block; }
  .p-menu-btn { display: flex !important; }
  /* Main area takes full width */
  .p-main { width: 100%; }
}

/* ── Topbar ── */
@media (max-width: 767px) {
  .p-topbar { padding: 0 12px; gap: 8px; }
  .p-topbar-left { min-width: 0; flex: 1; }

  /* Truncate long breadcrumb pages */
  .p-breadcrumb-page {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .p-topbar-right { gap: 4px; flex-shrink: 0; }
  .p-view-site   { display: none; }

  /* "New Customer" button: icon only on small screens */
  .p-topbar-right .p-btn-primary .p-btn-label {
    display: none;
  }
  .p-admin-pill-name {
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (max-width: 374px) {
  .p-topbar { padding: 0 10px; }
  .p-breadcrumb-page { max-width: 72px; }
  .p-topbar-btn { width: 30px; height: 30px; }
  .p-topbar-btn svg { width: 13px; height: 13px; }
}

/* Safe-area insets */
@supports (padding: env(safe-area-inset-left)) {
  @media (max-width: 767px) {
    .p-topbar {
      padding-left:  max(12px, env(safe-area-inset-left));
      padding-right: max(12px, env(safe-area-inset-right));
    }
    .p-sidebar {
      padding-left:  env(safe-area-inset-left);
      padding-bottom: env(safe-area-inset-bottom);
    }
    .p-content {
      padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }
  }
}

/* ── Page content ── */
@media (max-width: 767px) {
  .p-content { padding: 12px 12px 32px; overflow-x: hidden; }
  .p-page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
  }
  .p-page-title { font-size: 1.1rem; letter-spacing: -0.02em; }
  .p-page-sub   { font-size: 0.76rem; }
  .p-page-actions { width: 100%; flex-wrap: wrap; gap: 6px; }
  .p-page-actions .p-btn { flex-shrink: 0; }
}

@media (max-width: 374px) {
  .p-content { padding: 10px 10px 24px; }
  .p-page-title { font-size: 1rem; }
}

/* ── Stat cards ── */
@media (max-width: 767px) {
  .p-stat-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 14px;
  }
  .p-stat-card {
    padding: 14px 10px;
    gap: 10px;
    border-radius: 10px;
  }
  .p-stat-icon { width: 36px; height: 36px; border-radius: 9px; }
  .p-stat-icon svg { width: 16px; height: 16px; }
  .p-stat-info .val { font-size: 1.4rem; }
  .p-stat-info .lbl { font-size: 0.7rem; }
  .p-stat-info .sub { font-size: 0.68rem; }
}

@media (max-width: 374px) {
  .p-stat-grid { grid-template-columns: 1fr; }
}

/* ── Grid utilities ── */
@media (max-width: 767px) {
  .p-grid-2,
  .p-grid-3 {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }
}

/* ── Cards ── */
@media (max-width: 767px) {
  .p-card { padding: 14px 12px; border-radius: 10px; margin-bottom: 12px; }
  .p-card-header {
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
  }
  .p-card-title { font-size: 0.84rem; }
  .p-card-title svg { width: 13px; height: 13px; }
}

/* ── Tables ── */
@media (max-width: 767px) {
  .p-tbl-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
    /* Scroll-shadow hint */
    background:
      linear-gradient(to right, white 20%, rgba(255,255,255,0)),
      linear-gradient(to left,  white 20%, rgba(255,255,255,0)) 100% 0,
      radial-gradient(farthest-side at 0%   50%, rgba(0,0,0,.06), transparent),
      radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.06), transparent) 100% 0;
    background-repeat: no-repeat;
    background-color: white;
    background-size: 30px 100%, 30px 100%, 10px 100%, 10px 100%;
    background-attachment: local, local, scroll, scroll;
  }
  .p-tbl {
    min-width: 480px; /* forces horizontal scroll rather than squishing */
    font-size: 0.79rem;
  }
  .p-tbl th { padding: 8px 10px; font-size: 0.63rem; }
  .p-tbl td { padding: 10px 10px; font-size: 0.78rem; }
  .col-shrink { white-space: nowrap; }
}

/* ── Modals: bottom-sheet on mobile ── */
@media (max-width: 767px) {
  .p-modal-overlay {
    padding: 0;
    align-items: flex-end;
  }
  .p-modal {
    border-radius: 18px 18px 0 0 !important;
    max-width: 100% !important;
    max-height: 92vh;
    width: 100%;
    padding: 18px 16px;
  }
  .p-modal-header { margin-bottom: 16px; padding-bottom: 12px; }
  .p-modal-title  { font-size: 0.94rem; }
  .p-modal-body   { margin-bottom: 16px; }
  .p-modal-footer {
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 14px;
  }
  .p-modal-footer .p-btn {
    flex: 1;
    justify-content: center;
    min-width: 90px;
  }
}

/* Landscape: center modals */
@media (max-width: 767px) and (orientation: landscape) {
  .p-modal-overlay { align-items: center; padding: 12px; }
  .p-modal { border-radius: 14px !important; max-height: 88vh; }
}

/* ── Forms ── */
@media (max-width: 767px) {
  .p-form-row,
  .p-form-row-2 { grid-template-columns: 1fr !important; gap: 12px; }
  .p-form-group { margin-bottom: 12px; }
  .p-form-control { font-size: 0.85rem; }
  .p-input-group { flex-direction: column; gap: 8px; }
  .p-input-group .p-form-control { width: 100%; }
  .p-input-group .p-btn { width: 100%; justify-content: center; }
  .p-form-row[style*="repeat(auto-fit"] { grid-template-columns: 1fr !important; }
}

/* ── Filter tabs & search ── */
@media (max-width: 767px) {
  .p-filter-tabs { flex-wrap: wrap; gap: 4px; }
  .p-filter-tab  { padding: 5px 10px; font-size: 0.72rem; }
  .p-search-wrap { width: 100%; }
  .p-search-input { min-width: 0; width: 100%; }
}

/* ── Settings & entity tabs ── */
@media (max-width: 767px) {
  .p-settings-tabs {
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .p-settings-tabs::-webkit-scrollbar { display: none; }
  .p-settings-tab { padding: 10px 12px; font-size: 0.74rem; }

  .p-entity-header { padding: 14px 14px 0; border-radius: 10px; }
  .p-entity-title  { font-size: 1.05rem; }
  .p-entity-sub    { font-size: 0.74rem; gap: 5px; }
  .p-entity-actions { width: 100%; justify-content: flex-start; }
  .p-entity-tab    { padding: 10px 12px; font-size: 0.74rem; }
}

/* ── Pagination ── */
@media (max-width: 767px) {
  .p-pagination { justify-content: center; gap: 4px; }
  .p-page-link  { padding: 5px 9px; font-size: 0.74rem; }
  .p-page-info  { width: 100%; text-align: center; }
}

/* ── Status chips ── */
@media (max-width: 767px) {
  .p-status-chips { gap: 8px; }
  .p-status-chip  { padding: 10px 12px; min-width: 68px; border-radius: 10px; }
  .p-status-chip-num { font-size: 1.2rem; }
  .p-status-chip-lbl { font-size: 0.59rem; }
}

/* ── Metrics row ── */
@media (max-width: 767px) {
  .p-metric-item  { padding: 9px 10px; }
  .p-metric-label { font-size: 0.77rem; }
  .p-metric-val   { font-size: 0.94rem; }
}

/* ── Plan grid ── */
@media (max-width: 767px) {
  .p-plan-grid { grid-template-columns: 1fr; gap: 12px; }
  .p-plan-card { padding: 18px 16px; border-radius: 12px; }
  .p-plan-name  { font-size: 0.92rem; }
  .p-plan-price { font-size: 1.4rem; }
}

/* ── Detail rows ── */
@media (max-width: 480px) {
  .p-detail-row { flex-direction: column; gap: 2px; padding: 10px 0; }
  .p-detail-lbl { width: 100%; min-width: 0; font-size: 0.7rem; }
  .p-detail-val { font-size: 0.81rem; }
}

/* ── Timeline ── */
@media (max-width: 767px) {
  .p-timeline-item { gap: 10px; padding: 12px 0; }
  .p-timeline-dot  { width: 26px; height: 26px; }
  .p-timeline-dot svg { width: 11px; height: 11px; }
  .p-timeline-action { font-size: 0.8rem; }
  .p-timeline-desc   { font-size: 0.74rem; }
  .p-timeline-meta   { font-size: 0.67rem; gap: 8px; }
}

/* ── Toast ── */
@media (max-width: 767px) {
  .p-toast-container {
    bottom: 12px;
    right: 10px;
    left: 10px;
  }
  .p-toast { min-width: 0; max-width: 100%; border-radius: 12px; }
}

/* ── Alerts ── */
@media (max-width: 767px) {
  .p-alert { padding: 10px 12px; font-size: 0.8rem; border-radius: 8px; }
}

/* ── Breadcrumb ── */
@media (max-width: 767px) {
  .p-breadcrumb { min-width: 0; overflow: hidden; }
  .p-breadcrumb-root { font-size: 0.74rem; }
  .p-breadcrumb-sep svg { width: 10px; height: 10px; }
  .p-breadcrumb-page { font-size: 0.74rem; }
}

/* ── Buttons: readable tap targets ── */
@media (max-width: 767px) {
  .p-btn { font-size: 0.79rem; }
  .p-btn-sm { padding: 6px 11px; font-size: 0.72rem; }
  /* Icon-only buttons: minimum 36px touch target */
  .p-btn-icon { min-width: 36px; min-height: 36px; }
  /* Dropdown items: more breathing room */
  .dropdown-item { padding: 10px 12px; font-size: 0.82rem; }
}

/* ── User card in sidebar footer ── */
@media (max-width: 1023px) {
  .p-user-card { padding: 8px 10px; }
  .p-user-name { font-size: 0.76rem; }
  .p-user-role { font-size: 0.6rem; }
}

/* ── "View public site" link inside nav ── */
@media (max-width: 1023px) {
  .p-nav > div:last-of-type a { font-size: 0.74rem; }
}

/* ── Overflow & text safety ── */
@media (max-width: 767px) {
  .p-root p,
  .p-root td,
  .p-root th,
  .p-root li {
    overflow-wrap: break-word;
    word-wrap: break-word;
  }
  canvas { max-width: 100% !important; }
}

/* ── 320px extreme small screens ── */
@media (max-width: 320px) {
  .p-content { padding: 8px 8px 20px; }
  .p-page-title { font-size: 0.95rem; }
  .p-stat-grid { grid-template-columns: 1fr; }
  .p-card { padding: 12px 10px; }
  .p-btn { font-size: 0.75rem; padding: 7px 10px; }
  .p-btn-sm { font-size: 0.68rem; padding: 5px 8px; }
  .p-topbar { padding: 0 8px; }
}

/* ============================================================
   BRANDING — Logo image in platform sidebar & public nav
   Added by: Branding Settings feature
============================================================ */

/* Platform admin sidebar logo image */
.p-brand-logo {
  width: var(--logo-w-desk, 180px);
  max-height: var(--logo-h-desk, 60px);
  object-fit: contain;
  flex-shrink: 0;
  display: block;
}

/* Public site nav logo image */
.nav-logo-image {
  width: var(--logo-w-desk, 180px);
  max-height: var(--logo-h-desk, 60px);
  object-fit: contain;
  flex-shrink: 0;
  display: block;
}

/* On mobile, switch to mobile dimensions */
@media (max-width: 767px) {
  .p-brand-logo {
    width: var(--logo-w-mob, 130px);
    max-height: var(--logo-h-mob, 44px);
  }
  .nav-logo-image {
    width: var(--logo-w-mob, 130px);
    max-height: var(--logo-h-mob, 44px);
  }
}

/* Ensure the p-brand wrapper doesn't clip the logo image */
.p-brand {
  overflow: visible;
}

/* When a logo image is shown, give the brand row a little breathing room */
.p-brand:has(.p-brand-logo) {
  gap: 10px;
  padding: 8px 16px;
  height: auto;
  min-height: var(--p-topbar-h, 60px);
}

/* Branding settings page upload zone */
.branding-upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  border: 2px dashed var(--p-border);
  border-radius: 12px;
  background: var(--p-bg);
  cursor: pointer;
  transition: border-color .18s, background .18s;
  text-align: center;
}
.branding-upload-zone:hover,
.branding-upload-zone:focus-within {
  border-color: var(--primary);
  background: var(--primary-light);
}
.branding-upload-zone svg {
  width: 32px;
  height: 32px;
  opacity: .4;
  margin-bottom: 10px;
  color: var(--p-text-muted);
}
.branding-upload-zone p {
  margin: 0;
  font-size: .82rem;
  color: var(--p-text-muted);
  line-height: 1.5;
}
