:root{
  --bg:#0b0f17;
  --panel:#111827;
  --panel2:#0f172a;
  --stroke:rgba(255,255,255,.08);
  --text:#e6edf3;
  --muted:#9aa4b2;

  --accent:#7c5cff;
  --info:#38bdf8;
  --warning:#f59e0b;
  --success:#22c55e;
  --danger:#ff4d6d;

  --shadow: 0 18px 60px rgba(0,0,0,.55);
  --radius:16px;
}

body.light{
  --bg:#f5f7fb;
  --panel:#ffffff;
  --panel2:#ffffff;
  --stroke:rgba(16,24,40,.10);
  --text:#0b1220;
  --muted:#475569;

  --shadow: 0 14px 40px rgba(2,6,23,.12);
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(124,92,255,.18), transparent 55%),
    radial-gradient(1000px 500px at 90% 0%, rgba(56,189,248,.14), transparent 52%),
    radial-gradient(900px 520px at 50% 120%, rgba(34,197,94,.12), transparent 60%),
    var(--bg);
  color:var(--text);
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

a{ color:inherit; text-decoration:none; }
hr{ border:0; border-top:1px solid var(--stroke); margin:16px 0; }

.container{ padding:24px; max-width:1280px; margin:0 auto; }

.card{
  background: linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,0));
  background-color: var(--panel);
  border:1px solid var(--stroke);
  border-radius: var(--radius);
  padding:16px;
  box-shadow: 0 10px 35px rgba(0,0,0,.18);
  margin-bottom:16px;
}

.title{ margin:0; font-size:18px; letter-spacing:.2px; }
.subtitle{ margin:6px 0 0; color:var(--muted); font-size:13px; line-height:1.4; }
.small{ color:var(--muted); font-size:12px; line-height:1.45; }

.mono{ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }
.right-align{ text-align:right; }

.hstack{ display:flex; gap:10px; align-items:center; }
.vstack{ display:flex; gap:10px; flex-direction:column; }

.sep{ border:0; border-top:1px solid var(--stroke); margin:14px 0; }

/* Topbar */
.topbar{
  position:sticky; top:0; z-index:40;
  backdrop-filter: blur(10px);
  background: rgba(10,14,22,.72);
  border-bottom:1px solid var(--stroke);
}
body.light .topbar{ background: rgba(255,255,255,.78); }

.topbar-inner{
  max-width:1280px; margin:0 auto;
  padding:14px 24px;
  display:flex; gap:14px;
  align-items:center; justify-content:space-between;
}

.brand{ display:flex; gap:12px; align-items:center; }
.brand h1{ margin:0; font-size:14px; letter-spacing:.3px; }
.brand p{ margin:2px 0 0; font-size:12px; color:var(--muted); }
.brand-badge{
  width:38px; height:38px; border-radius:14px;
  background: linear-gradient(135deg, rgba(124,92,255,.9), rgba(56,189,248,.65));
  display:flex; align-items:center; justify-content:center;
  box-shadow: 0 12px 30px rgba(124,92,255,.22);
}

.nav{ display:flex; gap:10px; align-items:center; flex-wrap:wrap; justify-content:flex-end; }
.nav a{
  padding:8px 10px;
  border-radius:12px;
  color:var(--muted);
  border:1px solid transparent;
}
.nav a:hover{ color:var(--text); border-color:var(--stroke); background: rgba(255,255,255,.03); }
.nav a.active{
  color:var(--text);
  border-color: rgba(124,92,255,.28);
  background: linear-gradient(135deg, rgba(124,92,255,.14), rgba(255,255,255,.02));
}
.nav .right{ display:flex; gap:10px; align-items:center; margin-left:4px; }

.user-chip{
  display:inline-flex; align-items:center; gap:8px;
  padding:8px 10px;
  border:1px solid var(--stroke);
  border-radius:999px;
  background: rgba(255,255,255,.02);
  color:var(--muted);
  font-size:12px;
}
.user-dot{
  width:9px; height:9px; border-radius:999px;
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(34,197,94,.15);
}

/* Inputs + buttons */
input, select, textarea{
  background: rgba(255,255,255,.03);
  border:1px solid var(--stroke);
  color: var(--text);
  padding:10px 12px;
  border-radius:12px;
  outline:none;
}
input::placeholder{ color: rgba(154,164,178,.75); }
input:focus, select:focus, textarea:focus{
  border-color: rgba(124,92,255,.35);
  box-shadow: 0 0 0 4px rgba(124,92,255,.12);
}

.form-row{
  display:flex; gap:10px; flex-wrap:wrap; align-items:center;
}
.form-row > *{ min-height:40px; }
.form-row input{ flex: 1 1 360px; }
.form-row select{ flex: 0 0 220px; }

.btn{
  border:1px solid var(--stroke);
  background: rgba(255,255,255,.03);
  color: var(--text);
  padding:10px 12px;
  border-radius:12px;
  cursor:pointer;
  transition: transform .06s ease, background .12s ease, border-color .12s ease;
}
.btn:hover{ background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.12); }
.btn:active{ transform: translateY(1px); }

.btn-sm{ padding:8px 10px; border-radius:12px; font-size:12px; }
.btn-ghost{ background: transparent; }
.btn-primary{
  border-color: rgba(124,92,255,.35);
  background: linear-gradient(135deg, rgba(124,92,255,.95), rgba(56,189,248,.55));
  color:white;
}
.btn-danger{
  border-color: rgba(255,77,109,.35);
  background: linear-gradient(135deg, rgba(255,77,109,.9), rgba(245,158,11,.2));
  color:white;
}

/* Tables */
.table-wrap{ overflow:auto; border-radius:14px; border:1px solid var(--stroke); }
table{ width:100%; border-collapse:collapse; background: rgba(255,255,255,.01); }
th, td{ padding:11px 12px; border-bottom:1px solid var(--stroke); text-align:left; vertical-align:top; }
th{ color:var(--muted); font-weight:600; font-size:12px; letter-spacing:.2px; }
tr:hover td{ background: rgba(255,255,255,.02); }

/* Badges */
.badge{
  display:inline-flex; align-items:center; gap:8px;
  border:1px solid var(--stroke);
  padding:7px 10px;
  border-radius:999px;
  font-size:12px;
  color: var(--text);
  background: rgba(255,255,255,.02);
  white-space:nowrap;
}
.badge-dot{ width:8px; height:8px; border-radius:999px; background: rgba(154,164,178,.9); }

.badge.queued{ background: linear-gradient(135deg, rgba(124,92,255,.16), rgba(255,255,255,.03)); border-color: rgba(124,92,255,.28); }
.badge.queued .badge-dot{ background: var(--accent); }

.badge.processing, .badge.sending{ background: linear-gradient(135deg, rgba(56,189,248,.14), rgba(255,255,255,.03)); border-color: rgba(56,189,248,.28); }
.badge.processing .badge-dot, .badge.sending .badge-dot{ background: var(--info); }

.badge.paused{ background: linear-gradient(135deg, rgba(245,158,11,.14), rgba(255,255,255,.03)); border-color: rgba(245,158,11,.28); }
.badge.paused .badge-dot{ background: var(--warning); }

.badge.completed{ background: linear-gradient(135deg, rgba(34,197,94,.14), rgba(255,255,255,.03)); border-color: rgba(34,197,94,.28); }
.badge.completed .badge-dot{ background: var(--success); }

.badge.failed, .badge.invalid, .badge.error{
  background: linear-gradient(135deg, rgba(255,77,109,.14), rgba(255,255,255,.03));
  border-color: rgba(255,77,109,.28);
}
.badge.failed .badge-dot, .badge.invalid .badge-dot, .badge.error .badge-dot{ background: var(--danger); }

.badge.valid{
  background: linear-gradient(135deg, rgba(34,197,94,.14), rgba(255,255,255,.03));
  border-color: rgba(34,197,94,.28);
}
.badge.valid .badge-dot{ background: var(--success); }

.badge.unknown, .badge.warning{
  background: linear-gradient(135deg, rgba(245,158,11,.14), rgba(255,255,255,.03));
  border-color: rgba(245,158,11,.28);
}
.badge.unknown .badge-dot, .badge.warning .badge-dot{ background: var(--warning); }

.badge.draft{
  background: rgba(255,255,255,.03);
  border-color: var(--stroke);
  color: var(--muted);
}
.badge.draft .badge-dot{ background: rgba(154,164,178,.9); }


.kpi .value { font-size: 20px; line-height: 1.2; }
#kStorage { word-break: break-all; font-size: 14px; }
/* KPIs + grids */
.grid{ display:flex; gap:12px; flex-wrap:wrap; }
.col-4{ flex: 1 1 240px; min-width: 0; }
.col-6{ flex: 1 1 360px; min-width: 0; }

.kpi{
  border:1px solid var(--stroke);
  border-radius: 16px;
  padding:12px;
  background: rgba(255,255,255,.02);
}
.kpi .label{ color: var(--muted); font-size:12px; }
.kpi .value{ font-size:24px; margin-top:4px; letter-spacing:.2px; }
.kpi .hint{ color: var(--muted); font-size:12px; margin-top:4px; }

/* Progress */
.progress{
  height:10px;
  border-radius:999px;
  border:1px solid var(--stroke);
  background: rgba(255,255,255,.02);
  overflow:hidden;
}
.progress > span{
  display:block; height:100%;
  background: linear-gradient(90deg, rgba(124,92,255,.95), rgba(34,197,94,.8));
  width: 0%;
}

/* Dialogs */
.dialog-backdrop{
  width:min(1100px, calc(100vw - 24px));
  border:1px solid var(--stroke);
  border-radius: 18px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
  padding:0;
}
dialog::backdrop{ background: rgba(0,0,0,.55); backdrop-filter: blur(4px); }

.dialog-head{
  display:flex; justify-content:space-between; align-items:center;
  padding:14px 14px 10px;
  border-bottom:1px solid var(--stroke);
}
.dialog-head h3{ margin:0; font-size:14px; letter-spacing:.2px; }
.dialog-body{ padding:14px; }
.dialog-foot{
  display:flex; justify-content:flex-end; gap:10px;
  padding:12px 14px;
  border-top:1px solid var(--stroke);
}

/* Tabs */
.tabs{ display:flex; gap:8px; flex-wrap:wrap; margin: 10px 0 0; }
.tab{
  border:1px solid var(--stroke);
  background: rgba(255,255,255,.02);
  color: var(--muted);
  padding:8px 10px;
  border-radius: 999px;
  cursor:pointer;
  font-size:12px;
}
.tab.active{
  color: var(--text);
  border-color: rgba(124,92,255,.28);
  background: linear-gradient(135deg, rgba(124,92,255,.14), rgba(255,255,255,.02));
}

/* Code blocks */
pre.code{
  margin:0;
  padding:12px;
  border-radius:14px;
  border:1px solid var(--stroke);
  background: rgba(0,0,0,.18);
  overflow:auto;
  font-size:12px;
  line-height:1.45;
}

/* Skeleton */
.skeleton{
  border-radius:999px;
  background: linear-gradient(90deg, rgba(255,255,255,.06), rgba(255,255,255,.02), rgba(255,255,255,.06));
  background-size: 200% 100%;
  animation: sk 1.2s infinite linear;
}
@keyframes sk{
  0%{ background-position: 200% 0; }
  100%{ background-position: -200% 0; }
}

/* ===== Backward compatibility with your old templates ===== */
.header{ padding:16px 24px; background: var(--panel); border-bottom:1px solid var(--stroke); display:flex; align-items:center; justify-content:space-between; }
.notice{ color:var(--muted); font-size:14px; }
.error{ color:var(--danger); }

button.primary{ background: var(--accent); border:none; color:white; }
button.danger{ background: var(--danger); border:none; color:white; }
button.success{ background: var(--success); border:none; color:white; }

/* Auth & Centering */
.center-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 80px);
  padding: 20px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 32px !important;
  animation: fadeIn 0.4s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.auth-title { margin: 0; font-size: 24px; font-weight: 700; }
.auth-hint { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
.btn-wide { width: 100%; margin-top: 10px; font-weight: 600; }
.inline-error { 
  color: var(--danger); 
  background: rgba(255, 77, 109, 0.1); 
  padding: 10px; 
  border-radius: 8px; 
  font-size: 13px; 
  margin-top: 10px;
  border: 1px solid rgba(255, 77, 109, 0.2);
}
label.small { display: block; margin-bottom: 6px; font-weight: 500; }

/* User Specific Status Colors */
.badge.active { 
  background: rgba(34,197,94,.1); border-color: rgba(34,197,94,.3); color: var(--text);
}
.badge.active .badge-dot { background: var(--success); }

.badge.suspended { 
  background: rgba(245,158,11,.1); border-color: rgba(245,158,11,.3); color: var(--text);
}
.badge.suspended .badge-dot { background: var(--warning); }

.badge.disabled { 
  background: rgba(255,77,109,.1); border-color: rgba(255,77,109,.3); color: var(--text);
}
.badge.disabled .badge-dot { background: var(--danger); }

/* Role Colors */
.badge.admin { 
  background: rgba(124,92,255,.1); border-color: rgba(124,92,255,.3); color: var(--text);
}
.badge.admin .badge-dot { background: var(--accent); }

/* Import Status Colors */
.badge.uploaded {
  background: rgba(255,255,255,.04);
  color: var(--muted);
  border-color: var(--stroke);
}
.badge.uploaded .badge-dot { background: var(--muted); }

/* Reuse existing classes but ensure mapping */
.badge.importing, .badge.processing {
  background: rgba(56,189,248,.1); border-color: rgba(56,189,248,.3); color: var(--text);
}
.badge.importing .badge-dot, .badge.processing .badge-dot { background: var(--info); }

/* Custom Checkbox */
.chk-wrap { display: flex; align-items: center; justify-content: center; height: 100%; }
.chk-custom {
  appearance: none;
  width: 18px; height: 18px;
  border: 1px solid var(--stroke);
  border-radius: 4px;
  background: rgba(255,255,255,.05);
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
}
.chk-custom:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.chk-custom:checked::after {
  content: '';
  position: absolute;
  left: 5px; top: 1px;
  width: 4px; height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Bulk Actions Bar */
.bulk-bar {
  position: fixed;
  bottom: 30px; left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--panel);
  border: 1px solid var(--stroke);
  padding: 12px 20px;
  border-radius: 100px;
  box-shadow: var(--shadow);
  display: flex; gap: 16px; align-items: center;
  z-index: 100;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.bulk-bar.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
.bulk-count {
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
  padding-right: 12px;
  border-right: 1px solid var(--stroke);
}

/* === FULL-WIDTH NO-HSCROLL PATCH (FULL-WIDTH NO-HSCROLL PATCH) === */

/* Full screen layout (remove 1200px cap everywhere) */
.container,
.topbar-inner{
  width: calc(100% - 32px) !important;
  max-width: none !important;
}

/* Prevent any accidental horizontal overflow */
html, body{ width:100%; overflow-x:hidden; }

/* Make navigation wrap nicely so it never pushes sideways */
.nav{ flex-wrap: wrap !important; }

/* Tables: remove forced min-width, force wrapping, no sideways scroll */
.table-wrap{
  overflow: visible !important;   /* no horizontal scrollbar */
}

table{
  width: 100% !important;
  min-width: 0 !important;
  table-layout: fixed !important; /* prevents overflow from wide cells */
}

th, td{
  white-space: normal !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
}

/* Make action button rows wrap instead of stretching the table */
.hstack{ flex-wrap: wrap; }
.right-align .hstack{ justify-content: flex-end; flex-wrap: wrap; }

/* Code blocks: wrap long lines to avoid sideways scrolling */
pre.code{
  white-space: pre-wrap !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
  overflow: hidden !important;
}

/* Status badge colors (completed green, failed red, others sensible) */
.badge.completed .badge-dot{ background: var(--success); }
.badge.failed .badge-dot{ background: var(--danger); }
.badge.queued .badge-dot{ background: var(--info); }
.badge.sending .badge-dot{ background: var(--warning); }
.badge.processing .badge-dot{ background: var(--warning); }
.badge.paused .badge-dot{ background: var(--warning); }
.badge.draft .badge-dot{ background: var(--muted); }
.badge.sent .badge-dot{ background: var(--success); }
.badge.retry .badge-dot{ background: var(--warning); }
.badge.suppressed .badge-dot{ background: var(--danger); }
.badge.pending .badge-dot{ background: var(--info); }

/* Slightly tighter on small screens */
@media (max-width: 640px){
  .container,.topbar-inner{ width: calc(100% - 18px) !important; }
  th,td{ padding: 10px 10px; }
}

/* === NO-HSCROLL V2 PATCH (NO-HSCROLL V2 PATCH) === */

/* Full screen everywhere */
.container,
.topbar-inner{
  width: calc(100% - 24px) !important;
  max-width: none !important;
}

.brand{ min-width: 0 !important; }
.nav, .right{ min-width: 0 !important; }
.topbar-inner{ min-width: 0 !important; }

/* Kill any page-level horizontal overflow */
html, body{ width:100%; overflow-x:hidden !important; }

/* Tables must NEVER cause sideways scroll */
.table-wrap{ overflow: visible !important; }
table{
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  table-layout: fixed !important;
}

/* Inline width styles on <th>/<td> are the #1 cause — override them */
th[style], td[style]{ width: auto !important; min-width: 0 !important; max-width: none !important; }

/* Wrap everything inside cells */
th, td{
  white-space: normal !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
  max-width: 0 !important; /* key for table-layout:fixed wrapping */
}

/* Buttons/actions must wrap instead of widening the table */
td .btn,
td button{
  max-width: 100%;
}
td .hstack{ flex-wrap: wrap !important; }
td .right-align .hstack{ flex-wrap: wrap !important; justify-content: flex-end !important; }

/* Code/pre blocks: wrap lines to prevent overflow */
pre, pre.code{
  white-space: pre-wrap !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
  overflow: hidden !important;
}

/* Nav wrap so full menu never forces overflow */
.nav{ flex-wrap: wrap !important; }
.nav a{ white-space: nowrap; }

/* Status colors (used by badges) */
.badge.completed .badge-dot{ background: var(--success); }
.badge.failed .badge-dot{ background: var(--danger); }
.badge.queued .badge-dot{ background: var(--info); }
.badge.processing .badge-dot{ background: var(--warning); }
.badge.sending .badge-dot{ background: var(--warning); }
.badge.paused .badge-dot{ background: var(--warning); }
.badge.draft .badge-dot{ background: var(--muted); }
.badge.sent .badge-dot{ background: var(--success); }
.badge.retry .badge-dot{ background: var(--warning); }
.badge.pending .badge-dot{ background: var(--info); }
.badge.suppressed .badge-dot{ background: var(--danger); }


/* VERIFY STATUS COLORS PATCH */
.badge.completed .badge-dot{ background: var(--success); }
.badge.failed .badge-dot{ background: var(--danger); }
.badge.queued .badge-dot{ background: var(--info); }
.badge.processing .badge-dot{ background: var(--warning); }
.badge.paused .badge-dot{ background: var(--warning); }
.badge.valid .badge-dot{ background: var(--success); }
.badge.invalid .badge-dot{ background: var(--danger); }
.badge.unknown .badge-dot{ background: var(--warning); }
.badge.info .badge-dot{ background: var(--info); }
.badge.warning .badge-dot{ background: var(--warning); }
.badge.danger .badge-dot{ background: var(--danger); }

/* LOGO_IMAGE_RULES */
.brand-badge{ overflow:hidden; }
.brand-badge img{
  width: 22px;
  height: 22px;
  object-fit: contain;
  display: block;
}


/* === FULLSCREEN + NO HORIZONTAL SCROLL (global) === */
html, body { max-width: 100%; overflow-x: hidden; }
.container { width: calc(100% - 28px); max-width: 100%; }
.topbar-inner { width: calc(100% - 28px); max-width: 100%; }

/* Tables: no forced min-width, wrap long content instead of pushing width */
.table-wrap { overflow-x: hidden; }
table { width: 100%; min-width: 0 !important; table-layout: fixed; }
th, td { overflow-wrap: anywhere; word-break: break-word; white-space: normal; }
td .hstack { flex-wrap: wrap; }

/* Badge status colors (campaigns/imports/verify/queue/etc.) */
.badge.completed .badge-dot { background: var(--success); }
.badge.failed .badge-dot { background: var(--danger); }
.badge.processing .badge-dot { background: var(--info); }
.badge.queued .badge-dot { background: var(--accent2); }
.badge.sending .badge-dot { background: var(--warning); }
.badge.paused .badge-dot { background: var(--warning); }
.badge.draft .badge-dot { background: rgba(234,240,255,.45); }
.badge.pending .badge-dot { background: var(--warning); }
.badge.sent .badge-dot { background: var(--success); }
.badge.retry .badge-dot { background: var(--warning); }
.badge.suppressed .badge-dot { background: rgba(234,240,255,.45); }
.badge.uploaded .badge-dot { background: var(--info); }
.badge.disabled .badge-dot { background: var(--danger); }

/* Brand logo image inside badge */
.brand-badge{ overflow:hidden; }
.brand-badge img{ width:22px; height:22px; object-fit:contain; display:block; }


/* === KPI/storage overrides (auto-added) === */
.kpi .value { font-size: 20px; line-height: 1.2; }
#kStorage { word-break: break-all; font-size: 14px; }
/* === end overrides === */
