/* ==========================================================================
   DDA Commercial Platform — SOTA Design System (Arabic First & Code Polish)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
  /* Color Palette - Midnight Slate & Precision Accents */
  --bg-app: #090d16;
  --bg-sidebar: #0f172a;
  --bg-topbar: rgba(15, 23, 42, 0.85);
  --bg-canvas: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --bg-dark-card: #131d31;
  --bg-dark-card-hover: #1e293b;

  /* Borders & Dividers */
  --border-subtle: #e2e8f0;
  --border-medium: #cbd5e1;
  --border-dark: #1e293b;
  --border-dark-hover: #334155;

  /* Typography Colors */
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-light: #f8fafc;
  --text-light-secondary: #94a3b8;
  --text-light-muted: #64748b;

  /* Brand Accents */
  --accent-primary: #2563eb;
  --accent-primary-hover: #1d4ed8;
  --accent-primary-light: #eff6ff;
  --accent-emerald: #10b981;
  --accent-emerald-light: #ecfdf5;
  --accent-emerald-border: #a7f3d0;
  --accent-emerald-text: #065f46;
  --accent-amber: #f59e0b;
  --accent-amber-light: #fffbeb;
  --accent-amber-border: #fde68a;
  --accent-amber-text: #92400e;
  --accent-rose: #ef4444;
  --accent-rose-light: #fef2f2;
  --accent-rose-border: #fecaca;
  --accent-rose-text: #991b1b;
  --accent-indigo: #6366f1;
  --accent-indigo-light: #eef2ff;

  /* Elevation & Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.03);
  --shadow-dark-card: 0 4px 20px -2px rgba(0, 0, 0, 0.3);

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Fonts */
  --font-sans: 'IBM Plex Sans Arabic', 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Dimensions */
  --sidebar-width: 270px;
  --topbar-height: 68px;
}

/* ==========================================================================
   CSS Reset & Base
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: var(--font-sans);
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  max-width: 100vw;
}

/* RTL stable layout */
[dir="rtl"] {
  text-align: right;
}

a {
  color: var(--accent-primary);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--accent-primary-hover);
}

.font-mono {
  font-family: var(--font-mono);
  direction: ltr;
}

code {
  font-family: var(--font-mono);
  direction: ltr;
  padding: 0.15rem 0.35rem;
  background: var(--bg-card-subtle);
  border-radius: var(--radius-sm);
  font-size: 0.85em;
}

pre {
  font-family: var(--font-mono);
  direction: ltr;
  display: block;
  max-width: 100%;
  white-space: pre-wrap;
  word-break: break-all;
  overflow-wrap: anywhere;
  box-sizing: border-box;
}

/* ==========================================================================
   App Layout Grid (Sidebar + Topbar + Main Canvas)
   ========================================================================== */
.app-shell {
  display: flex;
  min-height: 100vh;
  width: 100%;
  max-width: 100vw;
  background-color: var(--bg-canvas);
  overflow-x: hidden;
  box-sizing: border-box;
}

/* Sidebar */
.app-sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border-dark);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  right: 0;
  z-index: 50;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-sizing: border-box;
}


.sidebar-brand {
  height: var(--topbar-height);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border-dark);
}

.brand-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 1.1rem;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4);
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-light);
  letter-spacing: -0.01em;
}

.brand-subtitle {
  font-size: 0.7rem;
  color: var(--text-light-muted);
  font-weight: 500;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.nav-group-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-light-muted);
  padding: 0 0.75rem 0.4rem;
}

.nav-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-md);
  color: var(--text-light-secondary);
  font-size: 0.88rem;
  font-weight: 500;
  transition: all 0.15s ease;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-light);
}

.nav-link.active {
  background: rgba(37, 99, 235, 0.18);
  color: #60a5fa;
  font-weight: 600;
  border-right: 3px solid #3b82f6;
}

.nav-link svg {
  width: 18px;
  height: 18px;
  opacity: 0.85;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-dark);
  background: rgba(0, 0, 0, 0.15);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  background: #334155;
  color: var(--text-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
}

.user-meta {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.72rem;
  color: var(--text-light-muted);
}

/* Main Area */
.app-main {
  flex: 1 1 auto;
  margin-right: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: calc(100vw - var(--sidebar-width));
  overflow-x: hidden;
  box-sizing: border-box;
}

/* Topbar */
.app-topbar {
  height: var(--topbar-height);
  background: #ffffff;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: var(--shadow-sm);
  box-sizing: border-box;
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.org-selector-chip {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.85rem;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-primary);
}

.org-selector-chip svg {
  color: var(--text-muted);
}

.env-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
}

.env-badge.live {
  background: var(--accent-emerald-light);
  color: var(--accent-emerald-text);
  border: 1px solid var(--accent-emerald-border);
}

.env-badge.test {
  background: var(--accent-amber-light);
  color: var(--accent-amber-text);
  border: 1px solid var(--accent-amber-border);
}

.wallet-balance-chip {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.35rem 0.85rem;
  background: #f8fafc;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.balance-amount {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.balance-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Page Canvas */
.page-canvas {
  flex: 1;
  padding: 2rem 2.5rem;
  max-width: 1380px;
  width: 100%;
  margin: 0 auto;
  min-width: 0;
  box-sizing: border-box;
}


/* Breadcrumbs & Page Header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2rem;
  gap: 1rem;
}

.page-title-group h1 {
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
}

.page-description {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* ==========================================================================
   Buttons & Action Controls
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.55rem 1.15rem;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: var(--font-sans);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent-primary);
  color: white;
  border-color: var(--accent-primary);
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover {
  background: var(--accent-primary-hover);
  color: white;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.4);
}

.btn-secondary {
  background: #ffffff;
  color: var(--text-primary);
  border-color: var(--border-medium);
}

.btn-secondary:hover {
  background: var(--bg-card-subtle);
  border-color: #94a3b8;
}

.btn-success {
  background: #059669;
  color: white;
}

.btn-success:hover {
  background: #047857;
}

.btn-danger {
  background: #dc2626;
  color: white;
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-card-subtle);
  color: var(--text-primary);
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  border-radius: var(--radius-lg);
}

/* ==========================================================================
   Cards & Surfaces
   ========================================================================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-medium);
}


.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
}

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

.card-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.dark-surface {
  background: var(--bg-dark-card);
  border: 1px solid var(--border-dark);
  color: var(--text-light);
}

.dark-surface .card-title {
  color: var(--text-light);
}

/* Metric / KPI Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.35rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

.stat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.stat-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stat-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-primary-light);
  color: var(--accent-primary);
}

.stat-value {
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-mono);
  letter-spacing: -0.03em;
}

.stat-subtext {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 0.35rem;
}

/* ==========================================================================
   Data Tables
   ========================================================================== */
.table-container {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  background: #ffffff;
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
  font-size: 0.88rem;
}

th {
  background: #f8fafc;
  padding: 0.85rem 1.15rem;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
}

td {
  padding: 0.95rem 1.15rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background-color: #f8fafc;
}

/* Badges & Status Chips */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  font-size: 0.76rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  line-height: 1.2;
}

.badge-success {
  background: var(--accent-emerald-light);
  color: var(--accent-emerald-text);
  border: 1px solid var(--accent-emerald-border);
}

.badge-warning {
  background: var(--accent-amber-light);
  color: var(--accent-amber-text);
  border: 1px solid var(--accent-amber-border);
}

.badge-danger {
  background: var(--accent-rose-light);
  color: var(--accent-rose-text);
  border: 1px solid var(--accent-rose-border);
}

.badge-info {
  background: var(--accent-primary-light);
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

.badge-neutral {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}

/* ==========================================================================
   Code Snippet & Token Display
   ========================================================================== */
.code-block-container {
  position: relative;
  background: #0f172a;
  border-radius: var(--radius-lg);
  border: 1px solid #1e293b;
  overflow: hidden;
  margin: 1rem 0;
  max-width: 100%;
  box-sizing: border-box;
}

.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  background: #1e293b;
  border-bottom: 1px solid #334155;
  color: #94a3b8;
  font-size: 0.75rem;
  font-family: var(--font-mono);
}

.code-content {
  padding: 1.25rem;
  overflow-x: auto;
  color: #e2e8f0;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  direction: ltr;
  text-align: left;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  max-width: 100%;
  box-sizing: border-box;
}

.copy-btn {
  background: rgba(255, 255, 255, 0.1);
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.15s ease;
  white-space: nowrap;
}

/* ==========================================================================
   Playground Layout & Console Styling
   ========================================================================== */
.playground-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 1.5rem;
  align-items: start;
  width: 100%;
  box-sizing: border-box;
}

.embed-builder-grid {
  grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
}

@media (max-width: 1100px) {
  .playground-grid,
  .embed-builder-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.playground-response-card {
  position: sticky;
  top: calc(var(--topbar-height) + 1.25rem);
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.response-viewer-body {
  position: relative;
  border-radius: var(--radius-md);
  background: #090d16;
  border: 1px solid #1e293b;
  overflow: hidden;
  max-width: 100%;
  box-sizing: border-box;
}

.pg-response-viewer {
  min-height: 480px;
  max-height: calc(100vh - 240px);
  overflow-y: auto;
  overflow-x: auto;
  padding: 1.25rem;
  color: #38bdf8;
  font-size: 0.84rem;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-all;
  overflow-wrap: anywhere;
  box-sizing: border-box;
}

/* Snippet Tabs */
.snippet-tabs-container {
  background: #090d16;
  border: 1px solid #1e293b;
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-top: 1rem;
  max-width: 100%;
  box-sizing: border-box;
}

.snippet-tabs-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.75rem;
  background: #0f172a;
  border-bottom: 1px solid #1e293b;
}

.snippet-tabs-list {
  display: flex;
  gap: 0.25rem;
}

.snippet-tab-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: var(--font-mono);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.snippet-tab-btn:hover {
  color: #f8fafc;
  background: rgba(255, 255, 255, 0.05);
}

.snippet-tab-btn.active {
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.25);
}


.copy-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.token-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: #0f172a;
  color: #38bdf8;
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  border: 1px solid #1e293b;
  direction: ltr;
}

/* ==========================================================================
   Forms & Input Controls
   ========================================================================== */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
}

.form-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

.form-control, input[type="text"], input[type="email"], input[type="password"], input[type="url"], input[type="number"], select, textarea {
  width: 100%;
  padding: 0.6rem 0.9rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  background: #ffffff;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  transition: all 0.15s ease;
  outline: none;
}

.form-control:focus, input:focus, select:focus, textarea:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* ==========================================================================
   Toasts & Flash Messages
   ========================================================================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 420px;
}

.toast {
  background: #0f172a;
  color: #ffffff;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-right: 4px solid var(--accent-primary);
  animation: slideUp 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast.success { border-right-color: var(--accent-emerald); }
.toast.error { border-right-color: var(--accent-rose); }
.toast.warning { border-right-color: var(--accent-amber); }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Interactive Tabs
   ========================================================================== */
.tabs-nav {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 1.5rem;
}

.tab-btn {
  padding: 0.65rem 1.15rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */
@media (max-width: 1024px) {
  .app-sidebar {
    transform: translateX(100%);
  }
  .app-sidebar.open {
    transform: translateX(0);
  }
  .app-main {
    margin-right: 0;
  }
  .page-canvas {
    padding: 1.5rem 1rem;
  }
}

/* ==========================================================================
   Modal Dialogs & Secret Key Presentation
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1.5rem;
}

.modal-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.08);
  width: 100%;
  max-width: 620px;
  border: 1px solid var(--border-subtle);
  overflow: hidden;
  animation: modalScaleIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalScaleIn {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  background: #f8fafc;
  border-top: 1px solid var(--border-subtle);
}

.key-display-box {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  background: #0f172a;
  padding: 0.5rem;
  border-radius: var(--radius-md);
  border: 1px solid #1e293b;
}

.key-display-box input {
  flex: 1;
  background: transparent;
  border: none;
  color: #38bdf8;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  padding: 0.5rem 0.75rem;
  outline: none;
  direction: ltr;
}

.key-display-box input:focus {
  box-shadow: none;
}
.demo-ribbon {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .75rem;
    padding: .65rem 1rem;
    background: #172554;
    color: #dbeafe;
    font-size: .82rem;
    letter-spacing: .01em;
}
.demo-ribbon strong { color: #fff; white-space: nowrap; }
.auth-stage { min-height: 78vh; display: grid; place-items: center; padding: 2rem 1rem; }
.auth-card { width: min(100%, 480px); padding: 2.5rem; border: 1px solid #dbe4ef; border-radius: 24px; background: #fff; box-shadow: 0 24px 70px rgba(15, 35, 66, .12); }
.auth-card-wide { width: min(100%, 660px); }
.auth-mark { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 16px; background: #172554; color: #fff; font-weight: 800; }
.auth-kicker { margin: 1.25rem 0 .35rem; color: #1d4ed8; font-size: .78rem; font-weight: 800; letter-spacing: .08em; }
.auth-card h1 { margin: 0; color: #14213d; font-size: 1.65rem; }
.auth-lead { color: #64748b; line-height: 1.8; }
.mfa-secret { margin: 1.25rem 0; padding: 1rem; border: 1px dashed #93a4b8; border-radius: 14px; background: #f8fafc; text-align: center; font: 700 .95rem/1.6 ui-monospace, monospace; overflow-wrap: anywhere; letter-spacing: .08em; }
.mfa-uri { margin-bottom: 1.25rem; color: #64748b; }
.mfa-uri code { display: block; margin-top: .6rem; overflow-wrap: anywhere; font-size: .72rem; }
.auth-form { display: grid; gap: .75rem; }
.auth-form label { color: #334155; font-weight: 700; }
.auth-form input { width: 100%; padding: .9rem 1rem; border: 1px solid #cbd5e1; border-radius: 12px; font: 600 1.05rem/1.4 inherit; box-sizing: border-box; }
.recovery-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; margin: 1.5rem 0; }
.recovery-grid code { padding: .8rem; border-radius: 10px; background: #f1f5f9; text-align: center; }
@media (max-width: 600px) { .demo-ribbon { align-items: flex-start; flex-direction: column; gap: .2rem; } .auth-card { padding: 1.5rem; } .recovery-grid { grid-template-columns: 1fr; } }
