:root{
  --bg:#0f172a; --side:#111827; --side-hover:#1f2937; --accent:#6366f1; --accent2:#8b5cf6;
  --text:#e5e7eb; --muted:#9ca3af; --card:#ffffff; --body:#f3f4f6; --border:#e5e7eb;
  --card-text:#1f2937; --shadow:0 6px 24px rgba(0,0,0,.06);
}
[data-theme="dark"]{
  --body:#0b1120; --card:#111827; --border:#1f2937; --card-text:#e5e7eb; --muted:#94a3b8;
  --shadow:0 6px 24px rgba(0,0,0,.4);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', system-ui, sans-serif; background: var(--body); color: var(--card-text); transition: background .3s, color .3s; }
a { text-decoration: none; }

/* Layout */
.p-layout { display: flex; min-height: 100vh; }
.p-sidebar {
  width: 262px; background: linear-gradient(180deg,#0f172a,#1e1b4b); color: var(--text);
  display: flex; flex-direction: column; position: fixed; height: 100vh; transition: .3s; z-index: 100;
}
.p-sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 22px 20px; font-size: 19px; font-weight: 700; color: #fff; border-bottom: 1px solid rgba(255,255,255,.08); }
.p-sidebar-brand i { color: var(--accent); font-size: 22px; }
.p-sidebar-nav { padding: 14px 12px; overflow-y: auto; flex: 1; }
.p-nav-group { margin-bottom: 8px; }
.p-nav-group-label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); padding: 8px 14px 4px; opacity: .7; }
.p-sidebar-nav .p-nav-link { display: flex; align-items: center; gap: 12px; padding: 11px 14px; color: var(--muted); border-radius: 10px; margin-bottom: 4px; font-size: 14.5px; transition: .2s; }
.p-sidebar-nav .p-nav-link i { font-size: 18px; }
.p-sidebar-nav .p-nav-link:hover { background: var(--side-hover); color: #fff; }
.p-sidebar-nav .p-nav-link.active { background: linear-gradient(90deg,var(--accent),var(--accent2)); color: #fff; box-shadow: 0 4px 14px rgba(99,102,241,.4); }
.p-nav-badge { margin-left: auto; background: var(--accent); color: #fff; border-radius: 20px; font-size: 11px; padding: 2px 8px; }

.p-main { flex: 1; margin-left: 262px; transition: .3s; display: flex; flex-direction: column; min-height: 100vh; }
.p-topbar { height: 66px; background: var(--card); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 16px; padding: 0 20px; position: sticky; top: 0; z-index: 50; }
.p-btn-toggle { border: none; background: transparent; font-size: 22px; cursor: pointer; color: var(--card-text); }
.p-topbar-title { font-size: 18px; font-weight: 700; }
.p-topbar-right { display: flex; align-items: center; gap: 14px; margin-left: auto; }
.p-wallet-chip { background: linear-gradient(135deg,#10b981,#059669); color: #fff; padding: 6px 14px; border-radius: 20px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.p-commission-chip { background: rgba(99,102,241,.12); color: var(--accent); padding: 6px 14px; border-radius: 20px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.p-ref-chip { background: var(--body); border: 1px solid var(--border); color: var(--card-text); padding: 6px 12px; border-radius: 20px; font-size: 12px; display: flex; align-items: center; gap: 8px; cursor: pointer; max-width: 280px; }
.p-ref-chip input { border: none; background: transparent; outline: none; width: 200px; font-size: 12px; color: var(--card-text); }

.p-content { padding: 26px; flex: 1; }
.p-page-title { font-size: 22px; font-weight: 700; margin-bottom: 18px; display: flex; align-items: center; gap: 10px; }

/* Cards */
.p-card { background: var(--card); border-radius: 16px; padding: 22px; box-shadow: var(--shadow); border: 1px solid var(--border); margin-bottom: 22px; }
.p-card-title { font-size: 16px; font-weight: 700; margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }
.p-card-title i { color: var(--accent); }

.p-stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 18px; margin-bottom: 24px; }
.p-stat { border-radius: 16px; padding: 20px; color: #fff; box-shadow: 0 8px 20px rgba(99,102,241,.25); position: relative; overflow: hidden; }
.p-stat.indigo { background: linear-gradient(135deg,#6366f1,#8b5cf6); }
.p-stat.green { background: linear-gradient(135deg,#10b981,#059669); }
.p-stat.orange { background: linear-gradient(135deg,#f59e0b,#d97706); }
.p-stat.red { background: linear-gradient(135deg,#ef4444,#dc2626); }
.p-stat.blue { background: linear-gradient(135deg,#3b82f6,#2563eb); }
.p-stat.teal { background: linear-gradient(135deg,#14b8a6,#0d9488); }
.p-stat .p-stat-label { font-size: 13px; opacity: .9; }
.p-stat .p-stat-value { font-size: 28px; font-weight: 800; margin-top: 6px; }
.p-stat .p-stat-icon { position: absolute; right: 14px; top: 14px; font-size: 26px; opacity: .35; }

.p-graph-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 18px; margin-bottom: 24px; }

/* Tables */
.p-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.p-table thead th { background: rgba(99,102,241,.06); text-align: left; padding: 12px 14px; font-size: 12.5px; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--border); }
.p-table th:first-child { border-top-left-radius: 10px; }
.p-table th:last-child { border-top-right-radius: 10px; }
.p-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 14px; }
.p-table tbody tr:hover td { background: rgba(99,102,241,.03); }
.p-table-wrap { width: 100%; overflow: auto; max-height: 70vh; }

/* Badges */
.p-badge { padding: 4px 11px; border-radius: 20px; font-size: 12px; font-weight: 600; display: inline-block; }
.p-badge.active, .p-badge.approved, .p-badge.completed { background: #dcfce7; color: #166534; }
.p-badge.pending { background: #fef9c3; color: #854d0e; }
.p-badge.rejected, .p-badge.canceled { background: #fee2e2; color: #991b1b; }
.p-badge.info, .p-badge.published { background: #dbeafe; color: #1e40af; }
.p-badge.draft { background: #e5e7eb; color: #374151; }

/* Buttons / forms */
.p-btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 10px; border: 1px solid transparent; font-size: 14px; font-weight: 600; cursor: pointer; transition: .2s; }
.p-btn-primary { background: var(--accent); color: #fff; }
.p-btn-primary:hover { background: #4f46e5; }
.p-btn-success { background: #10b981; color: #fff; }
.p-btn-danger { background: #ef4444; color: #fff; }
.p-btn-outline { background: transparent; border: 1px solid var(--border); color: var(--card-text); }
.p-btn-sm { padding: 6px 12px; font-size: 13px; }
.p-input, .p-select, .p-textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px; outline: none; background: var(--card); color: var(--card-text); }
.p-input:focus, .p-select:focus, .p-textarea:focus { border-color: var(--accent); }
.p-textarea { min-height: 90px; resize: vertical; }

/* Notifications dropdown */
.p-dropdown { position: relative; }
.p-dropdown-menu { position: absolute; right: 0; top: 50px; width: 320px; background: var(--card); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: 8px; display: none; z-index: 200; max-height: 420px; overflow: auto; }
.p-dropdown-menu.show { display: block; }
.p-notif-item { display: flex; gap: 10px; padding: 10px; border-radius: 10px; }
.p-notif-item:hover { background: rgba(99,102,241,.06); }
.p-notif-item.unread { background: rgba(99,102,241,.08); }
.p-notif-ico { font-size: 20px; }
.p-notif-title { font-weight: 600; font-size: 13.5px; }
.p-notif-msg { font-size: 12.5px; color: var(--muted); }
.p-notif-time { font-size: 11px; color: var(--muted); }
.p-profile { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.p-avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; border: 2px solid var(--accent); }
.p-avatar-txt { width: 38px; height: 38px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; }

.p-row { display: flex; flex-wrap: wrap; gap: 18px; }
.p-col { flex: 1; min-width: 300px; }
.p-mb { margin-bottom: 18px; }
.p-muted { color: var(--muted); }
.p-text-sm { font-size: 13px; }
.p-copy { cursor: pointer; }

/* Builder section list */
.p-section-item { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; }
.p-switch { position: relative; width: 44px; height: 24px; }
.p-switch input { opacity: 0; width: 0; height: 0; }
.p-slider { position: absolute; cursor: pointer; inset: 0; background: #cbd5e1; border-radius: 20px; transition: .2s; }
.p-slider:before { content: ""; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.p-switch input:checked + .p-slider { background: var(--accent); }
.p-switch input:checked + .p-slider:before { transform: translateX(20px); }

.p-color-row { display: flex; align-items: center; gap: 10px; }

/* Login */
.p-auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg,#0f172a,#1e1b4b); padding: 20px; }
.p-auth-card { width: 100%; max-width: 420px; background: var(--card); border-radius: 18px; padding: 34px; box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.p-auth-brand { text-align: center; margin-bottom: 22px; color: var(--accent); font-size: 40px; }

/* Landing page preview iframe-ish */
.lp-render { background: #fff; color: #1f2937; border-radius: 14px; overflow: hidden; }
.lp-hero { padding: 70px 24px; text-align: center; background-size: cover; background-position: center; }
.lp-section { padding: 50px 24px; }
.lp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; }
.lp-card { border: 1px solid #eee; border-radius: 12px; padding: 20px; }
.lp-container { max-width: 1080px; margin: 0 auto; }

.p-sidebar.collapsed { width: 70px; }
.p-sidebar.collapsed .p-brand-text, .p-sidebar.collapsed .p-nav-link span, .p-sidebar.collapsed .p-nav-group-label { display: none; }
.p-main.collapsed { margin-left: 70px; }
@media (max-width: 768px) {
  .p-sidebar { transform: translateX(-100%); }
  .p-sidebar.open { transform: translateX(0); }
  .p-main { margin-left: 0; }
  .p-content { padding: 14px; }
  .p-wallet-chip, .p-commission-chip, .p-ref-chip span { display: none; }
}
@media print { .p-sidebar, .p-topbar { display: none; } .p-main { margin-left: 0; } }
