:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #090a0c;
  color: #f1f3f5;
  font-synthesis: none;
  --border: #30333a;
  --panel: #141519;
  --panel-soft: #0e0f12;
  --muted: #a9adb5;
  --action: #62a8f5;
  --action-soft: #183658;
  --danger: #f0a5a5;
  --success: #68d5ad;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { min-width: 20rem; min-height: 100vh; margin: 0; background: #090a0c; }
button, input, select, textarea { font: inherit; }
button, select, input { min-height: 2.75rem; }
button {
  border: 1px solid #76b5fa; border-radius: 0.55rem; padding: 0.65rem 1rem;
  background: var(--action); color: #07090c; font-weight: 750; cursor: pointer;
}
button:hover { background: #83baf7; }
button:disabled { cursor: wait; opacity: 0.65; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 1px solid #6684a5; outline-offset: 2px;
}
.button-secondary { border-color: #41454d; background: #202227; color: #eef0f3; }
.button-secondary:hover { background: #2a2d33; }
.text-button { min-height: auto; border: 0; padding: 0.4rem; background: transparent; color: var(--action); }
.text-button:hover { background: #22242a; }
.button-link {
  display: inline-flex; min-height: 2.75rem; align-items: center; justify-content: center;
  border: 1px solid #76b5fa; border-radius: 0.55rem; padding: 0.65rem 1rem;
  background: var(--action); color: #07090c; font-weight: 750; text-decoration: none;
}
.button-link:hover { background: #83baf7; }
.button-link-secondary { border-color: #41454d; background: #202227; color: #eef0f3; }
.button-link-secondary:hover { background: #2a2d33; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.centered-shell {
  display: grid; min-height: 100vh; place-items: center; padding: 1.25rem;
  background: #090a0c;
}
.card { border: 1px solid var(--border); border-radius: 0.85rem; background: var(--panel); box-shadow: 0 1rem 3rem rgb(0 0 0 / 16%); }
.auth-card { width: min(100%, 29rem); padding: clamp(1.5rem, 5vw, 2.5rem); }
.eyebrow { margin: 0; color: #9fcaff; font-size: 0.75rem; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; }
h1 { margin: 0.45rem 0 0; font-size: clamp(2rem, 7vw, 2.8rem); line-height: 1.08; letter-spacing: -0.035em; }
h2 { margin: 0; font-size: 1.05rem; }
.intro { max-width: 42rem; margin: 0.8rem 0 0; color: #c0c3c9; line-height: 1.6; }
.muted { margin: 0.35rem 0 0; color: var(--muted); line-height: 1.45; }
.form-stack, .dialog-form { display: grid; gap: 1rem; margin-top: 1.5rem; }
label { display: grid; gap: 0.45rem; color: #d1d3d8; font-size: 0.9rem; font-weight: 650; }
input, select, textarea {
  width: 100%; border: 1px solid #3a3d44; border-radius: 0.5rem; padding: 0.65rem 0.75rem;
  background: #0d0e11; color: #f3f4f6;
}
select {
  appearance: none;
  padding-right: 2.75rem;
  background-image:
    linear-gradient(45deg, transparent 50%, #9fcaff 50%),
    linear-gradient(135deg, #9fcaff 50%, transparent 50%);
  background-position:
    calc(100% - 1.45rem) calc(50% - 0.15rem),
    calc(100% - 1.1rem) calc(50% - 0.15rem);
  background-repeat: no-repeat;
  background-size: 0.35rem 0.35rem;
  cursor: pointer;
}
select:disabled { cursor: not-allowed; opacity: 0.6; }
textarea { resize: vertical; line-height: 1.45; }
.form-status { min-height: 1.4rem; margin: 0; color: var(--muted); line-height: 1.4; }
.form-status[data-state="error"] { color: var(--danger); }
.form-status[data-state="success"] { color: var(--success); }
.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; display: flex; width: 16rem; flex-direction: column; justify-content: space-between;
  padding: 1.5rem; border-right: 1px solid #292b31; background: #101115;
}
.brand { margin: 0.35rem 0 0; font-size: 1.08rem; font-weight: 800; letter-spacing: -0.02em; }
nav { display: grid; gap: 0.4rem; margin: 2.5rem -0.6rem auto; }
nav a { border-radius: 0.5rem; padding: 0.7rem 0.8rem; color: #b2b5bc; font-weight: 650; text-decoration: none; }
nav a[aria-current="page"] { background: var(--action-soft); color: #dcecff; }
.account-block { padding-top: 1rem; border-top: 1px solid #2b2e34; }
.account-name { margin: 0; font-weight: 750; }
.account-block button { width: 100%; margin-top: 1rem; }
.workspace { margin-left: 16rem; padding: clamp(1.5rem, 5vw, 4rem); }
.page-panel { max-width: 70rem; margin: 0 auto; }
.mobile-header, .mobile-nav { display: none; }
.business-switcher { margin: 1rem 0; color: var(--muted); font-size: 0.78rem; }
.business-switcher-label { display: block; margin-bottom: 0.45rem; font-weight: 650; }
.business-menu { position: relative; }
.business-menu-button {
  display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 0.75rem;
  border-color: #3a3d44; padding: 0.65rem 0.75rem; background: #0d0e11; color: #f3f4f6;
  font-size: 0.9rem; text-align: left;
}
.business-menu-button:hover { border-color: #4a4e57; background: #111318; }
.business-menu-chevron {
  width: 0.5rem; height: 0.5rem; flex: 0 0 auto; border-right: 1.5px solid #9fcaff;
  border-bottom: 1.5px solid #9fcaff; transform: translateY(-0.15rem) rotate(45deg);
}
.business-menu-button[aria-expanded="true"] .business-menu-chevron { transform: translateY(0.15rem) rotate(225deg); }
.business-menu-popover {
  position: absolute; z-index: 20; top: calc(100% + 0.45rem); right: 0; left: 0;
  display: grid; gap: 0.25rem; max-height: min(22rem, 55vh); overflow-y: auto;
  border: 1px solid #343840; border-radius: 0.7rem; padding: 0.4rem;
  background: #14161a; box-shadow: 0 1rem 2.5rem rgb(0 0 0 / 45%);
}
.business-menu-option {
  display: flex; width: 100%; min-height: 3.6rem; align-items: center; justify-content: space-between;
  gap: 0.75rem; border: 0; border-radius: 0.5rem; padding: 0.65rem 0.7rem;
  background: transparent; color: #eef0f3; font-weight: 650; text-align: left;
}
.business-menu-option:hover { background: #20242a; }
.business-menu-option[aria-selected="true"] { background: #172b41; color: #e4f1ff; }
.business-menu-option-copy { display: grid; gap: 0.2rem; min-width: 0; }
.business-menu-option-copy strong { overflow: hidden; font-size: 0.88rem; text-overflow: ellipsis; white-space: nowrap; }
.business-menu-option-copy small { color: #9198a3; font-size: 0.7rem; font-weight: 550; }
.business-menu-check { flex: 0 0 auto; color: #9fcaff; font-size: 0.9rem; }
.sidebar .business-menu-popover { top: auto; bottom: calc(100% + 0.45rem); }
.mobile-switcher { display: none; }
.business-grid, .summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1rem; margin-top: 2rem; }
.business-card, .empty-state { padding: 1.25rem; }
.business-card h2 { margin-top: 0.65rem; font-size: 1.25rem; }
.business-card-button { min-height: 9rem; border-color: var(--border); background: var(--panel); color: #f1f3f5; text-align: left; }
.business-card-button:hover { border-color: #4e79a7; background: #191c21; }
.summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.summary-card { display: grid; gap: 0.3rem; padding: 1.1rem; }
.summary-card strong { font-size: 1.8rem; }
.summary-card span { color: var(--muted); }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-top: 2rem; }
.detail-card { padding: 1.1rem; }
.detail-card p { margin: 0.55rem 0 0; line-height: 1.5; overflow-wrap: anywhere; white-space: pre-wrap; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; }
.admin-form { margin-top: 2rem; padding: 1.25rem; }
.form-heading { display: flex; align-items: start; justify-content: space-between; gap: 1rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin: 1.2rem 0; }
fieldset { display: flex; flex-wrap: wrap; gap: 0.8rem 1.25rem; margin: 0 0 1.2rem; border: 1px solid var(--border); border-radius: 0.6rem; padding: 0.9rem; }
legend { padding: 0 0.35rem; color: #d1d3d8; font-size: 0.9rem; font-weight: 700; }
.check-row { display: flex; align-items: center; gap: 0.55rem; }
.check-row input { width: 1.1rem; min-height: 1.1rem; accent-color: var(--action); }
.user-list { display: grid; gap: 0.8rem; margin-top: 1.25rem; }
.user-card { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.15rem; }
.badges { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.7rem; }
.badge { border: 1px solid #32689f; border-radius: 99rem; padding: 0.25rem 0.55rem; background: #142b43; color: #bcdcff; font-size: 0.75rem; }
.badge-danger { border-color: #643d47; background: #2c1820; color: #f3b4b4; }
dialog { width: min(calc(100% - 2rem), 32rem); border: 1px solid #3a3d44; border-radius: 0.85rem; padding: 1.4rem; background: #141519; color: #f1f3f5; }
dialog::backdrop { background: rgb(0 0 0 / 78%); }
dialog h2 { margin-top: 0.35rem; font-size: 1.35rem; }
dialog fieldset { display: grid; margin: 0; }
dialog hr { width: 100%; border: 0; border-top: 1px solid var(--border); }
.wide-dialog { width: min(calc(100% - 2rem), 48rem); max-height: calc(100vh - 2rem); }
.wide-dialog .form-grid { margin: 0; }
.form-note { margin: 0; color: var(--muted); font-size: 0.9rem; line-height: 1.5; }
.field-hint { color: var(--muted); font-size: 0.75rem; font-weight: 500; }
.full-field { grid-column: 1 / -1; }
.action-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.25rem; }
.filter-bar {
  display: grid; grid-template-columns: minmax(12rem, 1fr) auto; gap: 0.65rem;
  align-items: end; margin-top: 1.5rem;
}
.lead-filter-bar { grid-template-columns: minmax(12rem, 1fr) minmax(9rem, 0.35fr) minmax(9rem, 0.35fr) auto; }
.record-list { display: grid; gap: 0.75rem; margin-top: 1rem; }
.record-card {
  display: flex; width: 100%; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 1rem 1.15rem; text-align: left;
}
.record-card-button { border-color: var(--border); background: var(--panel); color: #f1f3f5; }
.record-card-button:hover { border-color: #4e79a7; background: #191c21; }
.record-card > :first-child { min-width: 0; }
.record-actions { display: flex; flex: 0 0 auto; flex-wrap: wrap; gap: 0.5rem; }
.record-title-row { display: flex; align-items: center; gap: 0.6rem; }
.record-summary { margin: 0.5rem 0 0; color: #d1d4d9; line-height: 1.45; }
.record-meta { margin: 0.55rem 0 0; color: var(--muted); font-size: 0.82rem; line-height: 1.4; }
.record-arrow { flex: 0 0 auto; color: #9fcaff; font-size: 1.8rem; }
.lead-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(18rem, 0.75fr); gap: 1rem; align-items: start; }
.lead-layout > .admin-form { margin-top: 1.5rem; }
.activity-stack { display: grid; gap: 1rem; margin-top: 1.5rem; }
.activity-stack .admin-form { margin: 0; }
.activity-card { padding: 1.25rem; }
.timeline { display: grid; gap: 0.85rem; margin-top: 1rem; }
.timeline-entry { padding-left: 0.8rem; border-left: 2px solid #33485f; }
.timeline-entry p { margin: 0; color: #d9dce1; line-height: 1.45; white-space: pre-wrap; }
.timeline-entry small { display: block; margin-top: 0.3rem; color: var(--muted); }

@media (max-width: 45rem) {
  .sidebar { display: none; }
  .workspace { margin: 0; padding: 1.25rem; }
  .mobile-header { display: flex; align-items: center; justify-content: space-between; margin: -1.25rem -1.25rem 1.75rem; padding: 1rem 1.25rem; border-bottom: 1px solid #292b31; background: #101115; }
  .mobile-nav { display: flex; gap: 0.35rem; margin: 0 0 1.75rem; }
  .mobile-nav a { flex: 1; text-align: center; }
  .mobile-switcher { display: grid; margin: 0 0 1.75rem; }
  .mobile-switcher .business-menu-popover { top: calc(100% + 0.45rem); bottom: auto; }
  .page-heading { align-items: start; flex-wrap: wrap; }
  .form-grid { grid-template-columns: 1fr; }
  .user-card { align-items: start; }
  .summary-grid, .detail-grid { grid-template-columns: 1fr; }
  .full-field { grid-column: auto; }
  .filter-bar, .lead-filter-bar { grid-template-columns: 1fr; }
  .record-card { align-items: start; }
  .record-actions { justify-content: end; }
  .lead-layout { grid-template-columns: 1fr; }
}

@media (max-width: 31rem) {
  .mobile-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .record-card { display: grid; }
  .record-actions { justify-content: start; }
}

@media (prefers-reduced-motion: no-preference) {
  button, nav a { transition: background-color 150ms ease; }
}
