/* ─── Design tokens ─────────────────────────────────────────────────────────── */
:root {
  --brand:        #64c5b2;
  --brand-dark:   #4ca592;
  --brand-light:  #e8f7f4;
  --brand-hover:  #56b0a0;

  --danger:       #ef4444;
  --danger-bg:    #fee2e2;
  --warning:      #d97706;
  --warning-bg:   #fef3c7;
  --success:      #16a34a;
  --success-bg:   #dcfce7;
  --info:         #2563eb;
  --info-bg:      #dbeafe;
  --gray:         #64748b;
  --gray-bg:      #f1f5f9;

  --text:         #1a2332;
  --text-muted:   #64748b;
  --text-light:   #94a3b8;

  --surface:      #ffffff;
  --surface-alt:  #f8fafc;
  --surface-hover:#f1f5f9;
  --border:       #e2e8f0;

  --radius-sm:    8px;
  --radius:       12px;
  --radius-lg:    16px;
  --radius-xl:    24px;

  --shadow-sm:    0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
  --shadow:       0 4px 16px rgba(15,23,42,.08);
  --shadow-lg:    0 16px 40px rgba(15,23,42,.12);

  --font:         'Barlow', system-ui, -apple-system, sans-serif;

  /* ─ Sidebar tokens ─ */
  --sidebar-w:    260px;
  --sb-bg:        #2d3748;
  --sb-border:    #1a202c;
  --sb-hover:     #3d4a5c;
  --sb-active:    #3d4a5c;
  --sb-text:      #f7fafc;
  --sb-muted:     #cbd5e0;
  --sb-accent:    #64c5b2;
  --transition:   0.18s ease;
}

/* ─── Reset & base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: #eef2f6;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; }
img { display: block; max-width: 100%; }

h1, h2, h3, h4 { margin: 0; font-weight: 700; line-height: 1.2; }
p { margin: 0; }

/* ─── App wrapper ────────────────────────────────────────────────────────────── */
.app-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ─── Navbar ─────────────────────────────────────────────────────────────────── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.navbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 32px;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.brand-mark {
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: .06em;
  padding: 5px 9px;
  border-radius: var(--radius-sm);
}

.brand-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
}

.navbar-links {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.nav-link {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  transition: color var(--transition), background var(--transition);
}

.nav-link:hover { color: var(--text); background: var(--surface-alt); }
.nav-link.active { color: var(--brand-dark); background: var(--brand-light); font-weight: 600; }

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-info { display: flex; flex-direction: column; line-height: 1.2; }
.user-name  { font-size: 13px; font-weight: 600; color: var(--text); }
.user-role  { font-size: 11px; color: var(--text-light); }

.btn-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
}

.btn-icon:hover { background: var(--surface-alt); color: var(--text); }

.mobile-menu-toggle { display: none; }

/* ─── Main content ───────────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px;
}

/* ─── Footer ─────────────────────────────────────────────────────────────────── */
.app-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  margin-top: auto;
}

.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 24px;
  font-size: 13px;
  color: var(--text-light);
}

/* ─── Page header ────────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--brand-dark);
}

.intro-text {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 15px;
  max-width: 560px;
}

/* ─── Buttons ─────────────────────────────────────────────────────────────────── */
.button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 20px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  white-space: nowrap;
}

.button:hover { transform: translateY(-1px); }
.button:active { transform: none; }

.button-primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 2px 8px rgba(100,197,178,.35);
}
.button-primary:hover { background: var(--brand-hover); }

.button-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.button-secondary:hover { background: var(--surface-alt); }

.button-danger {
  background: var(--danger);
  color: #fff;
}

.button-sm { padding: 6px 14px; font-size: 13px; }
.button-full { width: 100%; justify-content: center; }
.button:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* ─── Cards ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 24px;
}

.card + .card { margin-top: 20px; }

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

.card-header h2, .card-header h3 {
  font-size: 16px;
  font-weight: 700;
}

/* ─── Stat grid ──────────────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-card__label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}

.stat-card__value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}

.stat-card--brand .stat-card__value { color: var(--brand-dark); }
.stat-card--warn  .stat-card__value { color: var(--warning); }
.stat-card--info  .stat-card__value { color: var(--info); }
.stat-card--gray  .stat-card__value { color: var(--gray); }
.stat-card--dark  .stat-card__value { color: #374151; }

.stat-card { cursor: default; }
.stat-card.is-active { outline: 2px solid var(--brand); outline-offset: -2px; }

/* ─── Table ──────────────────────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

table { width: 100%; border-collapse: collapse; }

thead { background: var(--surface-alt); }

th {
  padding: 13px 18px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  white-space: nowrap;
}

td {
  padding: 14px 18px;
  font-size: 14px;
  border-top: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr { transition: background var(--transition); }
tbody tr:hover { background: #f9fbfd; }

.row-link { cursor: pointer; }

/* ─── Status badge ───────────────────────────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--badge-bg, #f1f5f9);
  color: var(--badge-color, #64748b);
  white-space: nowrap;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* ─── Doc/message status badges ─────────────────────────────────────────────── */
.doc-status {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
}
.doc-status--ok   { background: var(--success-bg); color: var(--success); }
.doc-status--wait { background: var(--warning-bg); color: var(--warning); }
.doc-status--recv { background: var(--info-bg); color: var(--info); }
.doc-status--rej  { background: var(--danger-bg); color: var(--danger); }

/* ─── Search / filter bar ────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  align-items: center;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-input-wrap svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 9px 12px 9px 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.search-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(100,197,178,.15);
}

.filter-select {
  padding: 9px 34px 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color var(--transition);
}

.filter-select:focus { outline: none; border-color: var(--brand); }

/* ─── Forms ──────────────────────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-group:last-child { margin-bottom: 0; }

label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

input[type='text'],
input[type='email'],
input[type='password'],
input[type='tel'],
textarea,
select {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(100,197,178,.15);
}

textarea { resize: vertical; min-height: 100px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ─── Alert ──────────────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 16px;
}

.alert-error   { background: var(--danger-bg);  color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: var(--success-bg); color: #14532d; border: 1px solid #86efac; }
.alert-info    { background: var(--info-bg);    color: #1e3a8a; border: 1px solid #93c5fd; }

/* ─── Auth pages ─────────────────────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #eef2f6 0%, #e8f7f4 100%);
}

.auth-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
}

.auth-header {
  text-align: center;
  margin-bottom: 28px;
}

.auth-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.auth-logo .brand-mark {
  font-size: 16px;
  padding: 8px 16px;
}

.auth-header h1 { font-size: 22px; margin-bottom: 6px; }
.auth-header p  { color: var(--text-muted); font-size: 14px; }

.auth-form { display: flex; flex-direction: column; }

.auth-footer {
  margin-top: 20px;
  text-align: center;
  font-size: 13px;
  color: var(--text-light);
}

/* ─── Tabs ───────────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
}

.tab-btn {
  padding: 10px 18px;
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color var(--transition), border-color var(--transition);
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--brand-dark); border-bottom-color: var(--brand); font-weight: 600; }

/* ─── Messages / Correspondence ─────────────────────────────────────────────── */
.message-list { display: flex; flex-direction: column; gap: 16px; }

.message-bubble {
  max-width: 75%;
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.message-bubble--admin {
  background: var(--brand-light);
  color: var(--text);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}

.message-bubble--customer {
  background: #e0f2fe;
  color: var(--text);
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}

.message-meta {
  font-size: 11px;
  color: var(--text-light);
  margin-bottom: 4px;
}

.message-meta--right { text-align: right; }

.message-item { display: flex; flex-direction: column; }
.message-item--right { align-items: flex-end; }

.message-compose {
  border-top: 1px solid var(--border);
  padding-top: 20px;
  margin-top: 20px;
}

.compose-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ─── Document list ──────────────────────────────────────────────────────────── */
.doc-list { display: flex; flex-direction: column; gap: 10px; }

.doc-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: background var(--transition);
}

.doc-item:hover { background: var(--surface-alt); }

.doc-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: var(--brand-light);
  color: var(--brand-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.doc-info { flex: 1; min-width: 0; }
.doc-name { font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ─── Case detail header ─────────────────────────────────────────────────────── */
.case-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 24px 28px;
  margin-bottom: 24px;
}

.case-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.case-title-row h1 { font-size: 22px; }

.case-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.case-meta-item { display: flex; flex-direction: column; gap: 3px; }
.case-meta-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-light); }
.case-meta-value { font-size: 14px; font-weight: 500; color: var(--text); }

/* ─── Modal ──────────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.4);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  backdrop-filter: blur(2px);
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 32px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.modal-header h2 { font-size: 18px; }

/* ─── Empty state ────────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state p { font-size: 14px; margin-top: 8px; }

/* ─── Spinner ─────────────────────────────────────────────────────────────────── */
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 0 auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Notices / tags ─────────────────────────────────────────────────────────── */
.notice-text {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 8px;
}

.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-alt);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* ─── Invite list ────────────────────────────────────────────────────────────── */
.customer-list { display: flex; flex-direction: column; gap: 10px; }

.customer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: #ffffff;
  border-radius: 10px;
  gap: 12px;
  border: 1px solid #f0f0f0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: box-shadow 0.2s, border-color 0.2s;
}

.customer-row:hover {
  border-color: #e5e7eb;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.customer-info { flex: 1; }
.customer-name { font-size: 14px; font-weight: 600; }
.customer-contact { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ─── Upload zone ────────────────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  background: var(--surface-alt);
}

.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--brand);
  background: var(--brand-light);
}

.upload-zone p { font-size: 14px; color: var(--text-muted); margin-top: 8px; }

/* ─── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .navbar-inner { gap: 16px; }
  .user-info { display: none; }
  .navbar-links { display: none; flex-direction: column; position: absolute; top: 64px; left: 0; right: 0; background: var(--surface); border-bottom: 1px solid var(--border); padding: 12px; box-shadow: var(--shadow); }
  .navbar-links.is-open { display: flex; }
  .mobile-menu-toggle { display: flex; }
  .navbar { position: relative; }
  .main-content { padding: 20px 16px; }
  .form-row { grid-template-columns: 1fr; }
  .case-title-row { flex-direction: column; }
  .page-header { flex-direction: column; }
}

/* ─── Setup / Onboarding ─────────────────────────────────────────────────────── */
.setup-progress {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 32px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.setup-progress-step {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.setup-progress-step + .setup-progress-step::before {
  content: '';
  width: 32px;
  height: 2px;
  background: var(--border);
  flex-shrink: 0;
}

.setup-progress-step.done + .setup-progress-step::before { background: var(--brand); }

.step-circle {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
}

.setup-progress-step.active .step-circle {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.setup-progress-step.done .step-circle {
  border-color: var(--brand);
  background: var(--brand-light);
  color: var(--brand-dark);
}

.step-circle-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.setup-progress-step.active .step-circle-label { color: var(--brand-dark); }
.setup-progress-step.done .step-circle-label  { color: var(--brand-dark); }

/* Setup card with numbered header */
.setup-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}

.setup-card-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
}

.setup-number {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.setup-card-header h2 { font-size: 16px; }
.setup-card-header p  { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

.setup-card-body { padding: 24px; }

/* Collapsible guide */
.guide-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  background: var(--brand-light);
  border: 1px solid rgba(100,197,178,.25);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--brand-dark);
  text-align: left;
  margin-bottom: 20px;
  transition: background var(--transition);
}

.guide-toggle:hover { background: #d4ede9; }
.guide-toggle svg { flex-shrink: 0; transition: transform .2s; }
.guide-toggle.open svg { transform: rotate(180deg); }

.guide-body {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  font-size: 14px;
  line-height: 1.7;
}

.guide-body h4 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin: 16px 0 8px;
}

.guide-body h4:first-child { margin-top: 0; }

.guide-body ol, .guide-body ul {
  padding-left: 20px;
  margin: 0;
}

.guide-body li { margin-bottom: 6px; }

.guide-body strong { color: var(--text); }

/* Permission tags */
.perm-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.perm-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  font-family: 'Consolas', 'JetBrains Mono', monospace;
}

.perm-tag--app {
  background: #ede9fe;
  color: #5b21b6;
  border: 1px solid #c4b5fd;
}

.perm-tag--delegated {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
}

.perm-badge {
  font-size: 10px;
  background: rgba(0,0,0,.08);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: var(--font);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* Code blocks */
.cmd-block {
  background: #1e293b;
  color: #e2e8f0;
  border-radius: var(--radius);
  padding: 14px 16px;
  font-family: 'Consolas', 'JetBrains Mono', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.6;
  overflow-x: auto;
  margin: 10px 0;
  position: relative;
}

.cmd-block .cmd-comment { color: #64748b; }
.cmd-block .cmd-keyword { color: #7dd3fc; }
.cmd-block .cmd-string  { color: #86efac; }

code {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: 'Consolas', 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--brand-dark);
}

/* Input with visibility toggle */
.input-secret-wrap {
  position: relative;
  display: flex;
}

.input-secret-wrap input {
  flex: 1;
  border-radius: var(--radius) 0 0 var(--radius);
  border-right: none;
}

.input-secret-wrap input:focus { z-index: 1; }

.input-secret-wrap .toggle-secret {
  border: 1px solid var(--border);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--surface-alt);
  color: var(--text-muted);
  padding: 0 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: background var(--transition);
}

.input-secret-wrap .toggle-secret:hover { background: var(--surface-hover); }

/* Test result banner */
.test-result {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  margin-top: 10px;
}

.test-result--ok    { background: var(--success-bg); color: #14532d; border: 1px solid #86efac; }
.test-result--error { background: var(--danger-bg);  color: #991b1b; border: 1px solid #fca5a5; }
.test-result--info  { background: var(--info-bg);    color: #1e3a8a; border: 1px solid #93c5fd; }

/* Setup section divider */
.setup-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* Env status indicator */
.env-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
}

.env-status--set   { background: var(--success-bg); color: var(--success); }
.env-status--unset { background: var(--warning-bg); color: var(--warning); }
.env-status--def   { background: var(--gray-bg);    color: var(--gray);   }

/* Save bar */
.save-bar {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: 0 -4px 16px rgba(15,23,42,.06);
  z-index: 50;
  margin: 0 -24px;
}

.save-bar p { font-size: 13px; color: var(--text-muted); }

@media (max-width: 600px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .modal { padding: 24px; }
  .auth-card { padding: 28px 20px; }
  .message-bubble { max-width: 90%; }
}

/* ─── Admin sidebar shell ────────────────────────────────────────────────────── */
.admin-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ─── Sidebar ────────────────────────────────────────────────────────────────── */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--sb-bg);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--sb-border);
  scrollbar-width: thin;
  scrollbar-color: var(--sb-border) transparent;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--sb-border);
  flex-shrink: 0;
}

.sidebar-logo .brand-mark {
  background: var(--sb-accent);
  color: #ffffff;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.09em;
  padding: 5px 9px;
  border-radius: 6px;
}

.sidebar-logo .brand-name {
  font-size: 14px;
  font-weight: 700;
  color: #f7fafc;
  letter-spacing: 0.01em;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow-y: auto;
  scrollbar-width: none;
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: var(--sb-muted);
  padding: 16px 12px 6px;
  flex-shrink: 0;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--sb-text);
  cursor: pointer;
  transition: background 0.13s, color 0.13s;
  text-decoration: none;
  flex-shrink: 0;
}

.sidebar-item:hover { background: var(--sb-hover); color: #f7fafc; }
.sidebar-item.is-active { background: var(--sb-active); color: var(--sb-accent); font-weight: 600; }

.sidebar-item svg { flex-shrink: 0; opacity: 0.65; }
.sidebar-item.is-active svg { opacity: 1; }

.sidebar-item-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-count {
  font-size: 11px;
  font-weight: 700;
  background: rgba(100, 197, 178, 0.15);
  color: #64c5b2;
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 22px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-item.is-active .sidebar-count {
  background: #dcfce7;
  color: #16a34a;
}

.sidebar-customer-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--sb-muted);
  flex-shrink: 0;
  margin-left: 1px;
}

.sidebar-item.is-active .sidebar-customer-dot { background: var(--sb-accent); }

.sidebar-divider {
  height: 1px;
  background: var(--sb-border);
  margin: 6px 12px;
  flex-shrink: 0;
}

.sidebar-footer-nav {
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 13px 14px;
  border-top: 1px solid var(--sb-border);
  flex-shrink: 0;
}

.sidebar-user .user-avatar {
  width: 30px;
  height: 30px;
  font-size: 12px;
  background: var(--sb-active);
  color: var(--sb-accent);
  flex-shrink: 0;
}

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

.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: #f7fafc;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role { font-size: 11px; color: var(--sb-muted); display: block; }

.sidebar-logout-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--sb-border);
  background: transparent;
  color: var(--sb-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.13s, color 0.13s, border-color 0.13s;
  flex-shrink: 0;
}

.sidebar-logout-btn:hover { background: var(--sb-hover); color: var(--sb-text); border-color: var(--sb-text); }

/* ─── Admin main area ────────────────────────────────────────────────────────── */
.main-area {
  min-height: 100vh;
  background: oklch(96.5% 0.008 220);
}

.main-area .main-content {
  max-width: none;
  padding: 32px 36px;
}

/* ─── Customer shell (top-bar layout) ───────────────────────────────────────── */
.customer-shell { display: flex; flex-direction: column; min-height: 100vh; }
.customer-shell .main-content { max-width: 1100px; margin: 0 auto; padding: 32px 24px; }

/* ─── Context heading strip ─────────────────────────────────────────────────── */
.context-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.context-strip h1 { font-size: 22px; font-weight: 700; }
.context-strip .context-meta { font-size: 13px; color: var(--text-muted); margin-top: 3px; }

@media (max-width: 900px) {
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 200; transform: translateX(-100%); transition: transform 0.2s ease; }
  .sidebar.is-open { transform: none; }
  .main-area .main-content { padding: 20px 16px; }
  .context-strip { flex-direction: column; align-items: flex-start; }
}

/* ─── Microsoft SSO button ───────────────────────────────────────────────────── */
.button-microsoft {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #fff;
  color: #1a1a1a;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 18px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition), box-shadow var(--transition);
  box-shadow: var(--shadow);
}

.button-microsoft:hover { background: #f6f8fa; box-shadow: var(--shadow-md); }

/* ─── Auth divider ───────────────────────────────────────────────────────────── */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 4px;
  font-size: 12px;
  color: var(--text-light);
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ─── Auth fallback details ──────────────────────────────────────────────────── */
.auth-fallback {
  margin-top: 12px;
}

.auth-fallback summary {
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  padding: 6px 0;
}

.auth-fallback summary:hover { color: var(--text); }

/* ─── Setup page form elements ───────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

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

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.label-hint {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-light);
  margin-left: 4px;
}

.field-hint {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 5px;
}

.copy-field {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.copy-field input { flex: 1; font-family: 'Consolas', 'JetBrains Mono', monospace; font-size: 13px; }

/* ─── Setup info / steps ─────────────────────────────────────────────────────── */
.setup-info {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
  font-size: 14px;
  line-height: 1.7;
}

.setup-info p { margin-bottom: 10px; }

.setup-steps {
  padding-left: 20px;
  margin: 8px 0 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setup-steps li { font-size: 13px; }

/* ─── Status badge variants for SSO state ────────────────────────────────────── */
.status-badge--active   { background: var(--success-bg); color: #14532d; border: 1px solid #86efac; }
.status-badge--inactive { background: var(--surface-alt); color: var(--text-muted); border: 1px solid var(--border); }

@media (max-width: 700px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-group--full { grid-column: auto; }
}
