html, body { height:100%; overflow:hidden; }
.app-shell { height:100vh; display:grid; grid-template-columns:248px minmax(0,1fr); }
.sidebar { position:relative; display:flex; flex-direction:column; gap:16px; padding:18px 14px; background:var(--surface); border-right:1px solid var(--border); min-width:0; transition:width .2s ease; }
.brand-block { display:flex; align-items:center; gap:10px; min-height:48px; overflow:hidden; }
.brand-mark { width:42px; height:42px; flex:0 0 42px; border-radius:13px; display:flex; align-items:center; justify-content:center; background:var(--accent); color:#fff; font-weight:900; }
.brand-copy { min-width:0; display:flex; flex-direction:column; }
.brand-copy strong { white-space:nowrap; }
.brand-copy span { color:var(--muted); font-size:11px; white-space:nowrap; }
.sidebar-toggle { align-self:flex-start; width:38px; height:38px; border:1px solid var(--border); border-radius:11px; background:var(--surface-soft); color:var(--text); cursor:pointer; }
.sidebar-nav { display:grid; gap:7px; }
.nav-item { display:flex; align-items:center; gap:11px; min-height:42px; padding:0 12px; border-radius:12px; text-decoration:none; color:var(--muted); font-weight:750; overflow:hidden; white-space:nowrap; }
.nav-item.is-active { color:var(--accent); background:var(--accent-soft); box-shadow:inset 3px 0 0 var(--accent); }
.nav-item.is-disabled { opacity:.48; cursor:not-allowed; }
.nav-icon { width:23px; text-align:center; font-size:18px; }
.sidebar-footer { margin-top:auto; color:var(--muted); font-size:12px; padding:0 12px; }
body.sidebar-collapsed .app-shell { grid-template-columns:76px minmax(0,1fr); }
body.sidebar-collapsed .brand-copy, body.sidebar-collapsed .nav-label { display:none; }
body.sidebar-collapsed .nav-item { justify-content:center; padding:0; }
body.sidebar-collapsed .sidebar-footer { text-align:center; padding:0; font-size:10px; }

.main-area { min-width:0; height:100vh; display:grid; grid-template-rows:auto minmax(0,1fr); }
.topbar { display:flex; align-items:flex-start; justify-content:space-between; gap:24px; padding:20px 26px 16px; border-bottom:1px solid var(--border); background:var(--surface); }
.topbar h1 { margin:0 0 6px; font-size:25px; }
.topbar p { margin:0; color:var(--muted); }
.topbar-actions { display:flex; gap:10px; }
.selector { position:relative; }
.selector summary { list-style:none; min-height:38px; padding:9px 12px; border:1px solid var(--border); border-radius:11px; background:var(--surface-soft); cursor:pointer; font-weight:750; white-space:nowrap; }
.selector summary::-webkit-details-marker { display:none; }
.selector-menu { position:absolute; top:46px; right:0; min-width:150px; display:grid; padding:7px; border:1px solid var(--border); border-radius:12px; background:var(--surface); box-shadow:var(--shadow); z-index:20; }
.selector-menu a { padding:9px 10px; border-radius:8px; text-decoration:none; }
.selector-menu a:hover { background:var(--accent-soft); color:var(--accent); }
.content-area { min-height:0; overflow:auto; padding:18px 26px 26px; }
.workspace-grid { display:grid; grid-template-columns:minmax(0,1.35fr) minmax(360px,.65fr); grid-template-rows:auto minmax(220px,1fr); gap:16px; min-height:100%; }
.panel { padding:18px; min-width:0; }
.panel-status { grid-column:1 / -1; }
.status-grid { margin-top:16px; display:grid; grid-template-columns:repeat(4,minmax(150px,1fr)); gap:12px; }
.status-card { padding:14px; border:1px solid var(--border); border-radius:14px; background:var(--surface-soft); }
.status-card span { display:block; color:var(--muted); font-size:12px; margin-bottom:7px; }
.status-card strong { font-size:17px; }
.panel-decisions { min-height:0; }
.panel-decisions .decision-list { margin-top:16px; }
.panel-next { display:flex; flex-direction:column; }
.next-stage { margin-top:18px; display:flex; gap:16px; align-items:center; padding:18px; border:1px dashed var(--accent); border-radius:15px; background:var(--accent-soft); }
.next-stage p { margin:0; line-height:1.5; }
.next-number { font-size:34px; font-weight:900; color:var(--accent); }
@media (max-width:1100px) { .workspace-grid{grid-template-columns:1fr;} .panel-status{grid-column:auto;} .status-grid{grid-template-columns:repeat(2,minmax(0,1fr));} }

.sidebar-account { margin-top:auto; display:grid; gap:4px; padding:12px; border:1px solid var(--border); border-radius:12px; background:var(--surface-soft); overflow:hidden; }
.sidebar-account > strong { font-size:13px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.sidebar-account > span { color:var(--muted); font-size:11px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.sidebar-account form { margin-top:6px; }
.sidebar-logout { width:100%; min-height:34px; display:flex; align-items:center; gap:9px; padding:0 9px; border:0; border-radius:9px; background:transparent; color:var(--muted); font-weight:750; cursor:pointer; }
.sidebar-logout:hover { background:var(--accent-soft); color:var(--accent); }
body.sidebar-collapsed .sidebar-account { padding:6px; align-items:center; }
body.sidebar-collapsed .sidebar-account > strong, body.sidebar-collapsed .sidebar-account > span { display:none; }
body.sidebar-collapsed .sidebar-logout { justify-content:center; padding:0; }
body.sidebar-collapsed .sidebar-footer { margin-top:0; }

.auth-body { height:auto; min-height:100vh; overflow:auto; }
.auth-page-shell { min-height:100vh; display:grid; grid-template-columns:minmax(360px,42%) minmax(520px,58%); }
.auth-brand-panel { position:relative; display:flex; flex-direction:column; justify-content:center; padding:70px clamp(48px,7vw,110px); background:linear-gradient(145deg,var(--accent),color-mix(in srgb,var(--accent) 60%,#10243f)); color:#fff; overflow:hidden; }
.auth-brand-panel::after { content:""; position:absolute; width:420px; height:420px; right:-170px; bottom:-170px; border:70px solid rgba(255,255,255,.08); border-radius:50%; }
.auth-brand-mark { width:66px; height:66px; display:flex; align-items:center; justify-content:center; border-radius:20px; background:#fff; color:var(--accent); font-weight:900; font-size:21px; margin-bottom:28px; }
.auth-brand-panel h1 { margin:0 0 10px; font-size:42px; line-height:1.08; }
.auth-brand-panel p { margin:0; max-width:520px; color:rgba(255,255,255,.82); font-size:17px; line-height:1.55; }
.auth-value-list { margin-top:38px; display:grid; gap:13px; max-width:520px; }
.auth-value-list > div { display:flex; gap:11px; align-items:flex-start; font-size:14px; line-height:1.45; }
.auth-value-list span { width:24px; height:24px; flex:0 0 24px; display:flex; align-items:center; justify-content:center; border-radius:50%; background:rgba(255,255,255,.16); font-weight:900; }
.auth-main { position:relative; display:flex; flex-direction:column; align-items:center; justify-content:center; padding:84px 36px 42px; }
.auth-top-actions { position:absolute; top:24px; right:28px; }
.auth-card { width:min(620px,100%); padding:28px; border:1px solid var(--border); border-radius:20px; background:var(--surface); box-shadow:var(--shadow); }
.dashboard-grid { grid-template-columns:minmax(0,1.15fr) minmax(380px,.85fr); }
.account-status-grid { grid-template-columns:repeat(4,minmax(0,1fr)); }
.status-card small { display:block; margin-top:7px; color:var(--muted); font-size:11px; overflow-wrap:anywhere; }
.trial-panel { min-height:0; }
.trial-summary { margin-top:16px; display:grid; grid-template-columns:150px minmax(0,1fr); gap:18px; align-items:stretch; }
.trial-days { display:flex; flex-direction:column; align-items:center; justify-content:center; border:1px solid var(--accent); border-radius:16px; background:var(--accent-soft); min-height:150px; }
.trial-days strong { font-size:52px; line-height:1; color:var(--accent); }
.trial-days span { margin-top:7px; color:var(--muted); font-size:12px; text-align:center; }
.trial-details { display:grid; gap:10px; }
.trial-details > div { display:flex; justify-content:space-between; gap:16px; padding:12px 14px; border:1px solid var(--border); border-radius:12px; background:var(--surface-soft); }
.trial-details span { color:var(--muted); font-size:12px; }
.trial-details strong { text-align:right; font-size:13px; }
.trial-summary.is-expired .trial-days { border-color:var(--danger); background:color-mix(in srgb,var(--danger) 8%,var(--surface)); }
.trial-summary.is-expired .trial-days strong { color:var(--danger); }
.trial-note { margin-top:14px; color:var(--muted); font-size:12px; line-height:1.45; }
.session-panel p { line-height:1.5; }
@media (max-width:1200px) { .auth-page-shell{grid-template-columns:38% minmax(0,62%);} .auth-brand-panel{padding:60px 36px;} .account-status-grid{grid-template-columns:repeat(2,minmax(0,1fr));} }
@media (max-width:900px) { .auth-page-shell{grid-template-columns:1fr;} .auth-brand-panel{display:none;} .auth-main{min-height:100vh;} }

.wizard-panel, .niche-detail-panel { min-height:100%; }
.wizard-panel { max-width:1180px; margin:0 auto; }
.wizard-panel .wizard-progress { margin-top:34px; }
.niche-detail-panel { overflow:auto; }

/* Patch 000.001.004: simplified client shell */
.brand-copy span { display:none; }
.page-description:empty { display:none; }
.topbar-button { min-height:38px; padding:0 13px; border:1px solid var(--border); border-radius:11px; background:var(--surface-soft); color:var(--text); font-weight:750; cursor:pointer; white-space:nowrap; }
.topbar-button:hover { border-color:var(--accent); color:var(--accent); }
.sidebar-bottom { margin-top:auto; display:grid; gap:8px; }
.sidebar-version { padding:0 10px; color:var(--muted); font-size:11px; }
.sidebar-bottom form { margin:0; }
.sidebar-bottom .sidebar-logout { width:100%; min-height:42px; padding:0 12px; border:1px solid var(--border); border-radius:12px; background:var(--surface-soft); }
body.sidebar-collapsed .sidebar-bottom .sidebar-version { padding:0; text-align:center; font-size:9px; overflow:hidden; }
body.sidebar-collapsed .sidebar-bottom .sidebar-logout { justify-content:center; padding:0; }
.dashboard-grid { grid-template-columns:minmax(0,1.15fr) minmax(360px,.85fr); grid-template-rows:auto minmax(260px,1fr); }
.session-panel { min-height:0; }
.organization-form .form-grid.three-columns { grid-template-columns:repeat(3,minmax(0,1fr)); }
@media (max-width:1100px) { .organization-form .form-grid.three-columns { grid-template-columns:1fr; } }

/* Patch 000.001.006: opportunities desktop */
.opportunity-workspace { width:100%; min-width:0; max-width:100%; height:100%; display:grid; grid-template-rows:auto minmax(0,1fr); gap:14px; }
.opportunity-filter-panel { padding:15px 18px; }
.opportunity-filters { display:grid; grid-template-columns:repeat(6,minmax(130px,1fr)); gap:10px; align-items:end; margin-top:13px; }
.opportunity-filters label { display:grid; gap:6px; }
.opportunity-filters label > span { color:var(--muted); font-size:11px; font-weight:800; }
.opportunity-filters select, .opportunity-filters input { width:100%; min-height:39px; border:1px solid var(--border); border-radius:10px; background:var(--surface); color:var(--text); padding:8px 10px; }
.opportunity-search { grid-column:span 2; }
.opportunity-filter-actions { display:flex; gap:8px; align-items:center; }
.opportunity-filter-actions .primary-button, .opportunity-filter-actions .secondary-button { min-height:39px; border:0; }
.opportunity-filter-actions .secondary-button { border:1px solid var(--border); }
.opportunity-list-panel { min-width:0; min-height:0; max-width:100%; display:grid; grid-template-rows:auto minmax(0,1fr) auto; padding:15px 18px; }
.opportunity-table-scroll { width:100%; min-width:0; min-height:0; max-width:100%; overflow:auto; margin-top:12px; border:1px solid var(--border); border-radius:13px; }
.opportunity-table { width:100%; min-width:860px; border-collapse:collapse; table-layout:fixed; background:var(--surface); }
.opportunity-table th, .opportunity-table td { padding:11px 10px; border-bottom:1px solid var(--border); text-align:left; vertical-align:top; }
.opportunity-table th { position:sticky; top:0; z-index:2; background:var(--surface-soft); color:var(--muted); font-size:11px; }
.opportunity-table tr:last-child td { border-bottom:0; }
.opportunity-table .col-date { width:142px; white-space:nowrap; font-size:12px; }
.opportunity-table .col-event { width:165px; }
.opportunity-table .col-priority { width:105px; }
.opportunity-table .col-status { width:120px; }
.opportunity-table .col-actions { width:150px; text-align:right; }
.opportunity-main-cell a { color:var(--text); text-decoration:none; }
.opportunity-main-cell strong, .opportunity-main-cell span, .opportunity-main-cell small { display:block; }
.opportunity-main-cell span { margin-top:4px; line-height:1.35; }
.opportunity-main-cell small { margin-top:4px; color:var(--muted); }
.row-actions { display:flex; justify-content:flex-end; gap:6px; }
.row-actions form { margin:0; }
.icon-action { width:31px; height:31px; display:inline-flex; align-items:center; justify-content:center; padding:0; border:1px solid var(--border); border-radius:9px; background:var(--surface-soft); color:var(--accent); text-decoration:none; font-weight:900; cursor:pointer; }
.icon-action.danger { color:var(--danger); }
.icon-action.is-disabled { opacity:.5; cursor:not-allowed; }
.opportunity-detail-workspace { display:grid; gap:14px; }
.opportunity-hero { display:flex; align-items:flex-start; justify-content:space-between; gap:18px; }
.opportunity-hero-main { min-width:0; }
.opportunity-hero-title { display:flex; align-items:flex-start; justify-content:space-between; gap:16px; margin-top:12px; }
.opportunity-hero-title h2 { margin:8px 0 0; font-size:24px; line-height:1.3; }
.opportunity-meta { display:flex; flex-wrap:wrap; gap:8px; align-items:center; margin-top:12px; color:var(--muted); font-size:12px; }
.opportunity-hero-actions { display:flex; gap:8px; flex-wrap:wrap; justify-content:flex-end; }
.opportunity-hero-actions form { margin:0; }
.opportunity-hero-actions button { border:0; cursor:pointer; }
.opportunity-hero-actions .secondary-button { border:1px solid var(--border); }
.opportunity-detail-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:14px; }
.detail-block { box-shadow:none; }
.detail-block p { line-height:1.55; white-space:pre-wrap; overflow-wrap:anywhere; }
.first-message-block, .history-block { grid-column:1 / -1; }
.niche-list-panel { min-height:100%; }
@media (max-width:1250px) { .opportunity-filters { grid-template-columns:repeat(3,minmax(0,1fr)); } .opportunity-search { grid-column:span 2; } }
.home-dashboard { display:grid; gap:14px; }
.home-dashboard-columns { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:14px; }
.dashboard-kpi { text-decoration:none; color:var(--text); }
.dashboard-kpi:hover { border-color:var(--accent); }
.access-summary { display:grid; grid-template-columns:170px minmax(0,1fr); gap:14px; margin-top:15px; }
.access-status-card { display:flex; flex-direction:column; align-items:center; justify-content:center; min-height:130px; border:1px solid var(--accent); border-radius:15px; background:var(--accent-soft); text-align:center; }
.access-status-card strong { color:var(--accent); font-size:22px; }
.access-status-card span { margin-top:6px; color:var(--muted); font-size:12px; }
.access-summary dl { display:grid; grid-template-columns:1fr auto; gap:10px 14px; margin:0; align-content:center; }
.access-summary dt { color:var(--muted); font-size:12px; }
.access-summary dd { margin:0; font-weight:800; text-align:right; }
.account-compact { display:grid; gap:9px; margin-top:15px; }
.account-compact > div { display:flex; justify-content:space-between; gap:14px; padding:12px; border:1px solid var(--border); border-radius:11px; background:var(--surface-soft); }
.account-compact span { color:var(--muted); font-size:12px; }
@media (max-width:1050px) { .home-dashboard-columns { grid-template-columns:1fr; } }

/* Patch 000.001.007: leadership buy-in assistant desktop */
.buyin-workspace { display: grid; gap: 14px; padding-bottom: 18px; }
.buyin-intro-panel, .buyin-settings-panel, .buyin-examples-panel, .buyin-document-panel, .buyin-objections-panel, .buyin-history-panel { padding: 16px 18px; }
.buyin-result-strip { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; margin-top: 13px; }
.buyin-result-strip > div { padding: 12px 13px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-soft); }
.buyin-result-strip strong, .buyin-result-strip span { display: block; }
.buyin-result-strip span { margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.buyin-builder { display: grid; grid-template-columns: minmax(420px,.85fr) minmax(540px,1.15fr); gap: 14px; align-items: start; }
.buyin-settings-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 11px; margin-top: 13px; }
.buyin-settings-grid .field { min-width: 0; }
.buyin-wide-field { grid-column: 1 / -1; }
.buyin-settings-grid input, .buyin-settings-grid select { width: 100%; }
.buyin-economics { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; margin-top: 14px; }
.buyin-economics > div { display: grid; gap: 5px; padding: 11px 12px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface-soft); }
.buyin-economics span { color: var(--muted); font-size: 11px; }
.buyin-economics strong { font-size: 19px; }
.buyin-example-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; margin-top: 12px; }
.buyin-example-card { position: relative; display: grid; gap: 5px; min-height: 122px; padding: 14px 12px 12px 42px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface-soft); cursor: pointer; }
.buyin-example-card:hover { border-color: var(--accent); }
.buyin-example-card input { position: absolute; opacity: 0; pointer-events: none; }
.buyin-example-check { position: absolute; left: 12px; top: 13px; width: 21px; height: 21px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: 7px; color: transparent; background: var(--surface); font-weight: 900; }
.buyin-example-card:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
.buyin-example-card:has(input:checked) .buyin-example-check { color: #fff; background: var(--accent); border-color: var(--accent); }
.buyin-example-kind { justify-self: start; padding: 2px 7px; border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 10px; font-weight: 850; }
.buyin-example-card.is-real .buyin-example-kind { color: var(--success); background: color-mix(in srgb,var(--success) 10%,var(--surface)); }
.buyin-example-card strong { line-height: 1.3; }
.buyin-example-card > span:not(.buyin-example-check):not(.buyin-example-kind) { line-height: 1.35; }
.buyin-example-card small { color: var(--muted); }
.buyin-generate-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 14px; }
.buyin-generate-row > span { color: var(--muted); font-size: 12px; line-height: 1.4; }
.buyin-generate-row button { border: 0; cursor: pointer; min-width: 220px; }
.buyin-document-actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin: 10px 0 14px; }
.buyin-document-actions button { cursor: pointer; }
.buyin-document-actions .secondary-button.is-active { color: #fff; background: var(--accent); border-color: var(--accent); }
.buyin-preview { max-height: 760px; overflow: auto; padding: 22px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.buyin-objections-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
.buyin-empty-document { padding: 28px; text-align: center; }
.buyin-empty-document p { color: var(--muted); }
@media (max-width:1250px) {
  .buyin-builder { grid-template-columns: 1fr; }
  .buyin-settings-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .buyin-wide-field { grid-column: span 2; }
}
@media (max-width:900px) {
  .buyin-result-strip, .buyin-settings-grid, .buyin-example-grid, .buyin-objections-grid { grid-template-columns: 1fr; }
  .buyin-wide-field { grid-column: auto; }
}

.buyin-generation-panel { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.buyin-settings-grid .field-label-row { margin-bottom: 4px; }

/* Buy-in assistant: idea-first flow, optional scenario and visual editor. */
.buyin-main-tabs { display:flex; gap:8px; align-items:center; }
.buyin-main-tabs a { display:inline-flex; align-items:center; gap:7px; padding:10px 16px; border:1px solid var(--border); border-radius:11px; background:var(--surface); color:var(--text); text-decoration:none; font-weight:800; }
.buyin-main-tabs a.is-active { color:#fff; background:var(--accent); border-color:var(--accent); }
.buyin-main-tabs a span { min-width:20px; height:20px; padding:0 6px; display:inline-flex; align-items:center; justify-content:center; border-radius:999px; background:var(--surface-soft); color:var(--text); font-size:11px; }
.buyin-audience-grid { display:grid; grid-template-columns:1fr 1fr; gap:12px; margin-top:13px; }
.buyin-audience-grid select { width:100%; }
.buyin-scenario-panel { grid-column:1 / -1; padding:16px 18px; }
.buyin-scenario-toggle { display:flex; align-items:center; gap:9px; width:max-content; margin-top:12px; font-weight:800; cursor:pointer; }
.buyin-scenario-toggle input { width:18px; height:18px; }
.buyin-scenario-fields { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:11px; margin-top:14px; }
.buyin-scenario-fields input { width:100%; }
.buyin-scenario-results { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:9px; margin-top:14px; }
.buyin-scenario-results > div { display:grid; gap:5px; padding:11px 12px; border:1px solid var(--border); border-radius:11px; background:var(--surface-soft); }
.buyin-scenario-results span { color:var(--muted); font-size:11px; }
.buyin-scenario-results strong { font-size:18px; }
.buyin-scenario-disclaimer { margin:12px 0 0; color:var(--muted); font-size:12px; line-height:1.45; }
.buyin-generate-row-full { grid-column:1 / -1; margin-top:0; padding:0 2px; }
.warning-text { color:var(--danger); font-weight:800; }
.buyin-document-heading { align-items:center; }
.buyin-document-heading .buyin-document-actions { margin:0; flex-wrap:wrap; }
.buyin-editor-pane { display:grid; gap:16px; }
.buyin-form-block { display:grid; gap:7px; margin:0; }
.rich-editor-toolbar { display:flex; gap:5px; flex-wrap:wrap; padding:7px; border:1px solid var(--border); border-bottom:0; border-radius:11px 11px 0 0; background:var(--surface-soft); }
.rich-editor-toolbar button { min-width:34px; height:32px; padding:0 9px; border:1px solid var(--border); border-radius:8px; background:var(--surface); color:var(--text); cursor:pointer; font-weight:800; }
.rich-editor-toolbar button:hover { border-color:var(--accent); color:var(--accent); }
.rich-editor { min-height:520px; max-height:720px; overflow:auto; padding:18px 20px; border:1px solid var(--border); border-radius:0 0 11px 11px; background:var(--surface); line-height:1.55; outline:none; }
.rich-editor:focus { border-color:var(--accent); box-shadow:0 0 0 2px color-mix(in srgb,var(--accent) 15%,transparent); }
.rich-editor h1,.buyin-preview h1 { font-size:25px; margin:0 0 16px; }
.rich-editor h2,.buyin-preview h2 { font-size:20px; margin:22px 0 10px; }
.rich-editor h3,.buyin-preview h3 { font-size:16px; margin:18px 0 8px; }
.rich-editor p,.buyin-preview p { margin:0 0 10px; }
.rich-editor blockquote,.buyin-preview blockquote { margin:12px 0; padding:10px 14px; border-left:4px solid var(--accent); background:var(--accent-soft); color:var(--muted); }
.buyin-document-buttons { margin-top:0; }
.buyin-history-list-large { display:grid; gap:8px; margin-top:14px; }
.buyin-history-list-large a { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:14px; align-items:center; padding:13px 14px; border:1px solid var(--border); border-radius:11px; color:var(--text); text-decoration:none; background:var(--surface-soft); }
.buyin-history-list-large a:hover { border-color:var(--accent); }
.buyin-history-list-large span { color:var(--muted); font-size:12px; white-space:nowrap; }
.buyin-limit-note { margin-top:12px; padding:10px 12px; border:1px solid var(--border); border-radius:10px; background:var(--surface-soft); color:var(--muted); }
@media (max-width: 1280px) {
  .buyin-scenario-fields { grid-template-columns:repeat(3,minmax(0,1fr)); }
  .buyin-scenario-results { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
@media (max-width: 980px) {
  .buyin-audience-grid,.buyin-scenario-fields,.buyin-scenario-results { grid-template-columns:1fr; }
}

/* Patch 000.001.010: historical niche checks */
.history-scan-launch-panel { margin-top: 14px; }
.history-scan-launch-content { display:flex; align-items:center; justify-content:space-between; gap:18px; padding:14px; border:1px solid var(--border); border-radius:14px; background:var(--surface-soft); }
.history-scan-launch-copy { display:grid; gap:5px; }
.history-scan-launch-copy span, .history-scan-launch-copy small { color:var(--muted); line-height:1.45; }
.history-scan-recent { margin-top:16px; }
.history-scan-recent h3 { margin:0 0 8px; font-size:15px; }
.history-scan-recent-list { display:grid; grid-template-columns:repeat(auto-fit,minmax(210px,1fr)); gap:8px; }
.history-scan-recent-list a { display:grid; gap:4px; padding:11px 12px; border:1px solid var(--border); border-radius:11px; color:var(--text); text-decoration:none; background:var(--surface); }
.history-scan-recent-list a:hover { border-color:var(--accent); }
.history-scan-recent-list span, .history-scan-recent-list small { color:var(--muted); font-size:12px; }
.app-dialog { width:min(620px,calc(100vw - 32px)); border:0; border-radius:18px; padding:0; color:var(--text); background:var(--surface); box-shadow:0 28px 80px rgba(15,23,42,.28); }
.app-dialog::backdrop { background:rgba(15,23,42,.55); backdrop-filter:blur(2px); }
.app-dialog form { padding:22px; }
.dialog-heading { display:flex; align-items:flex-start; justify-content:space-between; gap:20px; margin-bottom:18px; }
.dialog-heading h2 { margin:0 0 6px; }
.dialog-heading p { margin:0; color:var(--muted); line-height:1.45; }
.dialog-close { width:36px; height:36px; border:1px solid var(--border); border-radius:10px; background:var(--surface-soft); color:var(--text); font-size:22px; }
.history-scan-periods { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:8px; }
.history-scan-periods label { cursor:pointer; }
.history-scan-periods input { position:absolute; opacity:0; pointer-events:none; }
.history-scan-periods span { min-height:48px; display:flex; align-items:center; justify-content:center; padding:8px; border:1px solid var(--border); border-radius:11px; text-align:center; font-size:12px; font-weight:800; background:var(--surface-soft); }
.history-scan-periods input:checked + span { border-color:var(--accent); background:var(--accent-soft); color:var(--accent); box-shadow:inset 0 0 0 1px var(--accent); }
.dialog-note { margin-top:14px; padding:12px; border:1px solid var(--border); border-radius:11px; background:var(--surface-soft); color:var(--muted); line-height:1.45; }
.dialog-actions { display:flex; justify-content:flex-end; gap:8px; margin-top:18px; }
.history-scan-page { display:grid; gap:14px; }
.history-scan-head-panel .back-link { display:inline-flex; margin-bottom:8px; color:var(--accent); text-decoration:none; font-weight:850; }
.history-scan-head-panel h2 { margin:0; }
.history-scan-period-line { display:flex; gap:22px; color:var(--muted); }
.history-scan-progress-panel { min-height:230px; display:flex; align-items:center; justify-content:center; }
.history-scan-progress { display:flex; align-items:center; gap:16px; max-width:560px; text-align:left; }
.history-scan-progress h2 { margin:0 0 6px; }
.history-scan-progress p { margin:0 0 6px; }
.history-scan-progress small { color:var(--muted); line-height:1.45; }
.history-scan-kpi-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:10px; }
.history-scan-kpi { display:grid; gap:8px; min-height:96px; }
.history-scan-kpi span { color:var(--muted); font-size:12px; }
.history-scan-kpi strong { font-size:30px; line-height:1; }
.history-scan-disclaimer { display:grid; gap:8px; }
.history-scan-disclaimer p { margin:0; line-height:1.5; }
.history-scan-disclaimer .primary-button { justify-self:start; margin-top:4px; }
.history-scan-table-wrap { overflow:auto; max-height:620px; }
.history-scan-table { width:100%; border-collapse:collapse; table-layout:fixed; }
.history-scan-table th { position:sticky; top:0; z-index:2; padding:10px; background:var(--surface-soft); color:var(--muted); text-align:left; font-size:11px; }
.history-scan-table td { padding:12px 10px; border-top:1px solid var(--border); vertical-align:top; line-height:1.4; }
.history-scan-table th:nth-child(1), .history-scan-table td:nth-child(1) { width:100px; }
.history-scan-table th:nth-child(2), .history-scan-table td:nth-child(2) { width:22%; }
.history-scan-table th:nth-child(3), .history-scan-table td:nth-child(3) { width:110px; }
.history-scan-table th:nth-child(4), .history-scan-table td:nth-child(4) { width:20%; }
.history-scan-table td strong, .history-scan-table td span, .history-scan-table td small { display:block; }
.history-scan-table td span, .history-scan-table td small { margin-top:4px; color:var(--muted); }
.history-scan-table td p { margin:0 0 7px; }
.history-scan-table blockquote { margin:6px 0; padding:8px 10px; border-left:3px solid var(--accent); background:var(--surface-soft); color:var(--muted); }
.history-scan-table a { color:var(--accent); font-weight:800; }
.history-scan-table tr.is-masked td { background:color-mix(in srgb,var(--surface-soft) 72%,transparent); }
.masked-result-label { display:inline-flex !important; align-items:center; min-height:34px; padding:0 12px; border:1px dashed var(--border); border-radius:9px; color:var(--muted) !important; }
.priority-pill { display:inline-flex !important; align-items:center; justify-content:center; min-height:25px; padding:0 9px; border-radius:999px; font-size:11px; font-weight:900; }
.priority-high { color:#b42318 !important; background:#fee4e2; }
.priority-medium { color:#b54708 !important; background:#fef0c7; }
.priority-low { color:#027a48 !important; background:#d1fadf; }
@media (max-width:1200px) { .history-scan-periods { grid-template-columns:repeat(3,minmax(0,1fr)); } .history-scan-kpi-grid { grid-template-columns:repeat(2,minmax(0,1fr)); } }
.buyin-history-proof-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)) auto; align-items:stretch; gap:8px; }
.buyin-history-proof-grid > div { display:grid; gap:5px; padding:11px 12px; border:1px solid var(--border); border-radius:11px; background:var(--surface-soft); }
.buyin-history-proof-grid span { color:var(--muted); font-size:11px; }
.buyin-history-proof-grid strong { font-size:22px; }
.buyin-history-proof-grid .secondary-button { align-self:stretch; justify-content:center; }

/* Patch 000.001.011: niche search profile */
.content-tabs { display:flex; align-items:center; gap:8px; margin:0 0 14px; }
.content-tab { display:inline-flex; align-items:center; justify-content:center; min-height:42px; padding:0 20px; border:1px solid var(--border); border-radius:12px; background:var(--surface); color:var(--text); text-decoration:none; font-weight:850; }
.content-tab:hover { border-color:var(--accent); color:var(--accent); }
.content-tab.is-active { border-color:var(--accent); background:var(--accent-soft); color:var(--accent); box-shadow:inset 0 -3px 0 var(--accent); }
.search-profile-heading { align-items:flex-start; }
.search-profile-heading-actions { display:flex; align-items:center; gap:9px; flex:0 0 auto; }
.search-profile-status { white-space:nowrap; }
.status-search-not_generated { background:var(--surface-soft); color:var(--muted); }
.status-search-pending,.status-search-processing,.status-search-retry { background:#fff3cd; color:#8a5a00; }
.status-search-review { background:var(--accent-soft); color:var(--accent); }
.status-search-confirmed { background:#dcfce7; color:#047857; }
.status-search-failed { background:#fee2e2; color:#b91c1c; }
.search-profile-progress,.inline-alert,.history-scan-locked-note { display:flex; align-items:flex-start; gap:12px; margin:14px 0; padding:13px 14px; border:1px solid var(--border); border-radius:12px; background:var(--surface-soft); }
.search-profile-progress > div,.inline-alert,.history-scan-locked-note { line-height:1.45; }
.search-profile-progress > div { display:grid; gap:4px; }
.inline-alert { display:grid; gap:4px; }
.inline-alert-info { border-color:color-mix(in srgb,var(--accent) 40%,var(--border)); background:var(--accent-soft); }
.inline-alert-warning { border-color:#f2c96d; background:#fff8df; }
.inline-alert-success { border-color:#86d9a4; background:#effcf4; }
.inline-alert-error { border-color:#f3a3a3; background:#fff1f1; }
.progress-spinner { width:22px; height:22px; border:3px solid var(--border); border-top-color:var(--accent); border-radius:50%; animation:search-profile-spin .8s linear infinite; flex:0 0 auto; }
@keyframes search-profile-spin { to { transform:rotate(360deg); } }
.search-profile-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:16px; margin-top:16px; }
.search-profile-column { min-width:0; }
.search-profile-label-row { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:7px; }
.search-profile-label-row label { font-weight:850; }
.search-profile-column textarea { width:100%; min-height:430px; resize:vertical; padding:13px 14px; border:1px solid var(--border); border-radius:12px; background:var(--surface); color:var(--text); font:14px/1.55 ui-monospace,SFMono-Regular,Consolas,"Liberation Mono",monospace; }
.search-profile-column textarea:focus { border-color:var(--accent); outline:none; box-shadow:0 0 0 2px color-mix(in srgb,var(--accent) 15%,transparent); }
.search-profile-column textarea:disabled { opacity:.72; cursor:not-allowed; background:var(--surface-soft); }
.search-profile-warnings { margin-top:14px; padding:13px 15px; border:1px solid #f2c96d; border-radius:12px; background:#fff8df; color:#6f4b00; }
.search-profile-warnings ul { margin:8px 0 0 18px; padding:0; }
.search-profile-warnings li + li { margin-top:5px; }
.search-profile-footer { display:flex; align-items:flex-end; justify-content:space-between; gap:18px; margin-top:16px; }
.search-profile-footnote { max-width:720px; color:var(--muted); font-size:12px; line-height:1.5; }
.search-profile-actions { display:flex; align-items:center; justify-content:flex-end; gap:8px; flex-wrap:wrap; }
.search-profile-actions form { margin:0; }
.search-profile-actions button[disabled] { opacity:.55; cursor:not-allowed; }
.history-scan-locked-note { display:grid; gap:4px; }
@media (max-width:1280px) { .search-profile-grid { grid-template-columns:repeat(2,minmax(0,1fr)); } .search-profile-column textarea { min-height:300px; } }
@media (max-width:820px) { .search-profile-grid { grid-template-columns:1fr; } .search-profile-footer { align-items:stretch; flex-direction:column; } .search-profile-actions { justify-content:stretch; } .search-profile-actions > *, .search-profile-actions button { flex:1; } }

/* Patch 000.001.012: compact keyword screen and desktop notifications */
.page-notification-stack { top: 86px; right: 22px; width: min(420px, calc(100vw - 44px)); }
.search-profile-column textarea { height: clamp(300px, calc(100vh - 520px), 430px); min-height: 300px; }
.search-profile-footer { justify-content: flex-end; margin-top: 14px; }
.search-profile-actions { margin-left: auto; }
.history-scan-launch-heading { align-items: center; }
@media (max-width: 1280px) {
  .page-notification-stack { right: 16px; width: min(390px, calc(100vw - 32px)); }
  .search-profile-column textarea { height: 300px; min-height: 300px; }
}

/* Realtime niche activation */
.niche-activation-panel {
  margin-top: 18px;
}

.niche-activation-heading {
  align-items: flex-start;
}

.niche-activation-heading p {
  margin: 6px 0 0;
}

.task-state-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  min-height: 78px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
}

.task-state-card > div {
  display: grid;
  gap: 5px;
}

.task-state-card strong {
  font-size: 16px;
}

.task-state-card span,
.task-state-card small {
  color: var(--muted);
  line-height: 1.45;
}

.task-state-card form {
  flex: 0 0 auto;
  margin: 0;
}

.task-state-progress {
  justify-content: flex-start;
}

.task-state-success {
  border-color: color-mix(in srgb, var(--success) 32%, var(--border));
}

.task-state-warning,
.task-state-ready {
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
}

.task-state-error {
  border-color: color-mix(in srgb, var(--danger) 35%, var(--border));
}

.inline-spinner {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: task-spinner 0.8s linear infinite;
}

@keyframes task-spinner {
  to { transform: rotate(360deg); }
}

/* 000.001.015: client-owned AI prompt and rich event rules */
.contract-heading { align-items:flex-start; }
.contract-heading-actions { display:flex; align-items:center; gap:10px; }
.contract-status-row { display:flex; align-items:center; gap:12px; margin:0 0 14px; }
.rules-table-wrap { overflow:auto; border:1px solid var(--border); border-radius:14px; }
.rules-table { width:100%; border-collapse:collapse; min-width:860px; }
.rules-table th, .rules-table td { padding:13px 12px; border-bottom:1px solid var(--border); text-align:left; vertical-align:top; }
.rules-table th { background:var(--surface-soft); white-space:nowrap; font-size:13px; }
.rules-table tr:last-child td { border-bottom:0; }
.rule-main-cell { width:100%; min-width:360px; }
.rule-main-cell strong, .rule-main-cell span { display:block; }
.rule-main-cell span { margin-top:5px; color:var(--muted); line-height:1.42; }
.rule-score { display:inline-flex; min-width:48px; justify-content:center; padding:5px 9px; border-radius:999px; background:var(--success-soft); font-weight:800; }
.rule-actions { display:flex; align-items:center; justify-content:flex-end; gap:6px; white-space:nowrap; }
.rule-actions form { margin:0; }
.empty-table { color:var(--muted); text-align:center !important; padding:28px !important; }
.contract-footer-actions { display:flex; justify-content:flex-end; align-items:center; gap:10px; margin-top:16px; }
.rule-dialog { width:min(820px,calc(100vw - 32px)); }
.rule-form-grid { display:grid; grid-template-columns:1fr 1fr; gap:14px; }
.rule-form-grid label { display:flex; flex-direction:column; gap:6px; font-weight:700; }
.rule-form-grid label small { color:var(--muted); font-weight:400; }
.rule-form-grid .full-field { grid-column:1 / -1; }
.rule-form-grid textarea { min-height:100px; resize:vertical; }
.ai-prompt-form label { display:flex; flex-direction:column; gap:8px; font-weight:800; }
.ai-prompt-form textarea { min-height:420px; resize:vertical; line-height:1.55; font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace; }
.ai-prompt-meta { display:flex; flex-wrap:wrap; gap:16px; margin-top:10px; color:var(--muted); font-size:13px; }
.contract-confirm-note { display:flex; align-items:center; justify-content:space-between; gap:16px; margin-top:16px; padding:14px; border:1px solid var(--warning-border); border-radius:12px; background:var(--warning-soft); }
.matched-rules-block { grid-column:1 / -1; }
.matched-rule-card { padding:15px; border:1px solid var(--border); border-radius:13px; background:var(--surface-soft); }
.matched-rule-card + .matched-rule-card { margin-top:12px; }
.matched-rule-head { display:flex; justify-content:space-between; align-items:flex-start; gap:16px; margin-bottom:10px; }
.matched-rule-head strong { font-size:16px; }
.matched-rule-score { font-weight:800; white-space:nowrap; }
.matched-rule-card dl { display:grid; grid-template-columns:180px 1fr; gap:8px 14px; margin:0; }
.matched-rule-card dt { color:var(--muted); }
.matched-rule-card dd { margin:0; line-height:1.45; }

/* 000.001.016: explicit draft/update flow and repaired rules/prompt layout */
.rules-table {
  width: 100%;
  min-width: 980px;
  table-layout: fixed;
}
.rules-table col.rules-col-main { width: auto; }
.rules-table col.rules-col-score { width: 92px; }
.rules-table col.rules-col-priority { width: 92px; }
.rules-table col.rules-col-status { width: 124px; }
.rules-table col.rules-col-actions { width: 132px; }
.rule-main-cell {
  width: auto;
  min-width: 0;
}
.rule-main-content {
  display: grid;
  gap: 7px;
  min-width: 0;
}
.rule-title {
  display: block;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.rule-definition {
  display: block;
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: normal;
}
.rule-score-cell,
.rule-priority-cell,
.rule-status-cell,
.rule-actions-cell {
  vertical-align: middle !important;
  white-space: nowrap;
}
.rule-actions-cell { padding-left: 8px !important; padding-right: 8px !important; }
.rule-actions {
  display: grid;
  grid-template-columns: repeat(3, 36px);
  align-items: center;
  justify-content: end;
  gap: 6px;
}
.rule-actions form { display: contents; }
.rule-action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  line-height: 1;
}
.contract-footer-actions-split {
  justify-content: space-between;
  align-items: flex-end;
}
.contract-confirm-group {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-left: auto;
}
.contract-confirm-hint {
  max-width: 560px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  text-align: right;
}
.ai-prompt-form {
  display: block;
  width: 100%;
}
.ai-prompt-editor-wrap {
  display: grid;
  gap: 9px;
  width: 100%;
}
.ai-prompt-editor-wrap > label {
  font-weight: 800;
}
.ai-prompt-form textarea.ai-prompt-editor {
  display: block;
  box-sizing: border-box;
  width: 100% !important;
  max-width: none;
  min-height: 460px;
  height: clamp(460px, calc(100vh - 390px), 620px);
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: 14px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  resize: vertical;
  white-space: pre-wrap;
}
.ai-prompt-form textarea.ai-prompt-editor:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 15%, transparent);
}
.ai-prompt-form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 14px;
}
.ai-prompt-meta { margin-top: 0; }
.contract-guidance-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 16px;
  padding: 15px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
}
.contract-guidance-note > div {
  display: grid;
  gap: 5px;
}
.contract-guidance-note span {
  color: var(--muted);
  line-height: 1.45;
}


/* 000.001.017: polished rule actions and cleaner AI prompt editor */
.rule-actions {
  grid-template-columns: repeat(3, 32px);
  gap: 7px;
}
.rule-action-button {
  width: 32px;
  min-width: 32px;
  height: 32px;
  min-height: 32px;
  border-radius: 9px;
  font-size: 16px;
  font-weight: 800;
  box-shadow: none;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, transform .15s ease;
}
.rule-action-button:hover {
  transform: translateY(-1px);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}
.rule-action-edit { color: var(--accent); }
.rule-action-toggle { color: var(--text); }
.rule-action-toggle:hover {
  color: var(--accent);
}
.rule-action-delete { color: var(--danger); }
.rule-action-delete:hover {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 7%, var(--surface));
  border-color: color-mix(in srgb, var(--danger) 35%, var(--border));
}
.ai-prompt-editor-wrap {
  gap: 0;
}

/* 000.001.018: dedicated event-rule editor with pinnable field guidance */
.rule-editor-back-row {
  margin-bottom: 12px;
}
.rule-editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);
  align-items: start;
  gap: 18px;
}
.rule-editor-form,
.rule-help-panel {
  min-width: 0;
}
.rule-editor-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 18px;
}
.rule-editor-heading h2,
.rule-help-heading h2 {
  margin: 0;
}
.rule-editor-heading p,
.rule-help-heading p {
  margin: 6px 0 0;
  line-height: 1.5;
}
.form-error-card {
  display: grid;
  gap: 4px;
  margin-bottom: 16px;
  padding: 13px 15px;
  border: 1px solid color-mix(in srgb, var(--danger) 38%, var(--border));
  border-radius: 12px;
  background: color-mix(in srgb, var(--danger) 7%, var(--surface));
  color: var(--danger);
}
.rule-editor-fields {
  display: grid;
  gap: 16px;
}
.rule-editor-compact-grid {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) minmax(120px, .7fr) minmax(120px, .7fr);
  gap: 14px;
}
.rule-editor-field {
  display: grid;
  gap: 7px;
}
.rule-editor-field > span {
  font-weight: 750;
  line-height: 1.3;
}
.rule-editor-field > small {
  color: var(--muted);
  line-height: 1.4;
}
.rule-editor-field input,
.rule-editor-field select,
.rule-editor-field textarea {
  box-sizing: border-box;
  width: 100%;
  max-width: none;
  font-family: inherit;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.5;
}
.rule-editor-field textarea {
  min-height: 118px;
  resize: vertical;
}
.rule-editor-field:focus-within > span {
  color: var(--accent);
}
.rule-editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.rule-help-panel {
  padding: 0;
  overflow: hidden;
  transition: box-shadow .16s ease, border-color .16s ease;
}
.rule-help-panel.is-pinned {
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 36px);
  border-color: color-mix(in srgb, var(--accent) 34%, var(--border));
  box-shadow: 0 10px 28px rgba(16, 40, 72, .12);
}
.rule-help-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 18px 15px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.rule-help-heading p {
  color: var(--muted);
  font-size: 13px;
}
.rule-help-pin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--muted);
  cursor: pointer;
}
.rule-help-pin svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transform: rotate(-28deg);
  transition: transform .16s ease, color .16s ease;
}
.rule-help-pin:hover,
.rule-help-pin:focus-visible {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 38%, var(--border));
  outline: none;
}
.rule-help-panel.is-pinned .rule-help-pin {
  color: var(--accent);
  background: var(--accent-soft);
}
.rule-help-panel.is-pinned .rule-help-pin svg {
  transform: rotate(0deg);
}
.rule-help-content {
  display: grid;
  gap: 0;
  max-height: calc(100vh - 150px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.rule-help-section {
  display: grid;
  gap: 8px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  transition: background-color .16s ease, box-shadow .16s ease;
}
.rule-help-section:last-child {
  border-bottom: 0;
}
.rule-help-section.is-active {
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
  box-shadow: inset 3px 0 0 var(--accent);
}
.rule-help-section h3 {
  margin: 0;
  font-size: 15px;
}
.rule-help-section p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.52;
}
.rule-help-example {
  display: grid;
  gap: 6px;
  padding: 10px 11px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
}
.rule-help-example strong {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.rule-help-example pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text);
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (max-width: 1180px) {
  .rule-editor-layout {
    grid-template-columns: minmax(0, 1fr) 340px;
  }
}
@media (max-width: 980px) {
  .rule-editor-layout {
    grid-template-columns: 1fr;
  }
  .rule-help-panel.is-pinned {
    position: static;
    max-height: none;
  }
  .rule-help-content {
    max-height: none;
  }
  .rule-help-pin {
    display: none;
  }
}

/* 000.001.019: common niche action, natural rule-help scrolling and safe saves */
.niche-tabs-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 14px;
}
.niche-tabs-toolbar .content-tabs {
  min-width: 0;
  margin: 0;
  flex-wrap: wrap;
}
.niche-global-action {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex: 0 0 auto;
}
.niche-global-action form { margin: 0; }
.niche-global-state {
  max-width: 260px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.3;
  text-align: right;
}
.niche-global-state.is-success { color: var(--success); }
.niche-global-state.is-warning { color: #a16207; }
.niche-global-state.is-error { color: var(--danger); }
.niche-global-state.is-ready { color: var(--accent); }
.niche-global-button { min-height: 40px; white-space: nowrap; }
.primary-button,
.secondary-button,
.icon-action,
button { cursor: pointer; }
.primary-button:disabled,
.secondary-button:disabled,
button:disabled {
  cursor: not-allowed;
  opacity: .58;
}
.rule-editor-form.is-saving { cursor: wait; }
.rule-editor-form.is-saving input,
.rule-editor-form.is-saving select,
.rule-editor-form.is-saving textarea { cursor: wait; }
.rule-editor-layout {
  grid-template-columns: minmax(0, 1fr) minmax(360px, 410px);
  gap: 20px;
}
.rule-editor-form { padding: 20px; }
.rule-help-content {
  max-height: none;
  overflow: visible;
  overscroll-behavior: auto;
}
.rule-help-panel.is-pinned .rule-help-content {
  max-height: calc(100vh - 150px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.ai-prompt-form-footer-simple {
  justify-content: flex-end;
}
@media (max-width: 1180px) {
  .niche-tabs-toolbar { align-items: flex-start; }
  .niche-global-state { display: none; }
  .rule-editor-layout { grid-template-columns: minmax(0, 1fr) 350px; }
}
@media (max-width: 980px) {
  .niche-tabs-toolbar { display: grid; grid-template-columns: 1fr; }
  .niche-global-action { justify-content: flex-start; flex-wrap: wrap; }
  .niche-global-state { display: inline; max-width: none; text-align: left; }
  .rule-editor-layout { grid-template-columns: 1fr; }
  .rule-help-panel.is-pinned { position: static; max-height: none; }
  .rule-help-panel.is-pinned .rule-help-content { max-height: none; overflow: visible; }
}

/* 000.001.020: contextual rule guidance, aligned editor and predictable navigation */
.rule-editor-layout {
  position: relative;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 390px);
  gap: 24px;
}
.rule-editor-form {
  padding: 24px;
  border-radius: 18px;
}
.rule-editor-heading {
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.rule-editor-heading h2 {
  font-size: 22px;
  line-height: 1.25;
}
.rule-editor-heading p {
  max-width: 760px;
}
.rule-editor-fields {
  gap: 10px;
}
.rule-editor-compact-grid {
  gap: 10px;
}
.rule-editor-field {
  gap: 8px;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  transition: background-color .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.rule-editor-field.is-active {
  border-color: color-mix(in srgb, var(--accent) 34%, var(--border));
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 9%, transparent);
}
.rule-editor-field > span {
  color: var(--text);
  font-size: 14px;
  font-weight: 750;
}
.rule-editor-field.is-active > span {
  color: var(--accent);
}
.rule-editor-field > small {
  font-size: 12px;
}
.rule-editor-field input,
.rule-editor-field select,
.rule-editor-field textarea {
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.rule-editor-field textarea {
  min-height: 112px;
  overflow-y: hidden;
  resize: vertical;
}
.rule-editor-field input:focus,
.rule-editor-field select:focus,
.rule-editor-field textarea:focus {
  border-color: color-mix(in srgb, var(--accent) 62%, var(--border));
  background: #fff;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 11%, transparent);
}
.rule-editor-actions {
  position: sticky;
  bottom: 0;
  z-index: 4;
  margin-top: 18px;
  padding: 16px 0 0;
  background: linear-gradient(to bottom, color-mix(in srgb, var(--surface) 0%, transparent), var(--surface) 24%);
}
.rule-help-panel {
  align-self: start;
  transform: translateY(var(--rule-help-offset, 0px));
  border-radius: 18px;
  overflow: hidden;
  transition: transform .18s ease, box-shadow .16s ease, border-color .16s ease;
}
.rule-help-panel.is-pinned {
  position: sticky;
  top: 16px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 32px);
  transform: none !important;
  overflow: hidden;
}
.rule-help-heading {
  flex: 0 0 auto;
  padding: 17px 18px 14px;
}
.rule-help-heading h2 {
  font-size: 18px;
  line-height: 1.25;
}
.rule-help-heading p {
  max-width: 290px;
  font-size: 12px;
  line-height: 1.45;
}
.rule-help-content {
  display: block;
  max-height: none;
  overflow: visible;
}
.rule-help-panel.is-pinned .rule-help-content {
  min-height: 0;
  max-height: calc(100vh - 136px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.rule-help-section[hidden] {
  display: none !important;
}
.rule-help-section {
  display: grid;
  gap: 10px;
  padding: 18px;
  border: 0;
  background: color-mix(in srgb, var(--accent) 4%, var(--surface));
}
.rule-help-section.is-active {
  box-shadow: inset 3px 0 0 var(--accent);
}
.rule-help-section h3 {
  font-size: 16px;
  line-height: 1.3;
}
.rule-help-section p {
  font-size: 13px;
  line-height: 1.55;
}
.rule-help-example {
  padding: 12px;
  border-radius: 12px;
  background: var(--surface);
}
.rule-help-example pre {
  font-size: 12px;
  line-height: 1.55;
}
@media (max-width: 1180px) {
  .rule-editor-layout {
    grid-template-columns: minmax(0, 1fr) 330px;
    gap: 16px;
  }
  .rule-editor-form { padding: 20px; }
}
@media (max-width: 980px) {
  .rule-editor-layout { grid-template-columns: 1fr; }
  .rule-help-panel,
  .rule-help-panel.is-pinned {
    position: static;
    max-height: none;
    transform: none !important;
  }
  .rule-help-panel.is-pinned .rule-help-content {
    max-height: none;
    overflow: visible;
  }
  .rule-help-pin { display: none; }
}

/* 000.001.021: hideable contextual rule help with explicit reopen control */
.rule-editor-layout.is-help-hidden {
  grid-template-columns: minmax(0, 1fr);
}
.rule-editor-layout.is-help-hidden .rule-editor-form {
  width: 100%;
}
.rule-help-panel[hidden] {
  display: none !important;
}
.rule-editor-help-open,
.rule-help-close {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-soft);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: 900 18px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease, color .15s ease, transform .15s ease;
}
.rule-editor-help-open:hover,
.rule-editor-help-open:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
}
.rule-help-heading-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}
.rule-help-close {
  color: var(--danger);
  font-size: 25px;
  font-weight: 500;
}
.rule-help-close:hover,
.rule-help-close:focus-visible {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--border));
  background: color-mix(in srgb, var(--danger) 8%, var(--surface));
  color: var(--danger);
  transform: translateY(-1px);
}

/* 000.001.023: compact user settings / profile */
.settings-tabs {
  margin-bottom: 14px;
}
.settings-profile-panel {
  width: min(100%, 680px);
}
.settings-profile-heading {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.settings-profile-heading h2 {
  margin: 0;
}
.settings-profile-form {
  display: grid;
  gap: 18px;
  width: min(100%, 420px);
  margin-top: 18px;
}
.settings-profile-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 15px;
  align-items: start;
}
.settings-profile-field {
  min-width: 0;
  width: 100%;
}
.settings-profile-field input {
  width: 100%;
  min-width: 0;
}
.settings-email-control {
  position: relative;
  width: 100%;
}
.settings-email-control input {
  width: 100%;
  padding-right: 46px;
  color: var(--muted);
  background: var(--surface-soft);
  cursor: default;
}
.settings-email-verified {
  position: absolute;
  top: 50%;
  right: 14px;
  width: 23px;
  height: 23px;
  border-radius: 999px;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #047857;
  background: color-mix(in srgb, #10b981 13%, var(--surface));
  border: 1px solid color-mix(in srgb, #10b981 38%, var(--border));
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
  pointer-events: none;
}
.settings-profile-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.settings-profile-actions .primary-button {
  min-width: 190px;
  border: 0;
}
.settings-profile-field.has-error input {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 10%, transparent);
}
.settings-profile-field-error {
  color: var(--danger) !important;
  font-weight: 700;
}
@media (max-width: 820px) {
  .settings-profile-panel,
  .settings-profile-form {
    width: 100%;
  }
  .settings-profile-actions {
    justify-content: stretch;
  }
  .settings-profile-actions .primary-button {
    width: 100%;
  }
}

/* Subscription and billing */
.subscription-current-panel,
.subscription-history-panel,
.subscription-invoice-form-panel,
.subscription-order-panel { margin-bottom:16px; }
.subscription-current-grid { display:grid; grid-template-columns:180px repeat(3,minmax(160px,1fr)); gap:12px; margin-top:14px; }
.subscription-status-card,
.subscription-current-item { min-height:96px; padding:18px; border:1px solid var(--border); border-radius:14px; background:var(--surface-soft); display:flex; flex-direction:column; justify-content:center; gap:8px; }
.subscription-status-card strong { font-size:22px; color:var(--accent); }
.subscription-status-card.status-expired strong { color:var(--danger); }
.subscription-current-item span,
.subscription-status-card span { color:var(--muted); font-size:13px; }
.subscription-current-item strong { font-size:18px; }
.subscription-plan-grid { display:grid; grid-template-columns:minmax(0,1.6fr) minmax(320px,.8fr); gap:16px; margin-bottom:16px; align-items:start; }
.subscription-plan-card { min-height:100%; }
.subscription-plan-card .panel-heading p { margin:6px 0 0; color:var(--muted); }
.subscription-price { margin-top:8px; font-size:28px; font-weight:900; color:var(--accent); }
.subscription-price small { font-size:14px; color:var(--muted); font-weight:700; }
.subscription-benefits { list-style:none; padding:0; margin:18px 0; display:grid; gap:10px; }
.subscription-benefits li { position:relative; padding-left:28px; line-height:1.45; }
.subscription-benefits li::before { content:"✓"; position:absolute; left:0; top:0; width:20px; height:20px; border-radius:50%; display:grid; place-items:center; background:var(--accent-soft); color:var(--accent); font-weight:900; }
.subscription-periods { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:10px; }
.subscription-period-card { position:relative; cursor:pointer; }
.subscription-period-card input { position:absolute; opacity:0; pointer-events:none; }
.subscription-period-card > span { display:flex; min-height:138px; flex-direction:column; gap:8px; padding:16px; border:1px solid var(--border); border-radius:14px; background:var(--surface-soft); transition:.15s ease; }
.subscription-period-card input:checked + span { border-color:var(--accent); background:var(--accent-soft); box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 12%,transparent); }
.subscription-period-card strong { font-size:16px; }
.subscription-period-card b { font-size:22px; color:var(--accent); }
.subscription-period-card small { color:var(--muted); }
.subscription-period-card em { margin-top:auto; color:var(--success); font-style:normal; font-weight:800; }
.subscription-actions { display:flex; flex-wrap:wrap; gap:10px; margin-top:16px; }
.subscription-actions .primary-button,
.subscription-actions .secondary-button { min-width:220px; justify-content:center; }
.subscription-availability-note { display:grid; gap:4px; margin-top:10px; color:var(--muted); font-size:12px; }
a[aria-disabled="true"] { pointer-events:none; opacity:.55; }
.subscription-history-table table { min-width:960px; }
.subscription-history-table td:last-child,
.subscription-history-table th:last-child { width:64px; text-align:center; }
.status-pill { display:inline-flex; align-items:center; justify-content:center; min-height:28px; padding:4px 10px; border:1px solid var(--border); border-radius:999px; background:var(--surface-soft); font-size:12px; font-weight:800; white-space:nowrap; }
.status-pill.status-paid { color:var(--success); border-color:color-mix(in srgb,var(--success) 40%,var(--border)); background:color-mix(in srgb,var(--success) 10%,var(--surface)); }
.status-pill.status-failed,
.status-pill.status-cancelled,
.status-pill.status-expired { color:var(--danger); border-color:color-mix(in srgb,var(--danger) 35%,var(--border)); background:color-mix(in srgb,var(--danger) 8%,var(--surface)); }
.status-pill.status-pending { color:#9a6500; border-color:#e7c36d; background:#fff8dc; }
.individual-plan-dialog { width:min(760px,calc(100vw - 32px)); }
.form-grid.two-columns { display:grid; grid-template-columns:1fr 1fr; gap:14px; }
.form-grid .full-width { grid-column:1 / -1; }
.compact-number-field { max-width:180px; }
.subscription-invoice-form-panel { max-width:980px; }
.subscription-invoice-form { margin-top:16px; }
.subscription-period-select { margin-bottom:20px; }
.subscription-period-select > span { display:block; margin-bottom:10px; font-weight:800; }
.subscription-period-select { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:10px; }
.subscription-period-select > span { grid-column:1 / -1; }
.subscription-period-select label { position:relative; }
.subscription-period-select label input { position:absolute; opacity:0; }
.subscription-period-select label > span { display:flex; flex-direction:column; gap:6px; min-height:104px; padding:14px; border:1px solid var(--border); border-radius:12px; background:var(--surface-soft); cursor:pointer; }
.subscription-period-select label input:checked + span { border-color:var(--accent); background:var(--accent-soft); }
.subscription-billing-fields { max-width:760px; display:grid; gap:14px; }
.subscription-billing-fields .form-row { display:grid; grid-template-columns:1fr 1fr; gap:14px; }
.subscription-billing-fields .compact-fields { grid-template-columns:180px 160px 180px; }
.subscription-billing-fields textarea { resize:vertical; }
.subscription-invoice-form .form-actions { max-width:760px; display:flex; justify-content:flex-end; gap:10px; margin-top:20px; padding-top:16px; border-top:1px solid var(--border); }
.subscription-order-panel { max-width:980px; }
.subscription-order-summary { display:grid; grid-template-columns:repeat(5,minmax(130px,1fr)); gap:10px; margin-top:16px; }
.subscription-order-summary > div { padding:14px; border:1px solid var(--border); border-radius:12px; background:var(--surface-soft); display:flex; flex-direction:column; gap:7px; }
.subscription-order-summary span { color:var(--muted); font-size:12px; }
.subscription-order-actions { display:flex; align-items:center; gap:10px; margin-top:18px; }
.subscription-order-actions form { margin:0; }
.subscription-order-note { margin-top:16px; padding:14px; border:1px solid var(--border); border-radius:12px; background:var(--surface-soft); color:var(--muted); }
.individual-success-panel { max-width:680px; text-align:center; padding:38px; }
.success-icon { width:64px; height:64px; border-radius:50%; display:grid; place-items:center; margin:0 auto 16px; background:color-mix(in srgb,var(--success) 14%,var(--surface)); color:var(--success); font-size:32px; font-weight:900; }
.individual-success-panel h2 { margin:0 0 10px; }
.individual-success-panel p { color:var(--muted); line-height:1.55; }
.individual-request-number { display:flex; justify-content:center; gap:12px; margin:20px 0; padding:14px; border-radius:12px; background:var(--surface-soft); }
@media (max-width:1100px) {
  .subscription-current-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .subscription-plan-grid { grid-template-columns:1fr; }
  .subscription-order-summary { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
@media (max-width:760px) {
  .subscription-periods,
  .subscription-period-select,
  .form-grid.two-columns,
  .subscription-billing-fields .form-row,
  .subscription-billing-fields .compact-fields { grid-template-columns:1fr; }
  .form-grid .full-width { grid-column:auto; }
  .subscription-current-grid,
  .subscription-order-summary { grid-template-columns:1fr; }
}

/* Patch 000.001.026: monitoring row and safe opportunity columns */
.opportunity-workspace { grid-template-rows:auto auto minmax(0,1fr); }
.opportunity-workspace > .monitoring-strip { margin-top:0; }
.opportunity-table .col-event, .opportunity-table .col-priority, .opportunity-table .col-status { overflow:hidden; }
.opportunity-table .col-event { width:180px; }
.opportunity-table .col-event .event-pill { display:inline-block; max-width:100%; overflow:hidden; text-overflow:ellipsis; vertical-align:top; }
.opportunity-table .col-event .event-pill { white-space:nowrap; }

/* Patch 000.001.027: three-column dashboard summary */
.home-dashboard-columns {
  grid-template-columns:minmax(300px,.86fr) minmax(390px,1.18fr) minmax(300px,.96fr);
  align-items:stretch;
}
.home-dashboard-columns > .panel { min-width:0; }
.home-dashboard-columns .access-summary { grid-template-columns:132px minmax(0,1fr); gap:12px; }
.home-dashboard-columns .access-status-card { min-height:124px; }
.home-dashboard-columns .access-status-card strong { font-size:19px; }
.home-dashboard-columns .account-compact strong { min-width:0; text-align:right; overflow-wrap:anywhere; }
.home-dashboard-columns .account-compact small { flex:0 0 auto; }
.monitoring-panel { display:flex; flex-direction:column; }
.monitoring-card-status {
  display:flex;
  align-items:center;
  gap:10px;
  margin-top:15px;
  padding:12px 13px;
  border:1px solid var(--border);
  border-radius:12px;
  background:var(--surface-soft);
}
.monitoring-card-status .monitoring-dot { margin-top:3px; }
.monitoring-card-status > div { display:grid; gap:3px; min-width:0; }
.monitoring-card-status strong { font-size:15px; line-height:1.3; }
.monitoring-card-status span { color:var(--muted); font-size:11px; line-height:1.35; }
.monitoring-card-status small { color:var(--danger); font-size:11px; font-weight:700; line-height:1.35; }
.monitoring-card-status.monitoring-checking small { color:#9b6500; }
.monitoring-card-status.monitoring-partial small { color:#9b6500; }
.monitoring-card-grid {
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:9px;
  margin-top:10px;
}
.monitoring-card-metric {
  display:grid;
  gap:5px;
  min-width:0;
  padding:10px 11px;
  border:1px solid var(--border);
  border-radius:11px;
  background:var(--surface-soft);
}
.monitoring-card-metric span { color:var(--muted); font-size:11px; line-height:1.3; }
.monitoring-card-metric strong { min-width:0; font-size:14px; line-height:1.3; overflow-wrap:anywhere; }
@media (max-width:1250px) {
  .home-dashboard-columns { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .home-dashboard-columns .account-panel { grid-column:1 / -1; }
}
@media (max-width:1100px) {
  .home-dashboard-columns { grid-template-columns:1fr; }
  .home-dashboard-columns .account-panel { grid-column:auto; }
}

/* Patch 000.001.030: dispatcher-style home dashboard and compact top bar */
.brand-block { gap:10px; }
.brand-menu-button {
  width:42px;
  height:42px;
  flex:0 0 42px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border:1px solid var(--border);
  border-radius:13px;
  background:var(--surface-soft);
  color:var(--accent);
  font-size:20px;
  font-weight:900;
  line-height:1;
  cursor:pointer;
}
.brand-menu-button:hover { border-color:var(--accent); background:var(--accent-soft); }
body.sidebar-collapsed .brand-block { justify-content:center; }
body.sidebar-collapsed .brand-menu-button { width:42px; }

.topbar { align-items:center; }
.topbar-actions { align-items:center; }
.topbar-subscription {
  min-height:42px;
  display:grid;
  align-content:center;
  gap:2px;
  padding:5px 11px;
  border:1px solid var(--border);
  border-radius:11px;
  background:var(--surface-soft);
  color:var(--text);
  text-decoration:none;
  white-space:nowrap;
}
.topbar-subscription:hover { border-color:var(--accent); }
.topbar-subscription span { color:var(--muted); font-size:10px; font-weight:650; line-height:1.1; }
.topbar-subscription strong { font-size:12px; font-weight:800; line-height:1.15; }
.topbar-icon-button,
.selector-icon > summary {
  width:42px;
  height:42px;
  min-height:42px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:0;
  border:1px solid var(--border);
  border-radius:11px;
  background:var(--surface-soft);
  color:var(--text);
  cursor:pointer;
}
.topbar-icon-button:hover,
.selector-icon > summary:hover { border-color:var(--accent); color:var(--accent); }
.topbar-icon-button svg { width:22px; height:22px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.selector-icon > summary { list-style:none; }
.selector-icon > summary::-webkit-details-marker { display:none; }
.language-code { font-size:12px; font-weight:900; letter-spacing:.02em; }
.theme-wheel {
  width:20px;
  height:20px;
  display:block;
  border:1px solid color-mix(in srgb,var(--text) 18%,transparent);
  border-radius:50%;
  background:conic-gradient(#2563eb 0 20%,#16a34a 20% 40%,#f59e0b 40% 60%,#dc2626 60% 80%,#7c3aed 80% 100%);
  box-shadow:inset 0 0 0 3px var(--surface);
}

.home-control-room { display:grid; gap:14px; }
.control-room-panel { padding:17px 18px 18px; }
.control-room-heading { align-items:center; }
.control-room-heading > div { display:flex; align-items:center; gap:16px; min-width:0; }
.control-room-heading h2 { white-space:nowrap; }
.system-state {
  display:inline-flex;
  align-items:center;
  gap:8px;
  min-height:30px;
  padding:5px 10px;
  border:1px solid var(--border);
  border-radius:999px;
  background:var(--surface-soft);
  font-size:12px;
}
.system-state-dot { width:9px; height:9px; flex:0 0 9px; border-radius:50%; background:var(--muted); box-shadow:0 0 0 4px color-mix(in srgb,var(--muted) 12%,transparent); }
.system-state-active { color:var(--success); border-color:color-mix(in srgb,var(--success) 35%,var(--border)); background:color-mix(in srgb,var(--success) 7%,var(--surface)); }
.system-state-active .system-state-dot { background:var(--success); box-shadow:0 0 0 4px color-mix(in srgb,var(--success) 14%,transparent); }
.system-state-checking { color:#9a6500; border-color:#efcc79; background:#fff9e8; }
.system-state-checking .system-state-dot { background:#d69200; box-shadow:0 0 0 4px rgba(214,146,0,.14); }
.system-state-attention { color:var(--danger); border-color:color-mix(in srgb,var(--danger) 35%,var(--border)); background:color-mix(in srgb,var(--danger) 6%,var(--surface)); }
.system-state-attention .system-state-dot { background:var(--danger); box-shadow:0 0 0 4px color-mix(in srgb,var(--danger) 13%,transparent); }
.system-state-paused,
.system-state-not_configured { color:var(--muted); }

.control-metrics {
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:10px;
  margin-top:14px;
}
.control-metric {
  min-width:0;
  min-height:92px;
  display:grid;
  align-content:space-between;
  gap:10px;
  padding:12px 13px;
  border:1px solid var(--border);
  border-radius:13px;
  background:var(--surface-soft);
  color:var(--text);
  text-decoration:none;
  transition:border-color .15s ease, transform .15s ease, background .15s ease;
}
a.control-metric:hover { border-color:var(--accent); background:var(--accent-soft); transform:translateY(-1px); }
.control-metric-head { display:flex; align-items:flex-start; justify-content:space-between; gap:8px; min-width:0; }
.control-metric-head > span { min-width:0; color:var(--muted); font-size:11px; line-height:1.3; }
.metric-help {
  width:20px;
  height:20px;
  flex:0 0 20px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:0;
  border:1px solid var(--border);
  border-radius:7px;
  background:var(--surface);
  color:var(--accent);
  font-size:11px;
  font-weight:900;
  cursor:pointer;
}
.metric-help:hover { border-color:var(--accent); }
.control-metric > strong { min-width:0; font-size:24px; line-height:1.05; overflow-wrap:anywhere; }
.control-metric > strong.control-metric-date { font-size:14px; line-height:1.25; }

.recent-priority-panel { padding:17px 18px 18px; }
.priority-board { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; margin-top:14px; }
.priority-column { min-width:0; padding:12px; border:1px solid var(--border); border-radius:14px; background:var(--surface-soft); }
.priority-column > header { display:flex; align-items:center; gap:8px; margin-bottom:10px; }
.priority-column h3 { margin:0; font-size:14px; }
.priority-column-dot { width:9px; height:9px; border-radius:50%; background:var(--muted); }
.priority-column-high .priority-column-dot { background:var(--danger); }
.priority-column-medium .priority-column-dot { background:#d69200; }
.priority-column-low .priority-column-dot { background:var(--success); }
.priority-opportunity-list { display:grid; gap:8px; }
.priority-opportunity-card {
  min-width:0;
  display:grid;
  gap:5px;
  padding:11px 12px;
  border:1px solid var(--border);
  border-radius:11px;
  background:var(--surface);
  color:var(--text);
  text-decoration:none;
  transition:border-color .15s ease, transform .15s ease;
}
.priority-opportunity-card:hover { border-color:var(--accent); transform:translateY(-1px); }
.priority-opportunity-top { display:flex; align-items:center; justify-content:space-between; gap:8px; min-width:0; }
.priority-opportunity-top time { color:var(--muted); font-size:10px; white-space:nowrap; }
.priority-opportunity-card > strong { min-width:0; font-size:13px; line-height:1.3; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.priority-opportunity-card > small { min-width:0; color:var(--muted); font-size:11px; line-height:1.35; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.opportunity-status-pill { flex:0 0 auto; display:inline-flex; align-items:center; min-height:20px; padding:2px 7px; border:1px solid var(--border); border-radius:999px; background:var(--surface-soft); color:var(--muted); font-size:9px; font-weight:850; white-space:nowrap; }
.opportunity-status-pill.status-new { color:var(--accent); border-color:color-mix(in srgb,var(--accent) 30%,var(--border)); background:var(--accent-soft); }
.opportunity-status-pill.status-in_work,
.opportunity-status-pill.status-contacted,
.opportunity-status-pill.status-replied,
.opportunity-status-pill.status-deal { color:var(--success); border-color:color-mix(in srgb,var(--success) 30%,var(--border)); background:color-mix(in srgb,var(--success) 8%,var(--surface)); }
.opportunity-status-pill.status-irrelevant { color:var(--danger); }
.priority-empty { min-height:76px; display:flex; align-items:center; justify-content:center; padding:12px; border:1px dashed var(--border); border-radius:11px; color:var(--muted); font-size:11px; line-height:1.4; text-align:center; }

@media (max-width:1200px) {
  .control-metrics { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .priority-board { grid-template-columns:1fr; }
}
@media (max-width:860px) {
  .topbar { align-items:flex-start; }
  .topbar-actions { flex-wrap:wrap; justify-content:flex-end; }
  .control-room-heading > div { align-items:flex-start; flex-direction:column; gap:8px; }
  .control-metrics { grid-template-columns:1fr; }
}

/* Patch 000.001.033: conditional scenario and individual tariff form */
.buyin-scenario-body[hidden] {
  display:none !important;
}
.individual-plan-dialog {
  width:min(880px,calc(100vw - 32px));
}
.individual-plan-form-grid {
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:14px;
}
.individual-plan-business-row,
.individual-plan-comment-field {
  grid-column:1 / -1;
}
.individual-plan-business-row {
  display:grid;
  grid-template-columns:minmax(0,1fr) minmax(0,1fr) 150px;
  gap:14px;
  align-items:end;
}
.individual-plan-business-row .compact-number-field {
  max-width:none;
}
.individual-plan-comment-field textarea {
  width:100%;
  min-height:120px;
  resize:vertical;
}
@media (max-width:760px) {
  .individual-plan-form-grid,
  .individual-plan-business-row {
    grid-template-columns:1fr;
  }
  .individual-plan-business-row,
  .individual-plan-comment-field {
    grid-column:auto;
  }
}

/* 000.001.048 — grouping opportunities from one publication */
.publication-group-row > td { padding:0 !important; background:var(--surface-soft); }
.publication-group { width:100%; }
.publication-group > summary {
  display:grid;
  grid-template-columns:142px minmax(260px,1fr) auto auto;
  align-items:center;
  gap:14px;
  min-height:66px;
  padding:11px 12px;
  cursor:pointer;
  list-style:none;
  border-bottom:1px solid transparent;
}
.publication-group > summary::-webkit-details-marker { display:none; }
.publication-group[open] > summary { border-bottom-color:var(--border); }
.publication-group-date { color:var(--muted); font-size:12px; white-space:nowrap; }
.publication-group-main { display:grid; gap:3px; min-width:0; }
.publication-group-main strong { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:14px; }
.publication-group-main small { color:var(--muted); font-size:11px; }
.publication-group-count {
  display:inline-flex;
  align-items:center;
  min-height:26px;
  padding:4px 9px;
  border:1px solid #9fc7f5;
  border-radius:999px;
  background:#edf6ff;
  color:#075db7;
  font-size:11px;
  font-style:normal;
  font-weight:700;
  white-space:nowrap;
}
.publication-group-items { display:grid; background:var(--surface); }
.publication-opportunity-item {
  display:grid;
  grid-template-columns:142px minmax(260px,1fr) 180px 105px 120px 150px;
  align-items:start;
  min-width:980px;
  border-bottom:1px solid var(--border);
}
.publication-opportunity-item:last-child { border-bottom:0; }
.publication-opportunity-item > div { min-width:0; padding:11px 10px; }
.publication-item-date { color:var(--muted); font-size:12px; white-space:nowrap; }
.publication-item-main { display:grid; gap:4px; }
.publication-item-main a { color:var(--text); text-decoration:none; }
.publication-item-main a:hover { color:var(--accent); }
.publication-item-main strong { font-size:13px; line-height:1.35; }
.publication-item-main small { color:var(--muted); font-size:11px; }
.publication-item-event,.publication-item-priority,.publication-item-status { overflow:hidden; }
.publication-item-event .event-pill { display:inline-block; max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.publication-item-actions { display:flex; justify-content:flex-end; }

.priority-publication-group { cursor:default; }
.priority-publication-group:hover { transform:none; }
.priority-publication-links { display:grid; gap:5px; margin-top:3px; }
.priority-publication-links a {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  min-width:0;
  padding:6px 7px;
  border:1px solid var(--border);
  border-radius:8px;
  background:var(--surface);
  color:var(--text);
  text-decoration:none;
}
.priority-publication-links a:hover { border-color:var(--accent); }
.priority-publication-links a span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:11px; }
.priority-publication-links a .priority-publication-copy {
  display:grid;
  gap:2px;
  min-width:0;
  white-space:normal;
}
.priority-publication-copy strong,
.priority-publication-copy small {
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.priority-publication-copy small { color:var(--muted); font-size:10px; font-weight:500; }
.priority-publication-links a em { flex:0 0 auto; }

.related-opportunities-panel { display:grid; gap:12px; }
.related-opportunities-warning {
  padding:10px 12px;
  border:1px solid #e8c06b;
  border-radius:10px;
  background:#fff8e8;
  color:#7b5200;
  font-weight:700;
}
.related-opportunities-list { display:grid; grid-template-columns:repeat(auto-fit,minmax(280px,1fr)); gap:9px; }
.related-opportunities-list > a {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  min-width:0;
  padding:11px 12px;
  border:1px solid var(--border);
  border-radius:11px;
  background:var(--surface-soft);
  color:var(--text);
  text-decoration:none;
}
.related-opportunities-list > a:hover { border-color:var(--accent); }
.related-opportunities-list > a > span:first-child { display:grid; gap:3px; min-width:0; }
.related-opportunities-list strong,.related-opportunities-list small { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.related-opportunities-list small { color:var(--muted); }
.priority-publication-meta { display:flex; align-items:center; gap:5px; flex:0 0 auto; }
.priority-publication-meta em { font-style:normal; }

/* 000.001.049 — compact indication for several rule matches in one direction. */
.direction-hit-count {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  line-height: 1.25;
  font-weight: 600;
  color: var(--muted-text, #64748b);
}

/* 000.001.055 — one consistent table style for single and grouped opportunities. */
/* 000.001.056 — group indicator follows the company name; duplicate right-side toggle removed. */
/* 000.001.057 — remove inherited grid gap so group titles align with regular opportunity rows. */
.icon-action-svg {
  width:16px;
  height:16px;
  fill:none;
  stroke:currentColor;
  stroke-width:1.8;
  stroke-linecap:round;
  stroke-linejoin:round;
}
.opportunity-table .row-actions {
  display:flex;
  justify-content:flex-end;
  gap:6px;
  flex-wrap:nowrap;
}
.opportunity-table .row-actions > .icon-action,
.opportunity-table .row-actions > form {
  flex:0 0 31px;
  width:31px;
  min-width:31px;
}
.opportunity-table .row-actions > form { margin:0; }
.opportunity-table .row-actions > .icon-action,
.opportunity-table .row-actions > form > .icon-action {
  box-sizing:border-box;
  width:31px;
  min-width:31px;
  height:31px;
  flex:0 0 31px;
  padding:0;
}
.opportunity-single-row > td {
  background:var(--surface);
}
.opportunity-single-row:hover > td,
.publication-opportunity-item:hover {
  background:color-mix(in srgb,var(--accent) 3%,var(--surface));
}
.publication-group-row > td {
  padding:0 !important;
  background:var(--surface);
}
.publication-group {
  width:100%;
}
.publication-group > summary {
  display:grid;
  grid-template-columns:142px minmax(320px,1fr) 105px 120px 150px;
  gap:0;
  align-items:center;
  min-width:860px;
  min-height:64px;
  padding:0;
  cursor:pointer;
  list-style:none;
  background:var(--surface-soft);
  border-bottom:0;
}
.publication-group > summary::-webkit-details-marker { display:none; }
.publication-group > summary:hover {
  background:color-mix(in srgb,var(--accent) 5%,var(--surface-soft));
}
.publication-group[open] > summary {
  background:color-mix(in srgb,var(--accent) 7%,var(--surface-soft));
  border-bottom:1px solid var(--border);
}
.publication-group-date {
  min-width:0;
  padding:11px 10px;
  color:var(--muted);
  font-size:12px;
  white-space:nowrap;
}
.publication-group-heading {
  min-width:0;
  padding:11px 10px;
}
.publication-group-main {
  display:grid;
  gap:3px;
  min-width:0;
}
.publication-group-title {
  display:flex;
  align-items:center;
  gap:9px;
  min-width:0;
}
.publication-group-title strong {
  min-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  font-size:14px;
  font-weight:850;
  line-height:1.3;
}
.publication-group-indicator {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  flex:0 0 30px;
  width:30px;
  height:30px;
  border:1px solid color-mix(in srgb,var(--accent) 48%,var(--border));
  border-radius:9px;
  background:var(--surface);
  color:var(--accent);
  font-size:20px;
  font-weight:800;
  line-height:1;
}
.publication-group-indicator::before { content:"+"; transform:translateY(-1px); }
.publication-group[open] .publication-group-indicator::before { content:"−"; }
.publication-group-main small {
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  color:var(--muted);
  font-size:11px;
}
.publication-group-controls {
  grid-column:3 / 6;
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:12px;
  min-width:0;
  padding:10px;
}
.publication-group-count {
  display:inline-flex;
  align-items:center;
  min-height:28px;
  padding:5px 10px;
  border:1px solid #9fc7f5;
  border-radius:999px;
  background:#edf6ff;
  color:#075db7;
  font-size:11px;
  font-style:normal;
  font-weight:700;
  white-space:nowrap;
}
.publication-group-items {
  display:grid;
  background:var(--surface);
}
.publication-opportunity-item {
  display:grid;
  grid-template-columns:142px minmax(320px,1fr) 105px 120px 150px;
  align-items:start;
  min-width:860px;
  background:var(--surface);
  border-bottom:1px solid var(--border);
}
.publication-opportunity-item:last-child { border-bottom:0; }
.publication-opportunity-item > div {
  min-width:0;
  padding:11px 10px;
}
.publication-item-date {
  color:var(--muted);
  font-size:12px;
  white-space:nowrap;
}
.publication-item-main {
  display:grid;
  gap:4px;
  padding-left:20px !important;
}
.publication-item-main a { color:var(--text); text-decoration:none; }
.publication-item-main a:hover { color:var(--accent); }
.publication-item-main strong {
  font-size:13px;
  font-weight:750;
  line-height:1.35;
}
.publication-item-main small { color:var(--muted); font-size:11px; }
.publication-item-priority,
.publication-item-status { overflow:hidden; }
.publication-item-actions {
  display:flex;
  justify-content:flex-end;
}

/* 000.001.058 — readable desktop typography and full monitoring labels. */
.panel-heading h2 {
  font-size:20px;
}
.muted-text {
  font-size:14px;
  line-height:1.45;
}
.field > span,
.opportunity-filters label > span {
  font-size:13px;
}
.field small {
  font-size:13px;
  line-height:1.45;
}

/* The eight dashboard indicators stay on one line on wide work screens. */
.control-metrics {
  grid-template-columns:repeat(8,minmax(0,1fr));
  gap:8px;
}
.control-metric {
  min-height:104px;
  padding:13px 12px;
}
.control-metric-head > span {
  font-size:13px;
  line-height:1.35;
}
.metric-help {
  width:22px;
  height:22px;
  flex-basis:22px;
  font-size:12px;
}
.control-metric > strong {
  font-size:26px;
}
.control-metric > strong.control-metric-date {
  font-size:15px;
  line-height:1.3;
}
.system-state {
  font-size:13px;
}

/* Monitoring strip: no abbreviated or unreadably small labels. */
.monitoring-strip {
  padding:12px 14px;
}
.monitoring-state strong {
  font-size:14px;
}
.monitoring-state span {
  font-size:13px;
  line-height:1.4;
}
.monitoring-values {
  gap:22px;
}
.monitoring-values > span {
  min-width:118px;
}
.monitoring-values small {
  font-size:12px;
  line-height:1.3;
  white-space:normal;
}
.monitoring-values strong {
  font-size:15px;
  line-height:1.3;
}
.monitoring-values .monitoring-last {
  min-width:142px;
}

/* Home opportunity board. */
.priority-column h3 {
  font-size:15px;
}
.priority-opportunity-top time {
  font-size:12px;
}
.priority-opportunity-card > strong {
  font-size:15px;
  line-height:1.35;
}
.priority-opportunity-card > small {
  font-size:13px;
  line-height:1.4;
}
.opportunity-status-pill {
  min-height:23px;
  padding:3px 8px;
  font-size:11px;
}
.priority-empty {
  font-size:13px;
}
.priority-publication-links a span {
  font-size:13px;
  line-height:1.35;
}
.priority-publication-copy small,
.direction-hit-count {
  font-size:12px;
}
.publication-group-count {
  font-size:12px;
}

/* Opportunities table. */
.opportunity-table th {
  font-size:13px;
  line-height:1.3;
}
.opportunity-table .col-date,
.publication-group-date,
.publication-item-date {
  font-size:13px;
}
.opportunity-main-cell strong {
  font-size:15px;
  line-height:1.35;
}
.opportunity-main-cell span {
  font-size:15px;
  line-height:1.4;
}
.opportunity-main-cell small {
  font-size:13px;
  line-height:1.4;
}
.publication-group-title strong {
  font-size:15px;
}
.publication-group-main small {
  font-size:13px;
  line-height:1.4;
}
.publication-item-main strong {
  font-size:14px;
}
.publication-item-main small {
  font-size:13px;
  line-height:1.4;
}
.opportunity-table .priority-pill,
.opportunity-table .status-pill {
  font-size:12px;
}
.table-footer {
  font-size:13px;
}

/* Niche cards and their secondary characteristics. */
.niche-card h3 {
  font-size:19px;
}
.niche-card p {
  font-size:16px;
  line-height:1.55;
}
.niche-card-meta span {
  font-size:14px;
  line-height:1.4;
}
.niche-template-admin-copy strong {
  font-size:15px;
}
.niche-template-admin-copy span {
  font-size:14px;
}

@media (max-width:1480px) {
  .control-metrics {
    grid-template-columns:repeat(4,minmax(0,1fr));
  }
}
@media (max-width:1100px) {
  .control-metrics {
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
  .monitoring-values > span,
  .monitoring-values .monitoring-last {
    min-width:0;
  }
}
@media (max-width:860px) {
  .control-metrics {
    grid-template-columns:1fr;
  }
}

/* 000.001.061 — stable opportunity detail header and complete rule labels. */
.opportunity-hero-main {
  flex:1 1 0;
  min-width:0;
}
.opportunity-hero-actions {
  flex:0 0 auto;
  flex-wrap:nowrap;
  align-items:center;
  white-space:nowrap;
}
.opportunity-hero-actions form,
.opportunity-hero-actions button {
  flex:0 0 auto;
}
.matched-rule-card dl {
  grid-template-columns:minmax(175px, 190px) minmax(0, 1fr);
}
.matched-rule-card dt {
  overflow:visible;
  text-overflow:clip;
  white-space:normal;
  overflow-wrap:normal;
}
@media (max-width:1120px) {
  .opportunity-hero {
    flex-direction:column;
  }
  .opportunity-hero-actions {
    width:100%;
    justify-content:flex-end;
  }
}

/* 000.001.074 — reserve a real layout row for administrator impersonation. */
body.admin-impersonation-active .main-area {
  grid-template-rows: auto auto minmax(0, 1fr);
}
body.admin-impersonation-active .admin-impersonation-banner {
  margin-bottom: 0;
}
body.admin-impersonation-active .page-notification-stack {
  top: 158px;
}
body.admin-impersonation-active .toast {
  top: auto;
  bottom: 24px;
  transform: translate(-50%, 20px);
}
body.admin-impersonation-active .toast.is-visible {
  transform: translate(-50%, 0);
}
