:root {
  --bg-primary: #090b0d;
  --bg-secondary: #0d1013;
  --surface-primary: #111519;
  --surface-secondary: #15191e;
  --surface-elevated: #191e23;
  --border-subtle: rgba(255,255,255,.07);
  --border-medium: rgba(255,255,255,.11);
  --text-primary: #f2eee6;
  --text-secondary: #a9adb3;
  --text-muted: #71767d;
  --accent-gold: #c6a665;
  --accent-gold-bright: #d6b66f;
  --accent-gold-muted: #806b43;
  --accent-gold-bg: rgba(198,166,101,.10);
  --stone: var(--bg-primary);
  --off-white: var(--text-primary);
  --graphite: var(--bg-secondary);
  --graphite-2: #080a0c;
  --slate: var(--text-secondary);
  --gold: var(--accent-gold);
  --forest: #b8985a;
  --bg: var(--bg-primary);
  --panel: var(--surface-primary);
  --panel-2: var(--surface-secondary);
  --ink: var(--text-primary);
  --muted: var(--text-secondary);
  --line: var(--border-subtle);
  --line-dark: var(--border-subtle);
  --accent: var(--accent-gold);
  --accent-2: var(--accent-gold-bright);
  --danger: #c86a65;
  --warn: #d1a860;
  --ok: #70a889;
  --shadow: 0 20px 52px rgba(0,0,0,.36);
  --serif: "DM Serif Display", Georgia, "Times New Roman", serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 14px/1.45 var(--sans);
  color: var(--ink);
  background: var(--bg);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
::selection { background: rgba(164, 124, 72, 0.26); }

.app { min-height: 100vh; display: block; }
.app-bar {
  height: 58px;
  position: sticky;
  top: 0;
  z-index: 8;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 460px) minmax(0, 1fr);
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  color: var(--off-white);
  background: var(--graphite);
  border-bottom: 1px solid rgba(255,255,255,0.09);
  box-shadow: 0 5px 18px rgba(25,26,28,0.14);
}
.app-bar-start, .app-bar-end, .compact-brand, .drawer-brand, .account-summary { display: flex; align-items: center; }
.app-bar-start { gap: 10px; }
.app-bar-end { gap: 14px; justify-self: end; }
.mobile-menu { flex: 0 0 auto; margin-left: 8px; }
.compact-brand { gap: 10px; border: 0; background: transparent; color: var(--off-white); padding: 4px; }
.compact-brand strong, .drawer-brand strong { font: 400 19px/1 var(--serif); letter-spacing: 0; }
.account-summary { gap: 8px; text-align: right; }
.account-summary strong { font-size: 12px; }
.account-summary small { color: #aaa6a0; text-transform: capitalize; }
.app-icon-button {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 4px;
  color: var(--off-white);
  background: transparent;
  font-size: 20px;
  line-height: 1;
}
.app-icon-button:hover { border-color: rgba(164,124,72,0.62); background: rgba(255,255,255,0.05); }
.nav-backdrop { position: fixed; inset: 0; z-index: 10; background: rgba(25,26,28,0.48); opacity: 0; pointer-events: none; transition: opacity 160ms ease; }
.nav-backdrop.open { opacity: 1; pointer-events: auto; }
.nav-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 11;
  width: min(310px, 88vw);
  display: flex;
  flex-direction: column;
  padding: 16px 14px;
  color: var(--off-white);
  background: var(--graphite-2);
  border-left: 1px solid rgba(255,255,255,0.1);
  box-shadow: -16px 0 42px rgba(25,26,28,0.28);
  transform: translateX(102%);
  transition: transform 180ms ease;
  overflow-y: auto;
}
.nav-drawer.open { transform: translateX(0); }
.drawer-header { display: flex; justify-content: space-between; align-items: center; padding: 0 2px 14px; border-bottom: 1px solid var(--line-dark); }
.drawer-brand { gap: 10px; }
.drawer-brand small { display: block; margin-top: 4px; color: #aaa6a0; font-size: 9px; text-transform: uppercase; letter-spacing: .08em; }
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 4px;
  background: rgba(164, 124, 72, 0.16);
  border: 1px solid rgba(164, 124, 72, 0.58);
  color: #e4c796;
  display: grid;
  place-items: center;
  font: 15px/1 var(--serif);
  letter-spacing: 0;
}
.nav-drawer nav { display: grid; gap: 18px; padding: 18px 0; }
.nav-group { display: grid; gap: 3px; }
.nav-group h2 { margin: 0 10px 5px; color: #8f8b84; font: 700 9px/1.2 var(--sans); text-transform: uppercase; letter-spacing: .1em; }
.nav-item {
  color: #d9d5cd;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 9px 10px;
  text-align: left;
  font-weight: 620;
  letter-spacing: 0;
  position: relative;
}
.nav-item::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  margin-right: 9px;
  background: rgba(251,250,248,0.28);
  vertical-align: 1px;
}
.nav-item:hover {
  background: rgba(255,255,255,0.045);
  border-color: rgba(255,255,255,0.06);
  color: #fff;
}
.nav-item.active {
  background: rgba(244, 241, 236, 0.095);
  border-color: rgba(164, 124, 72, 0.32);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--gold);
}
.nav-item.active::before { background: var(--gold); }

.main { min-width: 0; background: rgba(244, 241, 236, 0.72); }
.page-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 26px 32px 22px;
  border-bottom: 1px solid rgba(222, 216, 206, 0.9);
  background: rgba(251, 250, 248, 0.78);
  backdrop-filter: blur(14px);
}
h1 { margin: 0; font: 400 34px/1.05 var(--serif); letter-spacing: 0.005em; color: #202224; }
h2 { margin: 0; font-size: 18px; }
h3 { margin: 0 0 10px; font-size: 15px; }
p { margin: 0; }
#page-subtitle { color: var(--muted); margin-top: 7px; max-width: 680px; }
.content { padding: 26px 32px 52px; }
.actions, .row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.action-menu { position: relative; background: transparent; border: 0; }
.action-menu > summary { width: 36px; height: 34px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); cursor: pointer; list-style: none; font-weight: 800; letter-spacing: 2px; }
.action-menu > summary::-webkit-details-marker { display: none; }
.action-menu[open] > summary { border-color: var(--gold); color: var(--ink); }
.action-menu > div { position: absolute; z-index: 8; top: calc(100% + 6px); right: 0; width: 210px; display: grid; padding: 6px; border: 1px solid var(--line); border-radius: 5px; background: var(--panel); box-shadow: var(--shadow); }
.action-menu > div button { width: 100%; border: 0; background: transparent; text-align: left; }
.action-menu > div button:hover { background: rgba(164,124,72,.09); }
.action-menu .danger-text { color: var(--danger); }

.button, button.primary, button.secondary, button.ghost {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 8px 11px;
  background: var(--panel);
  color: var(--ink);
  min-height: 34px;
  font-weight: 680;
}
button.primary { background: var(--forest); border-color: var(--forest); color: var(--off-white); box-shadow: 0 1px 0 rgba(255,255,255,0.16) inset; }
button.primary:hover { background: #263b34; }
button.secondary { background: rgba(251,250,248,0.72); border-color: #d5cec2; color: #28342f; }
button.ghost { background: transparent; color: #44504d; }
button.secondary:hover, button.ghost:hover, .button:hover {
  border-color: #c9bda9;
  background: #f6f2eb;
}
.icon-button { border: 0; background: transparent; font-size: 24px; line-height: 1; }

.toolbar {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(150px, 190px) minmax(130px, 170px);
  gap: 8px;
  margin-bottom: 14px;
  align-items: center;
  background: rgba(251,250,248,0.72);
  border: 1px solid rgba(222,216,206,0.86);
  padding: 9px;
  border-radius: 5px;
}
.toolbar input, .toolbar select { width: 100%; }
.segmented-control { display: inline-flex; gap: 2px; padding: 3px; margin-bottom: 14px; border: 1px solid var(--line); border-radius: 5px; background: rgba(251,250,248,.76); }
.segmented-control button { min-height: 30px; padding: 5px 11px; border: 0; border-radius: 3px; background: transparent; color: #46504d; font-weight: 700; }
.segmented-control button.active { background: var(--graphite); color: var(--off-white); }
.import-mapping { max-height: 68vh; overflow-y: auto; padding-right: 4px; }
.import-review-form { min-width: min(880px, 82vw); }
.import-summary { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.import-row-editor { margin-top: 7px; color: var(--muted); }
.import-row-editor summary { cursor: pointer; font-size: 11px; font-weight: 700; }
.import-row-editor .form-grid { margin-top: 8px; min-width: 430px; }
.import-filename-cell { max-width: 360px; }
.import-filename-link { display: block; max-width: min(360px, 32vw); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.import-errors { display: grid; gap: 5px; padding: 10px; border-left: 2px solid var(--danger); background: rgba(200,106,101,.08); }
.import-errors p { margin: 0; font-size: 11px; color: var(--text-secondary); }
input, select, textarea {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 7px 9px;
  background: var(--off-white);
  color: var(--ink);
  min-width: 0;
  min-height: 32px;
}
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid rgba(164, 124, 72, 0.36);
  outline-offset: 2px;
}
textarea { min-height: 84px; resize: vertical; }
label { display: grid; gap: 5px; color: var(--muted); font-weight: 650; font-size: 12px; }
label span { color: var(--muted); }
.prefixed-input { display: grid; grid-template-columns: auto 1fr; align-items: center; border: 1px solid var(--line); border-radius: 4px; background: var(--off-white); overflow: hidden; }
.prefixed-input > span { padding: 7px 0 7px 10px; color: #59615e; font-weight: 760; }
.prefixed-input input { border: 0; background: transparent; outline: 0; }
.checklist-form { display: grid; gap: 14px; }
.checklist-section { display: grid; gap: 8px; }
.checklist-section + .checklist-section { border-top: 1px solid var(--line); padding-top: 14px; }
.checklist-toggle, .checklist-status { display: grid; grid-template-columns: 22px minmax(0,1fr) auto; gap: 8px; align-items: center; min-height: 34px; padding: 7px 9px; border: 1px solid rgba(222,216,206,.82); border-radius: 4px; background: rgba(251,250,248,.7); }
.checklist-toggle input { width: 16px; height: 16px; min-height: 0; accent-color: var(--forest); }
.checklist-toggle span, .checklist-status strong { color: var(--ink); font-size: 13px; }
.checklist-toggle em, .checklist-status em { color: var(--muted); font-size: 11px; font-style: normal; }
.checklist-status > span { color: var(--forest); font-weight: 800; text-align: center; }
.photo-group { display: grid; gap: 7px; padding: 11px; border-left: 2px solid rgba(164,124,72,.48); background: rgba(244,241,236,.54); }
.photo-group > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.photo-group h4 { margin: 0; color: var(--ink); font-size: 13px; }
.photo-requirements { display: grid; gap: 6px; }
.muted-group { opacity: .72; }
.segmented-field { display: flex; align-items: center; gap: 8px; font-size: 11px; }
.segmented-field select { min-height: 28px; padding: 4px 26px 4px 7px; }
.review-note { color: #8a612d; font-size: 11px; }
.checklist-overview .checklist-section { margin-top: 10px; }
.autosave-status { color: var(--muted); font-size: 11px; }
.initial-checklist { margin-top: 12px; }

.table-wrap {
  background: rgba(251,250,248,0.92);
  border: 1px solid rgba(222,216,206,0.9);
  border-radius: 5px;
  overflow-x: auto;
  box-shadow: 0 8px 28px rgba(34,35,37,0.045);
}
table { width: 100%; min-width: 760px; border-collapse: collapse; }
th, td { padding: 10px 14px; border-bottom: 1px solid rgba(222,216,206,0.72); text-align: left; vertical-align: top; }
th { color: #62676d; font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; background: #f3efe8; font-weight: 760; }
tbody tr { transition: background 120ms ease; }
tbody tr:hover { background: rgba(164,124,72,0.055); }
tbody tr:focus-within { background: rgba(47,69,61,0.07); }
tr:last-child td { border-bottom: 0; }
.link-button { border: 0; background: transparent; color: #2f453d; padding: 0; font-weight: 720; }
.link-button:hover { color: #1f302a; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }

.status, .pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 2px 8px; background: #ebe7df; color: #343938; font-size: 11px; font-weight: 760; letter-spacing: 0.02em; }
.pill.green { background: #e3ebe4; color: var(--ok); }
.pill.warn { background: #f0e6d4; color: var(--warn); }
.pill.gray { background: #ebeae7; color: #535b59; }

.grid { display: grid; gap: 16px; }
.two-col { grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.8fr); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.card {
  background: rgba(251,250,248,0.92);
  border: 1px solid rgba(222,216,206,0.9);
  border-radius: 5px;
  padding: 16px;
  box-shadow: 0 8px 28px rgba(34,35,37,0.045);
}
.card header { display: flex; justify-content: space-between; gap: 12px; align-items: start; margin-bottom: 12px; }
.card dl { display: grid; grid-template-columns: 110px 1fr; gap: 8px; margin: 0; }
.card dt { color: var(--muted); }
.card dd { margin: 0; min-width: 0; word-break: break-word; }

.pipeline { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(252px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 12px; }
.stage { background: rgba(34,35,37,0.035); border: 1px solid rgba(222,216,206,0.95); border-radius: 5px; min-height: 360px; padding: 10px; }
.stage h3 { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: #4e5553; }
.stage h3 span { font-size: 11px; background: rgba(34,35,37,0.08); color: #4d534f; border-radius: 999px; padding: 2px 7px; }
.opp-card { background: var(--off-white); border: 1px solid rgba(222,216,206,0.92); border-radius: 5px; padding: 11px; margin-bottom: 9px; box-shadow: 0 6px 16px rgba(34, 35, 37, 0.06); }
.opp-card strong { display: block; margin-bottom: 4px; }
.opp-card small { display: block; color: var(--muted); margin-bottom: 10px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.form-grid .wide { grid-column: 1 / -1; }
details { border: 1px solid rgba(222,216,206,0.9); border-radius: 5px; padding: 10px 12px; background: #f5f1ea; }
summary { font-weight: 700; cursor: pointer; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(34, 35, 37, 0.62); display: grid; place-items: center; padding: 24px; z-index: 10; }
.modal { width: min(760px, 100%); max-height: min(90vh, 860px); overflow: auto; background: var(--off-white); border-radius: 6px; box-shadow: var(--shadow); }
.modal > header { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--line); background: #f7f3ed; }
.modal h2 { font-family: var(--serif); font-weight: 400; font-size: 25px; }
.modal-body { padding: 20px; }
.hidden { display: none !important; }
.compact-fieldset { border: 1px solid var(--line); border-radius: 6px; padding: 12px; }
.compact-fieldset legend { padding: 0 6px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; }
.check-row { display: inline-flex; align-items: center; gap: 8px; min-height: 30px; margin-right: 16px; color: var(--ink); }
.tiny-action { margin-top: 6px; padding: 4px 8px; border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 4px; font-size: 12px; width: fit-content; }
.tiny-action:hover { color: var(--ink); border-color: var(--ink); }

.notice { border: 1px solid var(--line); background: var(--off-white); border-radius: 5px; padding: 11px 14px; margin: 12px 32px 0; }
.notice.error { border-color: #fecdca; background: #fffbfa; color: var(--danger); }
.notice.warn { border-color: #fedf89; background: #fffcf5; color: var(--warn); }
.notice.ok { border-color: #abefc6; background: #f6fef9; color: var(--ok); }
.empty, .loading { color: var(--muted); background: rgba(251,250,248,0.7); border: 1px dashed #d7d0c5; border-radius: 5px; padding: 24px; text-align: center; }
.empty.compact { padding: 14px; background: transparent; }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; color: var(--muted); }
.plain-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.plain-list li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.plain-list li:last-child { border-bottom: 0; }
.muted, small, .meta-line { color: var(--muted); }
.spaced { margin-top: 16px; }
.detail-actions { margin-top: 16px; }
.detail-card { max-width: 860px; }
.inline-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-top: 16px; align-items: end; }
.optional-grid { margin-top: 12px; }
.opp-title { margin-bottom: 4px; text-align: left; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

.auth-shell:empty { display: none; }
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background: linear-gradient(145deg, #202422, #303b37 56%, #252725);
}
.auth-frame { width: min(420px, 100%); }
.auth-brand { color: var(--off-white); display: flex; gap: 12px; align-items: center; margin-bottom: 22px; }
.auth-brand strong { font: 400 26px/1 var(--serif); display: block; }
.auth-brand small { color: #bab7b0; text-transform: uppercase; font-size: 10px; letter-spacing: .08em; }
.auth-panel { background: var(--off-white); border: 1px solid rgba(255,255,255,.15); border-radius: 6px; padding: 26px; box-shadow: var(--shadow); }
.auth-panel h1 { font-size: 29px; margin-bottom: 8px; }
.auth-panel > p { color: var(--muted); margin-bottom: 22px; }
.auth-panel form { display: grid; gap: 14px; }
.auth-panel .primary { width: 100%; margin-top: 4px; }
.auth-link { border: 0; background: transparent; color: var(--forest); padding: 5px 0; font-weight: 700; }
.auth-message { margin-top: 14px; color: var(--muted); }
.auth-message.error { color: var(--danger); }
.session-panel { margin-top: 18px; border-top: 1px solid var(--line-dark); padding: 15px 9px 0; display: grid; gap: 3px; }
.session-panel strong { font-size: 12px; color: var(--off-white); }
.session-panel small { color: #aaa6a0; }
.session-logout { width: fit-content; border: 0; background: transparent; color: #d1cbc1; padding: 7px 0; font-size: 12px; }
.session-logout:hover { color: #fff; }

.dashboard-intro { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 22px; }
.dashboard-intro h2 { font: 400 28px/1.1 var(--serif); }
.dashboard-intro p { margin-top: 7px; color: var(--muted); }
.scope-note { flex: 0 0 auto; color: var(--muted); font-size: 11px; border-left: 2px solid var(--gold); padding-left: 10px; }
.dashboard-metrics { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 12px; }
.metric { min-height: 112px; display: flex; flex-direction: column; justify-content: space-between; }
.metric small { text-transform: uppercase; letter-spacing: .08em; font-size: 9px; font-weight: 760; }
.metric strong { font: 400 32px/1 var(--serif); color: var(--graphite); }
.attention-list { display: grid; gap: 0; }
.attention-item { display: grid; grid-template-columns: minmax(140px, .7fr) minmax(200px, 1.3fr) auto; gap: 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.attention-item:last-child { border-bottom: 0; }
.priority-record { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 3px; text-align: left; }
.priority-record small { color: var(--text-muted); font-size: 10px; font-weight: 650; }
.future-strip { display: grid; grid-template-columns: repeat(4, minmax(140px, 1fr)); gap: 12px; }
.future-item { border-top: 1px solid var(--line); padding-top: 10px; }
.future-item strong { display: block; font-size: 12px; }
.future-item small { display: block; margin-top: 4px; }
.settings-section { padding: 18px 0; border-top: 1px solid var(--line); }
.settings-section:first-child { border-top: 0; padding-top: 0; }
.settings-section h2 { margin-bottom: 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.settings-links { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 8px; }
.settings-link { display: flex; justify-content: space-between; align-items: center; padding: 13px 14px; border: 1px solid var(--line); border-radius: 4px; background: var(--off-white); color: var(--ink); text-align: left; font-weight: 700; }
.settings-link:hover { border-color: #c9bda9; background: #f6f2eb; }
.qa-review-group { display: grid; grid-template-columns: minmax(120px, .24fr) 1fr; gap: 14px; padding: 10px 0; border-top: 1px solid var(--line); }
.qa-review-group > strong { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.qa-review-group .plain-list { margin: 0; }

@media (max-width: 860px) {
  .app-bar { padding: 0 14px; }
  .account-summary { display: none; }
  .page-header { align-items: stretch; flex-direction: column; padding: 18px; }
  h1 { font-size: 29px; }
  .content { padding: 18px; }
  .toolbar, .two-col, .form-grid { grid-template-columns: 1fr; }
  .pipeline { grid-auto-columns: minmax(240px, 86vw); }
  .dashboard-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-intro { align-items: start; flex-direction: column; }
  .future-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .attention-item { grid-template-columns: 1fr; gap: 4px; }
}

@media (max-width: 520px) {
  .compact-brand strong { font-size: 17px; }
  .dashboard-metrics, .future-strip { grid-template-columns: 1fr; }
  .metric { min-height: 92px; }
}
.metric-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin: 16px 0;
}

.metric-strip div {
  display: grid;
  gap: 4px;
}

.metric-strip strong { font-size: 1.05rem; }

.comparison-grid {
  display: grid;
  grid-template-columns: minmax(120px, .7fr) repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.merge-field {
  display: grid;
  grid-template-columns: minmax(120px, .7fr) minmax(0, 2fr);
  align-items: center;
  gap: 12px;
}

.optional-section {
  padding: 12px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.optional-section summary { cursor: pointer; font-weight: 650; }

@media (max-width: 700px) {
  .metric-strip { grid-template-columns: 1fr; }
}

/* CloseHQ executive system */
html { color-scheme: dark; }
body { min-width: 320px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.app { display: grid; grid-template-columns: 244px minmax(0, 1fr); grid-template-rows: 64px minmax(0, 1fr); min-height: 100vh; background: var(--bg-primary); }
.app-bar { grid-column: 2; grid-row: 1; position: sticky; top: 0; height: 64px; padding: 0 28px; background: rgba(13,16,19,.94); border-bottom: 1px solid var(--border-subtle); box-shadow: none; backdrop-filter: blur(18px); }
.app-bar-start .compact-brand { display: none; }
.mobile-menu { display: none; }
.nav-backdrop { display: none; }
.nav-drawer { grid-column: 1; grid-row: 1 / 3; position: sticky; inset: auto; top: 0; z-index: 11; width: 244px; height: 100vh; padding: 20px 14px 16px; transform: none; background: #080a0c; border: 0; border-right: 1px solid var(--border-subtle); box-shadow: none; }
.drawer-header { min-height: 46px; padding: 0 8px 20px; }
.drawer-header .app-icon-button { display: none; }
.drawer-brand small { color: var(--text-muted); letter-spacing: .06em; }
.brand-mark { border-color: rgba(198,166,101,.46); background: var(--accent-gold-bg); color: var(--accent-gold-bright); }
.nav-drawer nav { gap: 24px; padding-top: 24px; }
.nav-group h2 { color: #555b62; letter-spacing: .12em; }
.nav-item { min-height: 38px; padding: 9px 12px; border: 0; color: #969ba2; font-size: 13px; }
.nav-item::before { width: 5px; height: 5px; background: #454a50; }
.nav-item:hover { border: 0; color: var(--text-primary); background: rgba(255,255,255,.035); }
.nav-item.active { color: var(--text-primary); background: var(--accent-gold-bg); border: 0; box-shadow: inset 2px 0 0 var(--accent-gold); }
.session-panel { margin-top: auto; }
.main { grid-column: 2; grid-row: 2; min-width: 0; background: var(--bg-primary); }
.global-search-wrap { position: relative; width: 100%; margin: 0; }
.global-search-wrap input { width: 100%; height: 36px; padding-left: 14px; border-color: var(--border-subtle); background: #0a0d10; }
.global-search-results { position: absolute; top: 43px; inset-inline: 0; z-index: 30; padding: 6px; background: var(--surface-elevated); border: 1px solid var(--border-medium); border-radius: 6px; box-shadow: var(--shadow); }
.global-search-results button { width: 100%; display: flex; justify-content: space-between; gap: 16px; padding: 10px; color: var(--text-primary); text-align: left; border: 0; border-radius: 3px; background: transparent; }
.global-search-results button:hover { background: rgba(255,255,255,.05); }
.global-search-results button span { display: grid; }
.global-search-results small { color: var(--accent-gold); text-transform: uppercase; font-size: 9px; letter-spacing: .08em; }
.global-search-results em { color: var(--text-muted); font-style: normal; font-size: 11px; text-align: right; }
.user-avatar { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; color: #17120a; background: var(--accent-gold); font-size: 11px; font-weight: 800; }
.account-summary { display: grid; gap: 1px; align-items: center; }
.account-summary strong { color: var(--text-primary); }
.account-summary small { color: var(--text-muted); }
.page-header { min-height: 100px; padding: 24px 32px 20px; align-items: center; border-bottom-color: var(--border-subtle); background: transparent; backdrop-filter: none; }
.page-header > div:first-child { min-width: 0; text-align: left; }
.page-header .actions { flex: 0 0 auto; justify-content: flex-end; }
h1 { color: var(--text-primary); font-size: 31px; }
h2, h3 { color: var(--text-primary); }
#page-subtitle { color: var(--text-muted); font-size: 12px; }
.content { padding: 24px 32px 56px; }
.eyebrow { display: block; margin-bottom: 7px; color: var(--accent-gold); font-size: 9px; font-weight: 780; letter-spacing: .12em; text-transform: uppercase; }
.button, button.primary, button.secondary, button.ghost, button.danger { min-height: 34px; padding: 7px 12px; border-radius: 3px; }
button.primary { color: #17130c; border-color: var(--accent-gold); background: var(--accent-gold); box-shadow: none; }
button.primary:hover { border-color: var(--accent-gold-bright); background: var(--accent-gold-bright); }
button.secondary { color: var(--text-primary); border-color: var(--border-medium); background: var(--surface-secondary); }
button.ghost { color: var(--text-secondary); border-color: transparent; background: transparent; }
button.secondary:hover, button.ghost:hover, .button:hover { color: var(--text-primary); border-color: rgba(198,166,101,.36); background: var(--accent-gold-bg); }
button.danger { color: #e19a95; border: 1px solid rgba(200,106,101,.35); background: rgba(200,106,101,.08); font-weight: 720; }
button.danger:hover { color: #fff; background: rgba(200,106,101,.2); }
button:disabled { opacity: .42; cursor: not-allowed; }
input, select, textarea { color: var(--text-primary); border-color: var(--border-medium); background: #0d1114; }
input::placeholder, textarea::placeholder { color: #565c63; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline-color: rgba(198,166,101,.5); border-color: rgba(198,166,101,.45); }
label, label span { color: var(--text-secondary); }
.toolbar { border-color: var(--border-subtle); background: var(--surface-primary); }
.table-wrap { border-color: var(--border-subtle); background: var(--surface-primary); box-shadow: none; }
table { color: var(--text-secondary); }
th, td { padding: 11px 14px; border-bottom-color: var(--border-subtle); }
th { position: sticky; top: 0; z-index: 1; color: var(--text-muted); background: #0d1114; letter-spacing: .09em; }
tbody tr:hover { background: rgba(198,166,101,.045); }
.link-button { color: var(--text-primary); }
.link-button:hover { color: var(--accent-gold-bright); }
.status, .pill { border: 1px solid var(--border-subtle); color: var(--text-secondary); background: rgba(255,255,255,.045); text-transform: capitalize; }
.pill.green { color: #8dbba0; border-color: rgba(112,168,137,.24); background: rgba(112,168,137,.09); }
.pill.warn { color: #dfbd7d; border-color: rgba(198,166,101,.25); background: var(--accent-gold-bg); }
.pill.gray { color: var(--text-muted); }
.card { border-color: var(--border-subtle); border-radius: 5px; background: var(--surface-primary); box-shadow: none; }
.card dt { color: var(--text-muted); }
.card dd { color: var(--text-primary); }
.stage { min-height: 440px; border-color: var(--border-subtle); background: var(--bg-secondary); }
.stage h3 { min-height: 30px; color: var(--text-secondary); }
.stage h3 span { color: var(--accent-gold); background: var(--accent-gold-bg); }
.opp-card { border-color: var(--border-subtle); background: var(--surface-primary); box-shadow: 0 10px 26px rgba(0,0,0,.18); }
.opp-card:hover { border-color: rgba(198,166,101,.24); transform: translateY(-1px); }
.dashboard-intro { min-height: 104px; align-items: center; padding: 0 2px; }
.dashboard-intro h2 { font-size: 34px; }
.scope-note { border-left-color: var(--accent-gold-muted); color: var(--text-muted); }
.dashboard-metrics, .compact-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 1px; margin-bottom: 22px; border: 1px solid var(--border-subtle); background: var(--border-subtle); }
.metric { min-height: 118px; padding: 17px; display: flex; flex-direction: column; justify-content: space-between; background: var(--surface-primary); }
.metric small { color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em; font-size: 9px; font-weight: 760; }
.metric strong { color: var(--text-primary); font: 400 30px/1 var(--serif); }
.metric-financial strong { color: var(--accent-gold-bright); }
.metric-rule { width: 24px; height: 1px; background: var(--accent-gold-muted); }
.metric-linked { cursor: pointer; transition: background .16s ease; }
.metric-linked:hover, .metric-linked:focus-visible { background: var(--accent-gold-bg); outline: 1px solid rgba(198,166,101,.28); outline-offset: -1px; }
.compact-metrics .metric { min-height: 90px; }
.compact-metrics .metric strong { font-size: 24px; }
.lead-command-page .content { padding-top: 10px; }
.lead-kpi-strip { gap: 1px; margin-bottom: 7px; border: 0; border-top: 1px solid var(--border-subtle); border-bottom: 1px solid var(--border-subtle); }
.lead-kpi-strip .metric { min-height: 50px; padding: 7px 12px; }
.lead-kpi-strip .metric strong { font-size: 19px; }
.lead-kpi-strip .metric-rule { display: none; }
.lead-toolbar { grid-template-columns: minmax(260px, 1fr) minmax(138px, 172px) minmax(125px, 155px) auto; gap: 7px; margin-bottom: 6px; padding: 0; border: 0; border-radius: 0; background: transparent; }
.lead-toolbar input, .lead-toolbar select, .lead-toolbar button { height: 32px; min-height: 32px; padding-top: 5px; padding-bottom: 5px; }
.lead-filter-toggle { min-width: 78px; }
.lead-advanced-filters { display: grid; grid-template-columns: repeat(3, minmax(145px, 1fr)) auto; gap: 8px; align-items: end; margin: 0 0 8px; padding: 10px; border: 1px solid var(--border-subtle); background: var(--surface-primary); }
.lead-advanced-filters label span { font-size: 9px; font-weight: 760; letter-spacing: .08em; text-transform: uppercase; }
.lead-table th, .lead-table td { padding-top: 9px; padding-bottom: 9px; }
.project-filter { gap: 6px; padding: 0; border: 0; background: transparent; }
.project-filter button { color: var(--text-muted); border: 1px solid var(--border-subtle); background: var(--surface-secondary); }
.project-filter button:hover { color: var(--text-primary); border-color: var(--border-medium); background: var(--surface-elevated); }
.project-filter button.active { color: var(--accent-gold-bright); border-color: rgba(198,166,101,.5); background: var(--accent-gold-bg); box-shadow: inset 0 -2px 0 var(--accent-gold); }
.dashboard-attention { border-top: 2px solid var(--accent-gold-muted); }
.attention-count { min-width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid rgba(198,166,101,.3); color: var(--accent-gold); }
.attention-item { border-bottom-color: var(--border-subtle); }
.stage-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 1px; margin-top: 12px; background: var(--border-subtle); }
.stage-summary > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 13px 15px; background: var(--surface-secondary); }
.stage-summary span { color: var(--text-muted); font-size: 10px; text-transform: uppercase; letter-spacing: .07em; }
.stage-summary strong { color: var(--text-primary); font: 400 22px/1 var(--serif); }
.compact-control { display: flex; align-items: center; gap: 9px; }
.compact-control span { font-size: 10px; text-transform: uppercase; letter-spacing: .07em; }
.compact-control select { min-width: 130px; }
.report-filter-bar { display: flex; align-items: end; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; padding: 12px; border: 1px solid var(--border-subtle); background: var(--surface-primary); }
.report-filter-bar label { display: grid; gap: 5px; min-width: 128px; }
.report-filter-bar label span { font-size: 9px; font-weight: 760; text-transform: uppercase; letter-spacing: .08em; }
.report-filter-bar input, .report-filter-bar select { min-height: 34px; padding: 6px 9px; }
.report-summary { margin-bottom: 16px; }
.report-table { max-height: 62vh; overflow: auto; }
.report-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin-bottom: 16px; }
.report-groups .card { padding: 14px; }
.report-group-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border-subtle); color: var(--text-secondary); }
.report-group-row strong { color: var(--text-primary); }
.obligation-strip { display: grid; grid-template-columns: repeat(2, minmax(160px, 240px)); gap: 1px; margin: 0 0 16px; background: var(--border-subtle); }
.obligation-strip > div { display: grid; gap: 5px; padding: 13px 15px; background: var(--surface-primary); }
.obligation-strip small { color: var(--text-muted); text-transform: uppercase; letter-spacing: .07em; }
.obligation-strip strong { color: var(--accent-gold-bright); font: 400 22px/1 var(--serif); }
.inline-history summary { cursor: pointer; color: var(--accent-gold); }
.inline-history div { display: grid; gap: 2px; padding: 7px 0; border-bottom: 1px solid var(--border-subtle); min-width: 150px; }
.inline-history div span { color: var(--text-muted); font-size: 10px; }
.borderless { border: 0; }
.profile-hero { min-height: 126px; display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 18px; padding: 22px 24px; border: 1px solid var(--border-subtle); border-left: 2px solid var(--accent-gold-muted); background: var(--surface-primary); }
.profile-hero h2 { margin: 2px 0 6px; font: 400 34px/1.06 var(--serif); }
.profile-hero p { color: var(--text-secondary); }
.data-panel > header { padding-bottom: 10px; border-bottom: 1px solid var(--border-subtle); }
.progress-tracker { display: grid; grid-template-columns: repeat(5, minmax(120px,1fr)); gap: 1px; margin-bottom: 18px; overflow-x: auto; border: 1px solid var(--border-subtle); background: var(--border-subtle); }
.progress-step { min-width: 112px; min-height: 78px; display: grid; grid-template-columns: 23px 1fr; gap: 8px; align-content: center; padding: 11px; background: var(--surface-primary); }
.progress-step span { width: 22px; height: 22px; display: grid; place-items: center; border: 1px solid var(--border-medium); border-radius: 50%; color: var(--text-muted); font-size: 10px; }
.progress-step strong { align-self: center; color: var(--text-muted); font-size: 10px; line-height: 1.25; }
.progress-step.complete span { color: #8dbba0; border-color: rgba(112,168,137,.34); }
.progress-step.complete strong { color: var(--text-secondary); }
.progress-step.current { background: var(--accent-gold-bg); }
.progress-step.current span { color: #17130c; border-color: var(--accent-gold); background: var(--accent-gold); }
.progress-step.current strong { color: var(--text-primary); }
.clean-deal-readiness { border-top: 2px solid var(--accent-gold-muted); }
.project-summary-grid { align-items: stretch; }
.customer-summary dl, .project-at-a-glance dl, .project-details dl { grid-template-columns: minmax(108px, 150px) 1fr; }
.project-details { margin-top: 12px; background: var(--surface-secondary); }
.project-details > summary, .workflow-disclosure > summary { cursor: pointer; font-size: 11px; font-weight: 720; }
.project-details-content, .workflow-disclosure-content { margin-top: 12px; }
.workflow-disclosure { margin-top: 26px; padding: 0; border: 0; background: transparent; }
.workflow-disclosure > summary { display: flex; justify-content: space-between; gap: 16px; padding: 0 0 8px; border-bottom: 1px solid var(--border-subtle); color: var(--text-primary); text-transform: uppercase; letter-spacing: .08em; }
.workflow-disclosure > summary strong { color: var(--text-secondary); font-size: 11px; letter-spacing: 0; text-transform: none; }
.clean-deal-readiness ul { display: grid; gap: 8px; padding: 0; list-style: none; }
.clean-deal-readiness li { display: flex; justify-content: space-between; gap: 18px; padding: 9px 0; border-bottom: 1px solid var(--border-subtle); }
.clean-deal-readiness li span { color: var(--text-secondary); }
.section-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin: 26px 0 10px; padding-bottom: 8px; border-bottom: 1px solid var(--border-subtle); }
.section-heading strong { color: var(--text-secondary); font-size: 11px; font-weight: 650; }
.operational-section { align-items: start; }
.operational-panel > header { margin-bottom: 10px; }
.operational-panel ul { list-style: none; display: grid; gap: 8px; margin: 0; padding: 0; }
.operational-panel li { padding-bottom: 8px; border-bottom: 1px solid var(--border-subtle); color: var(--text-secondary); }
.comp-total { display: flex; align-items: baseline; justify-content: space-between; padding: 15px; border-top: 1px solid var(--border-medium); border-bottom: 1px solid var(--border-medium); }
.comp-total span { color: var(--text-muted); text-transform: uppercase; font-size: 10px; letter-spacing: .08em; }
.comp-total strong { color: var(--accent-gold-bright); font: 400 26px/1 var(--serif); }
.settings-link { color: var(--text-primary); border-color: var(--border-subtle); background: var(--surface-secondary); }
.settings-link:hover { border-color: rgba(198,166,101,.3); background: var(--accent-gold-bg); }
.qa-review-group { border-color: var(--border-subtle); }
.qa-review-group > strong { color: var(--text-muted); }
.modal-backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(8px); }
.modal { border-color: var(--border-medium); background: var(--surface-elevated); box-shadow: var(--shadow); }
.modal > header { border-bottom-color: var(--border-subtle); }
.modal > header, details, .optional-section { color: var(--text-primary); border-color: var(--border-subtle); background: var(--surface-secondary); }
.action-menu { border: 0; background: transparent; }
.action-menu > div { border-color: var(--border-medium); background: var(--surface-elevated); }
.action-menu > summary { border-color: var(--border-medium); color: var(--text-muted); background: transparent; }
.notice { border-color: var(--border-medium); background: var(--surface-secondary); }
.notice.error { color: #e7aaa6; border-color: rgba(200,106,101,.3); background: rgba(200,106,101,.08); }
.notice.warn { color: #dfbd7d; border-color: rgba(198,166,101,.28); background: var(--accent-gold-bg); }
.notice.ok { color: #8dbba0; border-color: rgba(112,168,137,.26); background: rgba(112,168,137,.08); }
.confirmation-summary { display: grid; grid-template-columns: 100px 1fr; gap: 8px; margin: 0; }
.confirmation-summary dt { color: var(--text-muted); }
.confirmation-summary dd { margin: 0; color: var(--text-primary); word-break: break-word; }
.related-record-summary > div { display: grid; grid-template-columns: repeat(auto-fit, minmax(105px,1fr)); gap: 1px; margin-top: 9px; background: var(--border-subtle); }
.related-record-summary span { display: grid; gap: 2px; padding: 10px; color: var(--text-muted); background: var(--surface-primary); font-size: 10px; }
.related-record-summary strong { color: var(--text-primary); font-size: 17px; }
.check-row { display: flex; align-items: center; grid-auto-flow: column; justify-content: start; }
.auth-shell { background: #080a0c; }
.auth-panel { color: var(--text-primary); border-color: var(--border-medium); background: var(--surface-primary); }
.auth-panel h1 { color: var(--text-primary); }
.auth-link { color: var(--accent-gold); }
.prefixed-input { border-color: var(--border-subtle); background: var(--surface-secondary); }
.prefixed-input > span { color: var(--accent-gold); }
.checklist-toggle, .checklist-status { border-color: var(--border-subtle); background: var(--surface-secondary); }
.checklist-toggle span, .checklist-status strong, .photo-group h4 { color: var(--text-primary); }
.checklist-toggle em, .checklist-status em { color: var(--text-muted); }
.checklist-status > span { color: var(--success); }
.photo-group { border-left-color: rgba(198,166,101,.44); background: rgba(255,255,255,.018); }
.muted-group { background: rgba(255,255,255,.012); }
.review-note { color: #dfbd7d; }

@media (max-width: 960px) {
  .app { display: block; }
  .app-bar { position: sticky; height: 58px; padding: 0 16px; }
  .app-bar-start .compact-brand, .mobile-menu { display: flex; }
  .mobile-menu { margin-left: 8px; }
  .compact-brand strong { display: none; }
  .nav-backdrop { display: block; }
  .nav-drawer { position: fixed; inset: 0 0 0 auto; width: min(310px, 88vw); height: 100vh; transform: translateX(102%); border-left: 1px solid var(--border-subtle); border-right: 0; box-shadow: -16px 0 42px rgba(0,0,0,.38); }
  .nav-drawer.open { transform: translateX(0); }
  .drawer-header .app-icon-button { display: grid; }
  .global-search-wrap { width: 100%; }
  .main { min-height: calc(100vh - 58px); }
}

@media (max-width: 860px) {
  .page-header { align-items: stretch; }
  .page-header .actions { justify-content: flex-start; }
}

@media (max-width: 700px) {
  .app-bar { grid-template-columns: auto minmax(0, 1fr) auto; }
  .app-bar-end { gap: 0; }
  .mobile-menu { margin-left: 0; }
  .global-search-wrap { width: auto; margin: 0 8px; }
  .global-search-wrap input { font-size: 16px; }
  .user-avatar, .account-summary { display: none; }
  .page-header { min-height: 0; padding: 18px; }
  .page-header .actions { justify-content: flex-start; }
  .content { padding: 16px 14px 42px; }
  .dashboard-intro { align-items: start; min-height: 0; }
  .dashboard-metrics, .compact-metrics { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .metric { min-height: 92px; padding: 13px; }
  .metric strong { font-size: 24px; }
  .profile-hero { min-height: 108px; padding: 17px; align-items: start; }
  .profile-hero h2 { font-size: 28px; }
  .progress-tracker { grid-template-columns: repeat(5, 128px); }
  .two-col, .form-grid, .toolbar { grid-template-columns: 1fr; }
  .qa-review-group { grid-template-columns: 1fr; }
  .photo-group > header { align-items: flex-start; flex-direction: column; }
  .report-filter-bar { display: grid; grid-template-columns: 1fr 1fr; }
  .report-filter-bar label { min-width: 0; }
  .report-table { max-height: none; }
  .obligation-strip { grid-template-columns: 1fr; }
  .segmented-field { align-items: flex-start; flex-direction: column; width: 100%; }
  .lead-command-page .content { padding-top: 8px; }
  .lead-kpi-strip { margin-bottom: 6px; }
  .lead-kpi-strip .metric { min-height: 50px; padding: 7px 12px; }
  .lead-toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .lead-toolbar #lead-search { grid-column: 1 / -1; }
  .lead-toolbar #lead-filter { grid-column: 1; }
  .lead-toolbar #lead-sort { grid-column: 2; }
  .lead-toolbar .lead-filter-toggle { grid-column: 1 / -1; }
  .lead-advanced-filters { grid-template-columns: 1fr; }
  .import-filename-link { max-width: 210px; }
}

@media (min-width: 701px) and (max-width: 960px) {
  .lead-toolbar { grid-template-columns: minmax(220px, 1fr) minmax(130px, 160px) minmax(120px, 145px) auto; }
  .lead-advanced-filters { grid-template-columns: repeat(3, minmax(125px, 1fr)) auto; }
}
