@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Noto+Sans+SC:wght@400;500;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* --brand-primary / --brand-primary-dark are overridden per-tenant via
     SB.ui.applyBranding(), which reads organizations.branding.primary_color
     and sets these on document.documentElement. When not set (anonymous
     pages, demo mode), they fall back to --primary defaults below. */
  --primary: var(--brand-primary, #2563eb);
  --primary-dark: var(--brand-primary-dark, #1d4ed8);
  --bg: #f7f8fc;
  --card: #ffffff;
  --text: #111827;
  --text-2: #1f2937;
  --muted: #6b7280;
  --border: #eaecf0;
  --border-soft: #f1f3f7;
  --green: #16a34a;
  --green-bg: #dcfce7;
  --yellow: #d97706;
  --yellow-bg: #fef3c7;
  --red: #dc2626;
  --red-bg: #fee2e2;
  --warn-bg: #fff7ed;
  --warn-text: #c2410c;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);

  --font-sans: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", Arial, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, "SF Mono", Menlo, Consolas, "Cascadia Mono", monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.65;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01", "cv11", "kern";
}

/* Better typographic hierarchy */
h1, h2, h3, h4 {
  font-weight: 600;
  letter-spacing: -0.018em;
  line-height: 1.3;
  color: var(--text);
}
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p  { line-height: 1.7; }

/* Tabular numbers in tables and money fields */
table, .num, input[type="number"], .money {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

code, pre, kbd { font-family: var(--font-mono); }

/* Inputs / selects pick up the same crisp font */
input, button, select, textarea {
  font-family: inherit;
  font-feature-settings: inherit;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.app-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  padding: 24px 0;
  margin-bottom: 28px;
}

.app-header h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
}

.subtitle {
  margin: 6px 0 0;
  opacity: .92;
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0;
  color: #fff;
}

.app-nav {
  display: flex;
  gap: 6px;
  padding-top: 14px;
  margin-bottom: -28px;
  flex-wrap: wrap;
}

.nav-link {
  color: rgba(255,255,255,.85);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 8px 8px 0 0;
  background: rgba(255,255,255,.1);
  transition: background .15s, color .15s;
}

.nav-link:hover { background: rgba(255,255,255,.2); color: #fff; }
.nav-link.active { background: var(--bg); color: var(--primary); }

/* Tabs (within bookkeeping) */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.tab-btn {
  background: transparent;
  border: none;
  padding: 9px 14px;
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-family: inherit;
  transition: color .15s, border-color .15s, background .15s;
  border-radius: 6px 6px 0 0;
}

.tab-btn:hover { color: var(--text); background: rgba(37,99,235,.04); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* AI steps (ai-bookkeeping + ai-tax pages) */
.ai-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-top: 14px;
}
.ai-step {
  text-align: left;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fafbff;
}
.ai-step-num {
  display: inline-flex;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #6d28d9);
  color: #fff;
  align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  margin-bottom: 10px;
}
.ai-step h3 { margin: 0 0 6px; font-size: 15px; font-weight: 600; }
.ai-step p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.55; }

.ai-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 6px;
  background: #fff;
  font-size: 13.5px;
}
.ai-row-name { font-weight: 500; color: var(--text); }
.ai-row-state { font-size: 13px; color: var(--muted); }

/* Quick service actions (portal + dashboard) */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.quick-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.quick-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: 0 6px 18px rgba(37,99,235,.08);
}
.quick-icon { font-size: 24px; line-height: 1; }
.quick-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
  line-height: 1.4;
  margin-top: 2px;
}
.quick-time {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.quick-btn {
  margin-top: auto;
  display: block;
  text-align: center;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  transition: background .15s;
}
.quick-btn:hover { background: var(--primary-dark); }
.quick-btn-2 {
  margin-top: 6px;
  background: #fff;
  color: var(--primary);
  border: 1px solid var(--primary);
}
.quick-btn-2:hover { background: rgba(37,99,235,.08); }

/* Document checklist (intake + portal) */
.checklist-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  background: #fafbff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
}

.checklist-list label {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 6px 4px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-2);
  cursor: pointer;
  border-bottom: 1px solid var(--border-soft);
}

.checklist-list label:last-child { border-bottom: none; }

.checklist-list input[type="checkbox"] {
  margin-top: 3px;
  flex-shrink: 0;
  accent-color: var(--primary);
}

.checklist-list label:hover { color: var(--text); }

@media (min-width: 640px) {
  .checklist-list { grid-template-columns: 1fr 1fr; }
}

/* Service selector toolbar (replaces the old tab grid) */
.svc-toolbar {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
  padding-bottom: 4px;
}

.svc-picker {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 320px;
  flex: 1;
}

.svc-picker-label {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.svc-picker select {
  appearance: none;
  -webkit-appearance: none;
  padding: 11px 38px 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background-color: #fff;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%236b7280' d='M0 0l6 8 6-8z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}

.svc-picker select:hover { border-color: #c7cdd6; }
.svc-picker select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

.svc-toolbar-spacer { flex: 0 0 auto; }
.svc-toolbar .btn { white-space: nowrap; }

/* Drop zone */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 40px 24px;
  text-align: center;
  background: #fafbff;
  transition: border-color .15s, background .15s;
  cursor: pointer;
}

.dropzone:hover, .dropzone.drag {
  border-color: var(--primary);
  background: #eff6ff;
}

.dropzone p { margin: 0 0 6px; color: var(--muted); }
.dropzone .upload-icon { font-size: 36px; margin-bottom: 10px; }

/* Account / category list */
.coa-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.coa-section h3 {
  margin: 0 0 8px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  font-weight: 700;
}

.coa-section ul {
  list-style: none;
  padding: 0;
  margin: 0 0 18px;
}

.coa-section li {
  padding: 7px 12px;
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 4px;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.coa-section li code {
  font-size: 11px;
  color: var(--muted);
  background: #fff;
  padding: 2px 6px;
  border-radius: 4px;
}

/* Transactions */
.txn-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.txn-toolbar .stat {
  font-size: 13px;
  color: var(--muted);
}

.txn-toolbar .stat strong { color: var(--text); }

select.cat-select {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  max-width: 220px;
}

select.cat-select.uncategorized { border-color: var(--yellow); background: var(--warn-bg); }
select.cat-select.ai { border-color: var(--primary); background: #eff6ff; }

.amount-pos { color: var(--green); font-weight: 600; }
.amount-neg { color: var(--text); }

/* Reports */
.report-toolbar {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.report-toolbar label {
  display: flex;
  flex-direction: column;
  font-size: 13px;
  color: var(--muted);
}

.report-toolbar input[type="date"] {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  margin-top: 5px;
}

.pl-report {
  font-family: var(--font-mono);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px 28px;
  background: #fff;
}

.pl-report h3 {
  margin: 0 0 4px;
  font-size: 20px;
  font-family: var(--font-sans);
  font-weight: 700;
  letter-spacing: -0.018em;
  text-align: center;
}

.pl-report .sub-head {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 22px;
  font-family: var(--font-sans);
}

.pl-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
}

.pl-section-head {
  margin-top: 14px;
  padding: 6px 0 5px;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: .05em;
  color: var(--muted);
}

.pl-section-head:first-child { margin-top: 0; }

.pl-account {
  padding-left: 18px;
}

.pl-subtotal {
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding-top: 6px;
  font-weight: 600;
}

.pl-total {
  border-top: 2px solid var(--text);
  border-bottom: 3px double var(--text);
  margin-top: 8px;
  padding: 8px 0;
  font-weight: 700;
  font-size: 15px;
}

.pl-total.positive { color: var(--green); }
.pl-total.negative { color: var(--red); }

.business-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.business-picker select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  min-width: 220px;
}

.warn-box {
  background: var(--warn-bg);
  border-left: 4px solid var(--yellow);
  padding: 13px 18px;
  border-radius: 8px;
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--warn-text);
  margin-bottom: 14px;
}

.info-box {
  background: #eff6ff;
  border-left: 4px solid var(--primary);
  padding: 13px 18px;
  border-radius: 8px;
  font-size: 13.5px;
  line-height: 1.65;
  color: #1e40af;
  margin-bottom: 14px;
}

/* Auth page */
.auth-body {
  background: linear-gradient(135deg, var(--primary) 0%, #4338ca 50%, #6d28d9 100%);
  min-height: 100vh;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-shell {
  width: 100%;
  max-width: 480px;
}

/* Role badge above the auth card */
.auth-role-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(255,255,255,.18);
  color: #fff;
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin: 0 auto 16px;
  backdrop-filter: blur(6px);
}
.auth-role-badge .role-icon { font-size: 16px; }

.auth-shell.staff-mode .auth-role-badge {
  background: rgba(15,23,42,.45);
  border-color: rgba(255,255,255,.25);
}

/* Staff mode: darker, more serious palette */
body.staff-mode {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 60%, #334155 100%) !important;
}

.auth-card {
  background: #fff;
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}

.auth-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.auth-head h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.auth-head p {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.auth-head .lang-switcher {
  background: var(--bg);
}

.auth-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 22px;
}

.auth-tabs .tab-btn {
  flex: 1;
  text-align: center;
}

.auth-pane.form-grid { gap: 14px; }

.btn.full {
  grid-column: 1 / -1;
  padding: 11px;
  font-size: 15px;
}

.auth-switch {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  margin: 8px 0 0;
}

.auth-switch a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.auth-switch a:hover { text-decoration: underline; }

.auth-foot {
  text-align: center;
  margin-top: 18px;
}

/* Progress bar */
.progress-bar {
  width: 100px;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  transition: width .25s;
}

/* Case modal */
.case-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, .55);
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 32px 16px;
  overflow-y: auto;
}

.case-modal-card {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 720px;
  padding: 24px 28px;
  box-shadow: 0 20px 50px rgba(0,0,0,.3);
}

/* Doc list in case detail */
.doc-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.doc-list li {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 6px 0;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}

.doc-list li:last-child { border-bottom: none; }

.doc-list .doc-status {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
  font-family: inherit;
}

/* Notes */
.note-entry {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.note-entry:last-child { border-bottom: none; }

.note-meta {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 2px;
}

.note-text { font-size: 14px; }

/* RTL support (Arabic) */
html[dir="rtl"] .form-grid label,
html[dir="rtl"] .filters label { text-align: right; }

html[dir="rtl"] .nav-link { border-radius: 0 0 8px 8px; }

html[dir="rtl"] .header-row,
html[dir="rtl"] .auth-head,
html[dir="rtl"] .form-actions { flex-direction: row-reverse; }

html[dir="rtl"] .pl-row { flex-direction: row-reverse; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px 28px;
  box-shadow: 0 1px 2px rgba(16,24,40,.04);
  margin-bottom: 24px;
}

@media (max-width: 640px) {
  .card { padding: 18px 18px; border-radius: 12px; }
}

.card h2 {
  margin: 0 0 16px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text);
}

.card h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
}

/* Form */
.form-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.01em;
}

.form-grid label.full { grid-column: 1 / -1; }

.form-grid input,
.form-grid select,
.form-grid textarea,
.filters input,
.filters select {
  margin-top: 6px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  line-height: 1.5;
  transition: border-color .15s, box-shadow .15s;
}

.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus,
.filters select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

.form-actions {
  display: flex;
  gap: 10px;
}

.btn {
  display: inline-block;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.005em;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}

.btn.primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 0 rgba(0,0,0,0.05);
}

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

.btn.ghost {
  background: #fff;
  border-color: var(--border);
  color: var(--text);
}

.btn.ghost:hover { background: #f3f4f6; }

.btn.danger {
  background: #fff;
  border-color: var(--red);
  color: var(--red);
}

.btn.danger:hover { background: var(--red-bg); }

.btn.small {
  padding: 5px 10px;
  font-size: 12px;
}

/* Filters */
.filters {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.filters label {
  display: flex;
  flex-direction: column;
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

/* Table */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

thead th {
  text-align: left;
  background: #f9fafb;
  color: var(--muted);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.55;
}

tbody tr:hover { background: #f9fafb; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 24px 0;
}

.empty.hidden { display: none; }

/* Tags */
.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.tag-low    { color: var(--green); background: var(--green-bg); }
.tag-medium { color: var(--yellow); background: var(--yellow-bg); }
.tag-high   { color: var(--red); background: var(--red-bg); }

.tag-complete    { color: var(--green); background: var(--green-bg); }
.tag-missing     { color: var(--warn-text); background: var(--warn-bg); }
.tag-needreview  { color: var(--yellow); background: var(--yellow-bg); }

.tag-status      { color: #1e40af; background: #dbeafe; }

/* Prompt box */
.prompt-box {
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  margin: 0;
}

.template { margin-top: 18px; }
.template:first-of-type { margin-top: 0; }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #111827;
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Header row + lang switcher */
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.lang-switcher {
  display: inline-flex;
  align-items: center;
  background: rgba(255,255,255,.15);
  border-radius: 999px;
  padding: 4px 10px;
}

.lang-label { font-size: 14px; }

.lang-select {
  border: none;
  background: transparent;
  color: #fff;
  padding: 4px 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 18px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%23ffffff' d='M0 0l5 6 5-6z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 4px center;
}
.lang-select option { color: #1a202c; background: #fff; }

/* Auth + light-bg pages: switcher inverts */
.auth-head .lang-select,
.lang-switcher.on-light .lang-select { color: var(--text); }
.auth-head .lang-select { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%231a202c' d='M0 0l5 6 5-6z'/></svg>"); }

.muted {
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.6;
  margin: 0 0 14px;
}

.mini-title {
  margin: 16px 0 8px;
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.link-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.link-row input {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: var(--font-mono);
  background: #f9fafb;
  color: var(--text);
}

.actions { white-space: nowrap; }
.actions .btn { margin-right: 4px; }

/* Wizard (intake form) */
.wizard-progress {
  display: flex;
  gap: 6px;
  margin-bottom: 22px;
}

.wizard-progress .step {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  transition: background .2s;
}

.wizard-progress .step.active,
.wizard-progress .step.done {
  background: var(--primary);
}

.wizard-step { display: none; }
.wizard-step.active { display: block; }

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 16px;
  margin-top: 6px;
}

.checkbox-grid label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  padding: 6px 0;
}

.checkbox-grid input[type="checkbox"] {
  margin-top: 3px;
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.review-block {
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 18px;
  margin-bottom: 14px;
}

.review-block h4 {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.review-block p { margin: 4px 0; font-size: 14px; }

.wizard-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 22px;
  gap: 10px;
}

.success-state {
  text-align: center;
  padding: 40px 20px;
}

.success-state .check {
  display: inline-flex;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--green-bg);
  color: var(--green);
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin-bottom: 16px;
}

/* Mobile */
@media (max-width: 800px) {
  .form-grid { grid-template-columns: repeat(2, 1fr); }
  .app-header h1 { font-size: 22px; }
  .card { padding: 16px; }
  .checkbox-grid { grid-template-columns: 1fr; }
}

@media (max-width: 500px) {
  .form-grid { grid-template-columns: 1fr; }
  .header-row { gap: 10px; flex-wrap: wrap; }
  .lang-select { font-size: 12px; }
}

/* ---- Mobile-friendly nav + tables ---- */
@media (max-width: 800px) {
  /* Nav: allow horizontal scroll instead of cramping. Touch users swipe. */
  .app-nav {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
  .app-nav::-webkit-scrollbar { height: 4px; }
  .app-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.3); border-radius: 2px; }
  .nav-link { white-space: nowrap; flex-shrink: 0; font-size: 13px; padding: 7px 11px; }

  /* Header row: stack title + right-side cluster instead of cramming */
  .header-row { flex-direction: column; align-items: flex-start; padding: 14px 16px; }
  .app-header h1 { font-size: 20px; }
  .app-header .subtitle { font-size: 12px; }

  /* Tables: containing wrapper scrolls — but also shrink default font so more fits */
  .table-wrap table { font-size: 13px; }
  .table-wrap th, .table-wrap td { padding: 8px 10px !important; }

  /* Form action buttons: stack instead of jam onto one line */
  .form-actions { flex-direction: column; align-items: stretch; }
  .form-actions .btn { width: 100%; justify-content: center; }

  /* Card padding so content gets breathing room without wasting space */
  .card { padding: 14px 14px; margin-bottom: 12px; }
  .container { padding: 0 12px; }

  /* Touch targets: bump buttons to at least 40px so they're tappable */
  .btn { min-height: 40px; padding: 10px 16px; }
  .btn.small { min-height: 32px; padding: 6px 10px; }

  /* Org strip in headers: hide the "Acting as" label on tiny screens, keep firm name only */
  .org-strip > div > div:first-child { display: none; }
  .org-strip { margin-right: 0 !important; }
}

/* Tablets in landscape — keep 2-col form grids but tighten everything else */
@media (max-width: 1024px) and (min-width: 801px) {
  .app-nav { gap: 4px; }
  .nav-link { padding: 7px 11px; font-size: 13px; }
}

/* ---- Skeletons (SB.ui.skeleton) ----
   Animated placeholder bars for loading lists/tables. */
.sb-skel-wrap { padding: 6px 0; }
.sb-skel-row { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border-soft); }
.sb-skel-row:last-child { border-bottom: 0; }
.sb-skel-bar {
  display: inline-block;
  height: 14px;
  border-radius: 6px;
  flex: 0 0 auto;
  background: linear-gradient(90deg, #eef2f6 0%, #f7f8fa 50%, #eef2f6 100%);
  background-size: 200% 100%;
  animation: sb-skel-shimmer 1.2s ease-in-out infinite;
}
@keyframes sb-skel-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---- Empty states (SB.ui.emptyState) ----
   Friendly nothing-here placeholders with optional CTA. */
.sb-empty {
  text-align: center;
  padding: 36px 24px;
  color: var(--muted);
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: 12px;
}
.sb-empty-icon { font-size: 38px; margin-bottom: 10px; line-height: 1; }
.sb-empty h3 { margin: 0 0 6px; color: var(--text); font-size: 17px; font-weight: 600; }
.sb-empty p { margin: 0; font-size: 14px; line-height: 1.55; max-width: 380px; margin-left: auto; margin-right: auto; }
