/* app.css — mobile-first, LTR (English) */
@import "fonts.css";

:root {
  --color-primary:        #2563EB;
  --color-primary-hover:  #1d4ed8;
  --color-primary-light:  #eff6ff;
  --color-secondary:      #6b7280;
  --color-success:        #16a34a;
  --color-success-light:  #f0fdf4;
  --color-error:          #dc2626;
  --color-error-light:    #fef2f2;
  --color-warning:        #d97706;
  --color-warning-light:  #fffbeb;
  --color-bg:             #f9fafb;
  --color-surface:        #ffffff;
  --color-border:         #e5e7eb;
  --color-border-strong:  #d1d5db;
  --color-text:           #111827;
  --color-text-secondary: #374151;
  --color-muted:          #6b7280;
  --color-muted-light:    #9ca3af;
  --red:                  #dc2626;

  --font-en: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-fa: "Vazirmatn", "Vazir", system-ui, -apple-system, sans-serif;

  --radius-xs:  0.25rem;
  --radius-sm:  0.375rem;
  --radius-md:  0.5rem;
  --radius-lg:  0.75rem;
  --radius-xl:  1rem;
  --radius-2xl: 1.5rem;

  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

  --transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 16px; }

body {
  margin: 0;
  font-family: var(--font-en);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Typography ─────────────────────────────────────────────────────────── */
h1 { font-size: clamp(1.375rem, 4vw, 1.875rem); font-weight: 700; }
h2 { font-size: clamp(1.125rem, 3vw, 1.375rem); font-weight: 600; }
h3 { font-size: clamp(1rem, 2.5vw, 1.125rem);   font-weight: 600; }
h1, h2, h3, h4 { margin-block: 0 0.5em; line-height: 1.25; letter-spacing: -0.01em; }
p  { margin-block: 0 1em; }

a  { color: var(--color-primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--color-primary-hover); text-decoration: none; }

code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.875em;
  background: #f3f4f6;
  color: #374151;
  padding: 0.125em 0.375em;
  border-radius: var(--radius-xs);
  border: 1px solid var(--color-border);
}

/* ── Layout ─────────────────────────────────────────────────────────────── */
.container {
  width: 100%;
  padding-inline: 1rem;
  margin-inline: auto;
}
@media (min-width: 480px)  { .container { max-width: 540px; } }
@media (min-width: 768px)  { .container { max-width: 768px;  padding-inline: 1.5rem; } }
@media (min-width: 1024px) { .container { max-width: 1024px; padding-inline: 2rem; } }
@media (min-width: 1280px) { .container { max-width: 1280px; } }

.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }

/* ── Navigation ─────────────────────────────────────────────────────────── */
.navbar {
  background: var(--color-surface);
  border-block-end: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 30;
  height: 56px;
  display: flex;
  align-items: center;
  box-shadow: var(--shadow-xs);
}
.navbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: none;
  width: 100%;
  padding-inline: 1.25rem;
}
@media (min-width: 768px) {
  .navbar .container { padding-inline: 1.5rem; }
}

.navbar-brand {
  font-weight: 700;
  font-size: 1.0625rem;
  color: var(--color-primary);
  letter-spacing: -0.01em;
  flex-shrink: 0;
  text-decoration: none;
}
.navbar-brand:hover { color: var(--color-primary-hover); }
.navbar-logo { height: 2rem; width: auto; display: block; }

.navbar-nav {
  align-items: center;
  gap: 0.25rem;
  flex: 1;
  padding-inline-start: 1.5rem;
}

.nav-link {
  display: flex;
  align-items: center;
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-muted);
  transition: color var(--transition), background-color var(--transition);
  white-space: nowrap;
}
.nav-link:hover { color: var(--color-text); background: #f3f4f6; }
.nav-link.active { color: var(--color-primary); background: var(--color-primary-light); }

.navbar-end {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.lang-btn {
  display: flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-muted);
  border: 1px solid var(--color-border);
  transition: all var(--transition);
  text-decoration: none;
}
.lang-btn:hover { color: var(--color-text); border-color: var(--color-border-strong); background: #f9fafb; }
.lang-btn--active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.lang-btn--active:hover { background: var(--color-primary-hover); color: #fff; }

/* ── Page chrome ─────────────────────────────────────────────────────────── */
.main-content {
  padding-block: 1.5rem;
}
@media (min-width: 768px) { .main-content { padding-block: 2rem; } }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-block-end: 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.page-header h1, .page-header h2 { margin: 0; }

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--color-muted);
}
.empty-state p { margin: 0; }

/* ── Breadcrumb ─────────────────────────────────────────────────────────── */
.breadcrumb-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.8125rem;
  color: var(--color-muted);
  text-decoration: none;
  margin-block-end: 0.25rem;
}
.breadcrumb-link:hover { color: var(--color-primary); }

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 1.25rem;
  box-shadow: var(--shadow-xs);
}
@media (min-width: 768px) { .card { padding: 1.5rem; } }

.card-section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-block-end: 1rem;
}
.card-section-title { font-size: 1rem; font-weight: 600; margin: 0 0 0.25rem; }
.card-section-hint  { font-size: 0.8125rem; color: var(--color-muted); margin: 0; }

.card-sep {
  border: none;
  border-block-start: 1px solid var(--color-border);
  margin-block: 1.25rem;
  margin-inline: -1.25rem;
}
@media (min-width: 768px) { .card-sep { margin-inline: -1.5rem; } }

.add-row {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}
.add-row-input { flex: 1; min-width: 0; }

/* ── Forms ──────────────────────────────────────────────────────────────── */
.form-group   { display: flex; flex-direction: column; gap: 0.375rem; margin-block-end: 1.125rem; }
.form-label   { font-size: 0.875rem; font-weight: 500; color: var(--color-text-secondary); display: flex; flex-direction: column; gap: 0.25rem; }
.form-grid-2  { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-block-end: 1rem; }
.font-mono    { font-family: ui-monospace, "Cascadia Code", "Source Code Pro", monospace; font-size: 0.85rem; }
.form-control {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  font-family: inherit;
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color var(--transition), box-shadow var(--transition);
  min-height: 44px;
  outline: none;
}
.form-control::placeholder { color: var(--color-muted-light); }
.form-control:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgb(37 99 235 / 0.15);
}

.form-control-sm {
  padding: 0.3125rem 0.625rem;
  font-size: 0.875rem;
  min-height: 36px;
}

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
  transition: background-color var(--transition), color var(--transition), border-color var(--transition), box-shadow var(--transition);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.25;
}
.btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
  color: #fff;
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text-secondary);
  border-color: var(--color-border-strong);
}
.btn-secondary:hover:not(:disabled) {
  background: #f9fafb;
  border-color: #9ca3af;
  color: var(--color-text);
}

.btn-danger {
  background: var(--color-surface);
  color: var(--color-error);
  border-color: #fca5a5;
}
.btn-danger:hover:not(:disabled) {
  background: var(--color-error-light);
  border-color: var(--color-error);
}

.btn-sm {
  padding: 0.3125rem 0.75rem;
  font-size: 0.8125rem;
  min-height: 32px;
  min-width: 32px;
  border-radius: var(--radius-sm);
}

/* ── Tables ─────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th {
  padding: 0.75rem 1rem;
  text-align: start;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #f9fafb;
  border-block-end: 1px solid var(--color-border);
}
td {
  padding: 0.875rem 1rem;
  text-align: start;
  border-block-end: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  vertical-align: middle;
}
tr:last-child td { border-block-end: none; }
tbody tr { transition: background-color var(--transition); }
tbody tr:hover { background: #fafafa; }
.clickable-row { cursor: pointer; }
.row-link { display: block; color: inherit; text-decoration: none; }

/* Mobile card layout for tables */
table[data-mobile="cards"] thead            { display: none; }
table[data-mobile="cards"] tr               { display: block; margin-block-end: 0.75rem; border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: 0.75rem; background: var(--color-surface); }
table[data-mobile="cards"] td               { display: flex; justify-content: space-between; align-items: center; border: none; padding-block: 0.375rem; }
table[data-mobile="cards"] td::before       { content: attr(data-label); font-weight: 600; font-size: 0.75rem; color: var(--color-muted); text-transform: uppercase; letter-spacing: 0.04em; }
@media (min-width: 768px) {
  table[data-mobile="cards"] thead          { display: table-header-group; }
  table[data-mobile="cards"] tr             { display: table-row; margin-block-end: 0; border: none; border-radius: 0; padding: 0; background: transparent; }
  table[data-mobile="cards"] td             { display: table-cell; justify-content: initial; border-block-end: 1px solid var(--color-border); padding-block: 0.875rem; }
  table[data-mobile="cards"] td::before     { display: none; }
  table[data-mobile="cards"] tr:last-child td { border-block-end: none; }
}

/* ── Alerts ─────────────────────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-lg);
  margin-block-end: 1rem;
  font-size: 0.9rem;
  line-height: 1.5;
}
.alert-error   {
  background: var(--color-error-light);
  color: #991b1b;
  border: 1px solid #fecaca;
}
.alert-success {
  background: var(--color-success-light);
  color: #166534;
  border: 1px solid #bbf7d0;
}
.alert-warning {
  background: var(--color-warning-light);
  color: #92400e;
  border: 1px solid #fde68a;
}

/* ── Badges ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1875em 0.625em;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
}
.badge-green     { background: #dcfce7; color: #166534; }
.badge-yellow    { background: #fef9c3; color: #854d0e; }
.badge-red       { background: #fee2e2; color: #991b1b; }
.badge-gray      { background: #f3f4f6; color: #4b5563; border: 1px solid #e5e7eb; }
.badge-blue      { background: var(--color-primary-light); color: var(--color-primary); }
.badge--success  { background: #dcfce7; color: #15803d; }
.badge--error    { background: #fee2e2; color: #b91c1c; }
.badge--warn     { background: #fef9c3; color: #854d0e; }

/* ── Utility ────────────────────────────────────────────────────────────── */
.hidden        { display: none !important; }
.mt-1          { margin-block-start: 0.25rem; }
.mt-2          { margin-block-start: 0.5rem; }
.mt-4          { margin-block-start: 1rem; }
.mt-6          { margin-block-start: 1.5rem; }
.mb-2          { margin-block-end: 0.5rem; }
.mb-4          { margin-block-end: 1rem; }
.ms-2          { margin-inline-start: 0.5rem; }
.text-center   { text-align: center; }
.text-muted    { color: var(--color-muted); font-size: 0.875rem; }
.text-sm       { font-size: 0.875rem; }
.text-xs       { font-size: 0.75rem; }
.text-primary  { color: var(--color-primary); }
.text-error    { color: var(--color-error); }
.font-medium   { font-weight: 500; }
.font-semibold { font-weight: 600; }
.w-full        { width: 100%; }
.flex-1        { flex: 1; }
[x-cloak]      { display: none !important; }
.form-inline   { display: inline; }
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ── Auth pages ─────────────────────────────────────────────────────────── */
.auth-wrap {
  min-height: calc(100vh - 56px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}
.auth-box   {
  width: 100%;
  max-width: 420px;
}
.auth-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2xl);
  padding: 2rem;
  box-shadow: var(--shadow-md);
}
.auth-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-block-end: 0.25rem;
  text-align: center;
  letter-spacing: -0.02em;
}
.auth-subtitle {
  text-align: center;
  color: var(--color-muted);
  font-size: 0.9rem;
  margin-block-end: 1.75rem;
}
.auth-footer {
  margin-block-start: 1rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--color-muted);
}
.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-block: 1.25rem;
  color: var(--color-muted);
  font-size: 0.8125rem;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

/* ── Dashboard cards ─────────────────────────────────────────────────────── */
.dash-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  margin-block-start: 1.5rem;
}
.dash-card {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.25rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}
.dash-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
  color: inherit;
}
.dash-icon  {
  font-size: 1.75rem;
  line-height: 1;
}
.dash-card-title { font-weight: 600; font-size: 0.9375rem; color: var(--color-text); }
.dash-card-desc  { font-size: 0.8125rem; color: var(--color-muted); margin-block-start: 0.125rem; }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 0.45);
  z-index: 40;
  backdrop-filter: blur(2px);
}
.modal {
  position: fixed;
  inset-block-start: 50%;
  inset-inline-start: 50%;
  transform: translate(-50%, -50%);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2xl);
  padding: 1.5rem;
  width: min(480px, calc(100vw - 2rem));
  z-index: 50;
  box-shadow: var(--shadow-xl);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-block-end: 1rem;
}
.modal-title  { margin: 0; font-size: 1.0625rem; font-weight: 600; }
.modal-close  {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--color-muted);
  padding: 0.25rem;
  line-height: 1;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
}
.modal-close:hover { color: var(--color-text); background: #f3f4f6; }
.modal-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  box-shadow: var(--shadow-xl);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-block-start: 1.5rem;
}

/* ── Simple editor ───────────────────────────────────────────────────────── */
.editor-wrap { border: 1px solid var(--color-border); border-radius: var(--radius-md); overflow: hidden; }
.editor-toolbar {
  display: flex; flex-wrap: wrap; gap: 2px; padding: 6px 8px;
  background: var(--color-bg); border-bottom: 1px solid var(--color-border);
}
.editor-toolbar button {
  min-width: 30px; height: 30px; padding: 0 6px;
  border: none; border-radius: var(--radius-sm); background: transparent;
  cursor: pointer; font-size: 0.875rem; color: var(--color-text);
  display: flex; align-items: center; justify-content: center;
}
.editor-toolbar button:hover { background: var(--color-border); }
.editor-toolbar .sep { width: 1px; background: var(--color-border); margin: 4px 2px; }
.editor-content {
  min-height: 8rem; max-height: 22rem; overflow-y: auto;
  padding: 10px 12px; outline: none; font-size: 0.925rem; line-height: 1.6;
}
.editor-content:focus { box-shadow: inset 0 0 0 2px var(--color-primary); }
.editor-content.editor-empty::before {
  content: attr(data-placeholder);
  color: var(--color-text-muted); pointer-events: none;
}

/* file upload zone */
.upload-zone {
  border: 2px dashed var(--color-border); border-radius: var(--radius-md);
  padding: 12px 16px; cursor: pointer; transition: border-color .15s;
  display: flex; align-items: center; gap: 10px; color: var(--color-text-muted);
}
.upload-zone:hover { border-color: var(--color-primary); color: var(--color-primary); }
.upload-zone input[type=file] { display: none; }
.file-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.file-chip {
  display: flex; align-items: center; gap: 6px; padding: 3px 10px;
  background: var(--color-bg); border: 1px solid var(--color-border);
  border-radius: 99px; font-size: 0.8rem;
}
.file-chip-remove { cursor: pointer; opacity: .6; }
.file-chip-remove:hover { opacity: 1; }

/* attachment link in message */
.attachment-link {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; background: var(--color-bg);
  border: 1px solid var(--color-border); border-radius: var(--radius-md);
  font-size: 0.8rem; text-decoration: none; color: var(--color-text);
}
.attachment-link:hover { border-color: var(--color-primary); color: var(--color-primary); }

/* ── Danger zone ─────────────────────────────────────────────────────────── */
.danger-zone {
  margin-block-start: 2rem;
  border-color: #fca5a5;
  background: #fff5f5;
}
.danger-zone h2 { color: var(--color-error); }

/* ── Metrics ─────────────────────────────────────────────────────────────── */
.metric-chart   { width: 100%; height: auto; display: block; }
.chart-wrap     { overflow-x: auto; }
.metric-legend  { display: flex; gap: 1rem; align-items: center; font-size: 0.8125rem; margin-block-end: 0.75rem; flex-wrap: wrap; color: var(--color-muted); }
.legend-dot          { display: inline-block; width: 0.625rem; height: 0.625rem; border-radius: 50%; }
.legend-dot-issue    { background: #3b82f6; }
.legend-dot-ok       { background: #22c55e; }
.legend-dot-fail     { background: #ef4444; }
.input-quota         { width: 6.25rem; }

/* Skeleton loading */
@keyframes skel-shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skel {
  background: linear-gradient(90deg, var(--color-border) 25%, rgba(255,255,255,.4) 50%, var(--color-border) 75%);
  background-size: 800px 100%;
  animation: skel-shimmer 1.4s infinite linear;
  border-radius: 4px;
}
.skel--line   { display: block; }
.skel-wrap    { pointer-events: none; }

.stats-row      { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.stat-card      {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 1.25rem;
  text-align: center;
  box-shadow: var(--shadow-xs);
}
.stat-value          { font-size: 1.75rem; font-weight: 700; line-height: 1.1; color: var(--color-text); }
.stat-value--ok      { color: var(--color-success); }
.stat-value--fail    { color: var(--color-error); }
.stat-label          { font-size: 0.8125rem; color: var(--color-muted); margin-block-start: 0.25rem; }
.stat-card           { position: relative; }
.stat-card .sc-help  { position: absolute; top: .5rem; left: .5rem; margin: 0; }
.stat-card .sc-help summary { color: var(--color-muted); padding: 0.125rem; border-radius: 50%; }
.stat-card .sc-help summary:hover { color: var(--color-primary); }
.stat-card .sc-help summary::after { display: none; }
.stat-card .sc-help[open] summary { color: var(--color-primary); }
.text-right          { text-align: end; }
.mono                { font-family: ui-monospace, "Cascadia Code", Menlo, monospace; font-size: 0.875rem; }
.mini-bar-wrap       { display: flex; align-items: center; gap: 0.5rem; }
.mini-bar            { height: 6px; border-radius: 3px; background: var(--color-primary); min-width: 2px; }
.mini-bar--ip        { background: var(--color-warning); }
.mini-bar-pct        { font-size: 0.75rem; color: var(--color-muted); white-space: nowrap; }

/* ── UA breakdown grid ───────────────────────────────────────────────────── */
.ua-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}
@media (min-width: 768px) { .ua-grid { grid-template-columns: 1fr 1fr; } }
.ua-bar-list   { display: flex; flex-direction: column; gap: 0.625rem; }
.ua-bar-row    { display: flex; align-items: center; gap: 0.75rem; }
.ua-bar-label  { min-width: 5.5rem; font-size: 0.875rem; color: var(--color-text-secondary); }
.ua-bar-track  { flex: 1; height: 8px; border-radius: 4px; background: var(--color-bg); overflow: hidden; }
.ua-bar-fill   { height: 100%; border-radius: 4px; min-width: 2px; transition: width 0.4s ease; }
.ua-bar-fill--os  { background: var(--color-primary); }
.ua-bar-fill--dev { background: #8b5cf6; }
.ua-bar-count  { min-width: 2.5rem; font-size: 0.8125rem; color: var(--color-muted); text-align: end; }

/* ── Tab bar ─────────────────────────────────────────────────────────────── */
.tab-bar   {
  display: flex;
  gap: 0.25rem;
  border-block-end: 2px solid var(--color-border);
  margin-block-end: 1.25rem;
  flex-wrap: wrap;
}
.tab { padding: 0.5rem 1rem; cursor: pointer; border-radius: var(--radius-sm) var(--radius-sm) 0 0; font-size: 0.875rem; font-weight: 500; border: none; background: none; color: var(--color-muted); transition: color var(--transition), background var(--transition); }
.tab.active { background: var(--color-primary); color: #fff; }
/* tab-panel visibility via Alpine x-show only */
.tab-link       { padding: 0.5rem 1rem; text-decoration: none; color: var(--color-muted); border-radius: var(--radius-sm) var(--radius-sm) 0 0; font-size: 0.875rem; font-weight: 500; transition: color var(--transition); }
.tab-link.active { color: var(--color-primary); border-block-end: 2px solid var(--color-primary); margin-block-end: -2px; font-weight: 600; }

/* ── CAPTCHA Strategy Cards ─────────────────────────────────────────────── */
.strategy-grid  { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); margin-block-end: 1rem; }
.strategy-card  {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: var(--color-surface);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--transition), border-color var(--transition);
}
.strategy-card:has(.strategy-acc-hdr[aria-expanded="true"]) { box-shadow: var(--shadow-md); border-color: var(--color-primary); }
.strategy-card:hover { box-shadow: var(--shadow-sm); border-color: var(--color-border-strong); }

/* ── Accordion settings toggle bar ── */
.strategy-acc-hdr {
  display: flex; align-items: center; gap: 0.5rem;
  width: 100%; padding: 0.4rem 0.75rem;
  background: var(--color-bg); border: none; cursor: pointer;
  text-align: start; color: var(--color-text);
  border-block-start: 1px solid var(--color-border);
  transition: background var(--transition);
  line-height: 1.3;
}
.strategy-acc-hdr:hover { background: #f1f5f9; }
.sah-code { font-size: 0.65rem !important; vertical-align: middle; }
.sah-name { font-weight: 600; font-size: 0.85rem; flex: 1; }
.sah-weight { font-size: 0.75rem !important; font-weight: 700 !important; padding: 0.1rem 0.4rem !important; }
.sah-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--color-border-strong); flex-shrink: 0; }
.sah-dot--on  { background: #22c55e; }
.sah-dot--off { background: #e2e8f0; }
.sah-chevron { color: var(--color-muted); flex-shrink: 0; transition: transform 0.2s ease; display: block; }
.sah-chevron--open { transform: rotate(180deg); }
/* Accordion body */
.strategy-acc-body { border-block-start: 1px solid var(--color-border); }
.strategy-preview { cursor: pointer; background: #f8fafc; min-height: 110px; display: flex; align-items: center; justify-content: center; border-block-end: 1px solid var(--color-border); transition: background var(--transition); }
.strategy-preview:hover { background: #f1f5f9; }
.preview-placeholder { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 110px; color: var(--color-muted); font-size: 0.8125rem; user-select: none; gap: 0.375rem; }
.preview-img    { width: 100%; height: auto; display: block; max-height: 160px; object-fit: contain; }
.strategy-info  { padding: 0.875rem; }
.strategy-name  { font-weight: 600; font-size: 0.9rem; margin-block-end: 0.625rem; color: var(--color-text); }
.strategy-controls { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.strategy-config  { margin-block-start: 0.625rem; padding-block-start: 0.625rem; border-block-start: 1px solid var(--color-border); display: flex; flex-direction: column; gap: 0.75rem; }
.strategy-label { display: flex; gap: 0.375rem; align-items: center; font-size: 0.8125rem; color: var(--color-muted); }
.input-sm { padding: 0.25rem 0.5rem; font-size: 0.875rem; border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm); width: 4.5rem; transition: border-color var(--transition); }
.input-sm:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 2px rgb(22 163 74 / 0.1); }

/* ── Strategy Config Sliders ────────────────────────────────────────────── */
.sc-field { display: flex; flex-direction: column; gap: 0.25rem; }
.sc-label-row { display: flex; justify-content: space-between; align-items: center; }
.sc-label { font-size: 0.78rem; color: var(--color-muted); font-weight: 500; }
.sc-val { font-size: 0.78rem; font-weight: 700; color: var(--color-primary); background: rgb(22 163 74 / 0.08); padding: 0.1rem 0.45rem; border-radius: 999px; min-width: 2.5rem; text-align: center; }
.sc-slider { -webkit-appearance: none; appearance: none; width: 100%; height: 5px; border-radius: 3px; background: var(--color-border-strong); outline: none; cursor: pointer; transition: background 0s; }
.sc-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 17px; height: 17px; border-radius: 50%; background: var(--color-primary); cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.2); border: 2px solid #fff; }
.sc-slider::-moz-range-thumb { width: 17px; height: 17px; border-radius: 50%; background: var(--color-primary); cursor: pointer; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.sc-marks { display: flex; justify-content: space-between; margin-block-start: 0.1rem; }
.sc-mark { font-size: 0.65rem; color: var(--color-muted); }
/* Mode radio pill buttons */
.sc-modes { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.sc-mode-opt { display: none; }
.sc-mode-lbl { padding: 0.25rem 0.625rem; border-radius: 999px; border: 1px solid var(--color-border-strong); font-size: 0.75rem; cursor: pointer; color: var(--color-muted); transition: all var(--transition); user-select: none; white-space: nowrap; }
.sc-mode-opt:checked + .sc-mode-lbl { background: var(--color-primary); color: #fff; border-color: var(--color-primary); font-weight: 600; }
/* Noise toggle buttons */
.sc-toggle-group { display: flex; border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.sc-toggle-opt { display: none; }
.sc-toggle-lbl { flex: 1; text-align: center; padding: 0.25rem 0.5rem; font-size: 0.75rem; cursor: pointer; color: var(--color-muted); transition: all var(--transition); }
.sc-toggle-opt:checked + .sc-toggle-lbl { background: var(--color-primary); color: #fff; font-weight: 600; }
/* HMAC key field */
.sc-key { display: flex; flex-direction: column; gap: 0.25rem; }
.sc-key-input { font-family: "SFMono-Regular", Consolas, monospace; font-size: 0.72rem; padding: 0.3rem 0.5rem; border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm); width: 100%; background: #f8fafc; color: var(--color-text); }

/* ── Strategy card header (sc-header / sc-body layout) ─────────────────── */
.sc-header {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 1rem; justify-content: space-between;
}
.sc-header-left  { display: flex; align-items: center; gap: 0.625rem; flex: 1; min-width: 0; }
.sc-header-right { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.sc-name { font-weight: 600; font-size: 0.9rem; color: var(--color-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-toggle-btn {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: var(--radius-sm);
  border: 1px solid var(--color-border-strong);
  background: var(--color-bg); color: var(--color-muted);
  cursor: pointer; transition: background var(--transition), color var(--transition);
}
.sc-toggle-btn:hover { background: var(--color-border); color: var(--color-text); }
.weight-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 3rem; padding: 0.15rem 0.5rem;
  border-radius: 999px; font-size: 0.75rem; font-weight: 700;
  background: var(--color-border); color: var(--color-muted);
  transition: background var(--transition), color var(--transition);
}
.weight-badge--active { background: rgb(22 163 74 / 0.12); color: var(--color-primary); }
.sc-body { border-block-start: 1px solid var(--color-border); }

/* ── Provider toggle switch ─────────────────────────────────────────────── */
.provider-toggle {
  position: relative; display: inline-flex; align-items: center;
  width: 36px; height: 20px; flex-shrink: 0; cursor: pointer;
}
.provider-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.provider-toggle-knob {
  position: absolute; inset: 0; border-radius: 999px;
  background: var(--color-border-strong);
  transition: background 0.2s;
}
.provider-toggle-knob::after {
  content: ''; position: absolute;
  inset-block: 2px; inset-inline-start: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2);
  transition: inset-inline-start 0.2s;
}
.provider-toggle--on .provider-toggle-knob { background: var(--color-primary); }
.provider-toggle--on .provider-toggle-knob::after { inset-inline-start: calc(100% - 18px); }

/* ── Docs page ───────────────────────────────────────────────────────────── */

/* layout */
.docs-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: 1rem;
  padding-block: 2rem 4rem;
  align-items: start;
}
@media (min-width: 1024px) {
  .docs-layout {
    grid-template-columns: 220px 1fr;
    gap: 3rem;
    padding-inline: 2rem;
  }
}

/* sidebar */
.docs-sidebar {
  display: none;
}
@media (min-width: 1024px) {
  .docs-sidebar {
    display: block;
    position: sticky;
    top: 5rem;
    max-height: calc(100vh - 6rem);
    overflow-y: auto;
  }
}
.docs-nav-title {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-muted);
  margin-block-end: 0.5rem;
}
.docs-nav {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}
.docs-nav a {
  display: block;
  padding: 0.3rem 0.75rem;
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  border-radius: var(--radius-sm);
  border-inline-start: 2px solid transparent;
  transition: color var(--transition), background var(--transition), border-color var(--transition);
}
.docs-nav a:hover { color: var(--color-primary); background: var(--color-primary-light); }
.docs-nav a.active { color: var(--color-primary); border-inline-start-color: var(--color-primary); background: var(--color-primary-light); font-weight: 600; }
.docs-nav-sep { height: 1px; background: var(--color-border); margin-block: 0.5rem; }

/* content */
.docs-content { min-width: 0; }

/* section anchors */
.docs-section { scroll-margin-top: 5rem; margin-block-end: 3rem; }

/* code blocks with copy button */
.docs-pre-wrap {
  position: relative;
  margin-block: 1rem;
}
.docs-pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 1.25rem 1rem;
  padding-block-end: 1.25rem;
  border-radius: var(--radius-lg);
  overflow-x: auto;
  font-size: 0.8125rem;
  line-height: 1.7;
  margin: 0;
}
.docs-pre code {
  font-family: "SFMono-Regular", Consolas, monospace;
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}
.copy-btn {
  position: absolute;
  top: 0.5rem;
  inset-inline-end: 0.5rem;
  padding: 0.25rem 0.625rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: rgba(255 255 255 / 0.08);
  color: #94a3b8;
  border: 1px solid rgba(255 255 255 / 0.12);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  font-family: var(--font-en);
}
.copy-btn:hover { background: rgba(255 255 255 / 0.15); color: #e2e8f0; }
.copy-btn.copied { color: #4ade80; border-color: #4ade80; }

/* step numbers */
.step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem;
  background: var(--color-primary); color: #fff;
  border-radius: 50%; font-weight: 700; flex-shrink: 0; font-size: 0.875rem;
}
.step-num--info { background: #6366f1; }
.step { display: flex; gap: 1rem; align-items: flex-start; margin-block-end: 2.5rem; }
.step-body { flex: 1; min-width: 0; }
.step-heading { margin-block-start: 0.25rem; }
.docs-hr { margin-block: 2.5rem; border: none; border-block-start: 1px solid var(--color-border); }

/* highlight / info / danger callouts */
.callout {
  display: flex; gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-radius: var(--radius-md);
  margin-block: 1.25rem;
  font-size: 0.875rem;
  line-height: 1.5;
  border: 1px solid;
}
.callout-icon { font-size: 1rem; flex-shrink: 0; line-height: 1.5; }
.callout--warn  { background: var(--color-warning-light); border-color: #fcd34d; color: #78350f; }
.callout--info  { background: #eff6ff; border-color: #93c5fd; color: #1e3a8a; }
.callout--ok    { background: var(--color-success-light); border-color: #86efac; color: #14532d; }
.callout--danger { background: var(--color-error-light); border-color: #fca5a5; color: #7f1d1d; }
/* legacy alias */
.highlight { background: var(--color-warning-light); border-inline-start: 4px solid var(--color-warning); padding: 0.75rem 1rem; border-radius: 0 var(--radius-md) var(--radius-md) 0; margin-block: 1rem; font-size: 0.875rem; color: #78350f; }

/* flow choice cards */
.flow-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-block: 1.5rem;
}
@media (min-width: 640px) {
  .flow-cards { grid-template-columns: 1fr 1fr; }
}
.flow-card {
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  background: var(--color-surface);
  position: relative;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.flow-card:hover { border-color: var(--color-primary); box-shadow: var(--shadow-md); }
.flow-card--rec  { border-color: var(--color-primary); }
.flow-card-badge {
  display: inline-block;
  font-size: 0.65rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  background: var(--color-primary); color: #fff;
  padding: 0.15em 0.5em; border-radius: 999px; margin-block-end: 0.5rem;
}
.flow-card-badge--muted { background: var(--color-muted); }
.flow-card h3 { margin-block: 0 0.4rem; font-size: 1rem; }
.flow-card p  { margin: 0; font-size: 0.8125rem; color: var(--color-muted); }
.flow-card ul { margin: 0.5rem 0 0; padding-inline-start: 1.2em; font-size: 0.8rem; color: var(--color-text-secondary); line-height: 1.6; }

/* visual flow diagram */
.flow-diagram {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-block: 1.5rem;
  font-size: 0.8rem;
}
.flow-row {
  display: grid;
  grid-template-columns: 1fr 24px 1fr 24px 1fr;
  align-items: center;
  gap: 0;
}
.flow-actor {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding-block-end: 0.5rem;
  border-block-end: 2px solid var(--color-border);
}
.flow-actor--browser { border-color: #6366f1; color: #6366f1; }
.flow-actor--backend { border-color: var(--color-primary); color: var(--color-primary); }
.flow-actor--service { border-color: var(--color-success); color: var(--color-success); }
.flow-spacer { border-block-end: 2px solid var(--color-border); height: 0; }

.flow-msg-row {
  display: grid;
  grid-template-columns: 1fr 24px 1fr 24px 1fr;
  align-items: center;
  min-height: 2.5rem;
}
.flow-cell { position: relative; }
.flow-line {
  position: absolute; top: 50%;
  height: 1px; background: var(--color-border-strong);
  transform: translateY(-50%);
}
.flow-line--full  { left: 0; right: 0; }
.flow-line--left  { left: 0; right: 50%; }
.flow-line--right { left: 50%; right: 0; }
.flow-arrow {
  position: absolute; top: 50%; transform: translateY(-50%);
  font-size: 0.6rem; color: var(--color-text-secondary);
  line-height: 1;
}
.flow-arrow--right { right: 0; }
.flow-arrow--left  { left: 0; }
.flow-label {
  font-size: 0.7rem; line-height: 1.3; text-align: center;
  padding: 0.15rem 0.25rem;
}
.flow-label code { font-size: 0.65rem; }
.flow-chip {
  display: inline-block;
  font-size: 0.65rem; font-weight: 600; letter-spacing: 0.02em;
  padding: 0.1em 0.4em;
  border-radius: 999px;
  background: #f3f4f6; color: var(--color-muted);
  border: 1px solid var(--color-border);
}
.flow-chip--blue   { background: #eff6ff; color: #2563eb; border-color: #bfdbfe; }
.flow-chip--green  { background: #f0fdf4; color: #16a34a; border-color: #bbf7d0; }
.flow-chip--purple { background: #f5f3ff; color: #7c3aed; border-color: #ddd6fe; }

/* section badge for token/classic */
.flow-badge {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-size: 0.75rem; font-weight: 600;
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  border: 1px solid #bbf7d0;
  margin-block-end: 0.75rem;
}
.flow-badge--muted { background: #f3f4f6; color: var(--color-muted); border-color: var(--color-border); }

/* inline badge */
.badge-rec {
  display: inline-block; vertical-align: middle;
  font-size: 0.6rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  background: var(--color-primary); color: #fff;
  padding: 0.1em 0.4em; border-radius: 999px;
  margin-inline-start: 0.4rem;
}

/* tab bar underline variant for docs */
.tab-bar--line {
  display: flex;
  gap: 0;
  border-block-end: 2px solid var(--color-border);
  margin-block-end: 1.25rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tab-bar--line .tab {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-muted);
  background: none;
  border: none;
  border-block-end: 2px solid transparent;
  margin-block-end: -2px;
  cursor: pointer;
  white-space: nowrap;
  border-radius: 0;
  transition: color var(--transition), border-color var(--transition);
}
.tab-bar--line .tab:hover { color: var(--color-text); }
.tab-bar--line .tab.active { color: var(--color-primary); border-block-end-color: var(--color-primary); font-weight: 600; }

/* API ref table */
.api-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.api-table th { text-align: start; padding: 0.5rem 0.75rem; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--color-muted); border-block-end: 2px solid var(--color-border); }
.api-table td { padding: 0.625rem 0.75rem; vertical-align: top; border-block-end: 1px solid var(--color-border); }
.api-table tr:last-child td { border-block-end: none; }
.api-table .method-badge { display: inline-block; font-size: 0.65rem; font-weight: 700; letter-spacing: 0.04em; padding: 0.2em 0.5em; border-radius: var(--radius-xs); }
.api-table .mb-post   { background: #fef3c7; color: #92400e; }
.api-table .mb-get    { background: #d1fae5; color: #065f46; }

/* cred table */
.cred-safe--yes { color: var(--color-success); font-weight: 600; }
.cred-safe--no  { color: var(--color-error); font-weight: 700; }

/* ── Weight total badge ──────────────────────────────────────────────────── */
.weight-total-badge {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.3rem 0.875rem; border-radius: 999px;
  font-size: 0.8125rem; font-weight: 700; letter-spacing: 0.01em;
  border: 1.5px solid var(--color-border-strong);
  background: #f3f4f6; color: var(--color-muted);
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  white-space: nowrap; flex-shrink: 0;
}
.weight-total-badge--ok   { background: var(--color-success-light); color: var(--color-success); border-color: #86efac; }
.weight-total-badge--warn { background: var(--color-warning-light); color: var(--color-warning); border-color: #fcd34d; }

/* ── Provider enabled toggle (pill switch) ───────────────────────────────── */
.provider-toggle {
  display: inline-flex; align-items: center; gap: 0.5rem;
  cursor: pointer; user-select: none; margin-block-start: 0.5rem;
}
.provider-toggle-cb { display: none; }
.provider-toggle-track {
  position: relative; width: 2.25rem; height: 1.25rem;
  background: var(--color-border-strong); border-radius: 999px;
  flex-shrink: 0;
  transition: background var(--transition);
}
.provider-toggle-track::after {
  content: ''; position: absolute; top: 0.175rem; inset-inline-start: 0.175rem;
  width: 0.9rem; height: 0.9rem; border-radius: 50%; background: #fff;
  box-shadow: var(--shadow-xs);
  transition: inset-inline-start var(--transition), background var(--transition);
}
.provider-toggle-cb:checked ~ .provider-toggle-track {
  background: var(--color-primary);
}
.provider-toggle-cb:checked ~ .provider-toggle-track::after {
  inset-inline-start: calc(2.25rem - 0.9rem - 0.175rem);
}
.provider-toggle-label {
  font-size: 0.8125rem; color: var(--color-muted); font-weight: 500;
  transition: color var(--transition);
}
.provider-toggle-label--on { color: var(--color-primary); }

/* ── Strategy weight field spacing ──────────────────────────────────────── */
.strategy-weight-field { margin-block-end: 0.625rem; }

/* ── Config help details ─────────────────────────────────────────────────── */
.sc-help {
  margin-block-start: 0.25rem;
}
.sc-help summary {
  font-size: 0.68rem;
  color: var(--color-primary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  user-select: none;
  list-style: none;
  outline: none;
}
.sc-help summary::-webkit-details-marker { display: none; }
.sc-help summary::after {
  content: '›';
  display: inline-block;
  transition: transform 0.2s ease;
  font-size: 0.75rem;
}
.sc-help[open] summary::after { transform: rotate(90deg); }
.sc-help-body {
  margin-block-start: 0.375rem;
  font-size: 0.72rem;
  color: var(--color-text-secondary);
  line-height: 1.55;
  background: var(--color-primary-light);
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.625rem;
}

/* ── Lucide icons ────────────────────────────────────────────────────────── */
.icon {
  display: inline-block;
  width:  1em;
  height: 1em;
  vertical-align: -0.15em;
  flex-shrink: 0;
}
.icon-sm  { width: 0.875rem; height: 0.875rem; }
.icon-md  { width: 1.125rem; height: 1.125rem; }
.icon-lg  { width: 1.5rem;   height: 1.5rem;   }
.icon-xl  { width: 2rem;     height: 2rem;     }
.icon-2xl { width: 2.5rem;   height: 2.5rem;   }

/* dash-icon uses lucide xl */
.dash-icon .icon { width: 2rem; height: 2rem; }

/* ── Color alias ─────────────────────────────────────────────────────────── */
:root { --color-danger: var(--color-error); }

/* ── Alert info variant ──────────────────────────────────────────────────── */
.alert-info {
  background: #eff6ff;
  color: #1e3a8a;
  border: 1px solid #bfdbfe;
}

/* ── Button outline variant ──────────────────────────────────────────────── */
.btn-outline {
  background: transparent;
  color: var(--color-text-secondary);
  border-color: var(--color-border-strong);
}
.btn-outline:hover:not(:disabled) {
  background: #f9fafb;
  border-color: #9ca3af;
  color: var(--color-text);
}

/* ── Focus-visible for interactive elements without explicit styles ────────── */
.lang-btn:focus-visible,
.modal-close:focus-visible,
.breadcrumb-link:focus-visible,
.tab-link:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ── fix form-inline: use display:contents so parent layout is unaffected ─── */
.form-inline { display: contents; }

/* ── Skip-to-content link ────────────────────────────────────────────────── */
.skip-link {
  position: absolute;
  inset-block-start: -100%;
  inset-inline-start: 0.5rem;
  z-index: 9999;
  background: var(--color-primary);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  font-weight: 600;
  text-decoration: none;
  transition: inset-block-start var(--transition);
}
.skip-link:focus { inset-block-start: 0; }

/* ── Hamburger button ────────────────────────────────────────────────────── */
.navbar-hamburger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--radius-md);
  color: var(--color-text);
  transition: background var(--transition);
  min-width: 44px;
  min-height: 44px;
  align-items: center;
}
.navbar-hamburger:hover { background: #f3f4f6; }
.navbar-hamburger:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.navbar-hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
  transition: transform var(--transition), opacity var(--transition);
}
.navbar-hamburger[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.navbar-hamburger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.navbar-hamburger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Mobile nav drawer */
.navbar-nav {
  display: none;
  align-items: center;
  gap: 0.25rem;
  flex: 1;
  padding-inline-start: 1.5rem;
}
@media (min-width: 768px) {
  .navbar-hamburger { display: none; }
  .navbar-nav { display: flex !important; }
}
.navbar-nav--open {
  display: flex !important;
  position: absolute;
  inset-block-start: 56px;
  inset-inline-start: 0;
  inset-inline-end: 0;
  flex-direction: column;
  align-items: stretch;
  background: var(--color-surface);
  border-block-end: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
  padding: 0.75rem 1rem;
  z-index: 29;
}
.navbar-nav--open .nav-link { justify-content: flex-start; }

/* ── Empty data-label pseudo-element fix ─────────────────────────────────── */
table[data-mobile="cards"] td[data-label=""]::before { display: none; }

/* ── Reduced motion ──────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
  .ua-bar-fill { transition: none !important; }
}

/* ── Font body classes ────────────────────────────────────────────────────── */
body.fa { font-family: var(--font-fa); }
body.en { font-family: var(--font-en); }

/* ── Button ghost ─────────────────────────────────────────────────────────── */
.btn-ghost {
  background: transparent;
  color: var(--color-muted);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) {
  background: #f3f4f6;
  color: var(--color-text);
  border-color: transparent;
}

/* ── Admin sidebar shell ─────────────────────────────────────────────────── */
.admin-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.admin-sidebar {
  width: 256px;
  background: #111827;
  color: #f3f4f6;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}

.admin-sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #1f2937;
  flex-shrink: 0;
}
.admin-sidebar-logo img { height: 1.75rem; width: auto; filter: brightness(10); }
.admin-sidebar-logo-name { font-weight: 700; font-size: 1rem; color: #fff; }

.admin-sidebar-user {
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid #1f2937;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex-shrink: 0;
}
.admin-sidebar-user-avatar {
  width: 2rem; height: 2rem; border-radius: 50%;
  background: #374151;
  display: flex; align-items: center; justify-content: center;
  color: #9ca3af; flex-shrink: 0;
}
.admin-sidebar-user-name { font-size: 0.8125rem; color: #f3f4f6; font-weight: 500; }
.admin-sidebar-user-role { font-size: 0.6875rem; color: #6b7280; margin-block-start: 0.1rem; }

.admin-sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.admin-sidebar-section {
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #4b5563;
  padding: 0.625rem 0.625rem 0.25rem;
  margin-block-start: 0.5rem;
}

.admin-nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  color: #9ca3af;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.admin-nav-link:hover { background: #1f2937; color: #f9fafb; }
.admin-nav-link.active { background: #374151; color: #fff; }
.admin-nav-link svg { width: 1rem; height: 1rem; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.admin-sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid #1f2937;
  flex-shrink: 0;
}

.admin-main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  background: #f3f4f6;
  display: flex;
  flex-direction: column;
}

.admin-main-inner {
  padding: 1.5rem;
  flex: 1;
}
@media (min-width: 1024px) { .admin-main-inner { padding: 2rem; } }

/* Mobile admin: sidebar collapses */
@media (max-width: 767px) {
  .admin-sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: -256px;
    z-index: 40;
    transition: inset-inline-start 0.25s ease;
  }
  .admin-sidebar--open { inset-inline-start: 0; }
  .admin-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgb(0 0 0 / 0.5);
    z-index: 39;
  }
  .admin-overlay--visible { display: block; }
  .admin-mobile-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background: #111827;
    border-bottom: 1px solid #1f2937;
    flex-shrink: 0;
  }
  .admin-mobile-hamburger {
    background: none; border: none; cursor: pointer; color: #9ca3af;
    padding: 0.25rem; display: flex; align-items: center; justify-content: center;
    min-width: 44px; min-height: 44px; border-radius: 0.375rem;
  }
  .admin-mobile-hamburger:hover { background: #1f2937; color: #f3f4f6; }
  .admin-mobile-logo { font-weight: 700; color: #fff; font-size: 0.9375rem; }
}
@media (min-width: 768px) {
  .admin-mobile-header { display: none; }
}

/* ── User panel app-shell (new sidebar layout) ───────────────────────────── */
:root {
  --sb-w:        240px;
  --sb-bg:       #0f172a;
  --sb-border:   #1e293b;
  --sb-text:     #94a3b8;
  --sb-text-hi:  #f1f5f9;
  --sb-active-bg: rgba(37,99,235,0.18);
  --sb-active-c:  #93c5fd;
  --topbar-h:    52px;
}

/* Outer shell */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.app-sidebar {
  width: var(--sb-w);
  background: var(--sb-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
  transition: transform 0.25s ease;
}

/* Main content area */
.app-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Sidebar: logo ── */
.sb-logo {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 1.125rem 1.25rem 0.875rem;
  border-block-end: 1px solid var(--sb-border);
  flex-shrink: 0;
}
.sb-logo-icon {
  width: 2rem;
  height: 2rem;
  background: var(--color-primary);
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
}
.sb-logo-icon svg { width: 1.125rem; height: 1.125rem; }
.sb-logo-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--sb-text-hi);
  letter-spacing: -0.01em;
}

/* ── Sidebar: main nav ── */
.sb-nav {
  padding: 0.75rem 0.75rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}
.sb-nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--sb-text);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  min-height: 44px;
  white-space: nowrap;
}
.sb-nav-item:hover { background: #1e293b; color: var(--sb-text-hi); }
.sb-nav-item.active { background: var(--sb-active-bg); color: var(--sb-active-c); }
.sb-nav-item svg {
  width: 1rem; height: 1rem; flex-shrink: 0;
  stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* ── Sidebar: project switcher ── */
.sb-section-divider {
  margin: 0.75rem 1.25rem 0;
  border: none;
  border-block-start: 1px solid var(--sb-border);
}

.sb-project-header {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 0.75rem;
  margin: 0.5rem 0.75rem 0;
  border-radius: 0.5rem;
  cursor: pointer;
  min-height: 44px;
  transition: background 0.15s;
}
.sb-project-header:hover { background: #1e293b; }

.sb-project-avatar {
  width: 1.875rem;
  height: 1.875rem;
  border-radius: 0.4375rem;
  background: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  text-transform: uppercase;
}

.sb-project-info { flex: 1; min-width: 0; }
.sb-project-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--sb-text-hi);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sb-project-label {
  font-size: 0.6875rem;
  color: var(--sb-text);
  margin-block-start: 0.0625rem;
}

.sb-project-arrow {
  color: var(--sb-text);
  flex-shrink: 0;
  transition: transform 0.2s;
}
.sb-project-arrow svg { width: 0.875rem; height: 0.875rem; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sb-project-header[aria-expanded="true"] .sb-project-arrow { transform: rotate(180deg); }

/* ── Sidebar: project switcher row (two-button split) ── */
.sb-project-row {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin: 0.5rem 0.75rem 0;
  border-radius: 0.5rem;
  overflow: visible;
}
.sb-project-info-btn {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.5rem 0.5rem 0.75rem;
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  text-align: start;
  border-radius: 0.5rem 0 0 0.5rem;
  transition: background 0.15s;
  min-height: 44px;
}
.sb-project-info-btn:hover { background: #1e293b; }
[dir="rtl"] .sb-project-info-btn { border-radius: 0 0.5rem 0.5rem 0; }
.sb-project-chevron-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.125rem;
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--sb-text);
  border-radius: 0 0.5rem 0.5rem 0;
  transition: background 0.15s, color 0.15s;
  border-inline-start: 1px solid rgba(255,255,255,.06);
}
.sb-project-chevron-btn:hover { background: #1e293b; color: var(--sb-text-hi); }
[dir="rtl"] .sb-project-chevron-btn { border-radius: 0.5rem 0 0 0.5rem; }
.sb-project-chevron-btn svg {
  width: 0.875rem;
  height: 0.875rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.2s;
}

/* ── Sidebar: project switcher dropdown ── */
.sb-switcher {
  background: #1a2535;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 0.625rem;
  padding: 0.25rem;
  margin: 0.25rem 0.75rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.0625rem;
  box-shadow: 0 4px 16px rgba(0,0,0,.35);
  z-index: 10;
}
.sb-switcher-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.625rem;
  border-radius: 0.375rem;
  font-size: 0.8125rem;
  color: var(--sb-text);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  background: none;
  border: none;
  width: 100%;
  text-align: start;
  min-height: 36px;
}
.sb-switcher-item:hover { background: #2d3a4f; color: var(--sb-text-hi); }
.sb-switcher-item--active { color: var(--sb-text-hi); font-weight: 600; }
.sb-switcher-check {
  width: 0.875rem;
  height: 0.875rem;
  margin-inline-start: auto;
  flex-shrink: 0;
  stroke: var(--color-primary);
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sb-switcher-divider {
  height: 1px;
  background: rgba(255,255,255,.08);
  margin: 0.125rem 0.25rem;
}
.sb-switcher-new {
  color: var(--color-primary);
  font-weight: 500;
}
.sb-switcher-avatar {
  width: 1.375rem;
  height: 1.375rem;
  border-radius: 0.3125rem;
  background: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6875rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  text-transform: uppercase;
}

/* ── Sidebar: sub-nav (project tabs) ── */
.sb-subnav {
  padding: 0.25rem 0.75rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}
.sb-subnav-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.375rem 0.75rem 0.375rem 2.375rem;
  border-radius: 0.5rem;
  font-size: 0.8125rem;
  color: var(--sb-text);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  min-height: 36px;
}
.sb-subnav-item:hover { background: #1e293b; color: var(--sb-text-hi); }
.sb-subnav-item.active { background: var(--sb-active-bg); color: var(--sb-active-c); }
.sb-subnav-item svg { width: 0.875rem; height: 0.875rem; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sb-subnav-item--disabled { opacity: 0.35; cursor: not-allowed; pointer-events: none; }

/* Sidebar nav row: item + action button side-by-side */
.sb-nav-row { display: flex; align-items: stretch; }
.sb-nav-row .sb-nav-item { flex: 1; min-width: 0; }
.sb-nav-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  flex-shrink: 0;
  border: none;
  background: none;
  color: var(--sb-text);
  cursor: pointer;
  border-radius: 0.5rem;
  font-size: 1.125rem;
  font-weight: 300;
  margin-inline-end: 0.25rem;
  transition: background 0.15s, color 0.15s;
}
.sb-nav-action-btn:hover { background: #1e293b; color: var(--sb-text-hi); }

/* ── Sidebar: spacer and bottom ── */
.sb-spacer { flex: 1; }

.sb-bottom {
  padding: 0.75rem;
  border-block-start: 1px solid var(--sb-border);
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  flex-shrink: 0;
}

.sb-user {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.625rem;
  border-radius: 0.5rem;
  margin-block-start: 0.25rem;
}
.sb-user-avatar {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: #1e293b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--sb-text-hi);
  flex-shrink: 0;
  text-transform: uppercase;
}
.sb-user-info { flex: 1; min-width: 0; }
.sb-user-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--sb-text-hi);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sb-user-email {
  font-size: 0.6875rem;
  color: var(--sb-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sb-logout-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--sb-text);
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.375rem;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
  min-width: 28px;
  min-height: 28px;
}
.sb-logout-btn:hover { background: #1e293b; color: var(--sb-text-hi); }
.sb-logout-btn svg { width: 0.875rem; height: 0.875rem; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ── Top bar ── */
.app-topbar {
  height: var(--topbar-h);
  background: var(--color-surface);
  border-block-end: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-inline: 1.5rem;
  gap: 1rem;
  flex-shrink: 0;
}
.topbar-start { display: flex; align-items: center; gap: 0.75rem; }
.topbar-end   { display: flex; align-items: center; gap: 0.625rem; }

.topbar-hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-muted);
  padding: 0.25rem;
  border-radius: 0.375rem;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}
.topbar-hamburger svg { width: 1.125rem; height: 1.125rem; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.topbar-hamburger:hover { background: #f3f4f6; color: var(--color-text); }

.topbar-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--color-text);
}

.topbar-lang {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: #f3f4f6;
  border-radius: 9999px;
  padding: 0.1875rem;
}
.topbar-lang-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.1875rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-muted);
  text-decoration: none;
  transition: all 0.15s;
  line-height: 1.5;
}
.topbar-lang-btn--active {
  background: #fff;
  color: var(--color-text);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.1);
}
.topbar-lang-btn:hover:not(.topbar-lang-btn--active) { color: var(--color-text); }

.topbar-token-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.3125rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--color-primary-light);
  color: var(--color-primary);
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
}
.topbar-token-btn:hover { background: #dbeafe; color: var(--color-primary-hover); }
.topbar-token-btn svg { width: 0.875rem; height: 0.875rem; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ── App main content ── */
.app-main {
  flex: 1;
  overflow-y: auto;
  background: #f3f4f6;
}
.app-main-inner {
  padding: 1.5rem;
}
@media (min-width: 1024px) { .app-main-inner { padding: 2rem; } }

/* ── Overlay for mobile sidebar ── */
.app-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 0.5);
  z-index: 39;
}
.app-overlay--visible { display: block; }

/* ── Mobile: sidebar slides in/out ── */
@media (max-width: 767px) {
  .app-sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    transform: translateX(-100%);
  }
  [dir="rtl"] .app-sidebar {
    transform: translateX(100%);
  }
  .app-sidebar--open {
    transform: translateX(0) !important;
  }
  .topbar-hamburger {
    display: flex;
  }
}
@media (min-width: 768px) {
  .topbar-hamburger { display: none; }
}

/* ── Project tabs (horizontal tab bar inside project detail page) ── */
.proj-tabs {
  display: flex;
  gap: 0;
  border-block-end: 2px solid var(--color-border);
  margin-block-end: 1.5rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.proj-tabs::-webkit-scrollbar { display: none; }

.proj-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-muted);
  text-decoration: none;
  border-block-end: 2px solid transparent;
  margin-block-end: -2px;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
  cursor: pointer;
  background: none;
  border-inline: none;
  border-block-start: none;
  font-family: inherit;
  min-height: 44px;
}
.proj-tab:hover { color: var(--color-text); }
.proj-tab.active {
  color: var(--color-primary);
  border-block-end-color: var(--color-primary);
  font-weight: 600;
}
.proj-tab svg { width: 0.875rem; height: 0.875rem; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ── New dashboard stat cards ── */
.dash-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.875rem;
  margin-block-end: 1.5rem;
}
@media (min-width: 768px) { .dash-stats { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1024px) { .dash-stats { grid-template-columns: repeat(5, 1fr); } }

.dash-stat {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-xs);
}
.dash-stat__value {
  font-size: clamp(1.5rem, 3.5vw, 2rem);
  font-weight: 700;
  line-height: 1;
  margin-block-end: 0.25rem;
}
.dash-stat__label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.dash-stat--issued  .dash-stat__value { color: var(--color-text); }
.dash-stat--ok      .dash-stat__value { color: var(--color-success); }
.dash-stat--fail    .dash-stat__value { color: var(--color-error); }
.dash-stat--abandon .dash-stat__value { color: #d97706; }
.dash-stat--rate    .dash-stat__value { color: var(--color-primary); }

/* ── Projects flat list ── */
.proj-list {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.proj-list-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 1.25rem;
  border-block-end: 1px solid var(--color-border);
  transition: background 0.15s;
}
.proj-list-row:last-child { border-block-end: none; }
.proj-list-row:hover { background: #f9fafb; }
.proj-list-avatar {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.5rem;
  background: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9375rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  text-transform: uppercase;
}
.proj-list-name {
  flex: 1;
  min-width: 0;
}
.proj-list-name strong {
  display: block;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.proj-list-meta {
  font-size: 0.75rem;
  color: var(--color-muted);
  margin-block-start: 0.125rem;
}
.proj-list-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* ── Dashboard redesign ────────────────────────────────────────────────── */
.activity-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-block-end: .75rem;
}
.activity-bar__label {
  font-size: .8125rem;
  color: var(--color-muted);
  font-weight: 500;
}
.range-tabs {
  display: flex;
  gap: .25rem;
  background: var(--color-surface-2, #f1f5f9);
  border-radius: .5rem;
  padding: .1875rem;
}
.range-tab {
  padding: .3125rem .875rem;
  border-radius: .375rem;
  font-size: .8125rem;
  font-weight: 500;
  border: none;
  background: transparent;
  color: var(--color-muted);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.range-tab.active {
  background: #fff;
  color: var(--color-text);
  box-shadow: 0 1px 3px rgb(0 0 0 / .1);
}
.range-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-block: 1.25rem .75rem;
}
.range-bar__label {
  font-size: .8125rem;
  color: var(--color-muted);
}
.dash-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: .75rem;
  margin-block-end: 1.25rem;
}
@media (min-width: 480px) and (max-width: 767px) {
  .dash-stats { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 479px) {
  .dash-stats { grid-template-columns: repeat(2, 1fr); }
  .dash-stat:last-child { grid-column: span 2; }
}
.dash-stat {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: .75rem;
  padding: 1rem 1.125rem;
}
.dash-stat__dot {
  width: .5rem;
  height: .5rem;
  border-radius: 50%;
  background: var(--color-muted);
  margin-block-end: .625rem;
}
.dash-stat--issued .dash-stat__dot { background: #64748b; }
.dash-stat--ok     .dash-stat__dot { background: var(--color-success); }
.dash-stat--fail   .dash-stat__dot { background: var(--color-error); }
.dash-stat--abandon .dash-stat__dot { background: #f59e0b; }
.dash-stat--rate   .dash-stat__dot { background: var(--color-primary); }
.dash-stat__value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.2;
  margin-block-end: .25rem;
}
.dash-stat--ok   .dash-stat__value { color: var(--color-success); }
.dash-stat--fail .dash-stat__value { color: var(--color-error); }
.dash-stat--rate .dash-stat__value { color: var(--color-primary); }
.dash-stat__label { font-size: .75rem; color: var(--color-muted); }
.dash-stats-hint {
  text-align: center;
  font-size: .8125rem;
  color: var(--color-muted);
  margin-block-end: 1.25rem;
}

/* Welcome empty state */
.welcome-card {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 1rem;
  padding: 3rem 2rem;
  text-align: center;
  margin-block-end: 1.5rem;
}
.welcome-card__icon {
  width: 4rem;
  height: 4rem;
  border-radius: 1rem;
  background: var(--color-primary-light, #eff6ff);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
}
.welcome-card__title { font-size: 1.25rem; font-weight: 700; margin-block-end: .5rem; }
.welcome-card__desc {
  color: var(--color-muted);
  font-size: .9375rem;
  max-width: 28rem;
  margin: 0 auto .75rem;
  line-height: 1.6;
}
.welcome-card__actions {
  display: flex;
  gap: .75rem;
  justify-content: center;
  margin-block-end: 1rem;
  flex-wrap: wrap;
}
.welcome-card__step {
  font-size: .8125rem;
  color: var(--color-muted);
  display: flex;
  align-items: center;
  gap: .5rem;
  justify-content: center;
}
.welcome-card__step-badge {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-size: .6875rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Quick action cards */
.dash-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-block-start: 1.25rem;
}
@media (max-width: 479px) { .dash-actions { grid-template-columns: 1fr; } }
.dash-action-card {
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  padding: 1.25rem;
}
.dash-action-card__icon {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: .625rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dash-action-card__icon--doc { background: #eff6ff; color: var(--color-primary); }
.dash-action-card__icon--proj { background: #f0fdf4; color: #16a34a; }
.dash-action-card__title { font-weight: 600; font-size: .9375rem; color: var(--color-text); }
.dash-action-card__desc { font-size: .8125rem; color: var(--color-muted); }

/* card-header utility */
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.125rem 1.25rem;
  border-block-end: 1px solid var(--color-border);
}
.card-header h2 { margin: 0; font-size: 1rem; }
.card-header__link {
  font-size: .8125rem;
  color: var(--color-primary);
  font-weight: 500;
  text-decoration: none;
}

/* Project avatar (small) */
.proj-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: .5rem;
  background: var(--color-primary);
  color: #fff;
  font-size: .75rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  flex-shrink: 0;
}

/* ── Project overview tab ───────────────────────────────────────────────── */
.proj-overview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-block: 1.5rem 1rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.proj-overview-identity { display: flex; align-items: center; gap: 1rem; }
.proj-avatar-lg {
  width: 3rem;
  height: 3rem;
  border-radius: .75rem;
  background: var(--color-primary);
  color: #fff;
  font-size: 1.25rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  flex-shrink: 0;
}
.proj-overview-name { font-size: 1.375rem; font-weight: 700; margin: 0 0 .25rem; }
.proj-overview-meta { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.proj-overview-hash {
  font-size: .75rem;
  color: var(--color-muted);
  background: var(--color-surface-2, #f1f5f9);
  padding: .125rem .375rem;
  border-radius: .25rem;
  font-family: ui-monospace, monospace;
}

/* Stat cards (overview) */
.ov-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .75rem;
  margin-block-end: 1.25rem;
}
@media (max-width: 767px) { .ov-stats { grid-template-columns: repeat(2, 1fr); } }
.ov-stat {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: .75rem;
  padding: 1rem 1.125rem;
  position: relative;
}
.ov-stat__value {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.2;
  margin-block-end: .25rem;
}
.ov-stat--ok   .ov-stat__value { color: var(--color-success); }
.ov-stat--fail .ov-stat__value { color: var(--color-error); }
.ov-stat--rate .ov-stat__value { color: var(--color-primary); }
.ov-stat__label { font-size: .75rem; color: var(--color-muted); }
.ov-stat__info {
  position: absolute;
  top: .75rem;
  left: .875rem;
  width: .875rem;
  height: .875rem;
  stroke: var(--color-muted);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: .5;
}

/* Config + chart grid */
.ov-grid {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 1.25rem;
  margin-block-end: 1.25rem;
}
@media (max-width: 767px) { .ov-grid { grid-template-columns: 1fr; } }
.ov-config__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-block-end: .75rem;
}
.ov-config__header h2 { font-size: .9375rem; margin: 0; }
.ov-config__manage {
  font-size: .8125rem;
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 500;
}
.ov-config__bar {
  height: .375rem;
  background: var(--color-surface-2, #f1f5f9);
  border-radius: 9999px;
  margin-block-end: 1rem;
  overflow: hidden;
}
.ov-config__bar-fill { height: 100%; background: var(--color-success); border-radius: 9999px; transition: width .3s; }
.ov-config__combo-label { display: block; font-size: .75rem; color: var(--color-muted); margin-block-end: .375rem; }
.ov-config__rows { display: flex; flex-direction: column; gap: .625rem; }
.ov-config__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .875rem;
  padding-block: .1875rem;
  border-block-end: 1px solid var(--color-border);
}
.ov-config__row:last-child { border-block-end: none; }
.ov-config__key { color: var(--color-muted); }
.ov-config__val { font-weight: 600; color: var(--color-text); }
.ov-chart-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-block-end: .75rem;
  flex-wrap: wrap;
  gap: .5rem;
}
.ov-chart-card__header h2 { font-size: .9375rem; margin: 0; }
.ov-chart-legend { display: flex; gap: .875rem; align-items: center; flex-wrap: wrap; }
.ov-chart-legend__item {
  font-size: .75rem;
  color: var(--color-muted);
  display: flex;
  align-items: center;
  gap: .3125rem;
}
.ov-chart-legend__item::before {
  content: '';
  width: .875rem;
  height: .1875rem;
  border-radius: 9999px;
  flex-shrink: 0;
}
.ov-chart-legend__item--issue::before { background: #3b82f6; }
.ov-chart-legend__item--ok::before    { background: var(--color-success); }
.ov-chart-legend__item--fail::before  { background: var(--color-error); }

/* ── Support ticket styles ─────────────────────────────────────────── */
.ticket-thread { display: flex; flex-direction: column; gap: 1rem; margin-top: .5rem; }
.message-bubble {
  padding: .875rem 1rem;
  border-radius: .75rem;
  max-width: 85%;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
}
.message-bubble--admin {
  background: var(--color-primary-light);
  border-color: rgba(37,99,235,.18);
  align-self: flex-start;
}
.message-bubble--user { align-self: flex-end; }
.message-meta { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .375rem; flex-wrap: wrap; }
.message-sender { font-weight: 600; font-size: .8125rem; }
.message-time { font-size: .75rem; }
.message-body { font-size: .9rem; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }

.priority-dot { display: inline-block; width: .5rem; height: .5rem; border-radius: 50%; vertical-align: middle; }
.priority-dot--low    { background: var(--color-muted); }
.priority-dot--medium { background: #f59e0b; }
.priority-dot--high   { background: #ea580c; }
.priority-dot--urgent { background: var(--color-error); }

.badge-blue { background: rgb(37 99 235/0.1); color: #2563eb; }

@media (min-width: 768px) {
  .support-grid { display: grid; grid-template-columns: 1fr 280px; gap: 1.5rem; align-items: start; }
}

/* ── Strategy cards v2 ──────────────────────────────────────────────────── */
.sc2-wrapper {
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: visible;
  background: var(--color-surface-1, #fff);
  transition: border-color .15s;
}
.sc2-wrapper--active { border-color: var(--color-primary); }
.sc2-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.125rem 1rem;
}
.sc2-icon-box {
  width: 3.5rem;
  height: 3.5rem;
  background: var(--color-surface-2, #f1f5f9);
  border-radius: .75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.sc2-icon-box--preview { background: #f8fafc; border: 1px solid var(--color-border); cursor: default; }
.sc2-preview-img { width: 100%; height: 100%; object-fit: cover; border-radius: .625rem; display: block; }
.sc2-preview-skeleton { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
.sc2-icon { width: 1.75rem; height: 1.75rem; }
.sc2-info { flex: 1; min-width: 0; }
.sc2-name { font-size: 1rem; font-weight: 700; color: var(--color-text); line-height: 1.3; }
.sc2-desc { font-size: .8125rem; color: var(--color-muted); margin-block-start: .2rem; }
.sc2-actions {
  display: flex;
  align-items: center;
  gap: .625rem;
  flex-shrink: 0;
}
.sc2-settings { background: var(--color-surface-2, #f8fafc); border-radius: 0 0 calc(var(--radius-lg) - 2px) calc(var(--radius-lg) - 2px); overflow: visible; }

/* Status chip (replaces toggle switch in strategy cards) */
.sc2-status-chip {
  display: inline-flex;
  align-items: center;
  gap: .3125rem;
  padding: .25rem .625rem;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-2, #f1f5f9);
  color: var(--color-muted);
  font-size: .8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.sc2-status-chip--on {
  background: #dcfce7;
  border-color: #86efac;
  color: #16a34a;
}
.sc2-status-dot {
  width: .5rem;
  height: .5rem;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* Total weight badge */
.sc2-total-badge {
  display: inline-flex;
  align-items: center;
  padding: .375rem .875rem;
  border-radius: 999px;
  font-size: .875rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}
.sc2-total-badge--ok  { background: #dcfce7; color: #16a34a; border: 1px solid #86efac; }
.sc2-total-badge--warn { background: #fef9c3; color: #854d0e; border: 1px solid #fde047; }

/* ── Select2-style custom dropdown ─────────────────────────────────────── */
.s2-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .4375rem .625rem;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: .8125rem;
  cursor: pointer;
  text-align: start;
  color: var(--color-text);
  transition: border-color .15s, box-shadow .15s;
  min-height: 2.125rem;
}
.s2-trigger:hover { border-color: #9ca3af; }
.s2-trigger--open {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
  outline: none;
}
.s2-trigger-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: start;
}
.s2-arrow {
  flex-shrink: 0;
  color: #6b7280;
  transition: transform .15s;
}
.s2-arrow--up { transform: rotate(180deg); }

.s2-drop {
  position: absolute;
  inset-inline-start: 0;
  inset-inline-end: 0;
  top: calc(100% + 3px);
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  box-shadow: 0 4px 20px rgba(0,0,0,.13);
  z-index: 9999;
  overflow: hidden;
}
.s2-enter { transition: opacity .1s ease, transform .1s ease; }
.s2-enter-start { opacity: 0; transform: translateY(-4px); }
.s2-enter-end   { opacity: 1; transform: translateY(0); }

.s2-search-wrap {
  display: flex;
  align-items: center;
  gap: .375rem;
  padding: .375rem .5rem;
  border-bottom: 1px solid #f3f4f6;
}
.s2-search-icon { flex-shrink: 0; }
.s2-search {
  flex: 1;
  border: none;
  outline: none;
  font-size: .8125rem;
  background: transparent;
  color: var(--color-text);
  min-width: 0;
}
.s2-search::placeholder { color: #9ca3af; }

.s2-opts { max-height: 14rem; overflow-y: auto; }
.s2-opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .5rem .75rem;
  cursor: pointer;
  font-size: .8125rem;
  color: var(--color-text);
  transition: background .08s;
}
.s2-opt:hover { background: #f9fafb; }
.s2-opt--sel  { background: #eff6ff; color: #2563eb; font-weight: 500; }
.s2-opt--sel:hover { background: #dbeafe; }
.s2-opt-label { flex: 1; text-align: start; }
.s2-check { flex-shrink: 0; }
.s2-empty { padding: .625rem .75rem; font-size: .8125rem; color: #9ca3af; text-align: center; }
