@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ============================================================
   Bondly — design system  (v2 redesign)
   Token NAMES preserved (inline styles in views reference them);
   values refreshed for a modern operations look.
   ============================================================ */
:root {
  /* Accent */
  --brand-600: #4f46e5;
  --brand-700: #4338ca;
  --brand-50:  #eef2ff;
  --brand-100: #e0e7ff;

  /* Ink / neutrals (slightly cool) */
  --ink-950: #14161f;
  --ink-900: #1b1e2b;
  --ink-800: #2a2f3e;
  --ink-600: #545b6e;
  --ink-500: #7a8194;
  --ink-400: #9aa1b3;

  /* Surfaces */
  --canvas: #f4f5fa;
  --surface: #ffffff;
  --surface-soft: #f1f3f9;
  --surface-blue: #f2f4ff;
  --border: #e6e8f0;
  --border-strong: #d3d7e3;

  /* Semantic */
  --success-700: #15803d;  --success-50: #dcfce7;
  --warning-700: #b45309;  --warning-50: #fef3c7;
  --danger-700:  #be123c;  --danger-50:  #ffe4e6;
  --red-800:     #9f1239;

  /* Sidebar (dark) */
  --nav-bg: #12141d;
  --nav-bg-soft: #1a1d29;
  --nav-line: #262a38;
  --nav-text: #c7ccda;
  --nav-text-dim: #838aa0;

  --shadow-sm: 0 1px 2px rgba(20, 22, 31, .05), 0 1px 3px rgba(20, 22, 31, .04);
  --shadow-md: 0 2px 6px rgba(20, 22, 31, .06), 0 8px 24px rgba(20, 22, 31, .07);
  --shadow-lg: 0 12px 40px rgba(20, 22, 31, .14);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  --font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --focus-ring: 0 0 0 3px rgba(79, 70, 229, .28);

  /* Back-compat aliases used in some views */
  --ms-blue: var(--brand-600);
  --ms-blue-dark: var(--brand-700);
  --ms-green: var(--success-700);
  --ms-yellow: #d97706;
  --ms-red: var(--danger-700);
  --surface-white: var(--surface);
  --surface-canvas: var(--canvas);
  --surface-border: var(--border);
  --text-primary: var(--ink-950);
  --text-secondary: var(--ink-600);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); -webkit-text-size-adjust: 100%; }

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(1200px 480px at 88% -8%, rgba(79, 70, 229, .06), transparent 60%),
    var(--canvas);
  color: var(--ink-950);
  font-family: var(--font-family);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { color: var(--ink-950); font-weight: 700; letter-spacing: -0.015em; margin: 0; text-wrap: balance; }
p { margin: 0; }

a { color: var(--brand-600); text-decoration: none; transition: color .18s var(--ease-out); }
a:hover { color: var(--brand-700); }

a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: 6px;
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ============================================================
   App shell + sidebar
   ============================================================ */
.workspace-shell { display: grid; grid-template-columns: 268px 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; align-self: start;
  height: 100vh; display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--nav-bg-soft), var(--nav-bg));
  border-right: 1px solid var(--nav-line);
  padding: 20px 16px; gap: 6px;
}
.sidebar__top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sidebar-brand { display: flex; align-items: center; gap: 12px; }
.sidebar-brand__copy { display: flex; flex-direction: column; line-height: 1.1; }
.brand-mark {
  display: grid; place-items: center; width: 38px; height: 38px; flex: none;
  background: linear-gradient(135deg, var(--brand-600), #7c3aed);
  color: #fff; font-weight: 800; font-size: 18px; border-radius: 11px;
  box-shadow: 0 6px 16px rgba(79, 70, 229, .4);
}
.brand-title { color: #fff; font-weight: 700; font-size: 16px; letter-spacing: -0.02em; }
.brand-subtitle { color: var(--nav-text-dim); font-size: 11.5px; font-weight: 500; }
.sidebar-close { display: none; background: transparent; border: 0; color: var(--nav-text-dim); font-size: 26px; cursor: pointer; line-height: 1; }

.sidebar__label { color: var(--nav-text-dim); font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; padding: 14px 10px 6px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-section { display: flex; flex-direction: column; gap: 2px; }
.sidebar-section + .sidebar-section { margin-top: 14px; }
.sidebar-section__label { margin: 0 0 4px; padding: 0 12px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-400, #94a3b8); }
.sidebar-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px; color: var(--nav-text);
  font-weight: 500; font-size: 14px; transition: background .16s var(--ease-out), color .16s var(--ease-out);
}
.sidebar-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sidebar-link.is-active { background: linear-gradient(135deg, rgba(79, 70, 229, .95), rgba(124, 58, 237, .9)); color: #fff; box-shadow: 0 6px 16px rgba(79, 70, 229, .35); }
.sidebar-link__icon { display: grid; place-items: center; width: 22px; opacity: .82; transition: transform .2s var(--ease-out), opacity .16s; }
.sidebar-link__icon svg { width: 18px; height: 18px; }
.sidebar-link:hover .sidebar-link__icon { opacity: 1; transform: translateY(-1px) scale(1.08); }
.sidebar-link.is-active .sidebar-link__icon { opacity: 1; }
.sidebar-signout__icon { display: inline-grid; place-items: center; }
.sidebar-signout__icon svg { width: 17px; height: 17px; }
lord-icon { display: block; }
.sidebar-link__count { margin-left: auto; background: var(--danger-700); color: #fff; font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; display: grid; place-items: center; }
.sidebar-link.is-active .sidebar-link__count { background: rgba(255, 255, 255, .25); }

.sidebar__bottom { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--nav-line); display: flex; flex-direction: column; gap: 8px; }
.sidebar-account { display: flex; align-items: center; gap: 11px; padding: 8px 6px; }
.sidebar-account__avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, #7c3aed, var(--brand-600)); color: #fff; font-weight: 700; flex: none; }
.sidebar-account__copy { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.sidebar-account__copy strong { color: #fff; font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-account__copy small { color: var(--nav-text-dim); font-size: 11.5px; }
.sidebar-signout { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 9px; color: var(--nav-text-dim); font-weight: 500; }
.sidebar-signout:hover { background: rgba(255, 255, 255, .06); color: #fff; }

.sidebar-scrim { display: none; }

/* Collapse toggle + collapsed rail (desktop only) */
.sidebar-collapse { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--nav-line); background: transparent; color: var(--nav-text-dim); font-size: 15px; line-height: 1; cursor: pointer; transition: background .16s, color .16s; }
.sidebar-collapse:hover { background: rgba(255, 255, 255, .07); color: #fff; }
@media (max-width: 860px) { .sidebar-collapse { display: none; } }
@media (min-width: 861px) {
  body.sidebar-collapsed .workspace-shell { grid-template-columns: 76px 1fr; }
  body.sidebar-collapsed .sidebar { padding: 20px 10px; }
  body.sidebar-collapsed .sidebar__top { 
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 20px;
  }
  body.sidebar-collapsed .sidebar-brand { gap: 0; justify-content: center; }
  body.sidebar-collapsed .sidebar-collapse { margin: 0 auto; }
  body.sidebar-collapsed .sidebar-brand__copy,
  body.sidebar-collapsed .sidebar-link > span:not(.sidebar-link__icon),
  body.sidebar-collapsed .sidebar__label,
  body.sidebar-collapsed .sidebar-section__label,
  body.sidebar-collapsed .sidebar-account__copy,
  body.sidebar-collapsed .sidebar-signout span:last-child { display: none !important; }
  
  body.sidebar-collapsed .sidebar-section {
    position: relative;
    margin-bottom: 6px;
  }
  body.sidebar-collapsed .sidebar-section + .sidebar-section {
    padding-top: 10px;
    margin-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }
  
  body.sidebar-collapsed .sidebar-link { justify-content: center; padding: 11px 0; position: relative; }
  body.sidebar-collapsed .sidebar-link__icon { width: auto; }
  body.sidebar-collapsed .sidebar-link__count { position: absolute; top: 5px; right: 12px; min-width: 8px; width: 8px; height: 8px; padding: 0; font-size: 0; border-radius: 50%; }
  body.sidebar-collapsed .sidebar__bottom { display: flex; flex-direction: column; align-items: center; gap: 8px; }
  body.sidebar-collapsed .sidebar-account, body.sidebar-collapsed .sidebar-signout { justify-content: center; padding: 6px 0; width: 100%; }
}

.workspace-main { display: flex; flex-direction: column; min-width: 0; }
.workspace-topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 14px 30px; background: rgba(255, 255, 255, .82); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.sidebar-open { display: none; background: transparent; border: 1px solid var(--border); border-radius: 9px; width: 40px; height: 40px; font-size: 18px; cursor: pointer; color: var(--ink-600); }
.workspace-breadcrumb { display: flex; align-items: center; gap: 8px; color: var(--ink-500); font-size: 13.5px; flex-wrap: wrap; }
.workspace-breadcrumb strong { color: var(--ink-950); font-weight: 600; }
.workspace-breadcrumb a { color: var(--ink-500); text-decoration: none; }
.workspace-breadcrumb a:hover { color: var(--brand-600); text-decoration: underline; }
.input-affix { display: flex; gap: 6px; align-items: stretch; }
.input-affix .form-control { flex: 1; }
.input-affix .btn { white-space: nowrap; }
.field-hint-ok { color: var(--success-700); font-size: 12px; margin-top: 4px; }
.field-hint-bad { color: var(--danger-700); font-size: 12px; margin-top: 4px; }
.form-control.is-valid { border-color: #86efac; }
.form-control.is-invalid { border-color: #fca5a5; }
.age-pill { display: inline-block; margin-top: 6px; padding: 2px 10px; border-radius: 999px; background: var(--brand-50, #eef2ff); color: var(--brand-700, #3730a3); font-size: 12px; font-weight: 600; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline__item { position: relative; padding: 0 0 16px 22px; }
.timeline__item::before { content: ""; position: absolute; left: 5px; top: 14px; bottom: -2px; width: 2px; background: var(--border); }
.timeline__item:last-child::before { display: none; }
.timeline__dot { position: absolute; left: 0; top: 4px; width: 12px; height: 12px; border-radius: 999px; background: var(--brand-400, #818cf8); box-shadow: 0 0 0 3px var(--brand-50, #eef2ff); }
.timeline__item--enrichment .timeline__dot { background: #f59e0b; box-shadow: 0 0 0 3px #fef3c7; }
.timeline__body { display: flex; flex-direction: column; gap: 2px; }
.timeline__body strong { font-size: 13.5px; color: var(--ink-950); }
.timeline__detail { font-size: 12.5px; color: var(--ink-600); }
.timeline__when { font-size: 11.5px; color: var(--ink-400, #94a3b8); font-family: var(--mono); }
.workspace-topbar__status { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--ink-500); font-size: 12.5px; font-weight: 500; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success-700); box-shadow: 0 0 0 3px var(--success-50); }

.container { width: 100%; max-width: 1160px; margin: 0 auto; padding: 30px; }
.footer { padding: 22px 30px 34px; color: var(--ink-400); font-size: 12.5px; text-align: center; }

/* ============================================================
   Auth screens
   ============================================================ */
.auth-app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.auth-topbar { padding: 22px 30px; }
.brand-lockup { display: inline-flex; align-items: center; gap: 11px; }
.brand-lockup .brand-title { color: var(--ink-950); }
.auth-shell { min-height: 62vh; display: grid; place-items: center; padding: 30px 20px; }
.auth-card { width: 100%; max-width: 428px; }
.auth-card__brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink-500); font-weight: 600; font-size: 13px; margin-bottom: 18px; }
.auth-card__brand .brand-mark { width: 30px; height: 30px; font-size: 15px; border-radius: 9px; }
.auth-footer { text-align: center; color: var(--ink-500); font-size: 13.5px; margin-top: 18px; }

/* ============================================================
   Page header
   ============================================================ */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 24px; flex-wrap: wrap; }
.page-header__copy { max-width: 60ch; }
.page-header h1 { font-size: 28px; margin: 4px 0 6px; }
.page-header p { color: var(--ink-600); }
.page-header__actions { display: flex; gap: 10px; flex-wrap: wrap; }
.eyebrow, .dashboard-eyebrow, .dashboard-card__eyebrow {
  display: inline-block; color: var(--brand-600); font-weight: 700;
  font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase;
}

/* ============================================================
   Cards
   ============================================================ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.card__header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.card__header h2 { font-size: 17px; }
.card__header p { color: var(--ink-500); font-size: 13px; margin-top: 2px; }
.card__body { padding: 22px 24px; }
.card--accent { border-top: 3px solid var(--brand-600); }
.card--review { border-top: 3px solid var(--warning-700); }
.form-card { padding: 8px; }
.form-card .form-section { padding: 18px 20px; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  --btn-bg: var(--surface); --btn-fg: var(--ink-800); --btn-bd: var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 10px; border: 1px solid var(--btn-bd);
  background: var(--btn-bg); color: var(--btn-fg);
  font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: transform .12s var(--ease-out), box-shadow .16s var(--ease-out), background .16s var(--ease-out), border-color .16s;
  white-space: nowrap; text-decoration: none;
}
/* keep the button's own text color on hover — the global a:hover must not win */
.btn:hover, a.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); color: var(--btn-fg); }
.btn:active { transform: translateY(0); }
.btn-primary { --btn-bg: linear-gradient(135deg, var(--brand-600), #6d5cf0); --btn-fg: #fff; --btn-bd: transparent; box-shadow: 0 6px 16px rgba(79, 70, 229, .28); }
.btn-primary:hover { --btn-bg: linear-gradient(135deg, var(--brand-700), var(--brand-600)); box-shadow: 0 10px 24px rgba(79, 70, 229, .34); }
.btn-secondary { --btn-bg: var(--surface); --btn-fg: var(--ink-800); }
.btn-secondary:hover { --btn-bg: var(--surface-soft); }
.btn-success { --btn-bg: var(--success-700); --btn-fg: #fff; --btn-bd: transparent; }
.btn-danger { --btn-bg: #fff; --btn-fg: var(--danger-700); --btn-bd: var(--danger-50); }
.btn-danger:hover { --btn-bg: var(--danger-50); }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-loading { opacity: .65; cursor: not-allowed; transform: none; }
.btn.is-loading { position: relative; color: transparent !important; }
.btn.is-loading::after { content: ""; position: absolute; width: 16px; height: 16px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: bondly-spin .6s linear infinite; color: #fff; }
.btn-secondary.is-loading::after, .btn-danger.is-loading::after { color: var(--ink-600); }
@keyframes bondly-spin { to { transform: rotate(360deg); } }

/* ============================================================
   Forms
   ============================================================ */
.form-section { padding: 6px 0 18px; border-bottom: 1px solid var(--border); }
.form-section:last-of-type { border-bottom: 0; }
.form-section__heading { font-size: 15px; font-weight: 700; margin-bottom: 16px; display: flex; flex-direction: column; gap: 3px; }
.form-section__heading span { font-size: 12.5px; font-weight: 500; color: var(--ink-500); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.form-grid--three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-group { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.form-group--full { grid-column: 1 / -1; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--ink-800); }
.optional { color: var(--ink-400); font-weight: 500; font-size: .92em; }
.form-control {
  width: 100%; padding: 10px 13px; font-family: inherit; font-size: 14px; color: var(--ink-950);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px;
  transition: border-color .16s var(--ease-out), box-shadow .16s var(--ease-out);
}
.form-control::placeholder { color: var(--ink-400); }
.form-control:hover { border-color: var(--ink-400); }
.form-control:focus { outline: none; border-color: var(--brand-600); box-shadow: var(--focus-ring); }
textarea.form-control { resize: vertical; min-height: 92px; line-height: 1.6; }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%237a8194' d='M6 8.5 1.5 4h9z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 13px center; padding-right: 34px; }
.form-control.is-invalid { border-color: var(--danger-700); box-shadow: 0 0 0 3px var(--danger-50); }
.field-error { color: var(--danger-700); font-size: 12px; font-weight: 500; }
.form-hint { color: var(--ink-500); font-size: 12px; }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding: 18px 20px 10px; }
.form-actions--split { justify-content: space-between; }
.form-actions__group { display: flex; gap: 10px; }
.review-message { font-family: var(--mono); font-size: 13px; line-height: 1.6; }

/* Autocomplete suggestion popovers (company / location) */
.location-picker, .company-picker { position: relative; }
.location-suggestions, .company-suggestions {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 40;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-lg); padding: 6px; max-height: 280px; overflow-y: auto;
}
.location-suggestion, .company-suggestion {
  display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left;
  padding: 9px 11px; border: 0; background: transparent; border-radius: 8px; cursor: pointer;
}
.location-suggestion:hover, .company-suggestion:hover { background: var(--brand-50); }
.location-suggestion strong, .company-suggestion strong { font-size: 13.5px; color: var(--ink-950); }
.location-suggestion small, .company-suggestion small { font-size: 11.5px; color: var(--ink-500); }
.location-suggestion-empty, .company-suggestion-empty { padding: 11px; font-size: 12.5px; color: var(--ink-500); }
.company-suggestion--add { color: var(--brand-600); font-weight: 600; font-size: 13px; border-top: 1px dashed var(--border); }
.company-suggestion--add:hover { background: var(--brand-50); }

/* ============================================================
   Tables
   ============================================================ */
.table-wrap, .dashboard-table-wrap { overflow-x: auto; border-radius: var(--radius-md); border: 1px solid var(--border); }
.table, .dashboard-table { width: 100%; border-collapse: collapse; font-size: 13.5px; background: var(--surface); }
.table thead th, .dashboard-table thead th {
  text-align: left; padding: 12px 16px; background: var(--surface-soft);
  color: var(--ink-500); font-weight: 600; font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table tbody td, .dashboard-table tbody td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td, .dashboard-table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr, .dashboard-table tbody tr { transition: background .12s var(--ease-out); }
.table tbody tr:hover, .dashboard-table tbody tr:hover { background: var(--surface-blue); }
.table-subtext { color: var(--ink-500); font-size: 12px; }
.table-actions { display: flex; gap: 8px; justify-content: flex-end; }
th.is-sortable { cursor: pointer; user-select: none; }
th.is-sortable::after { content: " ⇅"; color: var(--ink-400); font-size: 10px; }
th.sort-asc::after { content: " ↑"; color: var(--brand-600); }
th.sort-desc::after { content: " ↓"; color: var(--brand-600); }

/* Injected table toolbar (search) */
.table-toolbar { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; padding: 14px 24px 0; }
.card__header--search { flex-wrap: wrap; }
/* Labelled, compact search — label on top, box, live count under it */
.table-tools { display: flex; flex-direction: column; gap: 4px; margin-left: auto; }
.table-tools__label { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-500); }
.table-search { width: 250px; max-width: 62vw; padding-left: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='%237a8194' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3-3'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: 11px center; transition: box-shadow .15s ease, border-color .15s ease; }
.table-search:focus { box-shadow: 0 0 0 3px var(--brand-100, #c7d2fe); }
.table-count { color: var(--ink-500); font-size: 12px; white-space: nowrap; }
@media (max-width: 640px) { .table-tools { width: 100%; margin-left: 0; } .table-search { width: 100%; max-width: none; } }

/* Clickable table rows (open the record) */
.table tbody tr.is-clickable { cursor: pointer; }
@media (prefers-reduced-motion: no-preference) { .table tbody tr.is-clickable { transition: background .12s ease; } }
.table tbody tr.is-clickable:hover { background: var(--brand-50, #eef2ff); }

/* Icon action buttons (tooltip on hover, label for screen readers) */
.btn-icon { width: 34px; height: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 9px; }
.btn-icon svg { display: block; }
.btn-icon--danger { color: var(--danger-600, #dc2626); border-color: #fecaca; background: #fff; }
.btn-icon--danger:hover { background: var(--danger-50, #fef2f2); border-color: #fca5a5; color: var(--danger-700, #b91c1c); }
.btn-icon--ok { color: var(--success-700, #15803d); border-color: #bbf7d0; background: #fff; }
.btn-icon--ok:hover { background: var(--success-50, #f0fdf4); }
.table-actions { display: flex; gap: 6px; align-items: center; }

/* Organisation cards: clickable to open manage panel */
.org-card.is-clickable-card { cursor: pointer; }
.org-card.is-clickable-card :where(a, button, input, select, textarea, summary, .org-card__manage) { cursor: auto; }
@media (prefers-reduced-motion: no-preference) { .org-card { transition: box-shadow .2s ease, transform .2s ease; } }
.org-card.is-clickable-card:hover { box-shadow: var(--shadow-md); }

/* ============================================================
   Badges / pills / alerts / empty states
   ============================================================ */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; letter-spacing: .01em; }
.badge-secondary { background: var(--surface-soft); color: var(--ink-600); }
.badge-warning { background: var(--warning-50); color: var(--warning-700); }
.badge-danger { background: var(--danger-50); color: var(--danger-700); }
.badge-success { background: var(--success-50); color: var(--success-700); }

.alert { display: flex; gap: 12px; align-items: flex-start; padding: 13px 16px; border-radius: 12px; margin-bottom: 18px; font-size: 13.5px; border: 1px solid transparent; }
.alert strong { font-weight: 700; }
.alert span { color: inherit; }
.alert--success { background: var(--success-50); border-color: #bbf7d0; color: #14532d; }
.alert--error { background: var(--danger-50); border-color: #fecdd3; color: #9f1239; }
.alert--info { background: var(--brand-50, #eef2ff); border-color: var(--brand-100, #c7d2fe); color: var(--brand-700, #3730a3); }

.empty-state { text-align: center; padding: 46px 24px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty-state__icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 16px; background: var(--brand-50); color: var(--brand-600); font-size: 24px; margin-bottom: 6px; }
.empty-state h3 { font-size: 17px; }
.empty-state p { color: var(--ink-500); max-width: 42ch; }
.empty-state__action { margin-top: 10px; }

/* ============================================================
   Review meta + approval editor
   ============================================================ */
.review-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.review-meta > div { background: var(--surface-soft); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 3px; }
.review-meta__label { color: var(--ink-500); font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; }
.review-meta__value { font-weight: 600; font-size: 14px; }
.approval-email-editor, #plainMessageEditor { display: flex; flex-direction: column; gap: 10px; }
.approval-visual-editor-shell { border: 1px solid var(--border-strong); border-radius: 12px; overflow: hidden; }
.approval-visual-editor-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 13px; background: var(--surface-soft); border-bottom: 1px solid var(--border); font-size: 12.5px; color: var(--ink-600); }
.approval-visual-editor { min-height: 220px; padding: 18px; background: #fff; line-height: 1.6; outline: none; }
.template-preview { width: 100%; min-height: 320px; border: 1px solid var(--border); border-radius: 12px; background: #fff; }

/* ============================================================
   Dashboard
   ============================================================ */
.dashboard-page { display: flex; flex-direction: column; gap: 24px; }
.dashboard-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.dashboard-title { font-size: 30px; margin: 6px 0 8px; max-width: 20ch; }
.dashboard-subtitle { color: var(--ink-600); max-width: 60ch; }
.dashboard-head__actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.dashboard-date { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; font-size: 12.5px; font-weight: 500; color: var(--ink-600); box-shadow: var(--shadow-sm); }
.dashboard-date__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand-600); }

.dashboard-metrics { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; }
.dashboard-metric { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 8px; position: relative; overflow: hidden; transition: transform .14s var(--ease-out), box-shadow .16s; }
.dashboard-metric:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.dashboard-metric__top { display: flex; align-items: center; gap: 8px; }
.dashboard-metric__index { font-family: var(--mono); font-size: 11px; color: var(--ink-400); }
.dashboard-metric__label { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-500); }
.dashboard-metric__number { font-size: 32px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.dashboard-metric__meta { font-size: 12px; color: var(--ink-500); }
.dashboard-metric--primary { background: linear-gradient(150deg, #ffffff, var(--brand-50)); border-color: var(--brand-100); }
.dashboard-metric--primary .dashboard-metric__number { color: var(--brand-700); }
.dashboard-metric--attention::before, .dashboard-metric--scheduled::before { content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 3px; }
.dashboard-metric--attention::before { background: var(--warning-700); }
.dashboard-metric--scheduled::before { background: var(--brand-600); }

.dashboard-focus { display: grid; grid-template-columns: 1fr 1.15fr; gap: 24px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); padding: 26px; box-shadow: var(--shadow-sm); }
.dashboard-focus__copy h2 { font-size: 21px; margin: 8px 0 8px; }
.dashboard-focus__copy p { color: var(--ink-600); max-width: 44ch; }
.dashboard-focus__actions { display: flex; flex-direction: column; gap: 10px; }
.dashboard-focus-action { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface-soft); transition: transform .14s var(--ease-out), box-shadow .16s; }
.dashboard-focus-action:hover { transform: translateX(3px); box-shadow: var(--shadow-sm); }
.dashboard-focus-action__count { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 11px; font-weight: 800; font-size: 16px; flex: none; color: #fff; }
.dashboard-focus-action span:nth-child(2) { display: flex; flex-direction: column; margin-right: auto; }
.dashboard-focus-action strong { font-size: 14px; color: var(--ink-950); }
.dashboard-focus-action small { font-size: 12px; color: var(--ink-500); }
.dashboard-focus-action--blue .dashboard-focus-action__count { background: var(--brand-600); }
.dashboard-focus-action--amber .dashboard-focus-action__count { background: var(--warning-700); }
.dashboard-focus-action--violet .dashboard-focus-action__count { background: #7c3aed; }
.dashboard-focus-clear { display: flex; align-items: center; gap: 13px; padding: 16px; border-radius: 14px; background: var(--success-50); }
.dashboard-focus-clear__mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--success-700); color: #fff; font-weight: 700; }
.dashboard-focus-clear strong { display: block; font-size: 14px; }
.dashboard-focus-clear small { color: var(--ink-600); font-size: 12px; }

.dashboard-empty { display: grid; grid-template-columns: 1.1fr 1fr; gap: 26px; align-items: center; background: linear-gradient(140deg, var(--surface), var(--surface-blue)); border: 1px solid var(--border); border-radius: var(--radius-xl); padding: 30px; }
.dashboard-empty__kicker { color: var(--brand-600); font-weight: 700; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; }
.dashboard-empty h2 { font-size: 22px; margin: 10px 0; }
.dashboard-empty p { color: var(--ink-600); margin-bottom: 16px; }
.dashboard-flow { display: flex; align-items: center; gap: 8px; }
.dashboard-flow__item { flex: 1; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px; text-align: center; display: flex; flex-direction: column; gap: 4px; }
.dashboard-flow__item span { font-family: var(--mono); color: var(--brand-600); font-size: 12px; }
.dashboard-flow__item strong { font-size: 13.5px; }
.dashboard-flow__item small { color: var(--ink-500); font-size: 11.5px; }
.dashboard-flow__line { width: 22px; height: 2px; background: var(--border-strong); flex: none; }

.dashboard-grid { display: grid; gap: 20px; }
.dashboard-grid--main { grid-template-columns: 1.3fr 1fr; }
.dashboard-grid--secondary { grid-template-columns: 1fr 1fr; }
.dashboard-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 22px; display: flex; flex-direction: column; gap: 16px; }
.dashboard-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.dashboard-card__head h2 { font-size: 17px; margin: 4px 0 3px; }
.dashboard-card__head p { color: var(--ink-500); font-size: 12.5px; }
.dashboard-card__stat { color: var(--ink-500); font-size: 12.5px; font-weight: 600; }
.dashboard-text-link { font-size: 13px; font-weight: 600; white-space: nowrap; }
.dashboard-card__empty { text-align: center; padding: 28px 16px; color: var(--ink-500); display: flex; flex-direction: column; gap: 6px; align-items: center; }
.dashboard-card__empty strong { color: var(--ink-800); }
.dashboard-card__empty-icon { font-size: 24px; color: var(--ink-400); }

.dashboard-birthday-list { display: flex; flex-direction: column; }
.dashboard-birthday-row { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 14px; padding: 13px 8px; border-bottom: 1px solid var(--border); transition: background .12s; }
.dashboard-birthday-row:last-child { border-bottom: 0; }
.dashboard-birthday-row:hover { background: var(--surface-blue); border-radius: 10px; }
.dashboard-birthday-date { text-align: center; min-width: 54px; }
.dashboard-birthday-date strong { display: block; font-size: 14px; }
.dashboard-birthday-date small { color: var(--brand-600); font-size: 11px; font-weight: 600; }
.dashboard-birthday-person { display: flex; flex-direction: column; min-width: 0; }
.dashboard-birthday-person strong { font-size: 14px; color: var(--ink-950); }
.dashboard-birthday-person small { color: var(--ink-500); font-size: 12px; }
.dashboard-birthday-location { color: var(--ink-500); font-size: 12px; }
.dashboard-birthday-arrow { color: var(--ink-400); }

.dashboard-delivery-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.dashboard-delivery-summary > div { background: var(--surface-soft); border-radius: 12px; padding: 14px; text-align: center; }
.dashboard-delivery-summary strong { display: block; font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.dashboard-delivery-summary span { color: var(--ink-500); font-size: 12px; }

.dashboard-status { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--surface-soft); color: var(--ink-600); }
.dashboard-status span { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.dashboard-status--sent, .dashboard-status--delivered, .dashboard-status--demorecorded, .dashboard-status--manualsent { background: var(--success-50); color: var(--success-700); }
.dashboard-status--manualpending, .dashboard-status--pending { background: var(--warning-50); color: var(--warning-700); }
.dashboard-status--deliveryfailed, .dashboard-status--failed { background: var(--danger-50); color: var(--danger-700); }

.dashboard-category-list { display: flex; flex-direction: column; gap: 12px; }
.dashboard-category-row__label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.dashboard-category-row__label span { color: var(--ink-500); font-variant-numeric: tabular-nums; }
.dashboard-category-bar { height: 8px; background: var(--surface-soft); border-radius: 999px; overflow: hidden; }
.dashboard-category-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand-600), #7c3aed); border-radius: 999px; }

.dashboard-pipeline { display: flex; flex-direction: column; gap: 14px; }
.dashboard-pipeline__item { display: flex; align-items: flex-start; gap: 12px; }
.dashboard-pipeline__marker { width: 11px; height: 11px; border-radius: 50%; margin-top: 4px; flex: none; }
.dashboard-pipeline__marker--blue { background: var(--brand-600); }
.dashboard-pipeline__marker--violet { background: #7c3aed; }
.dashboard-pipeline__marker--green { background: var(--success-700); }
.dashboard-pipeline__item strong { display: block; font-size: 14px; }
.dashboard-pipeline__item small { color: var(--ink-500); font-size: 12px; }

/* ============================================================
   User management
   ============================================================ */
.user-management-page { display: flex; flex-direction: column; gap: 22px; }
.user-management-header, .user-management-list__head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.user-management-summary { display: flex; align-items: center; gap: 30px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px 20px; box-shadow: var(--shadow-sm); }
.user-management-summary > div:not(.user-management-summary__note) { display: flex; flex-direction: column; }
.user-management-summary > div:not(.user-management-summary__note) strong { font-size: 22px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.user-management-summary > div:not(.user-management-summary__note) span { color: var(--ink-500); font-size: 12.5px; margin-top: 4px; }
.user-management-summary__note { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.user-management-summary__note > span:last-child { display: flex; flex-direction: column; }
.user-management-summary__note strong { color: var(--ink-950); font-size: 13px; }
.user-management-summary__note small { color: var(--ink-500); font-size: 11.5px; }
.user-management-summary__lock { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: var(--brand-50); color: var(--brand-600); font-size: 18px; flex: none; }
.user-management-count { color: var(--ink-500); font-size: 13px; font-weight: 600; }
.user-management-list__hint { color: var(--ink-500); font-size: 13px; }
.user-management-empty { text-align: center; padding: 40px; color: var(--ink-500); }
.user-management-empty__icon { font-size: 28px; color: var(--ink-400); }

.user-card-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.user-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.user-card__identity { display: flex; align-items: center; gap: 12px; }
.user-card__avatar { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: linear-gradient(135deg, var(--brand-600), #7c3aed); color: #fff; font-weight: 700; font-size: 17px; flex: none; }
.user-card__details { display: flex; flex-direction: column; gap: 7px; min-width: 0; padding: 12px 0 2px; border-top: 1px solid var(--border); }
.user-card__details > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.user-card__details span { color: var(--ink-500); font-size: 12.5px; }
.user-card__details strong { font-size: 13.5px; font-weight: 600; text-align: right; }
.user-card__permissions { display: flex; flex-wrap: wrap; gap: 6px; }
/* Card footer: full-width primary action, then Edit + Deactivate split evenly,
   so all three read as one deliberate button group. */
.user-card__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); }
.user-card__permissions { flex: 1 1 100%; justify-content: center; }
.user-card__edit { flex: 1 1 auto; display: inline-flex; align-items: center; justify-content: center; padding: 9px 12px; border-radius: 9px; background: var(--surface-soft); color: var(--ink-800); font-size: 13px; font-weight: 600; }
.user-card__edit:hover { background: var(--brand-50); color: var(--brand-700); }
.user-card__inline-form { flex: 1 1 auto; display: flex; }
.user-card__inline-form > .btn { width: 100%; }
.user-card__danger { width: 100%; background: var(--danger-50); color: var(--danger-700); border: 0; padding: 9px 12px; border-radius: 9px; font-weight: 600; font-size: 13px; cursor: pointer; }
.user-card__danger:hover { background: #ffd0d6; }
.user-card__promote-form { flex: 1 1 100%; margin-top: 2px; }
.user-card__promote { width: 100%; background: transparent; border: 1px dashed var(--border-strong); color: var(--ink-600); padding: 8px 12px; border-radius: 9px; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.user-card__promote:hover { border-color: var(--brand-600); color: var(--brand-700); background: var(--brand-50); }
.user-status { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.user-status--approved { background: var(--success-50); color: var(--success-700); }
.user-status--pending { background: var(--warning-50); color: var(--warning-700); }
.user-status--deactivated { background: var(--danger-50); color: var(--danger-700); }

.user-permission-options, .user-form-permissions { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.user-permission-option { display: flex; align-items: flex-start; gap: 10px; padding: 11px 13px; border: 1px solid var(--border); border-radius: 11px; cursor: pointer; transition: border-color .14s, background .14s; }
.user-permission-option:hover { border-color: var(--brand-600); background: var(--brand-50); }
.user-permission-option input { margin-top: 3px; }
.user-form-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 22px; }

/* Modal */
/* Native <dialog>: let the browser show/hide it. Never force `display` on the
   dialog itself or it gets stuck permanently open. Style the ::backdrop instead. */
.user-permissions-modal { padding: 0; border: 0; background: transparent; width: 92vw; max-width: 560px; max-height: 88vh; overflow: visible; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.user-permissions-modal::backdrop { background: rgba(20, 22, 31, .5); backdrop-filter: blur(3px); }
.user-permissions-modal__panel { width: 100%; max-height: 88vh; overflow-y: auto; background: var(--surface); border-radius: var(--radius-lg); }
.user-permissions-modal__head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.user-permissions-modal__close { background: none; border: 0; font-size: 24px; line-height: 1; color: var(--ink-500); cursor: pointer; }
.user-permissions-modal__intro { padding: 16px 22px 0; color: var(--ink-500); font-size: 13px; }
.user-permissions-modal__body { padding: 16px 22px; }
.user-permissions-modal__footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--surface); }

/* ============================================================
   Templates
   ============================================================ */
.template-form { display: flex; flex-direction: column; gap: 18px; }
.template-editor-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.template-code-editor { font-family: var(--mono); font-size: 13px; line-height: 1.6; min-height: 280px; }
.template-preview-card { border: 1px solid var(--border); border-radius: 14px; overflow: hidden; background: var(--surface); }
.template-preview-card__header { padding: 11px 15px; background: var(--surface-soft); border-bottom: 1px solid var(--border); font-size: 12.5px; font-weight: 600; color: var(--ink-600); }
.tabs { display: inline-flex; gap: 4px; padding: 4px; background: var(--surface-soft); border-radius: 11px; }
.tabs button, .tabs a { padding: 7px 14px; border-radius: 8px; border: 0; background: transparent; font-weight: 600; font-size: 13px; color: var(--ink-600); cursor: pointer; }
.tabs .is-active { background: var(--surface); color: var(--brand-600); box-shadow: var(--shadow-sm); }

/* ============================================================
   Utilities + toast
   ============================================================ */
.text-center { text-align: center; }
.wrap { max-width: 1160px; margin: 0 auto; }

/* Paste-to-fill on the contact form */
.paste-fill { margin: 0 0 20px; }
.paste-fill__toggle { display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border: 1px dashed var(--border-strong); border-radius: 10px; background: var(--surface-soft); color: var(--ink-800); font-weight: 600; font-size: 13px; cursor: pointer; }
.paste-fill__toggle:hover { border-color: var(--brand-600); color: var(--brand-700); background: var(--brand-50); }
.paste-fill__body { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-soft); }
.paste-fill__actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.paste-fill__result { font-size: 12.5px; font-weight: 600; }

/* Settings */
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.settings-grid .card--wide { grid-column: 1 / -1; }
@media (max-width: 900px) { .settings-grid { grid-template-columns: 1fr; } .settings-grid .card--wide { grid-column: auto; } }

/* ---- Settings sub-pages ---- */
.settings-shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); gap: 26px; align-items: start; }
.settings-nav { position: sticky; top: 18px; display: flex; flex-direction: column; gap: 2px; padding: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-sm); }
.settings-nav__group { margin: 12px 0 2px; padding: 0 10px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-400, #94a3b8); }
.settings-nav__group:first-child { margin-top: 2px; }
.settings-nav__link { position: relative; display: flex; align-items: center; padding: 9px 12px; border-radius: 10px; color: var(--ink-600); text-decoration: none; font-size: 13.5px; font-weight: 500; transition: background .15s ease, color .15s ease, transform .15s ease; }
.settings-nav__link:hover { background: var(--surface-soft, #f1f5f9); color: var(--ink-950); }
.settings-nav__link.is-active { background: var(--brand-50, #eef2ff); color: var(--brand-700, #3730a3); font-weight: 600; }
.settings-nav__link.is-active::before { content: ""; position: absolute; left: -8px; top: 50%; transform: translateY(-50%); width: 3px; height: 18px; border-radius: 3px; background: var(--brand-500, #6366f1); }
.settings-content { min-width: 0; }
@media (max-width: 860px) {
  .settings-shell { grid-template-columns: 1fr; }
  .settings-nav { position: static; flex-direction: row; flex-wrap: nowrap; overflow-x: auto; gap: 4px; }
  .settings-nav__group { display: none; }
  .settings-nav__link { white-space: nowrap; }
  .settings-nav__link.is-active::before { display: none; }
}

/* Modern toggle switch */
.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13.5px; color: var(--ink-700, #334155); user-select: none; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle__track { position: relative; flex: none; width: 40px; height: 22px; border-radius: 999px; background: var(--ink-200, #e2e8f0); transition: background .2s ease; }
.toggle__track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 999px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s cubic-bezier(.34,1.56,.64,1); }
.toggle input:checked + .toggle__track { background: var(--brand-500, #6366f1); }
.toggle input:checked + .toggle__track::after { transform: translateX(18px); }
.toggle input:focus-visible + .toggle__track { outline: 2px solid var(--brand-400, #818cf8); outline-offset: 2px; }

/* ---- Micro-interactions (respect reduced motion) ---- */
@media (prefers-reduced-motion: no-preference) {
  .settings-content > .card, .settings-content > section.card { animation: cardIn .32s ease both; }
  .settings-content > .card:nth-child(2) { animation-delay: .05s; }
  .card { transition: box-shadow .2s ease, transform .2s ease, border-color .2s ease; }
  .settings-content .card:hover { box-shadow: var(--shadow-md); }
  .option-row { transition: border-color .18s ease, box-shadow .18s ease, background .18s ease; }
  .option-row__body { animation: rowOpen .24s ease both; }
  .btn { transition: transform .12s ease, box-shadow .18s ease, background .15s ease, color .15s ease, border-color .15s ease; }
  .btn-primary:hover, .btn-success:hover { transform: translateY(-1px); }
  .btn:active { transform: translateY(0); }
  .settings-nav__link:active { transform: scale(.98); }
}
@keyframes cardIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes rowOpen { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.option-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.option-chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px; background: var(--surface-soft); border: 1px solid var(--border); border-radius: 999px; }
.option-chip__label { display: flex; flex-direction: column; line-height: 1.1; }
.option-chip__label strong { font-size: 13px; }
.option-chip__label small { font-family: var(--mono); font-size: 10.5px; color: var(--ink-500); }
.option-chip form { display: flex; }
.option-chip__remove { width: 22px; height: 22px; border-radius: 50%; border: 0; background: transparent; color: var(--ink-500); font-size: 16px; line-height: 1; cursor: pointer; }
.option-chip__remove:hover { background: var(--danger-50); color: var(--danger-700); }

/* Isolation check list */
.check-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.check-list__item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px; }
.check-list__mark { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; font-weight: 700; flex: none; }
.check-list__mark.is-pass { background: var(--success-50); color: var(--success-700); }
.check-list__mark.is-fail { background: var(--danger-50); color: var(--danger-700); }
.check-list__verdict { margin-left: auto; font-family: var(--mono); font-size: 12px; font-weight: 600; }
.check-list__verdict.is-pass { color: var(--success-700); }
.check-list__verdict.is-fail { color: var(--danger-700); }

/* Org console (multi-tenant) */
.org-banner { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding: 11px 16px; margin-bottom: 18px; border-radius: 12px; background: var(--warning-50); border: 1px solid #f5d98a; color: #7a4d00; font-size: 13.5px; }
.org-new { position: relative; }
.org-new > summary { list-style: none; } .org-new > summary::-webkit-details-marker { display: none; }
.org-new__form { position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; width: 320px; display: flex; flex-direction: column; gap: 12px; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); }
.org-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.org-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.org-card.is-suspended { opacity: .72; }
.org-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.org-card__head h2 { font-size: 17px; display: flex; align-items: center; gap: 8px; }
.org-plan-badge { flex: none; display: inline-flex; flex-direction: column; align-items: flex-end; text-align: right; padding: 6px 12px; border-radius: 12px; background: var(--brand-50, #eef2ff); border: 1px solid var(--brand-100, #c7d2fe); }
.org-plan-badge strong { font-size: 13px; color: var(--brand-700, #3730a3); line-height: 1.1; }
.org-plan-badge small { font-size: 11px; color: var(--brand-600, #4f46e5); font-variant-numeric: tabular-nums; }
.org-plan-badge--none { background: var(--surface-soft, #f1f5f9); border-color: var(--border); }
.org-plan-badge--none strong { color: var(--ink-600); } .org-plan-badge--none small { color: var(--ink-400); }
.org-manage__group { padding: 14px 0; border-top: 1px dashed var(--border); }
.org-manage__group:first-child { border-top: 0; padding-top: 4px; }
.org-manage__title { margin: 0 0 10px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-400, #94a3b8); }
.org-manage__row { margin-bottom: 12px; }
.org-card__meta { color: var(--ink-500); font-size: 12.5px; margin-top: 4px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.org-card__meta .mono { font-family: var(--mono); }
.org-card__stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 12px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.org-card__stats > div { text-align: center; }
.org-card__stats strong { display: block; font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
.org-card__stats span { font-size: 11px; color: var(--ink-500); }
.org-card__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.org-card__actions form { display: inline; }
.org-card__manage > summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--brand-600); list-style: none; }
.org-card__manage > summary::-webkit-details-marker { display: none; }
.org-card__manage > summary::before { content: "⚙ "; }
.org-card__manage-body { margin-top: 12px; display: flex; flex-direction: column; gap: 12px; }
.org-card__rule { border: 0; border-top: 1px dashed var(--border); margin: 4px 0; }

/* Editable option rows (tones / categories) */
.option-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.option-row { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); overflow: hidden; }
.option-row[open] { border-color: var(--brand-100); box-shadow: var(--shadow-sm); }
.option-row__summary { display: flex; align-items: center; gap: 10px; padding: 11px 14px; cursor: pointer; list-style: none; }
.option-row__summary::-webkit-details-marker { display: none; }
.option-row__name { display: flex; align-items: baseline; gap: 8px; }
.option-row__name small { font-family: var(--mono); font-size: 11px; color: var(--ink-500); }
.option-row__flag { margin-left: auto; font-size: 11px; color: var(--brand-600); font-weight: 600; }
.option-row__edit { margin-left: auto; font-size: 12px; font-weight: 600; color: var(--brand-600); border: 1px solid var(--brand-100); background: var(--brand-50); padding: 4px 10px; border-radius: 999px; }
.option-row__flag + .option-row__edit { margin-left: 8px; }
.option-row:hover .option-row__edit { background: var(--brand-100); }
.option-row[open] .option-row__edit { background: var(--brand-600); color: #fff; border-color: var(--brand-600); }
.option-row[open] .option-row__edit::after { content: " ▾"; }

/* AI models & pricing reference */
.ai-reference { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
.ai-reference > summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--brand-600); list-style: none; }
.ai-reference > summary::-webkit-details-marker { display: none; }
.ai-reference > summary::before { content: "▸ "; }
.ai-reference[open] > summary::before { content: "▾ "; }
.ai-reference__body { margin-top: 14px; display: flex; flex-direction: column; gap: 16px; }
.ai-reference__head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; font-size: 13.5px; }
.ai-reference__head a { font-size: 12.5px; }
.ai-reference .table td, .ai-reference .table th { padding: 8px 12px; font-variant-numeric: tabular-nums; }
.option-row__body { padding: 4px 14px 14px; border-top: 1px solid var(--border); }
.option-add { margin-top: 4px; }
.option-add > summary { display: inline-flex; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--brand-600); padding: 6px 0; list-style: none; }
.option-add > summary::-webkit-details-marker { display: none; }
.option-add > summary::before { content: "+ "; }
.checkbox-inline { display: inline-flex; align-items: center; gap: 8px; font-weight: 500 !important; }

/* API token reveal */
.token-reveal { margin-bottom: 18px; }
.token-reveal__value { display: block; margin: 8px 0; padding: 12px 14px; background: var(--ink-950); color: #7ee0a8; border-radius: 10px; font-family: var(--mono); font-size: 13px; word-break: break-all; user-select: all; }

.bondly-toasts { position: fixed; top: 18px; right: 18px; z-index: 90; display: flex; flex-direction: column; gap: 10px; }
.bondly-toast { display: flex; align-items: flex-start; gap: 10px; min-width: 260px; max-width: 380px; padding: 13px 15px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); font-size: 13.5px; animation: bondly-toast-in .3s var(--ease-out); }
.bondly-toast--success { border-left: 4px solid var(--success-700); }
.bondly-toast--error { border-left: 4px solid var(--danger-700); }
@keyframes bondly-toast-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1080px) {
  .dashboard-metrics { grid-template-columns: repeat(3, 1fr); }
  .dashboard-grid--main, .dashboard-grid--secondary, .dashboard-focus, .dashboard-empty { grid-template-columns: 1fr; }
  .template-editor-layout { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .workspace-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0; width: 280px; z-index: 70;
    transform: translateX(-100%); transition: transform .25s var(--ease-out);
  }
  body.sidebar-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  body.sidebar-open .sidebar-scrim { display: block; position: fixed; inset: 0; z-index: 60; background: rgba(20, 22, 31, .45); }
  .sidebar-close, .sidebar-open { display: grid; place-items: center; }
  .container { padding: 20px 16px; }
  .workspace-topbar { padding: 12px 16px; }
}
@media (max-width: 640px) {
  .dashboard-metrics { grid-template-columns: repeat(2, 1fr); }
  .form-grid, .form-grid--three { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .form-actions, .form-actions--split { flex-direction: column-reverse; align-items: stretch; }
  .form-actions .btn, .form-actions__group { width: 100%; }
  .form-actions__group { flex-direction: column-reverse; }
  .dashboard-birthday-row { grid-template-columns: auto 1fr; }
  .dashboard-birthday-location, .dashboard-birthday-arrow { display: none; }
}

/* Enrichment: collapsible assign panel */
.assign-panel > summary { list-style: none; cursor: pointer; }
.assign-panel > summary::-webkit-details-marker { display: none; }
.assign-panel > summary::after { content: "▸"; margin-left: auto; color: var(--text-muted); transition: transform .15s ease; }
.assign-panel[open] > summary::after { transform: rotate(90deg); }

/* ============ Page transitions, progress bar & skeletons ============ */
/* Cross-document view transitions (Chromium); degrades to a normal load. */
@view-transition { navigation: auto; }
@media (prefers-reduced-motion: no-preference) {
  ::view-transition-old(root) { animation: vtOut .18s ease both; }
  ::view-transition-new(root) { animation: vtIn .26s cubic-bezier(.2,.7,.2,1) both; }
}
@keyframes vtOut { to { opacity: 0; transform: translateY(-4px); } }
@keyframes vtIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Top navigation progress bar */
#nav-progress { position: fixed; top: 0; left: 0; height: 3px; width: 0; opacity: 0; z-index: 3000;
  background: linear-gradient(90deg, var(--brand-500, #6366f1), var(--brand-400, #818cf8));
  box-shadow: 0 0 8px var(--brand-400, #818cf8); border-radius: 0 3px 3px 0; }

/* Shimmer skeletons */
@keyframes shimmer { 0% { background-position: -420px 0; } 100% { background-position: 420px 0; } }
.skeleton { display: inline-block; border-radius: 6px; background: var(--ink-100, #eef1f5);
  background-image: linear-gradient(90deg, rgba(0,0,0,0) 0, rgba(0,0,0,.045) 40%, rgba(0,0,0,0) 80%);
  background-size: 420px 100%; background-repeat: no-repeat; animation: shimmer 1.3s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* Route skeleton overlay (covers the content region during navigation) */
#route-skeleton { position: absolute; inset: 0; padding: 26px 28px; background: var(--bg, #f4f6fb);
  opacity: 0; visibility: hidden; transition: opacity .18s ease; z-index: 40; pointer-events: none; }
#route-skeleton.is-visible { opacity: 1; visibility: visible; }
#route-skeleton .rs-head { display: flex; flex-direction: column; gap: 12px; margin: 8px 0 26px; }
#route-skeleton .rs-eyebrow { width: 110px; height: 10px; }
#route-skeleton .rs-title { width: 260px; height: 26px; }
#route-skeleton .rs-sub { width: 440px; max-width: 70%; height: 12px; }
#route-skeleton .rs-card { background: var(--surface, #fff); border: 1px solid var(--border); border-radius: 16px; padding: 18px 22px; box-shadow: var(--shadow-sm); }
#route-skeleton .rs-row { display: grid; grid-template-columns: 2.2fr 1fr 1fr 1fr; gap: 18px; align-items: center; padding: 15px 0; border-bottom: 1px solid var(--border); }
#route-skeleton .rs-row:last-child { border-bottom: 0; }
#route-skeleton .rs-row span { height: 14px; }
#route-skeleton .rs-row--head span { height: 9px; opacity: .6; }

/* ============ Cross-app cohesion pass ============ */
.pkg-price { font-variant-numeric: tabular-nums; }
/* Dashboard metric tiles: match the card interaction language */
.dashboard-metric:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
@media (prefers-reduced-motion: no-preference) {
  .dashboard-metric { animation: cardIn .38s ease both; }
  .dashboard-metric:nth-child(2) { animation-delay: .04s; }
  .dashboard-metric:nth-child(3) { animation-delay: .08s; }
  .dashboard-metric:nth-child(4) { animation-delay: .12s; }
  .dashboard-metric:nth-child(5) { animation-delay: .16s; }
  .dashboard-metric:nth-child(6) { animation-delay: .20s; }
  .auth-card { animation: cardIn .4s cubic-bezier(.2,.7,.2,1) both; }
}
/* One consistent focus ring on every control */
.form-control:focus, .table-search:focus, select.form-control:focus, textarea.form-control:focus { border-color: var(--brand-600); box-shadow: var(--focus-ring, 0 0 0 3px var(--brand-100, #c7d2fe)); }
/* Uniform link colour inside content */
.card__body a:not(.btn):not(.badge) { color: var(--brand-600); text-underline-offset: 2px; }

/* ============ Billing ============ */
.billing-status{display:grid;grid-template-columns:repeat(4,1fr);gap:16px}
.billing-status>div{display:flex;flex-direction:column;gap:3px}
.billing-status span{font-size:12px;color:var(--ink-500)}
.billing-status strong{font-size:15px;color:var(--ink-950)}
@media (max-width:640px){.billing-status{grid-template-columns:1fr 1fr}}
.plan-card{position:relative;border:1px solid var(--border);border-radius:16px;padding:24px;background:var(--surface);display:flex;flex-direction:column;gap:6px;transition:box-shadow .2s ease,transform .2s ease}
.plan-card:hover{box-shadow:var(--shadow-sm);transform:translateY(-2px)}
.plan-card--current{border-color:var(--brand-500,#6366f1);box-shadow:var(--shadow-sm)}
.plan-card__flag{position:absolute;top:-11px;left:22px;background:var(--brand-600,#4f46e5);color:#fff;font-size:11px;font-weight:700;letter-spacing:.05em;text-transform:uppercase;padding:3px 10px;border-radius:999px}
.plan-card__name{font-weight:700;font-size:17px}
.plan-card__price{font-size:30px;font-weight:800;letter-spacing:-.02em;font-variant-numeric:tabular-nums}
.plan-card__price small{font-size:14px;font-weight:600;color:var(--ink-500)}
.plan-card__limits{list-style:none;margin:8px 0 16px;padding:0;display:flex;flex-direction:column;gap:6px}
.plan-card__limits li{font-size:14px;color:var(--ink-600);display:flex;gap:8px}
.plan-card__limits li::before{content:"✓";color:#15803d;font-weight:700}
.plan-card__pay{display:flex;flex-direction:column;gap:8px;margin-top:auto}
.sub-banner{display:flex;align-items:center;justify-content:space-between;gap:14px;flex-wrap:wrap;margin-bottom:16px;padding:12px 16px;border-radius:12px;font-size:13.5px;background:var(--brand-50,#eef2ff);border:1px solid var(--brand-100,#c7d2fe);color:var(--brand-700,#3730a3)}
.sub-banner--warn{background:var(--danger-50,#fef2f2);border-color:#fca5a5;color:var(--danger-700,#b91c1c)}

/* ============ Universal Compact iOS-Style Status Toggle Switch ============ */
.status-toggle-pill {
  position: relative !important;
  display: inline-flex !important;
  align-items: center !important;
  width: 74px !important;
  height: 24px !important;
  padding: 0 !important;
  border-radius: 999px !important;
  border: 1px solid rgba(0, 0, 0, 0.15) !important;
  cursor: pointer !important;
  transition: background 0.25s ease, box-shadow 0.25s ease, transform 0.15s ease !important;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.18), 0 1px 2px rgba(0, 0, 0, 0.06) !important;
  user-select: none !important;
  text-decoration: none !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
  vertical-align: middle !important;
}

.status-toggle-pill.is-active,
.status-toggle-pill[data-status="active"] {
  background: linear-gradient(180deg, #22c55e 0%, #15803d 100%) !important;
}

.status-toggle-pill.is-inactive,
.status-toggle-pill[data-status="inactive"] {
  background: linear-gradient(180deg, #ef4444 0%, #b91c1c 100%) !important;
}

.status-toggle-pill .status-toggle-text {
  position: absolute !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  color: #ffffff !important;
  font-family: inherit !important;
  font-weight: 800 !important;
  line-height: 1 !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45) !important;
  pointer-events: none !important;
  white-space: nowrap !important;
  transition: opacity 0.2s ease !important;
}

.status-toggle-pill.is-active .status-toggle-text {
  left: 8px !important;
  right: auto !important;
  font-size: 9px !important;
  letter-spacing: 0.04em !important;
  text-align: left !important;
}

.status-toggle-pill.is-inactive .status-toggle-text {
  right: 7px !important;
  left: auto !important;
  font-size: 8px !important;
  letter-spacing: 0.02em !important;
  text-align: right !important;
}

.status-toggle-pill .status-toggle-knob {
  position: absolute !important;
  top: 2px !important;
  display: block !important;
  width: 18px !important;
  height: 18px !important;
  border-radius: 50% !important;
  background: radial-gradient(circle at 35% 35%, #ffffff 0%, #f1f5f9 100%) !important;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.35), inset 0 -1px 1px rgba(0, 0, 0, 0.12) !important;
  transition: left 0.22s cubic-bezier(0.4, 0, 0.2, 1) !important;
  pointer-events: none !important;
  flex-shrink: 0 !important;
}

.status-toggle-pill.is-active .status-toggle-knob {
  left: 51px !important;
}

.status-toggle-pill.is-inactive .status-toggle-knob {
  left: 3px !important;
}

.status-toggle-pill:hover {
  filter: brightness(1.08) !important;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.22), 0 2px 5px rgba(0, 0, 0, 0.12) !important;
}

.status-toggle-pill:active {
  transform: scale(0.96) !important;
}

