/* ==========================================================================
   PaaS Client Panel — Stylesheet
   Reuses the design tokens from the public website (style.css) so client
   experience matches the marketing site visually.
   ========================================================================== */

:root {
  /* Re-declared so the panel works standalone (no website CSS dependency). */
  --bg-primary: #0A0E27;
  --bg-surface: #141937;
  --bg-elevated: #1C2249;
  --border-subtle: #232A52;

  --accent-primary: #00D9FF;
  --accent-secondary: #7C3AED;
  --accent-success: #10D9A0;
  --accent-alert: #FF4E6C;
  --accent-warning: #FFB800;

  --text-primary: #E8ECF4;
  --text-secondary: #8B92B0;
  --text-muted: #5A6388;

  --gradient-accent: linear-gradient(135deg, #00D9FF 0%, #7C3AED 100%);
  --gradient-card: linear-gradient(180deg, rgba(28, 34, 73, 0.6) 0%, rgba(20, 25, 55, 0.4) 100%);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.5);

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;

  --font-heading: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;

  --container-max: 1200px;
  --sidebar-width: 240px;
  --header-height: 64px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  font-size: 15px;
  min-height: 100vh;
}
a { color: var(--accent-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; }
ul { list-style: none; }

/* --- Background grid (subtle) -------------------------------------------- */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 217, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 217, 255, 0.025) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(ellipse at center, black 0%, transparent 75%);
  pointer-events: none;
  z-index: 0;
}

/* ===================================================== Auth (login) layout */

.auth-shell {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  position: relative;
  z-index: 1;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--gradient-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 36px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(8px);
}
.auth-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 24px;
  margin-bottom: 32px;
}
.auth-logo-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--gradient-accent);
  display: grid;
  place-items: center;
  color: #0a0e27;
  font-size: 18px;
}
.auth-title { font-family: var(--font-heading); font-size: 22px; margin-bottom: 8px; }
.auth-subtitle { color: var(--text-secondary); margin-bottom: 24px; font-size: 14px; }

.auth-langs {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 24px;
}
.lang-btn {
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  transition: var(--transition);
}
.lang-btn:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}
.lang-btn.is-active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #0a0e27;
}

/* ===================================================== Panel app shell ---- */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}
.sidebar {
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  padding: 24px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 18px;
  margin-bottom: 28px;
  padding: 0 8px;
}
.sidebar-logo-mark {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--gradient-accent);
  display: grid; place-items: center;
  color: #0a0e27; font-size: 14px;
}
.sidebar nav ul { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
}
.sidebar nav a:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  text-decoration: none;
}
.sidebar nav a.active {
  background: var(--bg-elevated);
  color: var(--accent-primary);
}
.sidebar-section-title {
  margin: 18px 12px 6px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.sidebar-footer {
  margin-top: auto;
  padding-top: 24px;
  border-top: 1px solid var(--border-subtle);
}
.sidebar-user {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
}
.sidebar-user b { color: var(--text-primary); }
.sidebar-user span { color: var(--text-muted); font-size: 12px; }

.main {
  padding: 24px 32px 64px;
  max-width: 1200px;
  width: 100%;
}
.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
}
.main-header h1 { font-family: var(--font-heading); font-size: 26px; }
.main-header .crumbs {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

/* ===================================================== Cards / sections --- */

.card {
  background: var(--gradient-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 24px;
}
.card h2 {
  font-family: var(--font-heading);
  font-size: 18px;
  margin-bottom: 16px;
}
.card p { color: var(--text-secondary); font-size: 14px; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.stat {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
}
.stat .label { font-size: 12px; color: var(--text-muted); letter-spacing: 0.04em; text-transform: uppercase; }
.stat .value { font-family: var(--font-heading); font-size: 26px; margin-top: 6px; }

/* ===================================================== Forms -------------- */

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  transition: var(--transition);
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(0, 217, 255, 0.15);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-help { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}
.checkbox:hover { border-color: var(--accent-primary); }
.checkbox input { margin-top: 3px; accent-color: var(--accent-primary); flex-shrink: 0; }
.checkbox-text { display: flex; flex-direction: column; gap: 2px; }
.checkbox-text b { font-size: 13px; }
.checkbox-text span { font-size: 12px; color: var(--text-muted); }

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}

/* ===================================================== Buttons ------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  transition: var(--transition);
  white-space: nowrap;
}
.btn-primary {
  background: var(--gradient-accent);
  color: #0a0e27;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); text-decoration: none; }
.btn-ghost {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
}
.btn-ghost:hover { border-color: var(--accent-primary); text-decoration: none; }
.btn-danger {
  background: rgba(255, 78, 108, 0.15);
  border: 1px solid var(--accent-alert);
  color: var(--accent-alert);
}
.btn-danger:hover { background: rgba(255, 78, 108, 0.25); text-decoration: none; }
.btn[disabled], .btn[aria-busy="true"] { opacity: 0.6; cursor: not-allowed; }

/* ===================================================== Status pills ------- */

.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.pill-queued    { background: rgba(255, 184, 0, 0.15); color: var(--accent-warning); }
.pill-running   { background: rgba(0, 217, 255, 0.15); color: var(--accent-primary); }
.pill-completed { background: rgba(16, 217, 160, 0.15); color: var(--accent-success); }
.pill-failed    { background: rgba(255, 78, 108, 0.15); color: var(--accent-alert); }
.pill-cancelled { background: rgba(139, 146, 176, 0.15); color: var(--text-secondary); }
.pill-timeout   { background: rgba(255, 78, 108, 0.15); color: var(--accent-alert); }
.pill-pending   { background: rgba(255, 184, 0, 0.15); color: var(--accent-warning); }
.pill-approved  { background: rgba(16, 217, 160, 0.15); color: var(--accent-success); }
.pill-rejected  { background: rgba(255, 78, 108, 0.15); color: var(--accent-alert); }
.pill-revoked   { background: rgba(139, 146, 176, 0.15); color: var(--text-secondary); }

/* ===================================================== Tables ------------ */

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.data th, table.data td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}
table.data th {
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
table.data td .ip { font-family: monospace; color: var(--accent-primary); }
table.data tr:hover { background: rgba(28, 34, 73, 0.4); }

.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
}
.empty-state h3 { color: var(--text-secondary); margin-bottom: 8px; font-family: var(--font-heading); }

/* ===================================================== Progress bar ------ */

.progress {
  background: var(--bg-elevated);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--gradient-accent);
  width: 0%;
  transition: width 0.4s ease;
}

/* ===================================================== Alerts / toasts --- */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 14px;
  border-left: 3px solid;
}
.alert-error   { background: rgba(255, 78, 108, 0.1);  border-color: var(--accent-alert);   color: #ffb1be; }
.alert-success { background: rgba(16, 217, 160, 0.1);  border-color: var(--accent-success); color: #b5f5dd; }
.alert-warn    { background: rgba(255, 184, 0, 0.08); border-color: var(--accent-warning); color: #ffe5a3; }
.alert-info    { background: rgba(0, 217, 255, 0.08); border-color: var(--accent-primary); color: #b8eeff; }

#toast-host {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}
.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  box-shadow: var(--shadow-md);
  animation: toast-in 0.3s ease;
  font-size: 14px;
}

/* ==========================================================================
   Admin extras — modal, filter rows, scope review cards
   ========================================================================== */

.alert-warning {
  background: rgba(255, 184, 0, 0.08);
  border-color: var(--accent-warning);
  color: #ffe5a3;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.filter-row input,
.filter-row select {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 8px 10px;
  font-size: 14px;
  min-width: 0;
}
.filter-row input { flex: 1 1 200px; }

.actions-cell {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.actions-cell select {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  font-size: 13px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 39, 0.7);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  width: 100%;
  max-width: 640px;
  box-shadow: var(--shadow-lg);
  max-height: 90vh;
  overflow-y: auto;
}

.scope-review {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 16px;
}
.scope-review header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.scope-review header strong { margin-right: 8px; }
.scope-review header code {
  margin-right: 8px;
  background: var(--bg-primary);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 13px;
}
.scope-review-body { display: flex; flex-direction: column; gap: 12px; }

.review-form {
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.review-form textarea {
  width: 100%;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-family: inherit;
  resize: vertical;
}

details > summary {
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 12px;
  margin-top: 4px;
}
details[open] > summary { color: var(--accent-primary); }
details pre {
  margin-top: 4px;
  max-height: 240px;
  overflow: auto;
}
.toast.error { border-left: 3px solid var(--accent-alert); }
.toast.success { border-left: 3px solid var(--accent-success); }
.toast.info { border-left: 3px solid var(--accent-primary); }
@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ===================================================== Header right side - */

.header-actions { display: flex; gap: 8px; align-items: center; }
.lang-switch {
  display: inline-flex;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.lang-switch button {
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
}
.lang-switch button.active { background: var(--bg-elevated); color: var(--accent-primary); }

/* ===================================================== Mobile ------------ */

@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
  }
  .sidebar nav ul { flex-direction: row; flex-wrap: wrap; }
  .sidebar nav a { flex: 1 1 auto; justify-content: center; }
  .sidebar-section-title, .sidebar-footer { display: none; }
  .main { padding: 16px; }
  .field-row { grid-template-columns: 1fr; }
}

/* --- Block-level button (full-width, comfortable padding) --- */
.btn-block {
  display: block;
  width: 100%;
  padding: 0.85rem 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  text-align: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}
.btn-block:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.btn-block:focus-visible {
  outline: 2px solid var(--accent-primary, #00d9ff);
  outline-offset: 2px;
}

/* ==========================================================================
   App shell — sidebar + main (matches HTML built by layout.js)
   Override / replace the legacy .app/.sidebar block (kept for compat).
   ========================================================================== */

body.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* --- Sidebar --- */
.sidebar {
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  padding: 24px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 18px;
  border-bottom: 1px solid var(--border-subtle);
}
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--gradient-accent);
  color: #0a0e27;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 20px;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 0;
}
.brand-text strong {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.01em;
}
.brand-text small {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  letter-spacing: 0.02em;
}

/* --- Sidebar nav (links built by layout.js) --- */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-height: 0;
}
.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: var(--transition);
  border: 1px solid transparent;
}
.sidebar-nav .nav-link:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  text-decoration: none;
}
.sidebar-nav .nav-link.is-active {
  background: linear-gradient(135deg, rgba(0, 217, 255, 0.18) 0%, rgba(124, 58, 237, 0.18) 100%);
  color: var(--accent-primary);
  border-color: rgba(0, 217, 255, 0.35);
  box-shadow: inset 0 0 0 1px rgba(0, 217, 255, 0.1);
}
.sidebar-nav .nav-icon {
  width: 22px;
  font-size: 16px;
  text-align: center;
  flex-shrink: 0;
  filter: grayscale(0.15);
}

/* Visual separator before admin links: any nav-link whose data-nav-id
   starts with "admin_" gets a top divider on the first occurrence. */
.sidebar-nav .nav-link[data-nav-id="admin_users"] {
  margin-top: 32px;
  position: relative;
  border-top: 1px solid var(--border-subtle);
  border-radius: 0 0 8px 8px;
}
.sidebar-nav .nav-link[data-nav-id="admin_users"]::before {
  content: 'Administration';
  position: absolute;
  top: -22px;
  left: 12px;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  pointer-events: none;
}
.sidebar-nav { position: relative; }

/* --- Sidebar footer (user card + logout) --- */
.sidebar-footer {
  padding-top: 18px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.nav-user {
  padding: 8px 10px;
  background: var(--bg-elevated);
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
}
.nav-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-user-email {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.nav-logout {
  width: 100%;
  padding: 9px 12px;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}
.nav-logout:hover {
  border-color: var(--accent-alert);
  color: var(--accent-alert);
  background: rgba(255, 78, 108, 0.08);
}

/* --- Main column --- */
body.app > main.main {
  padding: 28px 36px 48px;
  max-width: 1280px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Topbar (lang switch, prepended by layout.js) */
.topbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

/* Page header (h1 + subtitle on each page) */
.page-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-bottom: 4px;
}
.page-header h1 {
  font-family: var(--font-heading);
  font-size: 28px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}
.page-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
}

/* --- KPI grid --- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.card.kpi {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 20px;
  background: var(--gradient-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}
.card.kpi::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-accent);
  opacity: 0;
  pointer-events: none;
  transition: var(--transition);
}
.card.kpi:hover {
  border-color: rgba(0, 217, 255, 0.3);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.card.kpi span {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}
.card.kpi strong {
  font-family: var(--font-heading);
  font-size: 26px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

/* --- Generic card override (panels with header + body) --- */
.card {
  background: var(--gradient-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 22px 24px;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
}
.card-header h2 {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}
.card-body { display: flex; flex-direction: column; gap: 12px; }

/* --- Small button variant --- */
.btn-sm {
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}
.btn-sm.btn-primary { color: #0a0e27; }

/* --- Table inside a card --- */
.table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table.data thead th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
}
.table.data tbody td {
  padding: 12px;
  border-bottom: 1px solid rgba(35, 42, 82, 0.5);
  color: var(--text-primary);
}
.table.data tbody tr:last-child td { border-bottom: none; }
.table.data tbody tr:hover { background: rgba(28, 34, 73, 0.4); }

.text-muted { color: var(--text-muted); font-size: 14px; }

/* --- Top-right lang switch inside .topbar (override compact size) --- */
.topbar .lang-switch {
  display: inline-flex;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.topbar .lang-switch .lang-btn {
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: var(--transition);
}
.topbar .lang-switch .lang-btn:hover { color: var(--text-primary); }
.topbar .lang-switch .lang-btn.is-active {
  background: var(--gradient-accent);
  color: #0a0e27;
}

/* --- Responsive --- */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  body.app { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
  }
  .sidebar-brand { padding: 0; border-bottom: none; flex: 1 1 auto; }
  .sidebar-nav { flex: 1 1 100%; flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .sidebar-nav .nav-link[data-nav-id="admin_users"] {
    margin-top: 0; padding-top: 10px; border-top: none; border-left: 1px solid var(--border-subtle); padding-left: 14px;
  }
  .sidebar-nav .nav-link[data-nav-id="admin_users"]::before { display: none; }
  .sidebar-footer { flex: 1 1 100%; flex-direction: row; align-items: center; padding-top: 12px; }
  .nav-user { flex: 1; }
  .nav-logout { width: auto; }
  body.app > main.main { padding: 20px 18px 32px; }
}
@media (max-width: 560px) {
  .kpi-grid { grid-template-columns: 1fr; }
}

/* ==========================================================================
   2026-05-03 site-wide UI polish
   - Self-sufficient button variants (work without .btn parent)
   - Native form controls inside [data-app-shell] (no .field wrapper required)
   - Fieldset/legend styling
   - Native select arrow + padding
   - File input styling
   - Custom checkbox affordance
   - Header w/ inline filter (page-header > select)
   - Action cell button cluster
   ========================================================================== */

/* --- Buttons: self-sufficient variants. Used as <a class="btn-primary">… */
.btn-primary,
.btn-ghost,
.btn-danger,
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.2;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition);
  white-space: nowrap;
  width: auto;            /* never let parent flex/grid stretch */
  align-self: flex-start; /* in flex/column parents, hug content */
}
.btn-primary {
  background: var(--gradient-accent);
  color: #0a0e27;
  border-color: transparent;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  text-decoration: none;
}
.btn-ghost {
  background: var(--bg-elevated);
  border-color: var(--border-subtle);
  color: var(--text-primary);
}
.btn-ghost:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  text-decoration: none;
}
.btn-danger {
  background: rgba(255, 78, 108, 0.12);
  border-color: rgba(255, 78, 108, 0.55);
  color: var(--accent-alert);
}
.btn-danger:hover {
  background: rgba(255, 78, 108, 0.22);
  text-decoration: none;
}
.btn-primary[disabled],
.btn-ghost[disabled],
.btn-danger[disabled],
.btn-primary[aria-busy="true"],
.btn-ghost[aria-busy="true"],
.btn-danger[aria-busy="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.btn-primary:focus-visible,
.btn-ghost:focus-visible,
.btn-danger:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* small variant — ensure compact even when used standalone */
.btn-sm,
.btn-primary.btn-sm,
.btn-ghost.btn-sm,
.btn-danger.btn-sm {
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 7px;
}

/* --- Action cluster (HTML / PDF / JSON in admin scans table) --- */
.actions-cell {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* --- Native form controls inside the panel shell --- */
[data-app-shell] input[type="text"],
[data-app-shell] input[type="email"],
[data-app-shell] input[type="password"],
[data-app-shell] input[type="number"],
[data-app-shell] input[type="search"],
[data-app-shell] input[type="url"],
[data-app-shell] input[type="tel"],
[data-app-shell] input[type="date"],
[data-app-shell] input[type="datetime-local"],
[data-app-shell] textarea,
[data-app-shell] select {
  width: 100%;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  transition: var(--transition);
  box-sizing: border-box;
}
[data-app-shell] input:focus,
[data-app-shell] textarea:focus,
[data-app-shell] select:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(0, 217, 255, 0.15);
}
[data-app-shell] input::placeholder,
[data-app-shell] textarea::placeholder {
  color: var(--text-muted);
}
[data-app-shell] textarea {
  min-height: 84px;
  resize: vertical;
}

/* --- Native <select> dropdown arrow --- */
[data-app-shell] select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 36px;
  cursor: pointer;
}
[data-app-shell] select:hover { border-color: var(--border-strong, #2a3360); }

/* compact select used inline in headers/toolbars */
[data-app-shell] select.select-sm,
[data-app-shell] .filters select {
  width: auto;
  padding: 8px 32px 8px 12px;
  font-size: 13px;
}

/* --- Auto-width select inside a page-header (used by admin/scans.html) --- */
.page-header select {
  width: auto;
  min-width: 220px;
  max-width: 360px;
  margin-top: 6px;
}

/* --- Fieldset / legend --- */
[data-app-shell] fieldset {
  display: flex;
  flex-direction: column;
  gap: 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 18px 20px 20px;
  margin: 0 0 16px;
  background: rgba(20, 26, 64, 0.35);
}
[data-app-shell] fieldset > legend {
  display: inline-block;
  padding: 2px 10px;
  margin-left: -4px;
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
}

/* horizontal field row inside a fieldset */
[data-app-shell] fieldset .field-row,
[data-app-shell] fieldset .grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

/* --- Plain <label> inside fieldset/card-body (no .field wrapper) --- */
[data-app-shell] fieldset > label,
[data-app-shell] .card-body > label,
[data-app-shell] form > label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* inline label (label + input on same row) */
[data-app-shell] label.inline {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

/* --- Custom checkbox / radio --- */
[data-app-shell] input[type="checkbox"],
[data-app-shell] input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  background: var(--bg-elevated);
  border: 1.5px solid var(--border-subtle);
  border-radius: 4px;
  cursor: pointer;
  position: relative;
  transition: var(--transition);
  vertical-align: middle;
}
[data-app-shell] input[type="radio"] { border-radius: 50%; }
[data-app-shell] input[type="checkbox"]:hover,
[data-app-shell] input[type="radio"]:hover {
  border-color: var(--accent-primary);
}
[data-app-shell] input[type="checkbox"]:checked {
  background: var(--gradient-accent);
  border-color: transparent;
}
[data-app-shell] input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 1px;
  width: 5px;
  height: 10px;
  border: solid #0a0e27;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
[data-app-shell] input[type="radio"]:checked {
  border-color: var(--accent-primary);
  background: var(--bg-elevated);
}
[data-app-shell] input[type="radio"]:checked::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--gradient-accent);
}
[data-app-shell] input[type="checkbox"]:focus-visible,
[data-app-shell] input[type="radio"]:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* checkbox cell layout (label-with-checkbox in fieldsets like scan_new) */
[data-app-shell] fieldset label:has(> input[type="checkbox"]),
[data-app-shell] fieldset label:has(> input[type="radio"]) {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  font-size: 13.5px;
  color: var(--text-primary);
}
[data-app-shell] fieldset label:has(> input[type="checkbox"]:checked),
[data-app-shell] fieldset label:has(> input[type="radio"]:checked) {
  border-color: rgba(0, 217, 255, 0.45);
  background: rgba(0, 217, 255, 0.08);
}
[data-app-shell] fieldset label:has(> input[type="checkbox"]):hover,
[data-app-shell] fieldset label:has(> input[type="radio"]):hover {
  border-color: var(--accent-primary);
}

/* --- File input --- */
[data-app-shell] input[type="file"] {
  width: 100%;
  padding: 8px 14px;
  background: var(--bg-elevated);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
}
[data-app-shell] input[type="file"]:hover { border-color: var(--accent-primary); }
[data-app-shell] input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 6px 14px;
  background: var(--gradient-accent);
  color: #0a0e27;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  font-size: 12.5px;
  cursor: pointer;
}
[data-app-shell] input[type="file"]::-webkit-file-upload-button {
  margin-right: 12px;
  padding: 6px 14px;
  background: var(--gradient-accent);
  color: #0a0e27;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  font-size: 12.5px;
  cursor: pointer;
}

/* --- Page header w/ trailing action(s) on the right --- */
.page-header {
  position: relative;
}
.page-header > .btn-primary,
.page-header > .btn-ghost,
.page-header > .btn-danger,
.page-header > a[class*="btn-"] {
  position: absolute;
  top: 4px;
  right: 0;
}

/* --- Alert / banner message --- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
}
.alert-warning {
  border-left: 3px solid var(--accent-warning);
  border-color: var(--border-subtle);
  background: rgba(255, 184, 0, 0.06);
  color: var(--text-primary);
}
.alert-error {
  border-left: 3px solid var(--accent-alert);
  background: rgba(255, 78, 108, 0.08);
  color: var(--text-primary);
}
.alert-success {
  border-left: 3px solid var(--accent-success);
  background: rgba(16, 217, 160, 0.08);
  color: var(--text-primary);
}

/* --- Filters bar (used in admin/users.html) --- */
.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
}
.filters input,
.filters select {
  width: auto;
  min-width: 180px;
}

/* --- Two-line cell (email + name in admin/users) --- */
.cell-stack { display: flex; flex-direction: column; gap: 2px; }
.cell-stack strong { color: var(--text-primary); font-size: 14px; }
.cell-stack small { color: var(--text-muted); font-size: 12px; }

/* --- Toast notifications (used by PaasLayout.toast) --- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--accent-primary);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  box-shadow: var(--shadow-md);
  z-index: 9999;
  font-size: 14px;
}
.toast.toast-error { border-left-color: var(--accent-alert); }
.toast.toast-success { border-left-color: var(--accent-success); }

