:root {
  --primary: #2563eb;
  --accent: #0f172a;
  --bg: #f6f7f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --danger: #dc2626;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
.container { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.1rem; margin-top: 0; }
a { color: var(--primary); }
code { background: #eef2f7; padding: 0.15em 0.4em; border-radius: 4px; word-break: break-all; }
.mono { font-family: ui-monospace, monospace; font-size: 0.85em; word-break: break-all; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.narrow { max-width: 480px; margin: 3rem auto; }
.spacer { flex: 1; }

.topnav {
  display: flex; align-items: center; gap: 1rem;
  background: var(--accent); color: #fff; padding: 0.6rem 1rem;
}
.topnav a { color: #cbd5e1; text-decoration: none; }
.topnav a.active, .topnav a:hover { color: #fff; }
.topnav .brand { font-weight: 700; color: #fff; }
.topnav .muted { color: #94a3b8; }

.tabs { display: flex; gap: 0.25rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border); }
.tabs a { padding: 0.4rem 0.9rem; text-decoration: none; color: var(--muted); border-radius: 6px 6px 0 0; }
.tabs a.active { background: var(--card); color: var(--text); border: 1px solid var(--border); border-bottom-color: var(--card); }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 1.25rem; margin-bottom: 1.25rem;
}
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
tr:last-child td { border-bottom: none; }

label { display: block; margin-bottom: 0.9rem; font-weight: 500; }
label.checkbox { display: flex; align-items: center; gap: 0.5rem; }
label.checkbox-compact { margin-bottom: 0.15rem; font-weight: 400; white-space: nowrap; }
input:not([type=checkbox]):not([type=color]), select, textarea {
  display: block; width: 100%; margin-top: 0.25rem; padding: 0.5rem 0.65rem;
  border: 1px solid var(--border); border-radius: 6px; font: inherit; background: #fff;
}
input[type=color] { margin-top: 0.25rem; height: 2.4rem; width: 5rem; padding: 0.15rem; border: 1px solid var(--border); border-radius: 6px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.inline-form { display: flex; gap: 0.5rem; align-items: center; }
.inline-form input, .inline-form select { margin-top: 0; width: auto; flex: 1; }
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

.btn {
  display: inline-block; padding: 0.5rem 1rem; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--border); background: #fff; color: var(--text);
  font: inherit; text-decoration: none;
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--primary); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-small { padding: 0.25rem 0.6rem; font-size: 0.85rem; }

.badge {
  display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px;
  font-size: 0.75rem; background: #e2e8f0; color: var(--text);
}
.badge-active { background: #dcfce7; color: #166534; }
.badge-expired { background: #fef3c7; color: #92400e; }
.badge-purged { background: #fee2e2; color: #991b1b; }

.alert { padding: 0.6rem 0.9rem; border-radius: 6px; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-info { background: #dbeafe; color: #1e40af; }

.stat-row { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 0.9rem 1.4rem; display: flex; flex-direction: column; min-width: 140px;
}
.stat-value { font-size: 1.5rem; font-weight: 700; }
.stat-label { color: var(--muted); font-size: 0.8rem; }

.impersonation-banner {
  background: #7c3aed; color: #fff; padding: 0.5rem 1rem;
  display: flex; align-items: center; gap: 1rem; justify-content: center;
}

/* Customer portal — full-screen brand-colored experience
   (themed per company via --primary / --accent) */
body.portal {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(160deg, var(--accent) 0%, var(--primary) 100%);
  background-attachment: fixed;
}
.portal-bg {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(600px 400px at 85% 10%, rgba(255,255,255,0.18), transparent 70%),
    radial-gradient(800px 500px at 10% 95%, rgba(255,255,255,0.10), transparent 70%);
}
.portal .portal-main { position: relative; z-index: 1; flex: 1; width: 100%; max-width: 960px; }
.portal-header { position: relative; z-index: 1; padding: 1.4rem 1rem; }
.portal-header a {
  display: flex; align-items: center; gap: 0.85rem;
  color: #fff; text-decoration: none; max-width: 960px; margin: 0 auto;
}
.portal-logo { height: 44px; filter: drop-shadow(0 2px 6px rgba(0,0,0,0.25)); }
.portal-name { font-size: 1.3rem; font-weight: 800; letter-spacing: 0.01em; text-shadow: 0 2px 10px rgba(0,0,0,0.25); }
.portal h1 { font-size: 1.7rem; letter-spacing: -0.01em; }
.portal .portal-main > h1, .portal .portal-topbar h1 { color: #fff; text-shadow: 0 2px 12px rgba(0,0,0,0.3); }
.portal .portal-main > .muted { color: rgba(255,255,255,0.75); }
.portal .card {
  background: rgba(255,255,255,0.92);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.55);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.28);
  padding: 1.75rem;
}
.portal .card.narrow { margin-top: 8vh; }
.portal .btn-primary {
  background: var(--primary); border-color: var(--primary);
  padding: 0.65rem 1.4rem; border-radius: 10px; font-weight: 600;
  box-shadow: 0 8px 22px rgba(0,0,0,0.22);
}
.portal .btn-primary:hover { transform: translateY(-1px); filter: brightness(1.08); }
.portal input:not([type=checkbox]), .portal select, .portal textarea { border-radius: 10px; padding: 0.65rem 0.8rem; }
.portal-topbar { display: flex; justify-content: space-between; align-items: center; }
.portal-footer {
  position: relative; z-index: 1;
  text-align: center; padding: 2rem 0; font-size: 0.85rem; color: rgba(255,255,255,0.65);
}

.branding-previews { display: flex; gap: 1.5rem; margin-top: 1rem; flex-wrap: wrap; }
.branding-preview { display: flex; flex-direction: column; gap: 0.5rem; align-items: flex-start; }
.branding-preview img { max-height: 120px; max-width: 260px; border: 1px solid var(--border); border-radius: 8px; background: #f1f5f9; }

/* Drag & drop upload */
.dropzone {
  border: 2px dashed var(--border); border-radius: 12px;
  padding: 2rem 1rem; text-align: center; margin-bottom: 1rem;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone.dragover { border-color: var(--primary); background: #eff6ff; }
.dropzone-title { font-size: 1.05rem; font-weight: 600; margin: 0 0 0.35rem; }
.file-list { list-style: none; padding: 0; margin: 0; }
.file-list li {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.4rem 0.2rem; border-bottom: 1px solid var(--border);
}
.file-list li span:first-child { flex: 1; word-break: break-all; }
.progress { margin-top: 1rem; height: 10px; border-radius: 999px; background: var(--border); overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--primary); border-radius: 999px; transition: width 0.2s; }

@media (max-width: 700px) {
  .grid-2 { grid-template-columns: 1fr; }
  .topnav { flex-wrap: wrap; }
  .portal .card { padding: 1.25rem; }
}
