:root {
  --purple-950: #1a0a2e;
  --purple-900: #2d1257;
  --purple-700: #5b2a91;
  --gold-500: #f5a623;
  --paper: #f7f4fa;
  --surface: #ffffff;
  --border: #e6dff0;
  --ink: #21152e;
  --muted: #6e6478;
  --danger: #b4233c;
  --success: #4f3472;
  --shadow: 0 18px 48px rgba(26, 10, 46, 0.08);
  --radius: 14px;
  --font-ui: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: "Playfair Display", Georgia, serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; max-width: 100%; overflow-x: hidden; background: var(--paper); color: var(--ink); }
body { margin: 0; min-height: 100vh; max-width: 100%; overflow-x: hidden; font-family: var(--font-ui); line-height: 1.55; }
button, input, select, textarea { font: inherit; }
::selection { color: #fff; background: var(--purple-700); }
a { color: var(--purple-700); text-underline-offset: 0.2em; }
svg { width: 1.25rem; height: 1.25rem; fill: currentColor; flex: none; }
h1, h2, h3, p { margin-top: 0; }
h1, h2 { font-family: var(--font-display); color: var(--purple-950); }
h1 { margin-bottom: 0.35rem; font-size: clamp(2rem, 4vw, 3rem); line-height: 1.08; letter-spacing: -0.025em; }
h2 { margin-bottom: 0.35rem; font-size: clamp(1.3rem, 2vw, 1.65rem); line-height: 1.2; }
h3 { margin-bottom: 0.25rem; }
p { color: var(--muted); }

:focus-visible { outline: 3px solid var(--gold-500); outline-offset: 3px; }
.skip-link { position: fixed; z-index: 100; top: 0.75rem; left: 0.75rem; padding: 0.7rem 1rem; background: var(--surface); transform: translateY(-180%); }
.skip-link:focus { transform: translateY(0); }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; display: flex; width: 264px; flex-direction: column; padding: 1.5rem; color: #fff; background: var(--purple-950); }
.brand-block { display: flex; align-items: center; gap: 0.8rem; }
.brand-block strong, .brand-block small { display: block; }
.brand-block strong { font-family: var(--font-display); font-size: 1.08rem; }
.brand-block small { margin-top: 0.05rem; color: rgba(255,255,255,.64); font-size: .78rem; }
.brand-mark { display: grid; width: 2.5rem; height: 2.5rem; place-items: center; border: 1px solid rgba(245,166,35,.6); border-radius: 50%; color: var(--gold-500); font-family: var(--font-display); font-weight: 700; }
.primary-nav { display: grid; gap: 0.35rem; margin-top: 2.25rem; }
.nav-link { display: flex; min-height: 44px; align-items: center; gap: 0.75rem; padding: 0.68rem 0.75rem; border-radius: 9px; color: rgba(255,255,255,.72); text-decoration: none; }
.nav-link:hover { color: #fff; background: rgba(255,255,255,.07); }
.nav-link.is-current { color: #fff; background: var(--purple-900); box-shadow: inset 3px 0 var(--gold-500); }
.sidebar-footer { display: grid; gap: 1rem; margin-top: auto; }
.environment-badge { justify-self: start; padding: .26rem .55rem; border: 1px solid rgba(255,255,255,.22); border-radius: 999px; color: rgba(255,255,255,.72); font-size: .72rem; letter-spacing: .05em; text-transform: uppercase; }
.user-summary { display: flex; align-items: center; gap: .7rem; }
.user-summary strong, .user-summary small { display: block; }
.user-summary small { color: rgba(255,255,255,.62); }
.avatar { display: grid; width: 2.2rem; height: 2.2rem; place-items: center; border-radius: 50%; background: var(--purple-700); font-size: .76rem; font-weight: 700; }
.text-button { min-height: 44px; padding: 0; border: 0; color: rgba(255,255,255,.72); background: transparent; cursor: pointer; text-decoration: underline; text-underline-offset: .25em; }
.text-button:hover { color: #fff; }
.main-column { min-height: 100vh; margin-left: 264px; }
.mobile-header { display: none; }
.content { width: min(1180px, calc(100% - 4rem)); margin: 0 auto; padding: 3.5rem 0 5rem; }
.page-header { display: flex; align-items: end; justify-content: space-between; gap: 1.5rem; margin-bottom: 2rem; }
.page-header p, .section-heading p { margin-bottom: 0; }

.button { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; padding: .7rem 1rem; border: 1px solid transparent; border-radius: 9px; font-weight: 700; text-decoration: none; cursor: pointer; }
.button.primary { color: #fff; background: var(--purple-700); }
.button.primary:hover { background: var(--purple-900); }
.button.secondary { border-color: var(--border); color: var(--purple-900); background: var(--surface); }
.button.secondary:hover { border-color: var(--purple-700); }
.button.full { width: 100%; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }

.attention-band, .access-principle { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; margin-bottom: 1.5rem; padding: 1.25rem 1.4rem; border: 1px solid var(--border); background: #fffaf0; box-shadow: inset 0 3px var(--gold-500); }
.attention-band h2 { font-size: 1.18rem; }
.attention-band h2, .attention-band p, .access-principle p { margin-bottom: 0; }
.access-principle { justify-content: flex-start; background: var(--surface); box-shadow: inset 0 3px var(--purple-700); }
.access-principle svg { width: 2rem; height: 2rem; color: var(--purple-700); }
.dashboard-layout { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(250px, .75fr); gap: 1.5rem; }
.work-section, .team-summary { margin-bottom: 1.5rem; padding: 1.5rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.section-heading { margin-bottom: 1.2rem; }
.section-heading.inline { display: flex; align-items: end; justify-content: space-between; gap: 1rem; }
.check-list, .activity-list { margin: 0; padding: 0; list-style: none; }
.check-list li { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: .9rem; padding: .95rem 0; border-top: 1px solid var(--border); }
.check-list li:first-child { border-top: 0; }
.check-list strong, .check-list small { display: block; }
.check-list small { color: var(--muted); }
.check-icon { display: grid; width: 2rem; height: 2rem; place-items: center; border-radius: 50%; color: var(--purple-700); background: #f1eafa; }
.status-label { display: inline-flex; align-items: center; width: max-content; padding: .28rem .58rem; border-radius: 999px; font-size: .75rem; font-weight: 700; white-space: nowrap; }
.status-label.ready { color: var(--purple-900); background: #eee7f7; }
.status-label.pending { color: #744b00; background: #fff0cd; }
.status-label.planned, .status-label.neutral { color: #4e4657; background: #eeebf1; }
.status-label.disabled { color: var(--danger); background: #fdecef; }
.compact-stats { margin: 0; }
.compact-stats div { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding: 1rem 0; border-top: 1px solid var(--border); }
.compact-stats div:first-child { border-top: 0; }
.compact-stats dt { color: var(--muted); }
.compact-stats dd { margin: 0; color: var(--purple-900); font-family: var(--font-display); font-size: 1.8rem; font-weight: 700; }
.compact-stats dd.text-value { font-family: var(--font-ui); font-size: .9rem; }
.summary-strip { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); margin-bottom: 1.5rem; border-block: 1px solid var(--border); background: rgba(255,255,255,.58); }
.summary-strip div { display: flex; align-items: baseline; gap: .7rem; padding: 1rem 1.25rem; border-left: 1px solid var(--border); }
.summary-strip div:first-child { border-left: 0; }
.summary-strip strong { color: var(--purple-900); font-family: var(--font-display); font-size: 1.7rem; }
.summary-strip span { color: var(--muted); font-size: .85rem; }
.activity-list li { display: grid; grid-template-columns: 150px minmax(0,1fr) auto; gap: 1rem; padding: .9rem 0; border-top: 1px solid var(--border); }
.activity-list time, .activity-list small { color: var(--muted); font-size: .82rem; }

.responsive-table { max-width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .85rem .75rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: .75rem; letter-spacing: .04em; text-transform: uppercase; }
td strong, td small { display: block; }
td small, .muted { color: var(--muted); }
.tag { display: inline-block; margin: 0 .25rem .25rem 0; padding: .2rem .5rem; border-radius: 6px; color: var(--purple-900); background: var(--paper); font-size: .78rem; }
.team-list article { display: flex; align-items: start; justify-content: space-between; gap: 1rem; padding: 1rem 0; border-top: 1px solid var(--border); }
.team-list article:first-child { border-top: 0; }
.team-list p { margin-bottom: 0; }
.member-count { color: var(--muted); white-space: nowrap; }
.empty-state { padding: 1.5rem; text-align: center; }
.empty-state p { margin: .3rem 0 0; }
.pagination { display: flex; justify-content: center; gap: 1rem; padding-top: 1.5rem; }
.message-stack { margin-bottom: 1rem; }
.message { padding: .9rem 1rem; border: 1px solid var(--border); background: var(--surface); box-shadow: inset 0 3px var(--purple-700); }

.breadcrumbs { display: flex; gap: .55rem; margin-bottom: 1rem; color: var(--muted); font-size: .86rem; }
.breadcrumbs span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compact-page-header { align-items: center; }
.filter-bar { display: grid; grid-template-columns: minmax(220px,1fr) minmax(180px,.35fr) auto; align-items: end; gap: 1rem; margin-bottom: 1.5rem; padding: 1rem; background: #eee9f2; }
.filter-bar.compact-filter { grid-template-columns: minmax(220px,360px) auto; justify-content: start; }
.filter-bar label, .stage-form label { display: block; margin-bottom: .3rem; color: var(--ink); font-size: .78rem; font-weight: 700; }
.filter-bar input, .filter-bar select, .record-form input, .record-form select, .record-form textarea, .stage-form select { width: 100%; min-height: 46px; padding: .68rem .78rem; border: 1px solid #cfc5dc; border-radius: 8px; color: var(--ink); background: #fff; }
.filter-bar input:hover, .filter-bar select:hover, .record-form input:hover, .record-form select:hover, .record-form textarea:hover, .stage-form select:hover { border-color: var(--purple-700); }
.row-link { font-weight: 700; white-space: nowrap; }
.status-label.stage-prospect, .status-label.stage-new, .status-label.stage-triage, .status-label.stage-open { color: #4e4657; background: #eeebf1; }
.status-label.stage-client, .status-label.stage-qualified, .status-label.stage-won { color: var(--purple-900); background: #eee7f7; }
.status-label.stage-inactive, .status-label.stage-lost { color: var(--danger); background: #fdecef; }
.status-label[class*="stage-"] { max-width: 18rem; white-space: normal; }

.form-surface { max-width: 860px; padding: clamp(1.1rem,3vw,2rem); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.record-form { display: grid; gap: 1.5rem; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 1.1rem 1.25rem; }
.field-wide { grid-column: 1 / -1; }
.record-form textarea { min-height: 112px; resize: vertical; }
.field-help { color: var(--muted); }
.form-actions { display: flex; flex-wrap: wrap; gap: .75rem; padding-top: .5rem; }

.family-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin: -1rem 0 1.5rem; }
.family-heading { margin-bottom: 1.5rem; }
.family-layout { display: grid; grid-template-columns: minmax(0,1.7fr) minmax(250px,.72fr); gap: 1.5rem; }
.family-context { margin-bottom: 1.5rem; padding: 1.5rem; border-radius: var(--radius); background: var(--purple-950); color: #fff; }
.family-context h2, .family-context strong { color: #fff; }
.family-context p, .family-context .section-heading p { color: rgba(255,255,255,.7); }
.detail-list { margin: 0; }
.detail-list div { padding: .85rem 0; border-top: 1px solid rgba(255,255,255,.16); }
.detail-list div:first-child { border-top: 0; }
.detail-list dt { color: rgba(255,255,255,.64); font-size: .78rem; }
.detail-list dd { margin: .18rem 0 0; overflow-wrap: anywhere; }
.context-note { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid rgba(255,255,255,.16); }
.member-list, .operational-list { margin: 0; padding: 0; list-style: none; }
.member-list li { display: grid; grid-template-columns: auto minmax(0,1fr) minmax(170px,.8fr) auto; align-items: center; gap: .9rem; padding: 1rem 0; border-top: 1px solid var(--border); }
.member-list li:first-child, .operational-list li:first-child { border-top: 0; }
.member-list strong, .member-list small, .member-contact span, .member-contact small, .operational-list strong, .operational-list small { display: block; }
.member-list small, .member-contact, .operational-list small { color: var(--muted); }
.person-monogram { display: grid; width: 2.4rem; height: 2.4rem; place-items: center; border-radius: 50%; color: var(--purple-900); background: #eee7f7; font-weight: 700; }
.operational-list li { display: grid; grid-template-columns: minmax(0,1fr) minmax(160px,.42fr) auto; align-items: center; gap: 1rem; padding: 1rem 0; border-top: 1px solid var(--border); }
.list-meta { text-align: right; }
.list-meta .status-label { margin-left: auto; }
.compact-action { min-height: 40px; padding: .5rem .7rem; border: 1px solid var(--border); border-radius: 8px; color: var(--purple-900); background: #fff; font-weight: 700; cursor: pointer; }
.compact-action:hover { border-color: var(--purple-700); }
.empty-row { display: block !important; padding: 1.5rem 0 !important; text-align: center; }

.pipeline-board { display: grid; grid-auto-columns: minmax(285px, 320px); grid-auto-flow: column; gap: 1rem; max-width: 100%; padding: .15rem .1rem 1rem; overflow-x: auto; scroll-snap-type: x proximity; }
.pipeline-column { min-height: 260px; scroll-snap-align: start; }
.pipeline-column > header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 58px; padding: .85rem 1rem; border-bottom: 2px solid var(--purple-700); background: #eee9f2; }
.pipeline-column > header h2 { margin: 0; font: 700 .92rem/1.3 var(--font-ui); }
.pipeline-column > header span { display: grid; min-width: 1.8rem; min-height: 1.8rem; place-items: center; border-radius: 999px; color: #fff; background: var(--purple-700); font-size: .75rem; font-weight: 700; }
.pipeline-items { display: grid; gap: .75rem; padding-top: .75rem; }
.opportunity-card { display: grid; gap: .9rem; padding: 1rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.opportunity-card h3 { margin: 0; font-size: 1rem; }
.opportunity-card p { margin: .2rem 0 0; font-size: .82rem; }
.opportunity-card dl { display: grid; gap: .55rem; margin: 0; }
.opportunity-card dl div { display: grid; grid-template-columns: 84px minmax(0,1fr); gap: .5rem; }
.opportunity-card dt { color: var(--muted); font-size: .75rem; }
.opportunity-card dd { margin: 0; overflow-wrap: anywhere; font-size: .8rem; }
.stage-form { padding-top: .75rem; border-top: 1px solid var(--border); }
.stage-form select { min-height: 42px; font-size: .82rem; }
.stage-form button { width: 100%; min-height: 40px; margin-top: .5rem; border: 0; border-radius: 8px; color: #fff; background: var(--purple-700); font-weight: 700; cursor: pointer; }
.stage-form button:hover { background: var(--purple-900); }
.pipeline-empty { padding: 1.2rem; color: var(--muted); text-align: center; font-size: .85rem; }
.board-empty { min-width: min(560px, calc(100vw - 3rem)); background: var(--surface); }

.login-body { background: var(--purple-950); }
.login-shell { display: grid; min-height: 100vh; min-width: 0; grid-template-columns: minmax(360px, .9fr) minmax(520px, 1.1fr); }
.login-context { display: flex; min-width: 0; flex-direction: column; justify-content: space-between; padding: clamp(2rem, 6vw, 5.5rem); color: #fff; background: radial-gradient(circle at 20% 85%, rgba(91,42,145,.48), transparent 34%), var(--purple-950); }
.login-context h1 { max-width: 680px; color: #fff; font-size: clamp(2.4rem, 5vw, 4.8rem); }
.login-context p { max-width: 620px; color: rgba(255,255,255,.7); font-size: 1.05rem; }
.login-security-note { display: flex; align-items: center; gap: .65rem; margin-bottom: 0; font-size: .88rem !important; }
.login-panel { display: grid; min-width: 0; place-items: center; padding: 2rem; background: var(--paper); }
.login-form-wrap { width: min(100%, 430px); max-width: 100%; min-width: 0; padding: clamp(1.5rem, 4vw, 2.7rem); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.login-form-wrap h2 { font-size: 2rem; }
.stack-form { display: grid; gap: 1rem; margin-top: 1.5rem; }
.field-group { display: grid; gap: .35rem; }
.field-group label { color: var(--ink); font-size: .88rem; font-weight: 700; }
.field-group input { width: 100%; min-height: 46px; padding: .7rem .8rem; border: 1px solid #cfc5dc; border-radius: 8px; color: var(--ink); background: #fff; }
.field-group input:hover { border-color: var(--purple-700); }
.field-error { margin-bottom: 0; color: var(--danger); font-size: .82rem; }
.error-summary { margin: 1rem 0; padding: 1rem; border: 1px solid #fdecef; background: #fff2f4; box-shadow: inset 0 3px var(--danger); }
.error-summary strong, .error-summary a { display: block; color: var(--danger); }
.form-help { margin: 1.25rem 0 0; font-size: .82rem; }

@media (max-width: 860px) {
  .sidebar { transform: translateX(-105%); transition: transform .2s ease; }
  .sidebar.is-open { transform: translateX(0); }
  .main-column { margin-left: 0; }
  .mobile-header { position: sticky; top: 0; z-index: 15; display: flex; min-height: 68px; align-items: center; justify-content: space-between; padding: .75rem 1rem; color: #fff; background: var(--purple-950); }
  .brand-block.compact .brand-mark { width: 2rem; height: 2rem; }
  .icon-button { display: grid; min-width: 44px; min-height: 44px; place-items: center; border: 0; border-radius: 8px; color: #fff; background: transparent; }
  .scrim { position: fixed; inset: 0; z-index: 18; background: rgba(13,4,24,.56); }
  .content { width: min(100% - 2rem, 720px); padding: 2rem 0 4rem; }
  .dashboard-layout { grid-template-columns: 1fr; }
  .family-layout { grid-template-columns: 1fr; }
  .login-shell { grid-template-columns: 1fr; }
  .login-context { min-height: 280px; padding: 2rem; }
  .login-context h1 { font-size: clamp(2.1rem, 10vw, 3.4rem); overflow-wrap: anywhere; }
  .login-security-note { display: none; }
}

@media (max-width: 560px) {
  .page-header, .section-heading.inline, .attention-band, .team-list article { align-items: stretch; flex-direction: column; }
  .page-header { display: flex; }
  .page-header .button { width: 100%; }
  .attention-band .status-label { align-self: flex-start; }
  .work-section, .team-summary { padding: 1.05rem; }
  .check-list li { grid-template-columns: auto minmax(0,1fr); }
  .check-list .status-label { grid-column: 2; }
  .activity-list li { grid-template-columns: 1fr; gap: .2rem; }
  .summary-strip { grid-template-columns: 1fr; }
  .summary-strip div { border-top: 1px solid var(--border); border-left: 0; }
  .summary-strip div:first-child { border-top: 0; }
  .filter-bar, .filter-bar.compact-filter, .form-grid { grid-template-columns: 1fr; }
  .filter-bar .button { width: 100%; }
  .field-wide { grid-column: auto; }
  .form-actions { display: grid; }
  .member-list li { grid-template-columns: auto minmax(0,1fr); align-items: start; }
  .member-contact, .member-list .status-label { grid-column: 2; }
  .operational-list li { grid-template-columns: 1fr; gap: .45rem; }
  .list-meta { text-align: left; }
  .list-meta .status-label { margin-left: 0; }
  .pipeline-board { display: grid; grid-auto-flow: row; grid-auto-columns: auto; overflow-x: visible; scroll-snap-type: none; }
  .login-panel { padding: 1rem; }
  .login-form-wrap { padding: 1.25rem; }
}

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