/* NM-CRM interface styles.
   Brand values below are the Neuro Morph defaults; /theme.css overrides the
   --brand-* and --font-* variables with each organisation's Branding settings. */

@font-face { font-family: 'Barlow'; font-style: normal; font-weight: 400; font-display: swap; src: url('../fonts/barlow-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow'; font-style: normal; font-weight: 500; font-display: swap; src: url('../fonts/barlow-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow'; font-style: normal; font-weight: 600; font-display: swap; src: url('../fonts/barlow-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow'; font-style: normal; font-weight: 700; font-display: swap; src: url('../fonts/barlow-latin-700-normal.woff2') format('woff2'); }

:root {
  --brand-primary: #782d8c;
  --brand-primary-hover: #66267770;
  --brand-primary-hover: #662677;
  --brand-primary-soft: #f2eaf4;
  --brand-primary-softer: #f8f5f9;
  --brand-on-primary: #ffffff;
  --brand-primary-text: #782d8c;
  --brand-accent: #1dbfd5;
  --brand-accent-soft: #dff6f9;
  --brand-accent-text: #117380;
  --brand-focus: #1aacc0;
  --font-heading: 'Barlow', 'Segoe UI', system-ui, sans-serif;
  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

  --bg: #f6f5f8;
  --surface: #ffffff;
  --text: #1f1d23;
  --text-muted: #5f5b66;
  --border: #e3e0e8;
  --border-strong: #cbc6d2;
  --success: #17703f;
  --success-soft: #e5f4ea;
  --warning: #8a5a00;
  --warning-soft: #fdf3dc;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --info-soft: #e8f4fb;
  --radius: 10px;
  --radius-small: 6px;
  --shadow: 0 1px 2px rgba(31, 29, 35, .06), 0 1px 3px rgba(31, 29, 35, .08);
  --sidebar-width: 248px;

  --sidebar-bg: #ffffff;
  --sidebar-text: #2b2830;
  --sidebar-muted: #77727f;
  --sidebar-hover: #f3f1f5;
  --sidebar-active-bg: var(--brand-primary-soft);
  --sidebar-active-text: var(--brand-primary-text);
  --sidebar-border: var(--border);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font-body); font-size: 15px; line-height: 1.5; color: var(--text); background: var(--bg); }
h1, h2, h3 { font-family: var(--font-heading); line-height: 1.25; margin: 0 0 .5rem; color: var(--text); }
h1 { font-size: 1.6rem; font-weight: 600; }
h2 { font-size: 1.15rem; font-weight: 600; }
p { margin: 0 0 .75rem; }
a { color: var(--brand-accent-text); text-underline-offset: 2px; }
a:hover { color: var(--brand-primary-text); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88em; background: var(--brand-primary-softer); padding: .1em .35em; border-radius: 4px; overflow-wrap: anywhere; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .8rem; background: var(--brand-primary-softer); padding: .75rem; border-radius: var(--radius-small); margin: .5rem 0 0; }
img { max-width: 100%; }
:focus-visible { outline: 3px solid var(--brand-focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: .5rem 1rem; z-index: 100; border-radius: var(--radius-small); }
.skip-link:focus { left: 8px; }
.muted { color: var(--text-muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.icon { width: 1.15em; height: 1.15em; fill: currentColor; flex: none; vertical-align: -0.2em; }

/* ----- Shell ----- */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-width); background: var(--sidebar-bg); color: var(--sidebar-text); border-right: 1px solid var(--sidebar-border); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; flex: none; }
.sidebar-brand { display: flex; align-items: center; justify-content: space-between; padding: 1.1rem 1rem .9rem; }
.brand-link { display: block; }
.brand-logo { display: block; max-height: 48px; width: auto; max-width: 200px; }
.icon-button.sidebar-close { display: none; }
.nav { padding: .25rem .6rem 1rem; flex: 1; }
.nav-heading { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--sidebar-muted); margin: 1.1rem .6rem .35rem; font-weight: 600; }
.nav-list { list-style: none; margin: 0; padding: 0; }
.nav-list a { display: flex; align-items: center; gap: .65rem; padding: .55rem .65rem; border-radius: var(--radius-small); color: var(--sidebar-text); text-decoration: none; font-weight: 500; }
.nav-list a:hover { background: var(--sidebar-hover); color: var(--sidebar-text); }
.nav-list a[aria-current="page"] { background: var(--sidebar-active-bg); color: var(--sidebar-active-text); }
.nav-list a[aria-current="page"] .icon { color: var(--brand-accent); }
.sidebar-brand ~ .nav .icon { opacity: .9; }
.sidebar-footer { font-size: .75rem; color: var(--sidebar-muted); padding: .75rem 1.25rem; margin: 0; }
.sidebar-backdrop { display: none; }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 60px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: .75rem; padding: 0 1.5rem; position: sticky; top: 0; z-index: 10; }
.topbar-org { font-family: var(--font-heading); font-weight: 600; color: var(--text-muted); }
.icon-button.menu-button { display: none; }
.content { padding: 1.75rem 1.5rem 3rem; max-width: 1240px; width: 100%; outline: none; }

.user-menu { margin-left: auto; position: relative; }
.user-menu summary { list-style: none; display: flex; align-items: center; gap: .5rem; cursor: pointer; padding: .3rem .5rem; border-radius: 999px; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover { background: var(--brand-primary-softer); }
.user-menu-name { font-weight: 500; }
.user-menu-panel { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(31, 29, 35, .14); min-width: 240px; padding: .5rem; z-index: 20; }
.user-menu-meta { padding: .5rem .6rem .75rem; border-bottom: 1px solid var(--border); margin-bottom: .35rem; font-size: .88rem; overflow-wrap: anywhere; }
.user-menu-panel a, .menu-item-button { display: flex; gap: .55rem; align-items: center; width: 100%; padding: .5rem .6rem; border-radius: var(--radius-small); color: var(--text); text-decoration: none; background: none; border: 0; font: inherit; cursor: pointer; text-align: left; }
.user-menu-panel a:hover, .menu-item-button:hover { background: var(--brand-primary-softer); color: var(--text); }

.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-primary); color: var(--brand-on-primary); display: inline-flex; align-items: center; justify-content: center; font-size: .8rem; font-weight: 600; flex: none; font-family: var(--font-heading); letter-spacing: .02em; }
.avatar-small { width: 30px; height: 30px; font-size: .72rem; }
.avatar-large { width: 56px; height: 56px; font-size: 1.15rem; }

/* ----- Page structure ----- */
.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-header h1 { margin-bottom: .2rem; }
.page-header .muted { margin: 0; }
.page-title-with-avatar { display: flex; gap: 1rem; align-items: center; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem 1.35rem; margin-bottom: 1.25rem; }
.card-flush { padding: 0; overflow: hidden; }
.card-pad { padding: 1.1rem 1.35rem .4rem; }
.card-header { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 + .card, .grid-2 + section { margin-top: 1.25rem; }
.grid-2-wide { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.2rem; display: flex; flex-direction: column; text-decoration: none; color: var(--text); border-left: 4px solid var(--brand-accent); }
.stat-card:hover { border-color: var(--brand-primary); border-left-color: var(--brand-primary); color: var(--text); }
.stat-label { font-size: .85rem; color: var(--text-muted); font-weight: 500; }
.stat-value { font-family: var(--font-heading); font-size: 2rem; font-weight: 600; line-height: 1.2; }
.stat-meta { font-size: .8rem; color: var(--text-muted); }
@media (max-width: 640px) {
    /* Phones: two compact cards per row instead of one tall card per line. */
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; margin-bottom: 1rem; }
    .stat-card { padding: .6rem .75rem; border-left-width: 3px; min-width: 0; }
    .stat-label { font-size: .75rem; line-height: 1.25; }
    .stat-value { font-size: 1.4rem; }
    .stat-meta { font-size: .72rem; line-height: 1.3; overflow-wrap: anywhere; }
}
.roadmap { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.roadmap li { display: flex; gap: .65rem; align-items: center; }

/* ----- Lists and tables ----- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: .7rem 1rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 600; background: var(--brand-primary-softer); white-space: nowrap; }
.table thead th a { color: inherit; text-decoration: none; }
.table thead th a:hover { color: var(--brand-primary-text); }
.table tbody tr:hover { background: #faf9fb; }
.table-compact th, .table-compact td { padding: .5rem .85rem; }
.table tbody:last-child tr:last-child td { border-bottom: 0; }
.group-row th { background: var(--bg); font-family: var(--font-heading); font-size: .9rem; text-transform: none; letter-spacing: 0; color: var(--text); }
.row-link { display: flex; align-items: center; gap: .7rem; color: var(--text); text-decoration: none; }
.row-link:hover strong { color: var(--brand-primary-text); text-decoration: underline; }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions form { display: inline; }
.permission-table select { min-width: 160px; }
.details { display: grid; grid-template-columns: max-content 1fr; gap: .5rem 1.25rem; margin: 0; }
.details dt { color: var(--text-muted); font-size: .88rem; }
.details dd { margin: 0; overflow-wrap: anywhere; }
.activity-list { list-style: none; margin: 0 0 .75rem; padding: 0; }
.activity-list li { display: grid; grid-template-columns: auto 1fr; gap: 0 .6rem; padding: .6rem 0; border-bottom: 1px solid var(--border); }
.activity-list li:last-child { border-bottom: 0; }
.activity-what { font-weight: 600; font-size: .9rem; }
.activity-detail { font-size: .9rem; color: var(--text-muted); overflow-wrap: anywhere; }
.activity-meta { grid-column: 1 / -1; font-size: .78rem; color: var(--text-muted); }
.empty-state { padding: 2rem 1.35rem; text-align: center; color: var(--text-muted); margin: 0; }
.pagination { display: flex; justify-content: space-between; align-items: center; padding: .75rem 1rem; border-top: 1px solid var(--border); gap: 1rem; flex-wrap: wrap; }
.pagination p { margin: 0; }
.pagination ul { list-style: none; display: flex; gap: .5rem; align-items: center; margin: 0; padding: 0; }
.tabs { display: flex; gap: .25rem; margin: 0 0 1rem; flex-wrap: wrap; }
.tabs a { padding: .4rem .8rem; border-radius: 999px; text-decoration: none; color: var(--text-muted); font-weight: 500; }
.tabs a[aria-current="page"] { background: var(--brand-primary-soft); color: var(--brand-primary-text); }
.link-list { padding-left: 1.2rem; }
.link-list li { margin-bottom: .3rem; }

/* ----- Badges and status ----- */
.badge { display: inline-block; padding: .12rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--brand-primary); color: var(--brand-on-primary); white-space: nowrap; }
.badge-soft { background: var(--brand-primary-soft); color: var(--brand-primary-text); }
.badge-warn { background: var(--warning-soft); color: var(--warning); }
.badge-rating-hot { background: var(--danger-soft); color: var(--danger); }
.badge-rating-warm { background: var(--warning-soft); color: var(--warning); }
.badge-rating-cold { background: var(--info-soft); color: var(--text); }
.status { display: inline-flex; align-items: center; gap: .35rem; font-size: .82rem; font-weight: 600; white-space: nowrap; }
.status::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status-active, .status-ok { color: var(--success); }
.status-inactive { color: var(--text-muted); }
.status-warn { color: var(--warning); }
.status-bad { color: var(--danger); }

/* ----- Forms ----- */
.form .field, .filters .field { margin-bottom: 1rem; min-width: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1.25rem; }
.form-narrow { max-width: 520px; }
label, legend { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .35rem; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; }
.req { color: var(--danger); }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="tel"], input[type="date"], input[type="number"], input[type="url"], select, textarea {
  width: 100%; padding: .6rem .75rem; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-small); min-height: 42px;
}
input:hover, select:hover, textarea:hover { border-color: #a9a3b2; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand-primary); box-shadow: 0 0 0 3px var(--brand-primary-soft); }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--danger); }
input:disabled { background: var(--bg); color: var(--text-muted); }
.input-short { max-width: 140px; }
.hint { font-size: .82rem; color: var(--text-muted); margin: .3rem 0 0; font-weight: 400; }
.field-error { color: var(--danger); font-size: .85rem; margin: .35rem 0 0; font-weight: 500; }
.checkbox, .radio { display: flex; gap: .55rem; align-items: flex-start; font-weight: 400; margin-bottom: .5rem; cursor: pointer; }
.checkbox input, .radio input { margin-top: .25rem; width: 16px; height: 16px; accent-color: var(--brand-primary); flex: none; }
.checkbox-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .1rem 1rem; }
.form-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: .5rem; flex-wrap: wrap; }
.password-wrap { position: relative; }
.password-wrap input { padding-right: 2.75rem; }
.password-wrap .icon-button { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.filters { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; padding-bottom: .25rem; }
.filters .field { flex: 1 1 160px; }
.filters .field:first-of-type { flex: 2 1 220px; }
.filter-actions { display: flex; gap: .5rem; margin-bottom: 1rem; }
.color-field { display: flex; gap: .5rem; align-items: center; }
.color-field input[type="color"] { width: 46px; height: 42px; padding: 2px; border: 1px solid var(--border-strong); border-radius: var(--radius-small); background: var(--surface); cursor: pointer; }
.inline-form { display: inline-block; margin-top: .75rem; }
.action-list { display: grid; gap: 1rem; }
.action-list form .hint { margin-top: .25rem; }

/* ----- Buttons ----- */
.button { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; padding: .55rem 1rem; min-height: 40px; border-radius: var(--radius-small); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; font-size: .92rem; text-decoration: none; cursor: pointer; white-space: nowrap; }
.button:hover { border-color: var(--brand-primary); color: var(--brand-primary-text); }
.button-primary { background: var(--brand-primary); border-color: var(--brand-primary); color: var(--brand-on-primary); }
.button-primary:hover { background: var(--brand-primary-hover); border-color: var(--brand-primary-hover); color: var(--brand-on-primary); }
.button-ghost { background: transparent; }
.button-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.button-danger:hover { background: #8f1c13; color: #fff; border-color: #8f1c13; }
.button-danger-ghost { background: transparent; color: var(--danger); border-color: #f1c0bb; }
.button-danger-ghost:hover { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.button-small { padding: .3rem .7rem; min-height: 32px; font-size: .84rem; }
.button-block { width: 100%; }
.button:disabled { opacity: .5; cursor: not-allowed; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: var(--radius-small); border: 0; background: transparent; color: inherit; cursor: pointer; }
.icon-button:hover { background: var(--brand-primary-softer); }
.link-button { background: none; border: 0; padding: 0; color: var(--brand-accent-text); font: inherit; text-decoration: underline; cursor: pointer; }

/* ----- Alerts ----- */
.flash-stack { margin-bottom: 1rem; }
.alert { display: flex; gap: .65rem; align-items: flex-start; padding: .8rem 1rem; border-radius: var(--radius-small); margin-bottom: .75rem; border: 1px solid transparent; }
.alert p { margin: 0; }
.alert p + p { margin-top: .4rem; }
.alert .icon { margin-top: .15rem; }
.alert-success { background: var(--success-soft); color: #0f5530; border-color: #b9e1c6; }
.alert-error { background: var(--danger-soft); color: #8f1c13; border-color: #f4c5bf; }
.alert-warning { background: var(--warning-soft); color: #6d4700; border-color: #f2dca6; }
.alert-info { background: var(--info-soft); color: #134a66; border-color: #c4e2f3; }
.alert-secret { display: block; background: var(--brand-accent-soft); border-color: var(--brand-accent); color: var(--text); }
.secret-row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin: .35rem 0; }
.secret-value { font-size: 1.05rem; padding: .3rem .6rem; background: var(--surface); }
.alert-secret .muted { margin: 0; }

/* ----- Branding page ----- */
.brand-preview { display: flex; gap: 1rem; align-items: center; padding: 1rem; background: var(--bg); border-radius: var(--radius-small); margin: .5rem 0 1rem; flex-wrap: wrap; }
.preview-link { color: var(--brand-accent-text); font-weight: 600; }
.upload-slot { display: flex; gap: 1rem; padding: 1rem 0; border-top: 1px solid var(--border); align-items: flex-start; }
.upload-preview { width: 120px; height: 64px; border-radius: var(--radius-small); border: 1px dashed var(--border-strong); display: flex; align-items: center; justify-content: center; padding: 6px; background: var(--surface); flex: none; }
.upload-preview img { max-height: 100%; max-width: 100%; object-fit: contain; }
.upload-preview-logo_dark { background: #2b1631; }
.upload-preview-icon { width: 64px; }
.upload-body { min-width: 0; flex: 1; }
.upload-body p { margin-bottom: .4rem; }
.upload-form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .35rem; }
.upload-form input[type="file"] { font-size: .82rem; max-width: 100%; }

/* ----- Auth and setup ----- */
.layout-auth { background: linear-gradient(160deg, var(--brand-primary-softer) 0%, var(--bg) 45%, var(--brand-accent-soft) 100%); }
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem 1rem; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border-radius: 14px; box-shadow: 0 10px 40px rgba(60, 20, 70, .12); padding: 2rem 2rem 1.75rem; border-top: 4px solid var(--brand-primary); }
.auth-card-wide { max-width: 760px; }
.auth-brand { text-align: center; margin-bottom: 1.5rem; }
.auth-logo { max-height: 72px; width: auto; max-width: 280px; }
.auth-title { font-size: 1.35rem; text-align: center; margin-bottom: 1.1rem; }
.auth-card-wide .auth-title { text-align: left; }
.auth-alt { text-align: center; margin: 1rem 0 0; font-size: .9rem; }
.auth-footer { margin-top: 1.25rem; color: var(--text-muted); font-size: .82rem; }
.setup-section { border-top: 1px solid var(--border); padding-top: 1.25rem; margin-top: 1.25rem; }
.checklist { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .35rem; }
.checklist li { display: flex; gap: .55rem; align-items: flex-start; font-size: .92rem; }
.checklist .is-ok .icon { color: var(--success); }
.checklist .is-bad .icon { color: var(--danger); }
.checklist .is-warn .icon { color: var(--warning); }
.steps { padding-left: 1.3rem; }
.steps li { margin-bottom: .4rem; }

/* ----- Errors ----- */
.error-page { text-align: center; padding: 3rem 1rem; }
.error-code { font-family: var(--font-heading); font-size: 3.5rem; font-weight: 700; color: var(--brand-primary-text); margin: 0; line-height: 1; }

/* ----- Dialog ----- */
.confirm-dialog { border: 0; border-radius: var(--radius); padding: 1.5rem; max-width: 440px; width: calc(100% - 2rem); box-shadow: 0 20px 60px rgba(31, 29, 35, .3); }
.confirm-dialog::backdrop { background: rgba(31, 29, 35, .45); }
.audit-details summary { cursor: pointer; color: var(--brand-accent-text); font-size: .82rem; }

/* ----- Responsive ----- */
@media (max-width: 960px) {
  .grid-2, .grid-2-wide { grid-template-columns: 1fr; }
  .grid-2 > .card { margin-bottom: 0; }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s ease; box-shadow: 0 0 40px rgba(0, 0, 0, .2); }
  .sidebar.is-open { transform: translateX(0); }
  .icon-button.sidebar-close { display: inline-flex; }
  .sidebar-backdrop:not([hidden]) { display: block; position: fixed; inset: 0; background: rgba(31, 29, 35, .4); z-index: 40; }
  .icon-button.menu-button { display: inline-flex; }
  .topbar { padding: 0 1rem; }
  .content { padding: 1.25rem 1rem 2.5rem; }
  .user-menu-name { display: none; }
}
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; }
  .details { grid-template-columns: 1fr; gap: .1rem; }
  .details dd { margin-bottom: .6rem; }
  .table thead th:nth-child(n+3), .table tbody td:nth-child(n+3) { display: none; }
  .table-compact thead th, .table-compact tbody td, .permission-table thead th, .permission-table tbody td { display: table-cell; }
  .auth-card { padding: 1.5rem 1.25rem; }
  .topbar-org { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
@media print {
  .sidebar, .topbar, .form-actions, .filters { display: none !important; }
}

/* ----- Command bar (Ctrl+K) ----- */
.command-trigger { display: inline-flex; align-items: center; gap: .5rem; margin-left: auto; padding: .4rem .6rem .4rem .75rem; min-width: 240px; border: 1px solid var(--border); border-radius: 999px; background: var(--bg); color: var(--text-muted); font: inherit; font-size: .88rem; cursor: pointer; }
.command-trigger:hover { border-color: var(--brand-primary); color: var(--text); }
.command-trigger-label { flex: 1; text-align: left; }
.command-trigger + .user-menu { margin-left: .5rem; }
kbd { font-family: ui-monospace, Menlo, monospace; font-size: .72rem; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; padding: .05rem .35rem; background: var(--surface); color: var(--text-muted); }
.command-dialog { border: 0; border-radius: 14px; padding: 0; width: min(620px, calc(100% - 2rem)); margin-top: 12vh; box-shadow: 0 24px 80px rgba(31, 29, 35, .35); }
.command-dialog::backdrop { background: rgba(31, 29, 35, .4); }
.command-box { display: flex; align-items: center; gap: .6rem; padding: .85rem 1rem; border-bottom: 1px solid var(--border); }
.command-box .icon { color: var(--brand-primary-text); width: 1.3em; height: 1.3em; }
.command-box input { border: 0; box-shadow: none; padding: .3rem 0; font-size: 1.05rem; min-height: 0; }
.command-box input:focus { box-shadow: none; }
.command-results { list-style: none; margin: 0; padding: .4rem; max-height: 50vh; overflow-y: auto; }
.command-results li { padding: .6rem .75rem; border-radius: var(--radius-small); cursor: pointer; display: flex; justify-content: space-between; gap: 1rem; }
.command-results li[aria-selected="true"] { background: var(--brand-primary-soft); color: var(--brand-primary-text); }
.command-results .command-group { font-size: .75rem; color: var(--text-muted); }
.command-results .command-empty { cursor: default; color: var(--text-muted); }
.command-hint { margin: 0; padding: .6rem 1rem; font-size: .78rem; color: var(--text-muted); border-top: 1px solid var(--border); }
@media (max-width: 860px) {
  .command-trigger { min-width: 0; }
  .command-trigger-label, .command-trigger kbd { display: none; }
}

/* Phase 2: contacts, companies, import, AI and custom fields */
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.page-title-with-avatar { display: flex; gap: .9rem; align-items: center; }
.avatar-square { border-radius: var(--radius-small); background: var(--brand-accent-text); }
.badge-success { background: var(--success-soft); color: var(--success); }
.alert-neutral { background: var(--brand-primary-softer); color: var(--text); border-color: var(--border); }
.card-warning { border-color: #f2dca6; background: var(--warning-soft); }
.card-warning h2 { color: #6d4700; display: flex; gap: .5rem; align-items: center; }
.card-muted { background: var(--brand-primary-softer); box-shadow: none; }
.card-muted p { margin: 0; }
.card-header { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: .5rem; }
.card-header h2 { margin: 0; }
.link-row { display: flex; justify-content: space-between; align-items: center; gap: .75rem; }
.plain-list, .hint-list { margin: .5rem 0 0; }
.plain-list { list-style: none; padding: 0; }
.plain-list li + li { margin-top: .75rem; }
.hint-list { color: var(--text-muted); font-size: .9rem; padding-left: 1.2rem; }
.check { display: flex; gap: .5rem; align-items: center; font-weight: 500; margin: .4rem 0; }
.check input { width: auto; margin: 0; }
.field-wide { grid-column: 1 / -1; }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.text-right { text-align: right; }
.row-muted td { color: var(--text-muted); }
.inline-form { display: inline; margin: 0; }
.danger-zone { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.steps { list-style: none; display: flex; gap: .5rem; padding: 0; margin: 0 0 1.25rem; flex-wrap: wrap; }
.steps li { padding: .3rem .8rem; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--text-muted); font-size: .85rem; }
.steps li[aria-current="step"] { background: var(--brand-primary); border-color: var(--brand-primary); color: var(--brand-on-primary); font-weight: 600; }
.provider-choice { margin-top: .75rem; }
.provider-choice .check { margin: .3rem 0; }
[hidden] { display: none !important; }
.card-danger { border-color: #f4c5bf; }
.card-danger h2 { color: var(--danger); }
.danger-zone.page-actions { justify-content: flex-start; }

/* ----- Phase 3: timeline, tasks, calendar, files, notifications ----- */
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-sensitive { background: #ece9f1; color: #4a4553; display: inline-flex; align-items: center; gap: .2rem; }
.badge-sensitive .icon { width: 12px; height: 12px; }
.bell { margin-left: auto; position: relative; color: var(--text-muted); text-decoration: none; }
.bell + .user-menu { margin-left: .25rem; }
.bell-count { position: absolute; top: 2px; right: 0; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 999px; background: var(--danger); color: #fff; font-size: .68rem; font-weight: 700; line-height: 18px; text-align: center; }
.log-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 .75rem; }
.quick-note { border: 1px solid var(--border); border-radius: var(--radius-small); padding: .6rem; margin-bottom: 1rem; background: var(--brand-primary-softer); }
.quick-note textarea { width: 100%; border: 1px solid var(--border); border-radius: var(--radius-small); padding: .5rem .6rem; font: inherit; resize: vertical; background: var(--surface); }
.quick-note-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin-top: .5rem; }
.quick-note-bar .button { margin-left: auto; }
.file-pick { display: inline-flex; align-items: center; gap: .3rem; color: var(--brand-accent-text); cursor: pointer; font-size: .9rem; position: relative; }
.file-pick input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.file-pick:focus-within { outline: 2px solid var(--brand-focus); outline-offset: 2px; border-radius: 4px; }
.upload-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin-top: .75rem; padding-top: .75rem; border-top: 1px solid var(--border); }
.upload-row .hint { flex-basis: 100%; margin: 0; }
.timeline { list-style: none; margin: 0; padding: 0; }
.tl-item { display: grid; grid-template-columns: 34px 1fr; gap: .75rem; padding: .85rem 0; border-top: 1px solid var(--border); }
.tl-icon { width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--brand-primary-soft); color: var(--brand-primary-text); }
.tl-icon .icon { width: 17px; height: 17px; }
.tl-call .tl-icon, .tl-email .tl-icon { background: var(--brand-accent-soft); color: var(--brand-accent-text); }
.tl-task .tl-icon { background: var(--warning-soft); color: var(--warning); }
.tl-closed .tl-icon { background: var(--success-soft); color: var(--success); }
.tl-closed .tl-subject { color: var(--text-muted); text-decoration: line-through; }
.tl-head { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.tl-subject { font-weight: 600; color: var(--text); text-decoration: none; }
.tl-subject:hover { text-decoration: underline; }
.tl-meta { margin: .15rem 0 0; color: var(--text-muted); font-size: .85rem; }
.tl-text { margin: .4rem 0 0; }
.tl-files { list-style: none; padding: 0; margin: .4rem 0 0; }
.tl-files a { display: inline-flex; align-items: center; gap: .25rem; }
.tl-files .icon { width: 15px; height: 15px; }
.tl-actions { display: flex; align-items: center; gap: .75rem; margin-top: .45rem; }
.col-check { width: 44px; }
.tick { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--border-strong); background: var(--surface); color: transparent; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.tick .icon { width: 15px; height: 15px; }
.tick:hover { border-color: var(--success); color: var(--success); }
.tick-done { background: var(--success); border-color: var(--success); color: #fff; }
.calendar { width: 100%; border-collapse: collapse; table-layout: fixed; }
.calendar th { padding: .5rem; font-size: .8rem; color: var(--text-muted); text-align: left; border-bottom: 1px solid var(--border); }
.calendar td { vertical-align: top; height: 110px; padding: .35rem; border: 1px solid var(--border); overflow: hidden; }
.calendar td.cal-other { background: var(--bg); }
.calendar td.cal-other .cal-date { color: var(--text-muted); }
.calendar td.cal-today .cal-date { background: var(--brand-primary); color: var(--brand-on-primary); border-radius: 999px; padding: 0 .45rem; }
.cal-date { font-size: .82rem; font-weight: 600; display: inline-block; }
.cal-items { list-style: none; margin: .25rem 0 0; padding: 0; }
.cal-items li { margin-bottom: .2rem; }
.cal-items a { display: block; font-size: .78rem; line-height: 1.3; padding: .15rem .35rem; border-radius: 4px; text-decoration: none; color: var(--text); background: var(--warning-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-meeting a { background: var(--brand-accent-soft); color: #0b4f58; }
.cal-overdue a { background: var(--danger-soft); color: var(--danger); }
.cal-done a { background: var(--success-soft); color: var(--success); text-decoration: line-through; }
.cal-time { font-weight: 600; margin-right: .2rem; }
.cal-key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin: 0 .2rem 0 .8rem; vertical-align: -1px; }
.cal-key-meeting { background: var(--brand-accent-soft); border: 1px solid #9adbe4; }
.cal-key-task { background: var(--warning-soft); border: 1px solid #f0d28f; }
.cal-key-overdue { background: var(--danger-soft); border: 1px solid #f3b4ae; }
.notification-list { list-style: none; margin: 0; padding: 0; }
.notification-list li { border-top: 1px solid var(--border); }
.notification-list li:first-child { border-top: 0; }
.notification-list a { display: flex; gap: .75rem; padding: .85rem 1.25rem; color: var(--text); text-decoration: none; }
.notification-list a:hover { background: var(--brand-primary-softer); }
.notification-list .is-unread a { background: var(--brand-primary-softer); }
.notification-list .is-unread strong::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--brand-primary); margin-right: .4rem; vertical-align: 1px; }
.notification-icon { color: var(--brand-primary-text); }
.bullet-list { list-style: disc; padding-left: 1.25rem; }
.bullet-list li { margin-bottom: .35rem; }
.ai-summary { font-size: 1.05rem; line-height: 1.6; }
.ai-row { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.suggested-task .check { margin-bottom: .5rem; }
@media (max-width: 640px) {
  .calendar td { height: 70px; padding: .2rem; }
  .cal-items a { font-size: .7rem; padding: .1rem .2rem; }
  .cal-time { display: none; }
  .quick-note-bar .button { margin-left: 0; }
}

/* ----- Phase 4: deals, board, pipelines ----- */
.text-danger { color: var(--danger); font-weight: 600; }
.deal-totals { margin-bottom: 1rem; }
.board { position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(170px, 1fr); gap: .75rem; overflow-x: auto; padding-bottom: .75rem; align-items: start; }
.board-col { background: var(--brand-primary-softer); border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem; min-height: 160px; display: flex; flex-direction: column; }
.board-col.is-over { outline: 2px dashed var(--brand-accent); outline-offset: -2px; }
.board-won .board-col-head h2 { color: var(--success); }
.board-lost .board-col-head h2 { color: var(--danger); }
.board-col-head h2 { font-size: .95rem; margin: 0; }
.board-col-head p { margin: .15rem 0 .5rem; }
.board-cards { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; flex: 1; min-height: 60px; }
.deal-card { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-small); padding: .6rem .7rem; display: flex; flex-direction: column; gap: .15rem; box-shadow: var(--shadow); }
.deal-card[draggable="true"] { cursor: grab; }
.deal-card.is-dragging { opacity: .5; }
.deal-card-name { font-weight: 600; text-decoration: none; color: var(--text); }
.deal-card-name:hover { text-decoration: underline; }
.deal-card-move { display: flex; gap: .35rem; margin-top: .35rem; }
.deal-card-move select { flex: 1; min-width: 0; font-size: .8rem; padding: .2rem .3rem; }
.stage-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; }
.stage-bar p { margin: 0; }
.stage-steps { list-style: none; display: flex; flex-wrap: wrap; gap: .35rem; margin: 0; padding: 0; }
.stage-steps li { padding: .3rem .7rem; border-radius: 999px; background: var(--brand-primary-softer); border: 1px solid var(--border); font-size: .85rem; }
.stage-steps li.is-current { background: var(--brand-primary); color: var(--brand-on-primary); border-color: var(--brand-primary); font-weight: 600; }
.stage-steps .link-button { font-size: .85rem; }
.stage-steps-static .stage-won { color: var(--success); }
.stage-steps-static .stage-lost { color: var(--danger); }
.option-list li { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .3rem 0; border-bottom: 1px solid var(--border); }
.badge-lc-customer { background: var(--success-soft); color: var(--success); }
.badge-lc-partner { background: var(--brand-primary-softer); color: var(--brand-primary-text); }
.badge-lc-qualified { background: var(--warning-soft); color: var(--warning); }

/* ----- Phase 5: search, saved views, reports, charts ----- */
.search-hint { color: var(--text-muted); display: inline-block; margin-top: .15rem; }
.search-group h2 .badge { vertical-align: middle; }
.saved-views { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin: -.5rem 0 1rem; }
.saved-views-label { display: inline-flex; align-items: center; gap: .3rem; font-size: .85rem; color: var(--text-muted); font-weight: 600; margin-right: .2rem; }
.saved-views-label .icon { width: 16px; height: 16px; }
.chip-group { display: inline-flex; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: .25rem; padding: .25rem .7rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none; font-size: .85rem; }
.chip .icon { width: 14px; height: 14px; }
.chip:hover { border-color: var(--brand-primary); color: var(--brand-primary-text); }
.chip.is-active { background: var(--brand-primary-soft); border-color: var(--brand-primary); color: var(--brand-primary-text); font-weight: 600; }
.chip-group .chip { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.chip-remove { border: 1px solid var(--border); border-left: 0; background: var(--surface); border-radius: 0 999px 999px 0; padding: .25rem .4rem; cursor: pointer; color: var(--text-muted); display: inline-flex; align-items: center; height: 100%; }
.chip-remove .icon { width: 12px; height: 12px; }
.chip-remove:hover { color: var(--danger); }
.chip-group .inline-form { display: inline-flex; align-self: stretch; }
.save-view { position: relative; }
.save-view summary { list-style: none; }
.save-view summary::-webkit-details-marker { display: none; }
.save-view-form { position: absolute; z-index: 20; top: calc(100% + .35rem); left: 0; width: min(320px, 85vw); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: .9rem; display: grid; gap: .5rem; }
.save-view-form .button { justify-self: start; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.report-card { text-decoration: none; color: var(--text); margin-bottom: 0; }
.report-card h2 { display: flex; align-items: center; gap: .45rem; font-size: 1.1rem; }
.report-card:hover { border-color: var(--brand-primary); }
.ask-form { display: flex; gap: .5rem; flex-wrap: wrap; }
.ask-form input { flex: 1 1 260px; }
.ask-answer { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.text-warning { color: var(--warning); }
.card-flush-title { padding: 1.1rem 1.35rem .6rem; margin: 0; }
.card-flush > .empty-state { padding: 0 1.35rem 1rem; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tfoot th, .table tfoot td { font-weight: 600; border-top: 2px solid var(--border); padding: .7rem 1rem; }
.table-scroll { max-height: 420px; overflow-y: auto; }
.bar-chart { margin: 0; }
.bar-chart ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .45rem; }
.bar-chart li { display: grid; grid-template-columns: minmax(90px, 32%) 1fr auto; align-items: center; gap: .6rem; font-size: .88rem; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { width: 100%; height: 14px; display: block; }
.bar-track { fill: var(--brand-primary-softer); }
.bar-fill { fill: var(--brand-primary); }
.bar-value { font-variant-numeric: tabular-nums; color: var(--text-muted); white-space: nowrap; }
.column-chart { margin: 0; }
.column-chart svg { width: 100%; height: 160px; display: block; margin-top: .5rem; }
.column-chart .chart-axis { stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; }
.column-chart-axis { display: flex; justify-content: space-between; margin-top: .25rem; }
.dash-table td, .dash-table th { padding: .45rem .7rem; }
@media (max-width: 640px) {
  .table.table-report thead th:nth-child(n), .table.table-report tbody td:nth-child(n), .table.table-report tfoot td:nth-child(n) { display: table-cell; }
  .bar-chart li { grid-template-columns: minmax(70px, 34%) 1fr auto; }
}
.quick-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .75rem; }
.table tbody:last-child tr:last-child th { border-bottom: 0; }

/* Phase 6: Outlook emails on contact and company pages */
.email-list .link-row { padding: .6rem 0; border-bottom: 1px solid var(--border, #e5e7eb); }
.email-list .link-row:last-child { border-bottom: 0; }

/* ----- Repeatable rows: social links, vendors, competitors ----- */
.social-rows, [data-repeat-list] { display: grid; gap: .5rem; }
.social-row, .pick-row { display: grid; grid-template-columns: minmax(8rem, 12rem) 1fr; gap: .5rem; align-items: center; }
.pick-row { grid-template-columns: minmax(10rem, 1fr) 1.2fr; }
.social-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .25rem .9rem; }
.h-small { font-size: .95rem; margin: 1rem 0 .5rem; }
@media (max-width: 600px) {
  .social-row, .pick-row { grid-template-columns: 1fr; }
  .pick-row, .social-row { gap: .35rem; padding-bottom: .5rem; border-bottom: 1px dashed var(--border); }
}

/* ----- Dashboard cards and the Customise mode ----- */
.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; align-items: start; }
.dash-grid > .dash-item > .card { margin-bottom: 0; }
.dash-wide { grid-column: 1 / -1; }
.dash-grid > .dash-item { min-width: 0; }
.stat-grid > .dash-item { display: flex; min-width: 0; }
.stat-grid > .dash-item > .stat-card { flex: 1; }
.dash-zone:empty { display: none; }
.dash-editor .dash-actions { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; margin-top: .75rem; }
.dash-role { display: inline-flex; align-items: center; gap: .5rem; }
.dash-item.is-editing { flex-direction: column; outline: 2px dashed var(--border); outline-offset: 3px; border-radius: var(--radius); background: var(--surface); }
.stat-grid > .dash-item.is-editing { flex-direction: column; }
.dash-zone.is-editing-zone { display: grid; min-height: 3.5rem; margin-bottom: 1.25rem; padding: .5rem; border: 1px dashed var(--border); border-radius: var(--radius); }
.dash-tools { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .6rem; padding: .35rem .6rem; font-size: .85rem; background: var(--brand-primary-soft); border-radius: var(--radius) var(--radius) 0 0; }
.dash-handle { cursor: grab; font-size: 1.1rem; line-height: 1; }
.dash-name { font-weight: 600; margin-right: auto; }
.dash-item.is-dragging { opacity: .45; }
.dash-placeholder { display: flex; flex-direction: column; gap: .25rem; padding: 1rem 1.2rem; border: 1px dashed var(--border); border-radius: 0 0 var(--radius) var(--radius); }
.dash-tray { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .75rem; }
.dash-tray-item { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .6rem .8rem; border: 1px solid var(--border); border-radius: var(--radius); }
.dash-js .dash-nojs { display: none; }
@media (max-width: 900px) {
  .dash-grid { grid-template-columns: 1fr; }
}

/* ----- Calendar quick-create and AI drafts ----- */
.calendar td { position: relative; }
.cal-add { position: absolute; top: .25rem; right: .3rem; width: 1.5rem; height: 1.5rem; line-height: 1.4rem; text-align: center; border-radius: 50%; text-decoration: none; font-weight: 700; color: var(--brand-primary-text); background: var(--brand-primary-soft); opacity: 0; transition: opacity .15s; }
.calendar td:hover .cal-add, .cal-add:focus { opacity: 1; }
@media (hover: none) { .cal-add { opacity: .85; } }
.calendar td[data-date] { cursor: cell; }
.dialog.quick-create { border: 0; border-radius: var(--radius); padding: 1.25rem 1.5rem; width: min(520px, calc(100% - 2rem)); box-shadow: 0 20px 60px rgba(31, 29, 35, .3); background: var(--surface); color: var(--text); }
.dialog.quick-create::backdrop { background: rgba(31, 29, 35, .45); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.dialog-head h2 { margin: 0; }
.qc-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; margin-bottom: 1rem; }
.qc-choices .button { justify-content: center; }
.qc-ai { border-top: 1px solid var(--border); padding-top: .75rem; }
.ai-draft { border-left: 4px solid var(--brand-accent); }
.form-actions-start { justify-content: flex-start; }
.email-draft summary { cursor: pointer; list-style: none; }
.email-draft summary::-webkit-details-marker { display: none; }
.email-draft summary h2 { display: inline-flex; align-items: center; gap: .4rem; margin: 0; }
.email-draft summary h2::after { content: '▸'; font-size: .9rem; color: var(--text-muted); }
.email-draft[open] summary h2::after { content: '▾'; }
.email-draft[open] summary { margin-bottom: .75rem; }
.task-email { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.email-preview { background: var(--bg, #f7f7f9); border: 1px solid var(--border); border-radius: var(--radius-small); padding: .75rem 1rem; max-height: 22rem; overflow: auto; }

/* ----- Company sign-up (0.9.0) ----- */
.auth-card-signup { max-width: 640px; }
.auth-intro { text-align: center; margin: -.5rem 0 1.25rem; }
.hp-field { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.signup-meta { display: flex; flex-wrap: wrap; gap: .25rem 1rem; color: var(--text-muted); font-size: .88rem; margin: .25rem 0 .5rem; }
.signup-message { background: var(--surface-2, #f6f4f8); border-radius: 8px; padding: .5rem .75rem; margin: .5rem 0; white-space: pre-line; font-size: .92rem; }
.signup-actions { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-start; margin-top: .75rem; }
.signup-actions details { flex: 1 1 260px; }
.signup-actions details[open] { background: var(--surface-2, #f6f4f8); border-radius: 8px; padding: .5rem .75rem; }
.signup-item + .signup-item { border-top: 1px solid var(--border); padding-top: 1rem; margin-top: 1rem; }
@media (max-width: 640px) { .auth-card-signup .form-grid { grid-template-columns: 1fr; } }
.signup-state { margin: 0 0 .5rem; }
.signup-company { margin: 0; }
.signup-reject { margin-top: .5rem; }

/* ----- Setup wizard (0.9.0) ----- */
.wizard-steps { display: flex; gap: .5rem 1.25rem; flex-wrap: wrap; list-style: none; padding: 0; margin: 0 0 1.25rem; color: var(--text-muted); font-size: .92rem; }
.wizard-steps li { display: flex; align-items: center; gap: .4rem; }
.wizard-steps span { display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%; border: 1px solid var(--border); font-weight: 600; }
.wizard-steps li[aria-current] { color: var(--text); font-weight: 600; }
.wizard-steps li[aria-current] span { background: var(--brand-primary, #782d8c); border-color: var(--brand-primary, #782d8c); color: #fff; }
.wizard-create { margin-top: 1.9rem; }
.config-text { width: 100%; font-family: ui-monospace, Menlo, monospace; font-size: .8rem; }
@media (max-width: 640px) { .wizard-create { margin-top: 0; } }

/* ----- Subscriptions (0.10.0) ----- */
.status.sub-trial { color: var(--brand-primary-text, #5c2069); }
.status.sub-active { color: var(--success); }
.status.sub-grace { color: #8a5a00; }
.status.sub-expired, .status.sub-cancelled { color: var(--danger); }
.split-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; padding-bottom: .6rem; }
.split-head h2, .split-head .tabs { margin: 0; }
.history-list { list-style: none; padding: 0; margin: 0; }
.history-list li { padding: .45rem 0; border-top: 1px solid var(--border); font-size: .92rem; }
.history-list li:first-child { border-top: 0; }
.sub-banner { margin-bottom: 1rem; }

/* Setup wizard (0.11): choices and the test email row */
.wizard-choice { border: 0; padding: 0; margin: 0 0 1rem; display: grid; gap: .5rem; }
.inline-field { display: flex; gap: .5rem; align-items: center; }
.inline-field input { flex: 1; min-width: 0; }
.setup-section .form-grid { margin-top: .5rem; }

/* Sign-in settings (0.12): group to role rows; Microsoft button on the sign-in page */
.sso-groups { display: grid; gap: .5rem; }
.sso-group-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: .5rem; }
@media (max-width: 600px) { .sso-group-row { grid-template-columns: 1fr; } }
.auth-divider { display: flex; align-items: center; gap: .75rem; color: var(--muted, #6b6475); font-size: .875rem; margin: 1rem 0; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; border-top: 1px solid var(--border, #e3dfe8); }
.button-microsoft { width: 100%; justify-content: center; gap: .6rem; }
.ms-logo { width: 18px; height: 18px; flex: none; }

/* Subscribe (0.13) */
.plan-choices { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.plan-choice { display: flex; gap: .6rem; align-items: flex-start; padding: .9rem; border: 1px solid var(--border, #e3dfe8); border-radius: 10px; cursor: pointer; }
.plan-choice > span { display: grid; gap: .2rem; }
.plan-choice:has(input:checked) { border-color: var(--primary, #782d8c); box-shadow: 0 0 0 1px var(--primary, #782d8c); }
.sub-total { font-size: 1.1rem; margin: 1rem 0 .5rem; }
.sub-instructions { background: var(--surface-2, #f6f4f8); border-radius: 8px; padding: .75rem 1rem; margin: .75rem 0; }
.sub-instructions h3 { margin: 0 0 .25rem; font-size: 1rem; }
.sub-request { border-left: 4px solid var(--accent, #1dbfd5); }
.badge-accent { background: var(--accent, #1dbfd5); color: #06323a; text-decoration: none; }
