:root {
  --ink: #17201f;
  --ink-soft: #465451;
  --muted: #71807c;
  --line: #dfe7e4;
  --line-strong: #cbd7d3;
  --canvas: #f4f7f5;
  --surface: #ffffff;
  --surface-soft: #f8faf9;
  --brand-950: #0d2926;
  --brand-900: #123832;
  --brand-800: #17473f;
  --brand-700: #205f54;
  --brand-600: #297769;
  --brand-100: #dcefe9;
  --brand-50: #edf7f4;
  --gold: #c89a43;
  --gold-soft: #fbf4e6;
  --danger: #b54747;
  --danger-soft: #fff0ef;
  --warning: #9b6818;
  --warning-soft: #fff6df;
  --success: #277251;
  --success-soft: #eaf7f0;
  --info: #356987;
  --info-soft: #edf6fb;
  --shadow-sm: 0 1px 2px rgba(17, 47, 42, .06), 0 6px 18px rgba(17, 47, 42, .04);
  --shadow-md: 0 16px 45px rgba(15, 42, 38, .14);
  --radius-sm: 8px;
  --radius: 13px;
  --radius-lg: 20px;
  --sidebar: 244px;
  --transition: 160ms ease;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body { margin: 0; color: var(--ink); background: var(--canvas); font-size: 14px; line-height: 1.5; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--brand-700); text-decoration: none; }
a:hover { color: var(--brand-900); }
svg { display: block; }
[hidden] { display: none !important; }

.sr-only {
  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;
}
.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 1000;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  color: white;
  background: var(--brand-900);
  transform: translateY(-150%);
  transition: transform var(--transition);
}
.skip-link:focus { transform: translateY(0); }
:focus-visible { outline: 3px solid rgba(41, 119, 105, .3); outline-offset: 2px; }

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 50;
  width: var(--sidebar);
  padding: 23px 16px 16px;
  color: #dbe8e4;
  background:
    radial-gradient(circle at 30% 0, rgba(77, 142, 126, .26), transparent 31%),
    linear-gradient(175deg, var(--brand-900), var(--brand-950));
  display: flex;
  flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 11px; color: inherit; min-width: 0; }
.brand:hover { color: inherit; }
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  flex: 0 0 40px;
  display: grid;
  place-items: center;
  color: var(--brand-800);
  background: #f6fbf9;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .14);
}
.brand-mark svg { width: 25px; height: 25px; fill: currentColor; stroke: currentColor; stroke-width: 2.7; stroke-linejoin: round; }
.brand-mark svg path:first-child { stroke: none; }
.brand > span:last-child { min-width: 0; display: flex; flex-direction: column; }
.brand strong { color: white; font-size: 15px; letter-spacing: -.01em; white-space: nowrap; }
.brand small { color: #9eb8b1; font-size: 11px; }
.main-nav { display: grid; gap: 5px; margin-top: 34px; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 43px;
  padding: 8px 11px;
  border-radius: 10px;
  color: #bdd0ca;
  font-weight: 600;
  transition: color var(--transition), background var(--transition);
}
.nav-link:hover { color: white; background: rgba(255,255,255,.07); }
.nav-link.is-active { color: white; background: rgba(255,255,255,.12); box-shadow: inset 3px 0 var(--gold); }
.nav-icon { width: 23px; text-align: center; font-size: 18px; line-height: 1; opacity: .9; }
.sidebar-footer { margin-top: auto; padding-top: 18px; border-top: 1px solid rgba(255,255,255,.1); }
.operator-card { position: relative; display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 9px; }
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--brand-900);
  background: #dbece7;
  font-weight: 750;
}
.avatar-small { width: 30px; height: 30px; font-size: 12px; }
.avatar-large { width: 54px; height: 54px; font-size: 20px; }
.operator-meta { min-width: 0; display: flex; flex-direction: column; }
.operator-meta strong { color: white; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.operator-meta small { color: #94afa7; font-size: 10px; }
.icon-button {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  color: inherit;
  background: transparent;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
}
.icon-button:hover { background: rgba(255,255,255,.1); }
.account-menu {
  position: absolute;
  right: 0;
  bottom: 43px;
  width: 150px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  box-shadow: var(--shadow-md);
}
.account-menu button { width: 100%; padding: 8px 10px; border: 0; border-radius: 7px; text-align: left; background: transparent; color: var(--ink); cursor: pointer; }
.account-menu button:hover { background: var(--surface-soft); }

.app-main { min-height: 100vh; margin-left: var(--sidebar); }
.mobile-header { display: none; }
.page-content { width: min(1580px, 100%); min-height: 100vh; margin: 0 auto; padding: 34px clamp(22px, 3vw, 48px) 48px; }
.page-header, .detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  margin-bottom: 25px;
}
.page-header h1, .detail-header h1 { margin: 2px 0 2px; font-size: clamp(28px, 3vw, 36px); line-height: 1.15; letter-spacing: -.035em; }
.page-header p, .detail-header p { margin: 3px 0 0; color: var(--muted); }
.eyebrow { color: var(--brand-600); font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.header-actions { display: flex; align-items: center; gap: 9px; }
.button {
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--ink);
  background: white;
  font-weight: 700;
  line-height: 1.1;
  cursor: pointer;
  transition: transform var(--transition), color var(--transition), background var(--transition), border-color var(--transition), box-shadow var(--transition);
}
.button:hover { color: var(--ink); transform: translateY(-1px); }
.button:active { transform: translateY(0); }
.button:disabled { cursor: not-allowed; opacity: .55; transform: none; }
.button-primary { color: white; background: var(--brand-700); border-color: var(--brand-700); box-shadow: 0 5px 14px rgba(32, 95, 84, .18); }
.button-primary:hover { color: white; background: var(--brand-800); border-color: var(--brand-800); }
.button-secondary { color: var(--brand-800); background: white; border-color: var(--line-strong); }
.button-secondary:hover { border-color: var(--brand-600); background: var(--brand-50); }
.button-quiet { color: var(--ink-soft); background: transparent; border-color: transparent; box-shadow: none; }
.button-quiet:hover { background: var(--surface-soft); }
.button-danger { color: var(--danger); background: var(--danger-soft); border-color: #f2cfcc; }
.button-full { width: 100%; }
.button-left { margin-right: auto; }
.button-spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; margin-bottom: 17px; }
.metric-card {
  min-height: 112px;
  padding: 17px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}
.metric-card > span { color: var(--ink-soft); font-size: 11px; font-weight: 700; }
.metric-card strong { margin: 3px 0 auto; font-size: 29px; line-height: 1.2; letter-spacing: -.03em; }
.metric-card small { color: var(--muted); font-size: 10px; }
.metric-card.metric-accent { color: white; border-color: transparent; background: linear-gradient(145deg, var(--brand-700), var(--brand-900)); }
.metric-card.metric-accent > span, .metric-card.metric-accent small { color: #cce0da; }
.workspace-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.leads-workspace { min-height: 450px; overflow: hidden; }
.toolbar {
  min-height: 67px;
  padding: 13px 15px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.filter-bar { flex: 1; display: flex; align-items: center; gap: 8px; }
.search-field {
  width: min(390px, 100%);
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  background: white;
}
.search-field:focus-within { border-color: var(--brand-600); box-shadow: 0 0 0 3px rgba(41,119,105,.1); }
.search-field input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); }
.compact-field select, .stage-select select {
  min-width: 128px;
  height: 38px;
  padding: 0 31px 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  color: var(--ink-soft);
  background: white;
}
.segmented-control { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-soft); }
.segmented-control button { min-height: 30px; padding: 5px 12px; border: 0; border-radius: 6px; color: var(--muted); background: transparent; font-weight: 700; cursor: pointer; }
.segmented-control button.is-active { color: var(--ink); background: white; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.inline-status { min-height: 220px; display: flex; align-items: center; justify-content: center; gap: 9px; color: var(--muted); }
.status-spinner { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--brand-600); border-radius: 50%; animation: spin .7s linear infinite; }

.kanban {
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(7, minmax(238px, 1fr));
  gap: 11px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
}
.kanban-column { min-height: 410px; scroll-snap-align: start; border: 1px solid #e7ecea; border-radius: 11px; background: #f7f9f8; }
.kanban-column > header { height: 45px; padding: 0 10px; display: flex; align-items: center; gap: 7px; border-bottom: 1px solid #e7ecea; }
.kanban-column h2 { margin: 0; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.stage-dot { width: 7px; height: 7px; border-radius: 50%; background: #7e928c; }
.stage-new { background: #4a7894; }
.stage-contacted { background: #7b6cab; }
.stage-estimate_scheduled { background: #c68a31; }
.stage-estimate_complete { background: #488a7b; }
.stage-won { background: #2f825d; }
.stage-lost { background: #a45d5d; }
.stage-archived { background: #84908d; }
.count-badge { margin-left: auto; min-width: 21px; height: 19px; padding: 1px 6px; border-radius: 20px; display: inline-grid; place-items: center; color: var(--muted); background: #e8eeec; font-size: 10px; font-weight: 800; }
.kanban-dropzone { min-height: 363px; padding: 8px; transition: background var(--transition); }
.kanban-dropzone.is-drag-over { background: var(--brand-50); box-shadow: inset 0 0 0 2px rgba(41,119,105,.2); }
.lead-card {
  margin-bottom: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink);
  background: white;
  box-shadow: 0 1px 2px rgba(17,47,42,.04);
  cursor: grab;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition), opacity var(--transition);
}
.lead-card:hover { color: var(--ink); transform: translateY(-1px); border-color: #bfcfc9; box-shadow: 0 7px 16px rgba(17,47,42,.08); }
.lead-card.is-dragging { opacity: .55; cursor: grabbing; }
.lead-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.lead-card h3 { margin: 0; font-size: 13px; line-height: 1.3; }
.lead-card-project { margin: 7px 0 9px; min-height: 34px; color: var(--ink-soft); font-size: 11px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lead-card-meta { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 9px; }
.lead-card-meta time { margin-left: auto; }
.channel-pill, .stage-pill, .role-pill, .status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  border-radius: 999px;
  color: var(--ink-soft);
  background: #edf2f0;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .02em;
  text-transform: uppercase;
  white-space: nowrap;
}
.channel-phone { color: #356987; background: #e9f3f8; }
.channel-email { color: #705a95; background: #f1edf8; }
.channel-web { color: #3f755f; background: #eaf5ef; }
.stage-pill.stage-won, .status-active { color: var(--success); background: var(--success-soft); }
.stage-pill.stage-lost, .status-inactive { color: var(--danger); background: var(--danger-soft); }

.lead-table-wrap { position: relative; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { padding: 11px 15px; color: var(--muted); background: var(--surface-soft); font-size: 9px; letter-spacing: .06em; text-align: left; text-transform: uppercase; white-space: nowrap; }
.data-table td { padding: 13px 15px; border-top: 1px solid var(--line); vertical-align: middle; }
.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover { background: #fbfcfc; }
.customer-cell { display: flex; align-items: center; gap: 9px; }
.customer-cell .avatar { width: 31px; height: 31px; font-size: 11px; }
.customer-cell span { min-width: 0; display: flex; flex-direction: column; }
.customer-cell strong, .project-cell strong { font-size: 11px; }
.customer-cell small, .project-cell small { color: var(--muted); font-size: 9px; }
.project-cell { max-width: 320px; }
.pagination { min-height: 58px; padding: 10px 15px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 11px; }
.empty-state { padding: 60px 20px; text-align: center; color: var(--muted); }
.empty-state h3 { margin: 8px 0 3px; color: var(--ink); font-size: 16px; }
.empty-state p { margin: 0; }
.empty-icon { width: 42px; height: 42px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center; color: var(--brand-700); background: var(--brand-50); font-size: 20px; }

.back-link { display: inline-block; margin-bottom: 13px; color: var(--muted); font-size: 11px; font-weight: 700; }
.lead-title-row { display: flex; align-items: center; gap: 13px; }
.channel-kicker { color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.detail-header { align-items: flex-end; }
.detail-header h1 { font-size: 29px; }
.detail-actions { min-width: 190px; }
.stage-select { display: flex; flex-direction: column; gap: 3px; }
.stage-select span { color: var(--muted); font-size: 9px; font-weight: 700; }
.stage-select select { min-width: 190px; color: var(--ink); font-weight: 700; }
.detail-layout { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(270px, .7fr); gap: 15px; }
.detail-primary, .detail-sidebar { display: grid; align-content: start; gap: 15px; }
.detail-card, .side-card { padding: 19px; }
.card-heading { min-height: 35px; margin-bottom: 16px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-heading h2 { margin: 0; font-size: 15px; letter-spacing: -.015em; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px 24px; }
.detail-item { min-width: 0; }
.detail-item dt { color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.detail-item dd { margin: 4px 0 0; color: var(--ink-soft); white-space: pre-line; overflow-wrap: anywhere; }
.detail-item.detail-span-2 { grid-column: span 2; }
.contact-list { margin: 0; display: grid; }
.contact-list > div { padding: 10px 0; border-top: 1px solid var(--line); }
.contact-list > div:first-child { padding-top: 0; border: 0; }
.contact-list dt { color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .05em; }
.contact-list dd { margin: 3px 0 0; overflow-wrap: anywhere; }
.timeline { position: relative; margin: 0; padding: 0; list-style: none; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 8px; bottom: 8px; width: 1px; background: var(--line); }
.timeline li { position: relative; padding: 0 0 19px 28px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline-marker { position: absolute; left: 1px; top: 4px; width: 13px; height: 13px; border: 3px solid white; border-radius: 50%; background: var(--brand-600); box-shadow: 0 0 0 1px var(--brand-100); }
.timeline h3 { margin: 0; font-size: 11px; }
.timeline p { margin: 3px 0; color: var(--ink-soft); white-space: pre-line; }
.timeline time { color: var(--muted); font-size: 9px; }
.timeline-loading > span { position: absolute; left: 1px; top: 4px; width: 13px; height: 13px; border-radius: 50%; background: var(--line); }
.appointment-summary { display: grid; gap: 9px; }
.appointment-date { padding: 12px; border-radius: 9px; background: var(--brand-50); }
.appointment-date strong { display: block; color: var(--brand-900); }
.appointment-date span { color: var(--brand-700); font-size: 11px; }
.appointment-location { color: var(--ink-soft); font-size: 11px; }
.muted { color: var(--muted); }
.edit-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.field-span-2 { grid-column: span 2; }
.form-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.character-count { margin-right: auto; color: var(--muted); font-size: 9px; }
.skeleton-line { height: 13px; border-radius: 5px; background: linear-gradient(90deg, #edf1f0 20%, #f8faf9 50%, #edf1f0 80%); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
.skeleton-line.short { width: 56%; }

.calendar-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 14px; align-items: start; }
.calendar-sidebar { display: grid; gap: 12px; }
.mini-card { padding: 16px; }
.today-date { display: block; margin: 4px 0 14px; font-size: 19px; line-height: 1.25; letter-spacing: -.02em; }
.today-summary { padding-top: 11px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.today-summary b { color: var(--brand-700); font-size: 16px; }
.mini-heading h2 { margin: 0 0 11px; font-size: 12px; }
.calendar-key { margin: 0; padding: 0; display: grid; gap: 9px; list-style: none; color: var(--ink-soft); font-size: 11px; }
.event-dot { width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; display: inline-block; background: var(--brand-600); }
.event-tentative { background: var(--warning); }
.event-completed { background: var(--success); }
.event-no-show { background: var(--danger); }
.event-cancelled { background: #9ba7a3; }
.calendar-tip { padding: 8px 4px; display: flex; gap: 9px; color: var(--muted); font-size: 10px; }
.calendar-tip span { color: var(--brand-600); font-size: 18px; }
.calendar-tip p { margin: 0; }
.calendar-card { min-width: 0; padding: 17px; }
.calendar-status { min-height: auto; padding: 10px; margin-bottom: 10px; border-radius: 8px; background: var(--warning-soft); color: var(--warning); }
#vhp-calendar {
  min-height: 680px;
  --fc-classic-button: var(--brand-700);
  --fc-classic-button-border: var(--brand-700);
  --fc-classic-button-strong: var(--brand-900);
  --fc-classic-button-strong-border: var(--brand-900);
  --fc-classic-primary: var(--brand-600);
  --fc-classic-event: var(--brand-600);
  --fc-classic-today: color-mix(in srgb, var(--brand-100) 72%, transparent);
}
.fc { --fc-border-color: var(--line); --fc-button-bg-color: var(--brand-700); --fc-button-border-color: var(--brand-700); --fc-button-hover-bg-color: var(--brand-800); --fc-button-hover-border-color: var(--brand-800); --fc-button-active-bg-color: var(--brand-900); --fc-button-active-border-color: var(--brand-900); --fc-event-bg-color: var(--brand-600); --fc-event-border-color: var(--brand-600); font-size: 11px; }
.fc .fc-toolbar-title { font-size: 17px; letter-spacing: -.02em; }
.fc .fc-button { border-radius: 7px !important; box-shadow: none !important; font-size: 10px !important; font-weight: 700 !important; text-transform: capitalize !important; }
.fc .fc-col-header-cell-cushion { padding: 7px 4px; color: var(--ink-soft); font-size: 9px; text-transform: uppercase; letter-spacing: .05em; }
.fc .fc-daygrid-day-number { color: var(--ink-soft); }
.fc .fc-day-today { background: var(--brand-50) !important; }
.fc-event { border-radius: 5px !important; padding: 1px 3px !important; }
.fc-event.status-tentative { --fc-event-bg-color: var(--warning); --fc-event-border-color: var(--warning); }
.fc-event.status-completed { --fc-event-bg-color: var(--success); --fc-event-border-color: var(--success); }
.fc-event.status-no_show { --fc-event-bg-color: var(--danger); --fc-event-border-color: var(--danger); }
.fc-event.status-cancelled { --fc-event-bg-color: #8c9995; --fc-event-border-color: #8c9995; opacity: .65; }
.status-tentative { --fc-classic-event: var(--warning); }
.status-completed { --fc-classic-event: var(--success); }
.status-no_show { --fc-classic-event: var(--danger); }
.status-cancelled { --fc-classic-event: #8c9995; opacity: .65; }

.settings-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 15px; align-items: start; }
.settings-nav { display: grid; gap: 4px; }
.settings-nav a { padding: 11px 12px; border-radius: 9px; display: flex; flex-direction: column; color: var(--ink-soft); }
.settings-nav a:hover { background: white; }
.settings-nav a.is-active { color: var(--brand-900); background: var(--brand-50); box-shadow: inset 3px 0 var(--brand-600); }
.settings-nav span { font-weight: 750; }
.settings-nav small { color: var(--muted); font-size: 9px; }
.settings-panel { min-height: 420px; padding: 19px; }
.settings-heading { display: flex; justify-content: space-between; gap: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.settings-heading h2 { margin: 0; font-size: 17px; }
.settings-heading p { margin: 2px 0 0; color: var(--muted); font-size: 11px; }
.settings-panel .inline-status { min-height: 260px; }
.user-list { display: grid; }
.user-row { min-height: 72px; padding: 11px 2px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: minmax(180px, 1fr) 120px 90px auto; align-items: center; gap: 13px; }
.user-row:last-child { border-bottom: 0; }
.user-identity { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-identity > span:last-child { min-width: 0; display: flex; flex-direction: column; }
.user-identity strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-identity small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.user-actions { display: flex; justify-content: flex-end; gap: 3px; }
.user-actions button { color: var(--muted); }
.role-pill { width: fit-content; }
.role-admin { color: #705a95; background: #f1edf8; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field > span:first-child, .label-row { color: var(--ink-soft); font-size: 11px; font-weight: 700; }
.label-row { display: flex; justify-content: space-between; gap: 10px; }
.label-row a { font-weight: 700; }
.field input, .field select, .field textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  outline: 0;
  color: var(--ink);
  background: white;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand-600); box-shadow: 0 0 0 3px rgba(41,119,105,.1); }
.field input:disabled, .field select:disabled, .field textarea:disabled { background: var(--surface-soft); color: var(--muted); }
.field small { color: var(--muted); font-size: 9px; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
.stack-form { display: grid; gap: 15px; }
.password-field { position: relative; }
.password-field input { padding-right: 56px; }
.password-field button { position: absolute; right: 5px; top: 5px; height: 30px; padding: 0 8px; border: 0; border-radius: 6px; color: var(--brand-700); background: transparent; font-size: 10px; font-weight: 800; cursor: pointer; }
.password-field button:hover { background: var(--brand-50); }
.check-field { display: flex; align-items: center; gap: 8px; color: var(--ink-soft); font-size: 11px; cursor: pointer; }
.check-field input { accent-color: var(--brand-700); }
.switch-field { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.switch-field > span { display: flex; flex-direction: column; }
.switch-field small { color: var(--muted); font-size: 9px; }
.switch-field input { appearance: none; width: 38px; height: 22px; padding: 2px; border-radius: 30px; background: #c8d2cf; cursor: pointer; transition: background var(--transition); }
.switch-field input::before { content: ""; display: block; width: 18px; height: 18px; border-radius: 50%; background: white; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform var(--transition); }
.switch-field input:checked { background: var(--brand-600); }
.switch-field input:checked::before { transform: translateX(16px); }
.form-alert, .form-success { padding: 10px 12px; border: 1px solid #f0c7c4; border-radius: 8px; color: var(--danger); background: var(--danger-soft); font-size: 11px; }
.form-success { border-color: #cbe7d7; color: var(--success); background: var(--success-soft); display: flex; flex-direction: column; }

.modal {
  width: min(570px, calc(100vw - 30px));
  max-height: calc(100vh - 34px);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg);
  background: transparent;
  box-shadow: var(--shadow-md);
}
.modal::backdrop { background: rgba(7, 25, 22, .58); backdrop-filter: blur(3px); }
.modal-small { width: min(450px, calc(100vw - 30px)); }
.modal-shell { max-height: calc(100vh - 34px); overflow: auto; border-radius: var(--radius-lg); background: white; }
.modal-header, .modal-footer { padding: 17px 19px; display: flex; align-items: center; gap: 9px; }
.modal-header { justify-content: space-between; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 1px 0 0; font-size: 18px; letter-spacing: -.02em; }
.modal-header .icon-button { color: var(--muted); font-size: 23px; }
.modal-header .icon-button:hover { background: var(--surface-soft); }
.modal-body { padding: 19px; display: grid; gap: 13px; }
.modal-footer { justify-content: flex-end; border-top: 1px solid var(--line); }

.auth-body { min-height: 100vh; background: #eef3f1; }
.auth-layout { min-height: 100vh; display: grid; grid-template-columns: minmax(350px, .95fr) minmax(460px, 1.05fr); }
.auth-story {
  position: relative;
  overflow: hidden;
  padding: clamp(28px, 4vw, 58px);
  color: white;
  background:
    radial-gradient(circle at 78% 22%, rgba(200,154,67,.21), transparent 22%),
    radial-gradient(circle at 18% 86%, rgba(66,137,121,.28), transparent 31%),
    linear-gradient(155deg, #164a41, #0a2522);
  display: flex;
  flex-direction: column;
}
.auth-story::after {
  content: "";
  position: absolute;
  right: -140px;
  bottom: -150px;
  width: 470px;
  height: 350px;
  opacity: .1;
  background: linear-gradient(135deg, transparent 49%, white 50%, transparent 51%) 0 0/45px 45px;
  transform: rotate(-8deg);
}
.brand-light { position: relative; z-index: 1; width: fit-content; }
.auth-story-copy { position: relative; z-index: 1; width: min(520px, 100%); margin: auto 0; padding: 90px 0; }
.eyebrow-light { color: #c8b078; }
.auth-story-copy h1 { margin: 9px 0 18px; font-size: clamp(38px, 5.2vw, 66px); line-height: 1.02; letter-spacing: -.055em; font-weight: 710; }
.auth-story-copy p { width: min(490px, 100%); margin: 0; color: #b9cec8; font-size: clamp(15px, 1.4vw, 19px); line-height: 1.65; }
.auth-proof { position: relative; z-index: 1; display: flex; align-items: center; gap: 8px; color: #a9c2bb; font-size: 11px; }
.proof-dot { width: 7px; height: 7px; border-radius: 50%; background: #7fc5a5; box-shadow: 0 0 0 5px rgba(127,197,165,.12); }
.auth-panel { padding: 30px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.auth-card { width: min(430px, 100%); padding: clamp(27px, 4vw, 43px); border: 1px solid rgba(205,218,213,.9); border-radius: 20px; background: rgba(255,255,255,.93); box-shadow: 0 25px 70px rgba(17,47,42,.11); }
.auth-heading { margin-bottom: 25px; }
.auth-heading h2 { margin: 6px 0 6px; font-size: 26px; line-height: 1.2; letter-spacing: -.035em; }
.auth-heading p { margin: 0; color: var(--muted); }
.auth-footer { margin: 22px 0 0; color: #899793; font-size: 10px; }

.toast-region { position: fixed; right: 18px; bottom: 18px; z-index: 200; width: min(370px, calc(100vw - 36px)); display: grid; gap: 8px; pointer-events: none; }
.toast {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand-600);
  border-radius: 10px;
  color: var(--ink);
  background: white;
  box-shadow: var(--shadow-md);
  display: flex;
  gap: 10px;
  pointer-events: auto;
  animation: toast-in .2s ease both;
}
.toast.is-error { border-left-color: var(--danger); }
.toast.is-warning { border-left-color: var(--warning); }
.toast.is-success { border-left-color: var(--success); }
.toast-content { min-width: 0; display: flex; flex-direction: column; }
.toast-content strong { font-size: 11px; }
.toast-content span { color: var(--muted); font-size: 10px; }
.toast button { margin-left: auto; align-self: flex-start; border: 0; color: var(--muted); background: transparent; cursor: pointer; }
.loading-bar { position: fixed; top: 0; left: var(--sidebar); right: 0; z-index: 300; height: 3px; overflow: hidden; background: rgba(41,119,105,.12); }
.loading-bar span { display: block; width: 35%; height: 100%; background: var(--brand-600); animation: loading 1s ease-in-out infinite; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes loading { from { transform: translateX(-120%); } to { transform: translateX(400%); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(7px); } }

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kanban { grid-template-columns: repeat(7, 250px); }
  .detail-layout { grid-template-columns: minmax(0, 1.5fr) minmax(260px, .7fr); }
}

@media (max-width: 900px) {
  :root { --sidebar: 232px; }
  .sidebar { transform: translateX(-102%); box-shadow: var(--shadow-md); transition: transform 220ms ease; }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open::after { content: ""; position: fixed; inset: 0; z-index: 40; background: rgba(7,25,22,.45); }
  .app-main { margin-left: 0; }
  .mobile-header { position: sticky; top: 0; z-index: 35; height: 56px; padding: 0 15px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 34px 1fr 34px; align-items: center; color: var(--ink); background: rgba(255,255,255,.92); backdrop-filter: blur(12px); }
  .mobile-header .icon-button:hover { background: var(--surface-soft); }
  .mobile-brand { justify-self: center; color: var(--brand-900); font-weight: 800; }
  .page-content { min-height: calc(100vh - 56px); padding-top: 25px; }
  .loading-bar { left: 0; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .filter-bar { flex-wrap: wrap; }
  .search-field { width: 100%; }
  .compact-field { flex: 1; }
  .compact-field select { width: 100%; }
  .segmented-control { align-self: flex-end; }
  .detail-layout { grid-template-columns: 1fr; }
  .detail-sidebar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-sidebar > :last-child { grid-column: span 2; }
  .calendar-layout { grid-template-columns: 1fr; }
  .calendar-sidebar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .calendar-tip { grid-column: span 2; }
  .settings-layout { grid-template-columns: 1fr; }
  .settings-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auth-layout { grid-template-columns: 1fr; }
  .auth-story { min-height: 310px; padding: 28px; }
  .auth-story-copy { padding: 55px 0 36px; }
  .auth-story-copy h1 { max-width: 620px; font-size: clamp(35px, 7vw, 52px); }
  .auth-panel { padding: 32px 18px; }
}

@media (max-width: 640px) {
  .page-content { padding: 20px 13px 35px; }
  .page-header, .detail-header { align-items: stretch; flex-direction: column; gap: 14px; }
  .header-actions, .detail-actions { width: 100%; }
  .header-actions .button, .detail-actions .stage-select, .detail-actions select { width: 100%; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .metric-card { min-height: 100px; padding: 14px; }
  .metric-card strong { font-size: 24px; }
  .filter-bar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .search-field { grid-column: span 2; }
  .segmented-control { align-self: stretch; }
  .segmented-control button { flex: 1; }
  .kanban { padding: 10px; grid-template-columns: repeat(7, min(82vw, 290px)); }
  .lead-table { min-width: 760px; }
  .detail-grid, .edit-grid { grid-template-columns: 1fr; }
  .detail-item.detail-span-2, .field-span-2 { grid-column: span 1; }
  .detail-sidebar { grid-template-columns: 1fr; }
  .detail-sidebar > :last-child { grid-column: span 1; }
  .calendar-sidebar { grid-template-columns: 1fr; }
  .calendar-tip { grid-column: span 1; }
  .calendar-card { padding: 10px; }
  #vhp-calendar { min-height: 600px; }
  .fc .fc-header-toolbar { align-items: stretch; flex-direction: column; gap: 8px; }
  .fc .fc-toolbar-chunk { display: flex; justify-content: center; }
  .user-row { grid-template-columns: 1fr auto; gap: 7px; }
  .user-row > .role-pill, .user-row > .status-pill { grid-column: span 1; }
  .user-actions { grid-column: 2; grid-row: 1 / span 2; }
  .field-row { grid-template-columns: 1fr; }
  .modal-footer { flex-wrap: wrap; }
  .modal-footer .button-left { width: 100%; margin: 0; }
  .auth-story { min-height: 260px; }
  .auth-story-copy { padding: 35px 0 18px; }
  .auth-story-copy p { font-size: 14px; line-height: 1.5; }
  .auth-panel { padding: 22px 13px; }
  .auth-card { padding: 26px 21px; }
}

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