:root {
  --bg-primary: #000; --bg-secondary: #0a0a0a; --bg-card: #111; --bg-hover: #1a1a1a;
  --border: #222; --text-primary: #fff; --text-secondary: #888; --text-muted: #555;
  --green: #22c55e; --green-bg: rgba(34,197,94,0.1);
  --red: #ef4444; --red-bg: rgba(239,68,68,0.1);
  --yellow: #eab308; --yellow-bg: rgba(234,179,8,0.1);
}
[data-theme="light"] {
  --bg-primary: #fff; --bg-secondary: #fafafa; --bg-card: #fff; --bg-hover: #f5f5f5;
  --border: #e5e5e5; --text-primary: #000; --text-secondary: #666; --text-muted: #999;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Inter',system-ui,sans-serif; background: var(--bg-primary); color: var(--text-primary); font-size: 14px; line-height: 1.5; }

/* Login */
.login-screen { display:flex; align-items:center; justify-content:center; min-height:100vh; }
.login-box { width:100%; max-width:360px; padding:0 20px; }
.login-logo { font-size:24px; font-weight:700; letter-spacing:-0.5px; text-align:center; margin-bottom:48px; }
.login-logo span { font-weight:300; opacity:0.5; }
.login-error { background:var(--red-bg); color:var(--red); padding:10px 14px; border-radius:6px; font-size:13px; margin-bottom:16px; display:none; }

/* Sidebar */
.sidebar { position:fixed; left:0; top:0; bottom:0; width:220px; background:var(--bg-secondary); border-right:1px solid var(--border); display:flex; flex-direction:column; z-index:100; }
.logo { padding:24px 24px 32px; font-size:18px; font-weight:700; letter-spacing:-0.5px; }
.logo span { font-weight:300; opacity:0.5; }
.sidebar nav { flex:1; }
.sidebar nav a { display:flex; align-items:center; gap:12px; padding:10px 24px; color:var(--text-muted); text-decoration:none; font-size:13px; font-weight:500; transition:all 0.15s; border-left:2px solid transparent; }
.sidebar nav a:hover { color:var(--text-secondary); background:var(--bg-hover); }
.sidebar nav a.active { color:var(--text-primary); border-left-color:var(--text-primary); background:var(--bg-hover); }
.sidebar nav a i { width:18px; text-align:center; font-size:13px; }
.sidebar-footer { border-top:1px solid var(--border); padding:12px 24px; }
.sidebar-user { font-size:12px; color:var(--text-secondary); margin-bottom:8px; }
.sidebar-user strong { color:var(--text-primary); font-weight:600; }
.sidebar-actions { display:flex; gap:12px; }
.sidebar-actions a { font-size:11px; color:var(--text-muted); text-decoration:none; cursor:pointer; transition:color 0.15s; }
.sidebar-actions a:hover { color:var(--text-primary); }

/* Main */
.main { margin-left:220px; padding:24px 32px; min-height:100vh; }
.header { display:flex; justify-content:space-between; align-items:center; margin-bottom:24px; }
.header h1 { font-size:20px; font-weight:600; letter-spacing:-0.3px; }

/* Stats */
.stats { display:grid; grid-template-columns:repeat(4,1fr); gap:12px; margin-bottom:24px; }
.stat-card { background:var(--bg-card); border:1px solid var(--border); border-radius:8px; padding:16px 20px; transition:border-color 0.15s; }
.stat-card:hover { border-color:var(--text-muted); }
.stat-card .label { font-size:10px; font-weight:600; text-transform:uppercase; letter-spacing:0.5px; color:var(--text-muted); margin-bottom:6px; }
.stat-card .value { font-size:24px; font-weight:700; letter-spacing:-1px; }

/* Cards */
.card { background:var(--bg-card); border:1px solid var(--border); border-radius:8px; margin-bottom:16px; width:100%; }
.card-header { padding:14px 20px; border-bottom:1px solid var(--border); display:flex; justify-content:space-between; align-items:center; }
.card-header h2 { font-size:14px; font-weight:600; }

/* Tables */
.table-wrap { overflow-x:auto; -webkit-overflow-scrolling:touch; }
table { width:100%; border-collapse:collapse; min-width:500px; }
th { text-align:left; padding:10px 16px; font-size:11px; font-weight:600; text-transform:uppercase; letter-spacing:0.5px; color:var(--text-muted); border-bottom:1px solid var(--border); white-space:nowrap; }
td { padding:10px 16px; border-bottom:1px solid var(--border); font-size:13px; color:var(--text-secondary); white-space:nowrap; }
tr:last-child td { border-bottom:none; }
tr:hover td { background:var(--bg-hover); }
.td-name { color:var(--text-primary); font-weight:500; }
.actions-cell { white-space:nowrap; }
.actions-cell .btn { margin-right:4px; }

/* Badges */
.badge { display:inline-block; padding:3px 8px; border-radius:4px; font-size:11px; font-weight:600; letter-spacing:0.3px; }
.badge.active, .badge.delivered, .badge.reviewed, .badge.clicked { background:var(--green-bg); color:var(--green); }
.badge.inactive, .badge.failed { background:var(--red-bg); color:var(--red); }
.badge.sent, .badge.pending { background:var(--yellow-bg); color:var(--yellow); }
.badge.super_admin { background:rgba(139,92,246,0.1); color:#8b5cf6; }
.badge.admin { background:rgba(59,130,246,0.1); color:#3b82f6; }
.badge.user { background:rgba(107,114,128,0.1); color:#6b7280; }

/* Buttons */
.btn { padding:8px 16px; border:none; border-radius:6px; cursor:pointer; font-size:13px; font-weight:500; font-family:'Inter',sans-serif; transition:all 0.15s; }
.btn-primary { background:var(--text-primary); color:var(--bg-primary); }
.btn-primary:hover { opacity:0.85; }
.btn-outline { background:transparent; color:var(--text-primary); border:1px solid var(--border); }
.btn-outline:hover { border-color:var(--text-muted); }
.btn-sm { padding:5px 10px; font-size:12px; }
.btn-danger { color:var(--red) !important; }
.btn-danger:hover { border-color:var(--red) !important; background:var(--red-bg) !important; }

/* Inputs */
.select-styled { padding:8px 12px; border:1px solid var(--border); border-radius:6px; font-size:13px; font-family:'Inter',sans-serif; outline:none; background:var(--bg-card); color:var(--text-primary); cursor:pointer; }
.select-styled:focus { border-color:var(--text-muted); }
.select-styled option { background:var(--bg-card); color:var(--text-primary); }
.input { width:100%; padding:10px 14px; border:1px solid var(--border); border-radius:6px; font-size:13px; font-family:'Inter',sans-serif; background:var(--bg-primary); color:var(--text-primary); outline:none; transition:border-color 0.15s; }
.input:focus { border-color:var(--text-muted); }
.input::placeholder { color:var(--text-muted); }
.form-label { font-size:12px; font-weight:600; color:var(--text-secondary); margin-bottom:6px; display:block; }
.form-group { margin-bottom:20px; }
.form-row { display:grid; grid-template-columns:repeat(auto-fit, minmax(140px, 1fr)); gap:16px; }

/* Link copy */
.link-copy { color:var(--text-muted); cursor:pointer; font-size:12px; transition:color 0.15s; }
.link-copy:hover { color:var(--text-primary); text-decoration:underline; }

/* Modal */
.modal-overlay { display:none; position:fixed; inset:0; background:rgba(0,0,0,0.6); z-index:200; align-items:center; justify-content:center; }
.modal-overlay.visible { display:flex; }
.modal { background:var(--bg-card); border:1px solid var(--border); border-radius:12px; width:100%; max-width:520px; max-height:90vh; overflow-y:auto; margin:20px; }
.modal-header { display:flex; justify-content:space-between; align-items:center; padding:20px 24px; border-bottom:1px solid var(--border); }
.modal-header h2 { font-size:16px; font-weight:600; }
.modal-close { background:none; border:none; color:var(--text-muted); font-size:24px; cursor:pointer; padding:0; line-height:1; }
.modal-close:hover { color:var(--text-primary); }
.modal-body { padding:24px; }
.modal-footer { display:flex; justify-content:flex-end; gap:10px; border-top:1px solid var(--border); margin-top:8px; padding-top:16px; }

/* Permissions list */
.permissions-list { border:1px solid var(--border); border-radius:8px; max-height:240px; overflow-y:auto; }
.perm-row { display:flex; align-items:center; justify-content:space-between; padding:10px 14px; border-bottom:1px solid var(--border); }
.perm-row:last-child { border-bottom:none; }
.perm-row label { display:flex; align-items:center; gap:8px; font-size:13px; color:var(--text-primary); cursor:pointer; flex:1; }
.perm-row label input[type="checkbox"] { cursor:pointer; }
.perm-row select { padding:4px 8px; border:1px solid var(--border); border-radius:4px; font-size:12px; background:var(--bg-primary); color:var(--text-primary); font-family:'Inter',sans-serif; }

/* Permission tags */
.perm-tags { display:flex; flex-wrap:wrap; gap:4px; }
.perm-tag { display:inline-block; padding:2px 6px; border-radius:3px; font-size:10px; font-weight:500; background:var(--bg-hover); color:var(--text-secondary); border:1px solid var(--border); }
.perm-tag.edit { background:rgba(59,130,246,0.1); color:#3b82f6; border-color:rgba(59,130,246,0.2); }
.perm-tag.view { background:rgba(107,114,128,0.1); color:#6b7280; border-color:rgba(107,114,128,0.2); }

/* Toast */
.toast { position:fixed; bottom:24px; left:50%; transform:translateX(-50%) translateY(80px); background:var(--text-primary); color:var(--bg-primary); padding:10px 24px; border-radius:8px; font-size:13px; font-weight:500; opacity:0; transition:all 0.3s; z-index:300; pointer-events:none; }
.toast.show { transform:translateX(-50%) translateY(0); opacity:1; }

/* Utility */
.section { display:none; }
.section.active { display:block; }
.empty-state { text-align:center; padding:40px 20px; color:var(--text-muted); font-size:13px; }
.app-wrapper { display:none; }
.app-wrapper.visible { display:block; }
.hidden { display:none; }

/* ---- RESPONSIVE ---- */
@media (max-width:1024px) {
  .stats { grid-template-columns:repeat(2,1fr); }
  .main { padding:20px 24px; }
}
@media (max-width:768px) {
  .sidebar { position:fixed; left:0; top:auto; bottom:0; width:100%; height:60px; flex-direction:row; border-right:none; border-top:1px solid var(--border); z-index:100; }
  .logo, .sidebar-footer { display:none; }
  .sidebar nav { display:flex; flex-direction:row; justify-content:space-around; align-items:center; width:100%; }
  .sidebar nav a { flex-direction:column; gap:2px; padding:8px 4px; font-size:10px; border-left:none; border-top:2px solid transparent; text-align:center; }
  .sidebar nav a.active { border-left:none; border-top-color:var(--text-primary); background:transparent; }
  .sidebar nav a i { width:auto; font-size:16px; }
  .sidebar nav a span { font-size:9px; }
  .main { margin-left:0; padding:16px 16px 80px; }
  .header { flex-direction:column; align-items:flex-start; gap:12px; }
  .header .select-styled { width:100%; }
  .stats { grid-template-columns:1fr 1fr; gap:8px; }
  .stat-card { padding:12px 14px; }
  .stat-card .value { font-size:20px; }
  .stat-card .label { font-size:9px; }
  .login-logo { font-size:20px; margin-bottom:32px; }
  .modal { margin:12px; }
  .form-row { grid-template-columns:1fr; }
}
@media (max-width:380px) {
  .stats { grid-template-columns:1fr; }
  .main { padding:12px 12px 80px; }
}

/* Ratio bar */
.ratio-bar-wrap { margin-bottom:24px; }
.ratio-bar { height:12px; border-radius:6px; overflow:hidden; display:flex; background:var(--border); margin-bottom:8px; }
.ratio-fill.google { background:#4285f4; }
.ratio-fill.internal { background:#eab308; }
.ratio-labels { display:flex; gap:16px; }
.ratio-label { font-size:12px; color:var(--text-secondary); display:flex; align-items:center; gap:6px; }
.ratio-dot { width:8px; height:8px; border-radius:50%; display:inline-block; }
.ratio-dot.google { background:#4285f4; }
.ratio-dot.internal { background:#eab308; }

/* Small select */
.select-sm { padding:4px 8px; font-size:12px; }
