/* ==========================================================================
   WhatsApp AI CRM - design system
   Style: clean B2B SaaS, data-dense but calm. One accent (brand), slate neutrals,
   semantic status colours that always pair with an icon or text.
   Light and dark themes are defined together from the same tokens.
   ========================================================================== */

:root {
  --brand: #0f766e;                 /* overridden per client from Settings > Branding */
  --brand-hover: color-mix(in srgb, var(--brand) 85%, #000);
  --brand-soft: color-mix(in srgb, var(--brand) 10%, #fff);
  --brand-text: var(--brand);
  --on-brand: #ffffff;

  --bg: #f5f7f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-sunken: #eef2f6;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #526075;            /* 6.0:1 on white */
  --text-subtle: #64748b;           /* 4.76:1 on white */

  --success: #15803d; --success-soft: #e8f6ee;
  --warning: #a16207; --warning-soft: #fdf6e3;
  --danger:  #b91c1c; --danger-soft:  #fdecec;
  --info:    #1d4ed8; --info-soft:    #eaf0fe;
  --violet:  #6d28d9; --violet-soft:  #f1ebfd;

  --chat-bg: #efeae2;
  --bubble-in: #ffffff;
  --bubble-ai: #d9fdd3;
  --bubble-agent: #dbeafe;
  --bubble-system: #fef3c7;
  --bubble-note: #fff7d6;

  --radius-sm: 6px; --radius: 8px; --radius-lg: 12px;
  --shadow-1: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow-2: 0 4px 16px rgba(15, 23, 42, .08);
  --shadow-3: 0 12px 32px rgba(15, 23, 42, .16);
  --sidebar-w: 240px;
  --topbar-h: 56px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --dur: 160ms;

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Arabic", "Helvetica Neue", Arial, sans-serif;
  --font-ar: "Noto Sans Arabic", "Inter", system-ui, sans-serif;
}

[data-bs-theme="dark"] {
  --brand-text: color-mix(in srgb, var(--brand) 60%, #fff);
  --brand-soft: color-mix(in srgb, var(--brand) 22%, #0b1220);
  --bg: #0b1220;
  --surface: #111a2b;
  --surface-2: #142035;
  --surface-sunken: #0e1626;
  --border: #22304a;
  --border-strong: #2f4060;
  --text: #e6ebf3;
  --text-muted: #a7b2c5;
  --text-subtle: #8f9bb0;

  --success: #4ade80; --success-soft: rgba(74, 222, 128, .12);
  --warning: #fbbf24; --warning-soft: rgba(251, 191, 36, .12);
  --danger:  #f87171; --danger-soft:  rgba(248, 113, 113, .12);
  --info:    #93b4ff; --info-soft:    rgba(147, 180, 255, .12);
  --violet:  #c4b5fd; --violet-soft:  rgba(196, 181, 253, .12);

  --chat-bg: #0d1524;
  --bubble-in: #1b2638;
  --bubble-ai: #12352c;
  --bubble-agent: #1b2d4f;
  --bubble-system: #3a2f12;
  --bubble-note: #33300f;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-2: 0 4px 16px rgba(0, 0, 0, .45);
  --shadow-3: 0 12px 32px rgba(0, 0, 0, .55);
}

/* Map Bootstrap variables to tokens so components follow both themes */
:root, [data-bs-theme="dark"] {
  --bs-body-bg: var(--bg);
  --bs-body-color: var(--text);
  --bs-body-font-family: var(--font);
  --bs-border-color: var(--border);
  --bs-secondary-color: var(--text-muted);
  --bs-tertiary-bg: var(--surface-2);
  --bs-secondary-bg: var(--surface-sunken);
  --bs-emphasis-color: var(--text);
  --bs-link-color: var(--brand-text);
  --bs-link-hover-color: var(--brand-hover);
  --bs-link-color-rgb: 15, 118, 110;
  --bs-focus-ring-color: color-mix(in srgb, var(--brand) 35%, transparent);
  --bs-border-radius: var(--radius-sm);
  --bs-border-radius-lg: var(--radius);
  --bs-card-bg: var(--surface);
}

html { font-size: 14px; }
@media (max-width: 767.98px) { html { font-size: 15px; } }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
.num, .table td.num, .stat-value { font-variant-numeric: tabular-nums; }
[dir="rtl"], .rtl-auto { unicode-bidi: plaintext; text-align: start; }
:lang(ar), .ar { font-family: var(--font-ar); }

a { text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, .h1 { font-size: 1.5rem; font-weight: 650; letter-spacing: -.01em; }
h2, .h2 { font-size: 1.15rem; font-weight: 650; }
h3, .h3 { font-size: 1rem; font-weight: 600; }
.text-muted { color: var(--text-muted) !important; }
.text-subtle { color: var(--text-subtle) !important; }
.small, small { font-size: .857rem; }
.xsmall { font-size: .786rem; }

/* Focus: always visible for keyboard users */
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
.btn:focus-visible, .form-control:focus, .form-select:focus, .form-check-input:focus {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 30%, transparent);
  border-color: var(--brand);
  outline: none;
}
.skip-link { position: absolute; left: 8px; top: -48px; z-index: 1100; background: var(--brand); color: var(--on-brand); padding: 8px 12px; border-radius: var(--radius-sm); }
.skip-link:focus { top: 8px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100dvh; }
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: var(--surface); border-right: 1px solid var(--border);
  position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; z-index: 40;
}
.sidebar-brand { height: var(--topbar-h); display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--border); font-weight: 650; color: var(--text); }
.sidebar-brand img { max-height: 30px; max-width: 120px; object-fit: contain; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--brand); color: var(--on-brand); display: grid; place-items: center; font-size: 1rem; flex: none; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px; }
.nav-group { margin-top: 12px; }
.nav-group-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-subtle); padding: 4px 10px; font-weight: 600; }
.nav-item-link {
  display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 6px 10px; margin: 1px 0;
  border-radius: var(--radius-sm); color: var(--text-muted); font-weight: 500;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav-item-link .bi { font-size: 1.05rem; width: 20px; text-align: center; }
.nav-item-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item-link.active { background: var(--brand-soft); color: var(--brand-text); font-weight: 600; box-shadow: inset 3px 0 0 var(--brand); }
.nav-item-link .count { margin-left: auto; font-size: .72rem; font-weight: 600; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; display: inline-grid; place-items: center; background: var(--danger); color: #fff; }
.nav-item-link .count.neutral { background: var(--surface-sunken); color: var(--text-muted); }
.sidebar-foot { border-top: 1px solid var(--border); padding: 8px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px;
  padding: 0 20px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.topbar .page-title { font-size: 1.05rem; font-weight: 650; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-search { max-width: 340px; flex: 1; margin-left: auto; position: relative; }
.topbar-search .bi { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-subtle); }
.topbar-search input { padding-left: 32px; background: var(--surface); }
.icon-btn {
  width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent; color: var(--text-muted); cursor: pointer;
  transition: background var(--dur) var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.content { padding: 20px; flex: 1; }
.content-narrow { max-width: 1100px; }
@media (max-width: 991.98px) {
  .sidebar { position: fixed; left: 0; transform: translateX(-100%); transition: transform 200ms var(--ease); box-shadow: var(--shadow-3); }
  .sidebar.open { transform: translateX(0); }
  .scrim { position: fixed; inset: 0; background: rgba(2, 6, 23, .5); z-index: 35; display: none; }
  .scrim.show { display: block; }
  .topbar { padding: 0 12px; }
  .content { padding: 16px; }
}
@media (min-width: 992px) { .menu-btn { display: none !important; } }

/* ---------- Surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.card-header { background: transparent; border-bottom: 1px solid var(--border); padding: 12px 16px; display: flex; align-items: center; gap: 8px; font-weight: 600; }
.card-header .bi { color: var(--text-subtle); }
.card-body { padding: 16px; }
.card-footer { background: transparent; border-top: 1px solid var(--border); padding: 10px 16px; }
.section-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-subtle); font-weight: 600; margin: 0 0 8px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 16px; }
.page-head .lead-text { color: var(--text-muted); margin: 2px 0 0; }
.page-head .actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 8px; }

/* Stat tiles */
.stat { padding: 14px 16px; height: 100%; }
.stat-label { font-size: .8rem; color: var(--text-muted); display: flex; align-items: center; gap: 6px; font-weight: 500; }
.stat-value { font-size: 1.6rem; font-weight: 650; letter-spacing: -.02em; line-height: 1.2; margin-top: 4px; }
.stat-sub { font-size: .8rem; color: var(--text-subtle); margin-top: 2px; }
.stat-icon { width: 28px; height: 28px; border-radius: 7px; display: inline-grid; place-items: center; background: var(--brand-soft); color: var(--brand-text); }

/* ---------- Buttons & forms ---------- */
.btn { font-weight: 550; border-radius: var(--radius-sm); min-height: 36px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease); }
.btn-sm { min-height: 30px; padding: 3px 10px; }
.btn-primary { --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand-hover); --bs-btn-hover-border-color: var(--brand-hover); --bs-btn-active-bg: var(--brand-hover); --bs-btn-active-border-color: var(--brand-hover); --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand); --bs-btn-color: var(--on-brand); --bs-btn-hover-color: var(--on-brand); }
.btn-outline-primary { --bs-btn-color: var(--brand-text); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand); --bs-btn-hover-color: var(--on-brand); --bs-btn-active-bg: var(--brand-hover); }
.btn-light, .btn-secondary-soft { background: var(--surface); border: 1px solid var(--border-strong); color: var(--text); }
.btn-light:hover, .btn-secondary-soft:hover { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }
.btn-ghost { background: transparent; border: 1px solid transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger-soft { background: var(--danger-soft); color: var(--danger); border: 1px solid transparent; }
.btn-danger-soft:hover { background: var(--danger); color: #fff; }
.btn[disabled], .btn.disabled { opacity: .5; cursor: not-allowed; }
.btn .spinner-border { width: 1rem; height: 1rem; border-width: 2px; }

.form-label { font-size: .857rem; font-weight: 600; margin-bottom: 4px; color: var(--text); }
.form-label .req { color: var(--danger); margin-left: 2px; }
.form-control, .form-select { background-color: var(--surface); border-color: var(--border-strong); color: var(--text); min-height: 36px; border-radius: var(--radius-sm); }
.form-control::placeholder { color: var(--text-subtle); }
.form-text, .help { font-size: .8rem; color: var(--text-muted); margin-top: 4px; }
.invalid-msg { color: var(--danger); font-size: .8rem; margin-top: 4px; display: flex; gap: 4px; align-items: center; }
.form-switch .form-check-input { width: 2.2em; height: 1.2em; }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px 16px; margin-bottom: 16px; }
legend { float: none; width: auto; font-size: .9rem; font-weight: 650; padding: 0 6px; margin: 0; }
@media (pointer: coarse) {
  .btn, .form-control, .form-select, .icon-btn, .nav-item-link { min-height: 44px; }
  .icon-btn { width: 44px; height: 44px; }
  .form-control, .form-select { font-size: 16px; }
}

/* ---------- Badges / chips (always icon or text, never colour alone) ---------- */
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; line-height: 1.5; white-space: nowrap; border: 1px solid transparent; }
.chip .bi { font-size: .8rem; }
.chip-neutral { background: var(--surface-sunken); color: var(--text-muted); }
.chip-brand { background: var(--brand-soft); color: var(--brand-text); }
.chip-success { background: var(--success-soft); color: var(--success); }
.chip-warning { background: var(--warning-soft); color: var(--warning); }
.chip-danger { background: var(--danger-soft); color: var(--danger); }
.chip-info { background: var(--info-soft); color: var(--info); }
.chip-violet { background: var(--violet-soft); color: var(--violet); }
.chip-outline { background: transparent; border-color: var(--border-strong); color: var(--text-muted); }

/* ---------- Tables ---------- */
.table { --bs-table-bg: transparent; --bs-table-color: var(--text); --bs-table-hover-bg: var(--surface-2); --bs-table-hover-color: var(--text); --bs-table-border-color: var(--border); margin: 0; }
.table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-subtle); font-weight: 600; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; padding: 9px 12px; position: sticky; top: 0; z-index: 1; }
.table td { padding: 10px 12px; vertical-align: middle; border-color: var(--border); }
.table-clickable tbody tr { cursor: pointer; }
.table-wrap { overflow-x: auto; }
.th-sort { color: inherit; display: inline-flex; gap: 4px; align-items: center; }
.th-sort:hover { color: var(--text); text-decoration: none; }
.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-sunken); color: var(--text-muted); display: grid; place-items: center; font-weight: 650; font-size: .8rem; flex: none; text-transform: uppercase; }
.avatar-sm { width: 26px; height: 26px; font-size: .7rem; }
.avatar-brand { background: var(--brand-soft); color: var(--brand-text); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Bulk bar */
.bulk-bar { position: sticky; bottom: 12px; z-index: 20; display: none; align-items: center; gap: 8px; flex-wrap: wrap; background: var(--text); color: var(--bg); border-radius: var(--radius); padding: 8px 12px; box-shadow: var(--shadow-3); margin-top: 12px; }
.bulk-bar.show { display: flex; }
.bulk-bar .form-select { min-height: 32px; width: auto; }

/* Empty states */
.empty { text-align: center; padding: 40px 16px; color: var(--text-muted); }
.empty .bi { font-size: 2rem; color: var(--text-subtle); display: block; margin-bottom: 8px; }
.empty h3 { color: var(--text); font-size: 1rem; margin-bottom: 4px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 8px 12px; color: var(--text-muted); font-weight: 550; border-bottom: 2px solid transparent; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--brand-text); border-bottom-color: var(--brand); }

/* ---------- Chat ---------- */
.chat { background: var(--chat-bg); padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.bubble { max-width: min(78%, 560px); padding: 7px 10px 5px; border-radius: 10px; white-space: pre-wrap; word-wrap: break-word; font-size: .93rem; box-shadow: var(--shadow-1); position: relative; color: var(--text); }
.bubble.in { background: var(--bubble-in); align-self: flex-start; border-top-left-radius: 3px; }
.bubble.out { background: var(--bubble-ai); align-self: flex-end; border-top-right-radius: 3px; }
.bubble.out.agent { background: var(--bubble-agent); }
.bubble.out.system { background: var(--bubble-system); }
.bubble.note { background: var(--bubble-note); align-self: center; border: 1px dashed var(--warning); max-width: 90%; font-size: .85rem; }
.bubble .meta { font-size: .7rem; color: var(--text-subtle); margin-top: 2px; text-align: right; display: flex; gap: 6px; justify-content: flex-end; align-items: center; }
.bubble.failed { outline: 1px solid var(--danger); }
.day-sep { align-self: center; font-size: .72rem; color: var(--text-muted); background: var(--surface); border-radius: 999px; padding: 2px 10px; margin: 8px 0; box-shadow: var(--shadow-1); }

/* ---------- Inbox (3 panes) ---------- */
.inbox { display: grid; grid-template-columns: 320px minmax(0, 1fr) 300px; height: calc(100dvh - var(--topbar-h)); background: var(--surface); }
.inbox-list { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.inbox-filters { padding: 10px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.seg { display: flex; gap: 2px; background: var(--surface-sunken); padding: 3px; border-radius: var(--radius-sm); overflow-x: auto; }
.seg a { flex: 1; text-align: center; padding: 4px 8px; border-radius: 4px; color: var(--text-muted); font-size: .8rem; font-weight: 600; white-space: nowrap; }
.seg a:hover { text-decoration: none; color: var(--text); }
.seg a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.conv-list { overflow-y: auto; flex: 1; }
.conv-item { display: flex; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); color: var(--text); position: relative; }
.conv-item:hover { background: var(--surface-2); text-decoration: none; }
.conv-item.active { background: var(--brand-soft); }
.conv-item.active::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--brand); }
.conv-item .name { font-weight: 600; font-size: .9rem; }
.conv-item .preview { font-size: .82rem; color: var(--text-muted); }
.conv-item .time { font-size: .72rem; color: var(--text-subtle); white-space: nowrap; }
.unread-dot { min-width: 18px; height: 18px; border-radius: 9px; background: var(--brand); color: var(--on-brand); font-size: .68rem; font-weight: 700; display: inline-grid; place-items: center; padding: 0 5px; }
.inbox-chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.inbox-chat-head { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-bottom: 1px solid var(--border); min-height: 56px; flex-wrap: wrap; }
.inbox-chat .chat { flex: 1; }
.composer { border-top: 1px solid var(--border); padding: 10px; background: var(--surface); }
.composer textarea { resize: none; min-height: 44px; max-height: 160px; }
.composer-modes { display: flex; gap: 4px; margin-bottom: 6px; }
.composer-modes button { border: 0; background: transparent; color: var(--text-muted); font-weight: 600; font-size: .8rem; padding: 4px 8px; border-radius: 4px; }
.composer-modes button.active { background: var(--surface-sunken); color: var(--text); }
.composer.note-mode textarea { background: var(--bubble-note); }
.inbox-side { border-left: 1px solid var(--border); overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 14px; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 4px 8px; font-size: .857rem; }
.kv dt { color: var(--text-subtle); font-weight: 500; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 1279.98px) { .inbox { grid-template-columns: 300px minmax(0, 1fr); } .inbox-side { display: none; } .inbox-side.show { display: flex; position: fixed; right: 0; top: var(--topbar-h); bottom: 0; width: 320px; background: var(--surface); z-index: 45; box-shadow: var(--shadow-3); } }
@media (max-width: 767.98px) { .inbox { grid-template-columns: 1fr; } .inbox.has-chat .inbox-list { display: none; } .inbox:not(.has-chat) .inbox-chat { display: none; } }

/* ---------- Timeline ---------- */
.timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 13px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.timeline li { position: relative; padding: 0 0 14px 38px; }
.timeline .t-icon { position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 2px solid var(--border); color: var(--text-muted); font-size: .8rem; }
.timeline .t-icon.brand { border-color: var(--brand); color: var(--brand-text); }
.timeline .t-icon.danger { border-color: var(--danger); color: var(--danger); }
.timeline .t-icon.success { border-color: var(--success); color: var(--success); }
.timeline .t-title { font-weight: 600; font-size: .88rem; }
.timeline .t-meta { font-size: .75rem; color: var(--text-subtle); }
.timeline .t-body { font-size: .857rem; color: var(--text-muted); margin-top: 2px; white-space: pre-wrap; }

/* ---------- Steps (wizard / import) ---------- */
.steps { display: flex; gap: 8px; list-style: none; padding: 0; margin: 0 0 20px; counter-reset: step; flex-wrap: wrap; }
.steps li { flex: 1; min-width: 120px; display: flex; align-items: center; gap: 8px; font-size: .857rem; color: var(--text-subtle); font-weight: 550; padding-bottom: 8px; border-bottom: 3px solid var(--border); }
.steps li .n { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-sunken); font-size: .75rem; font-weight: 700; flex: none; }
.steps li.done { color: var(--text-muted); border-color: var(--brand); }
.steps li.done .n { background: var(--brand); color: var(--on-brand); }
.steps li.current { color: var(--text); border-color: var(--brand); }
.steps li.current .n { background: var(--brand-soft); color: var(--brand-text); box-shadow: inset 0 0 0 2px var(--brand); }

/* ---------- Calendar ---------- */
.cal { display: grid; grid-template-columns: 56px repeat(7, minmax(110px, 1fr)); border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; background: var(--surface); max-height: 70vh; }
.cal-head { position: sticky; top: 0; z-index: 2; background: var(--surface-2); border-bottom: 1px solid var(--border); padding: 6px; text-align: center; font-size: .78rem; font-weight: 600; }
.cal-head.today { color: var(--brand-text); }
.cal-hour { font-size: .7rem; color: var(--text-subtle); text-align: right; padding: 2px 6px; border-top: 1px solid var(--border); height: 48px; }
.cal-col { position: relative; border-left: 1px solid var(--border); }
.cal-cell { height: 48px; border-top: 1px solid var(--border); }
.cal-cell.closed { background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 6px, var(--surface-sunken) 6px, var(--surface-sunken) 12px); }
.cal-event { position: absolute; left: 3px; right: 3px; border-radius: 6px; padding: 3px 6px; font-size: .72rem; line-height: 1.3; overflow: hidden; background: var(--brand-soft); border-left: 3px solid var(--brand); color: var(--text); }
.cal-event:hover { text-decoration: none; box-shadow: var(--shadow-2); }
.cal-event.cancelled { opacity: .55; text-decoration: line-through; border-left-color: var(--text-subtle); background: var(--surface-sunken); }
.hours-grid { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; align-items: center; }

/* ---------- Misc ---------- */
.toast-wrap { position: fixed; right: 16px; bottom: 16px; z-index: 1080; display: flex; flex-direction: column; gap: 8px; }
.toast-msg { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: var(--radius); box-shadow: var(--shadow-3); display: flex; gap: 8px; align-items: center; max-width: 380px; animation: toast-in 200ms var(--ease); }
.toast-msg.danger { background: var(--danger); color: #fff; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.progress { background: var(--surface-sunken); height: 8px; border-radius: 999px; }
.progress-bar { background: var(--brand); }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .8rem; background: var(--surface-sunken); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; white-space: pre-wrap; word-break: break-all; color: var(--text); }
code { color: var(--violet); }
.secret { font-family: ui-monospace, monospace; letter-spacing: .02em; }
.funnel-row { display: grid; grid-template-columns: 110px 1fr 70px; align-items: center; gap: 10px; margin-bottom: 8px; font-size: .857rem; }
.bar-track { background: var(--surface-sunken); border-radius: 4px; height: 22px; overflow: hidden; }
.bar-fill { background: var(--brand); height: 100%; border-radius: 4px; min-width: 2px; }
.chart-box { position: relative; height: 260px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.status-dot.ok { background: var(--success); } .status-dot.bad { background: var(--danger); } .status-dot.warn { background: var(--warning); }
.auth-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 16px; background: radial-gradient(1200px 500px at 50% -10%, var(--brand-soft), transparent), var(--bg); }
.auth-card { width: 100%; max-width: 400px; }
.list-plain { list-style: none; padding: 0; margin: 0; }
.list-plain li + li { border-top: 1px solid var(--border); }
.color-swatch { width: 36px; height: 36px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); padding: 0; }
.dropzone { border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 28px; text-align: center; background: var(--surface-2); transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease); }
.dropzone.drag { border-color: var(--brand); background: var(--brand-soft); }
.modal-content { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-3); }
.modal-backdrop.show { opacity: .5; }
.dropdown-menu { background: var(--surface); border-color: var(--border); box-shadow: var(--shadow-2); --bs-dropdown-link-hover-bg: var(--surface-2); --bs-dropdown-link-color: var(--text); --bs-dropdown-link-hover-color: var(--text); }
.alert { border-radius: var(--radius); display: flex; gap: 10px; align-items: flex-start; }
.alert .bi { margin-top: 2px; }
.alert-success { background: var(--success-soft); color: var(--text); border-color: color-mix(in srgb, var(--success) 30%, transparent); }
.alert-danger { background: var(--danger-soft); color: var(--text); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.alert-warning { background: var(--warning-soft); color: var(--text); border-color: color-mix(in srgb, var(--warning) 30%, transparent); }
.alert-info { background: var(--info-soft); color: var(--text); border-color: color-mix(in srgb, var(--info) 30%, transparent); }

/* ---------- Layout fixes from visual QA ---------- */
.inbox > * { min-width: 0; }
.inbox .seg { flex-wrap: wrap; overflow: visible; }
.inbox .seg a { flex: 1 0 auto; }
@media (min-width: 1280px) { .side-toggle { display: none !important; } }
@media (max-width: 991.98px) { .sidebar { box-shadow: none; } .sidebar.open { box-shadow: var(--shadow-3); } }
fieldset.card { padding-top: 14px !important; }
fieldset.card > legend { float: left; width: 100%; font-size: .95rem; font-weight: 650; padding: 0; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
fieldset.card > legend .bi { color: var(--text-subtle); }
fieldset.card > legend + * { clear: both; }
