:root {
  --navy-950: #07111a;
  --navy-900: #0b1620;
  --navy-800: #132430;
  --navy-700: #1d3544;
  --blue-600: #176b9f;
  --blue-500: #2482bb;
  --blue-100: #e8f3f9;
  --gold-500: #d7a24b;
  --gold-100: #fff4dd;
  --green-600: #318366;
  --green-100: #e8f5ef;
  --red-600: #b84b4b;
  --red-100: #fceceb;
  --orange-600: #a9632f;
  --orange-100: #fdf0e6;
  --ink-900: #17232c;
  --ink-700: #42515c;
  --ink-500: #6c7a84;
  --ink-400: #8c98a1;
  --line: #e1e7eb;
  --surface: #ffffff;
  --canvas: #f4f7f8;
  --shadow-sm: 0 1px 2px rgba(7, 17, 26, 0.05), 0 4px 14px rgba(7, 17, 26, 0.04);
  --shadow-lg: 0 22px 55px rgba(7, 17, 26, 0.18);
  --radius: 14px;
  --sidebar-width: 248px;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--canvas); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink-900);
  background: var(--canvas);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.svg-sprite symbol rect { fill: none; }

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  color: #d8e2e8;
  background:
    radial-gradient(circle at 15% 8%, rgba(36, 130, 187, 0.13), transparent 25%),
    var(--navy-900);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.brand { display: flex; align-items: center; gap: 12px; height: 76px; padding: 0 22px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; transform: rotate(45deg); border: 1px solid rgba(255,255,255,.28); background: linear-gradient(145deg, var(--blue-500), #15577c); border-radius: 9px; box-shadow: 0 6px 18px rgba(0,0,0,.22); }
.brand-mark span { transform: rotate(-45deg); color: white; font-size: 17px; font-weight: 800; }
.brand strong { display: block; color: white; font-size: 19px; letter-spacing: -.02em; }
.brand small { display: block; margin-top: 2px; color: #7f97a6; font-size: 8px; font-weight: 700; letter-spacing: .16em; }

.primary-nav { padding: 20px 13px; }
.nav-item { position: relative; width: 100%; height: 44px; display: flex; align-items: center; gap: 13px; padding: 0 13px; margin-bottom: 5px; color: #91a5b2; background: transparent; border: 0; border-radius: 9px; cursor: pointer; text-align: left; transition: .18s ease; }
.nav-item:hover { color: #e8eff3; background: rgba(255,255,255,.05); }
.nav-item.is-active { color: white; background: linear-gradient(90deg, rgba(36,130,187,.25), rgba(36,130,187,.09)); }
.nav-item.is-active::before { content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: 3px; border-radius: 3px; background: var(--blue-500); }
.nav-item svg { width: 18px; height: 18px; }
.nav-item span { flex: 1; font-weight: 600; }
.nav-item em { min-width: 23px; padding: 3px 6px; color: #9bb2bf; background: rgba(255,255,255,.07); border-radius: 10px; font-size: 10px; font-style: normal; text-align: center; }
.nav-item.is-active em { color: #d9f1ff; background: rgba(36,130,187,.22); }

.sidebar-insight { margin: 8px 18px 0; padding: 18px; background: rgba(255,255,255,.045); border: 1px solid rgba(255,255,255,.07); border-radius: 12px; }
.eyebrow { display: block; color: var(--ink-500); font-size: 10px; font-weight: 800; letter-spacing: .12em; }
.sidebar-insight .eyebrow { color: #668294; }
.sidebar-insight strong { display: block; margin-top: 9px; color: white; font-size: 24px; letter-spacing: -.03em; }
.sidebar-insight p { margin: 2px 0 12px; color: #8097a5; font-size: 11px; }
.mini-progress { height: 4px; overflow: hidden; background: rgba(255,255,255,.07); border-radius: 3px; }
.mini-progress span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--blue-500), #54b3dd); border-radius: inherit; transition: width .5s ease; }

.sidebar-footer { margin-top: auto; padding: 16px 13px; border-top: 1px solid rgba(255,255,255,.07); }
.profile-button { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px; color: #d8e2e8; background: transparent; border: 0; border-radius: 9px; text-align: left; cursor: pointer; }
.profile-button:hover { background: rgba(255,255,255,.05); }
.avatar { flex: 0 0 34px; height: 34px; display: grid; place-items: center; color: white; background: #28485a; border: 1px solid rgba(255,255,255,.12); border-radius: 50%; font-size: 11px; font-weight: 800; }
.profile-button > span:nth-child(2) { min-width: 0; flex: 1; }
.profile-button strong, .profile-button small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-button strong { font-size: 12px; }
.profile-button small { margin-top: 2px; color: #758d9c; font-size: 9px; }
.profile-button svg { width: 14px; height: 14px; color: #68818f; }

.main-column { width: calc(100% - var(--sidebar-width)); min-height: 100vh; margin-left: var(--sidebar-width); }
.topbar { position: sticky; top: 0; z-index: 30; height: 76px; display: flex; align-items: center; gap: 20px; padding: 0 30px; background: rgba(255,255,255,.93); border-bottom: 1px solid var(--line); backdrop-filter: blur(14px); }
.global-search { flex: 1; max-width: 530px; height: 40px; display: flex; align-items: center; gap: 10px; padding: 0 12px; background: #f5f7f8; border: 1px solid transparent; border-radius: 9px; transition: .2s ease; }
.global-search:focus-within { background: white; border-color: #a8c9da; box-shadow: 0 0 0 3px rgba(36,130,187,.1); }
.global-search svg { width: 17px; height: 17px; color: var(--ink-500); }
.global-search input { flex: 1; min-width: 0; color: var(--ink-900); background: transparent; border: 0; outline: 0; }
.global-search input::placeholder { color: #97a2a9; }
kbd { padding: 3px 6px; color: #87939b; background: white; border: 1px solid #dde3e6; border-bottom-width: 2px; border-radius: 5px; font-family: inherit; font-size: 9px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.icon-button { width: 38px; height: 38px; display: inline-grid; place-items: center; padding: 0; color: var(--ink-500); background: transparent; border: 1px solid transparent; border-radius: 9px; cursor: pointer; transition: .16s ease; }
.icon-button:hover { color: var(--ink-900); background: #f1f4f5; }
.icon-button svg { width: 18px; height: 18px; }
.notification-button { position: relative; }
.notification-button span { position: absolute; top: 7px; right: 8px; width: 6px; height: 6px; background: var(--gold-500); border: 1px solid white; border-radius: 50%; }
.primary-button, .secondary-button, .danger-button { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 16px; border-radius: 9px; font-weight: 700; cursor: pointer; transition: .16s ease; }
.primary-button { color: white; background: var(--navy-800); border: 1px solid var(--navy-800); box-shadow: 0 3px 10px rgba(11,22,32,.14); }
.primary-button:hover { background: var(--navy-900); transform: translateY(-1px); }
.primary-button:disabled { opacity: .55; cursor: wait; transform: none; }
.primary-button svg { width: 16px; height: 16px; }
.secondary-button { color: var(--ink-700); background: white; border: 1px solid #d8e0e4; }
.secondary-button:hover { border-color: #b8c5cc; background: #f9fafb; }
.danger-button { color: var(--red-600); background: white; border: 1px solid #edc9c7; }
.danger-button:hover { background: var(--red-100); }
.mobile-menu { display: none; }

main { min-height: calc(100vh - 76px); padding: 28px 30px 48px; }
.page { max-width: 1500px; margin: 0 auto; animation: fade-in .18s ease; }
@keyframes fade-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.page-heading h1 { margin: 4px 0 4px; font-size: clamp(25px, 2.2vw, 33px); line-height: 1.08; letter-spacing: -.035em; }
.page-heading p { margin: 0; color: var(--ink-500); font-size: 13px; }
.page-heading .heading-actions { display: flex; gap: 9px; }
.mode-pill { display: inline-flex; align-items: center; gap: 6px; margin-left: 8px; padding: 4px 8px; color: var(--orange-600); background: var(--orange-100); border-radius: 999px; font-size: 9px; font-weight: 800; letter-spacing: .08em; vertical-align: middle; }
.mode-pill::before { content: ""; width: 6px; height: 6px; background: #d98a43; border-radius: 50%; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric-card { position: relative; min-height: 137px; padding: 19px; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.metric-card::after { content: ""; position: absolute; right: -25px; bottom: -40px; width: 110px; height: 110px; background: radial-gradient(circle, rgba(36,130,187,.09), transparent 65%); }
.metric-top { display: flex; align-items: center; justify-content: space-between; }
.metric-label { color: var(--ink-500); font-size: 11px; font-weight: 700; }
.metric-icon { width: 31px; height: 31px; display: grid; place-items: center; color: var(--blue-600); background: var(--blue-100); border-radius: 8px; }
.metric-icon.gold { color: #98691d; background: var(--gold-100); }
.metric-icon.green { color: var(--green-600); background: var(--green-100); }
.metric-icon.slate { color: #536872; background: #edf1f3; }
.metric-icon svg { width: 16px; height: 16px; }
.metric-value { display: block; margin-top: 13px; font-size: 28px; line-height: 1; letter-spacing: -.035em; }
.metric-foot { display: flex; align-items: center; gap: 5px; margin-top: 9px; color: var(--ink-400); font-size: 10px; }
.metric-foot .up { color: var(--green-600); font-weight: 800; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, .8fr); gap: 18px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.panel-header { min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 0 19px; border-bottom: 1px solid #e8edef; }
.panel-header h2 { margin: 0; font-size: 14px; letter-spacing: -.01em; }
.panel-header p { margin: 3px 0 0; color: var(--ink-400); font-size: 10px; }
.text-button { display: inline-flex; align-items: center; gap: 4px; color: var(--blue-600); background: transparent; border: 0; font-size: 11px; font-weight: 700; cursor: pointer; }
.text-button svg { width: 13px; height: 13px; }

.pipeline-board { display: grid; grid-template-columns: repeat(5, minmax(130px, 1fr)); min-height: 360px; padding: 15px; gap: 10px; overflow-x: auto; }
.pipeline-column { min-width: 135px; padding: 10px; background: #f7f9fa; border: 1px solid #edf0f2; border-radius: 10px; }
.pipeline-column-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.pipeline-column-head span { color: var(--ink-700); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.pipeline-column-head em { min-width: 20px; padding: 3px 6px; color: var(--ink-500); background: white; border: 1px solid var(--line); border-radius: 9px; font-size: 9px; font-style: normal; text-align: center; }
.lead-card { position: relative; padding: 12px; margin-bottom: 8px; background: white; border: 1px solid #e4eaed; border-radius: 9px; cursor: pointer; transition: .16s ease; }
.lead-card:hover { transform: translateY(-1px); border-color: #bed2dc; box-shadow: 0 5px 12px rgba(11,22,32,.06); }
.lead-card::before { content: ""; position: absolute; inset: 10px auto 10px 0; width: 2px; border-radius: 2px; background: #a9bac3; }
.lead-card.high::before, .lead-card.urgent::before { background: var(--gold-500); }
.lead-card strong { display: block; overflow: hidden; font-size: 11px; white-space: nowrap; text-overflow: ellipsis; }
.lead-card small { display: block; margin-top: 3px; overflow: hidden; color: var(--ink-400); font-size: 9px; white-space: nowrap; text-overflow: ellipsis; }
.lead-card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 11px; color: var(--ink-500); font-size: 9px; }
.type-dot { display: inline-flex; align-items: center; gap: 4px; text-transform: capitalize; }
.type-dot::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--blue-500); }
.type-dot.multifamily::before { background: var(--gold-500); }
.type-dot.commercial::before { background: var(--green-600); }
.type-dot.storm::before { background: var(--red-600); }
.pipeline-empty { padding: 18px 4px; color: #a4aeb4; font-size: 10px; text-align: center; }

.task-list { padding: 6px 18px 12px; }
.task-row { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 9px; padding: 13px 0; border-bottom: 1px solid #edf1f2; }
.task-row:last-child { border-bottom: 0; }
.task-check { width: 19px; height: 19px; display: grid; place-items: center; color: transparent; background: white; border: 1px solid #cbd5da; border-radius: 6px; cursor: pointer; }
.task-check:hover { border-color: var(--green-600); }
.task-check svg { width: 12px; height: 12px; }
.task-row.is-complete .task-check { color: white; background: var(--green-600); border-color: var(--green-600); }
.task-check.is-complete { color: white; background: var(--green-600); border-color: var(--green-600); }
.task-row.is-complete strong { color: var(--ink-400); text-decoration: line-through; }
.task-copy { min-width: 0; }
.task-copy strong { display: block; overflow: hidden; font-size: 11px; white-space: nowrap; text-overflow: ellipsis; }
.task-copy small { display: block; margin-top: 3px; color: var(--ink-400); font-size: 9px; }
.due-chip { padding: 4px 7px; color: var(--ink-500); background: #f3f6f7; border-radius: 6px; font-size: 9px; font-weight: 700; white-space: nowrap; }
.due-chip.overdue { color: var(--red-600); background: var(--red-100); }
.due-chip.today { color: var(--orange-600); background: var(--orange-100); }

.activity-list { padding: 8px 18px 15px; }
.activity-row { position: relative; display: grid; grid-template-columns: 26px 1fr; gap: 10px; padding: 10px 0; }
.activity-row:not(:last-child)::after { content: ""; position: absolute; left: 12px; top: 34px; bottom: -8px; width: 1px; background: #e5eaed; }
.activity-icon { width: 25px; height: 25px; display: grid; place-items: center; color: var(--blue-600); background: var(--blue-100); border-radius: 50%; z-index: 1; }
.activity-icon svg { width: 12px; height: 12px; }
.activity-copy strong { display: block; font-size: 10px; font-weight: 700; }
.activity-copy p { margin: 3px 0 0; color: var(--ink-400); font-size: 9px; line-height: 1.4; }

.toolbar { display: flex; align-items: center; gap: 9px; margin-bottom: 14px; }
.table-search { min-width: 220px; flex: 1; height: 40px; display: flex; align-items: center; gap: 8px; padding: 0 12px; background: white; border: 1px solid var(--line); border-radius: 9px; }
.table-search svg { width: 16px; height: 16px; color: var(--ink-400); }
.table-search input { width: 100%; background: transparent; border: 0; outline: 0; }
.filter-select { height: 40px; padding: 0 32px 0 12px; color: var(--ink-700); background: white; border: 1px solid var(--line); border-radius: 9px; outline: 0; }

.data-panel { overflow: hidden; background: white; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { height: 43px; padding: 0 15px; color: var(--ink-500); background: #f8fafb; border-bottom: 1px solid var(--line); font-size: 9px; font-weight: 800; letter-spacing: .07em; text-align: left; text-transform: uppercase; }
.data-table td { height: 63px; padding: 9px 15px; border-bottom: 1px solid #edf1f3; color: var(--ink-700); font-size: 11px; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background .14s ease; }
.data-table tbody tr:hover { background: #fbfcfd; }
.record-name { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.record-avatar { flex: 0 0 32px; height: 32px; display: grid; place-items: center; color: #315b73; background: #e7f0f4; border-radius: 9px; font-size: 10px; font-weight: 800; }
.record-avatar.gold { color: #8f6626; background: var(--gold-100); }
.record-avatar.green { color: var(--green-600); background: var(--green-100); }
.record-name strong, .record-name small { display: block; max-width: 220px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.record-name strong { color: var(--ink-900); font-size: 11px; }
.record-name small { margin-top: 2px; color: var(--ink-400); font-size: 9px; }
.status-badge, .priority-badge { display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; border-radius: 7px; font-size: 9px; font-weight: 800; text-transform: capitalize; white-space: nowrap; }
.status-badge::before { content: ""; width: 5px; height: 5px; background: currentColor; border-radius: 50%; opacity: .75; }
.status-new, .status-preconstruction, .status-open, .status-intake, .status-preliminary, .status-pending, .status-received, .status-apex { color: var(--blue-600); background: var(--blue-100); }
.status-contacted, .status-scheduled, .status-in_progress, .status-reviewing, .status-increase { color: var(--orange-600); background: var(--orange-100); }
.status-qualified, .status-active, .status-complete, .status-won, .status-approved, .status-verified, .status-reviewed, .status-counted, .status-incorporated, .status-closed, .status-none, .status-not_applicable { color: var(--green-600); background: var(--green-100); }
.status-estimating, .status-proposal, .status-billing, .status-closeout, .status-takeoff, .status-pricing, .status-review, .status-submitted, .status-allowance, .status-subcontracted, .status-by_others { color: #7a5c1a; background: var(--gold-100); }
.status-lost, .status-on_hold, .status-rfi, .status-excluded, .status-decrease { color: var(--red-600); background: var(--red-100); }
.priority-badge { color: var(--ink-500); background: #f1f4f5; }
.priority-high, .priority-urgent { color: var(--red-600); background: var(--red-100); }
.money-cell { color: var(--ink-900) !important; font-variant-numeric: tabular-nums; font-weight: 700; }
.action-group { display: flex; align-items: center; justify-content: flex-end; gap: 3px; }
.row-action { width: 30px; height: 30px; display: grid; place-items: center; color: var(--ink-400); background: transparent; border: 0; border-radius: 7px; cursor: pointer; }
.row-action:hover { color: var(--ink-900); background: #edf2f4; }
.row-action svg { width: 14px; height: 14px; }
.row-action.convert { color: var(--green-600); }
.table-empty { padding: 54px 20px; color: var(--ink-400); text-align: center; }
.table-empty strong { display: block; margin-bottom: 5px; color: var(--ink-700); }

.project-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.project-card { padding: 18px; background: white; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); cursor: pointer; transition: .17s ease; }
.project-card:hover { transform: translateY(-2px); border-color: #bfd0d8; box-shadow: 0 10px 25px rgba(11,22,32,.07); }
.project-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.project-card .project-icon { width: 35px; height: 35px; display: grid; place-items: center; color: var(--blue-600); background: var(--blue-100); border-radius: 9px; }
.project-card .project-icon svg { width: 17px; height: 17px; }
.project-card h3 { margin: 14px 0 3px; font-size: 14px; letter-spacing: -.015em; }
.project-card > p { margin: 0; color: var(--ink-400); font-size: 10px; }
.project-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0; padding: 13px 0; border-top: 1px solid #edf1f2; border-bottom: 1px solid #edf1f2; }
.project-meta small, .project-meta strong { display: block; }
.project-meta small { color: var(--ink-400); font-size: 8px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; }
.project-meta strong { margin-top: 4px; font-size: 11px; }
.project-card-foot { display: flex; align-items: center; justify-content: space-between; color: var(--ink-500); font-size: 9px; }

.estimate-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.estimate-card { padding: 18px; background: white; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); cursor: pointer; transition: .17s ease; }
.estimate-card:hover { transform: translateY(-2px); border-color: #e0bc79; box-shadow: 0 10px 25px rgba(11,22,32,.07); }
.estimate-card-head { display: flex; align-items: flex-start; justify-content: space-between; }
.estimate-icon { width: 36px; height: 36px; display: grid; place-items: center; color: #94671f; background: var(--gold-100); border-radius: 9px; }
.estimate-icon svg { width: 17px; height: 17px; }
.estimate-card h3 { margin: 14px 0 3px; font-size: 14px; }
.estimate-card > p { min-height: 30px; margin: 0; color: var(--ink-400); font-size: 10px; }
.estimate-money { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 15px 0; padding: 13px 0; border-top: 1px solid #edf1f2; border-bottom: 1px solid #edf1f2; }
.estimate-money small, .estimate-money strong { display: block; }
.estimate-money small { color: var(--ink-400); font-size: 8px; font-weight: 800; text-transform: uppercase; }
.estimate-money strong { margin-top: 4px; font-size: 11px; }
.approval-track { height: 5px; overflow: hidden; background: #edf1f2; border-radius: 5px; }
.approval-track span { display: block; height: 100%; background: linear-gradient(90deg, var(--blue-500), var(--green-600)); }
.estimate-card-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 9px; color: var(--ink-500); font-size: 8px; }

.record-dialog { width: min(680px, calc(100vw - 32px)); max-height: min(760px, calc(100vh - 32px)); padding: 0; overflow: hidden; background: white; border: 0; border-radius: 16px; box-shadow: var(--shadow-lg); }
.record-dialog::backdrop { background: rgba(5,14,21,.58); backdrop-filter: blur(3px); }
.record-dialog form { display: flex; flex-direction: column; max-height: min(760px, calc(100vh - 32px)); }
.dialog-header { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin: 4px 0 0; font-size: 21px; letter-spacing: -.025em; }
.dialog-body { padding: 22px; overflow-y: auto; }
.dialog-footer { flex: 0 0 auto; display: flex; align-items: center; justify-content: flex-end; gap: 9px; padding: 15px 22px; background: #f8fafb; border-top: 1px solid var(--line); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { color: var(--ink-700); font-size: 10px; font-weight: 800; }
.field label span { color: var(--red-600); }
.field input, .field select, .field textarea { width: 100%; min-height: 42px; padding: 9px 11px; color: var(--ink-900); background: white; border: 1px solid #d8e0e4; border-radius: 8px; outline: 0; transition: .15s ease; }
.field textarea { min-height: 92px; resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: #7db2cc; box-shadow: 0 0 0 3px rgba(36,130,187,.1); }
.field small { color: var(--ink-400); font-size: 9px; }
.ratebook-save-control { display: grid; grid-template-columns: 1fr auto; gap: 10px 16px; margin-top: 18px; padding: 14px; background: #fff9eb; border: 1px solid #ead8ae; border-radius: 9px; }
.ratebook-save-control strong, .ratebook-save-control small { display: block; }
.ratebook-save-control strong { font-size: 10px; }
.ratebook-save-control small { margin-top: 4px; color: var(--ink-500); font-size: 8px; line-height: 1.45; }
.ratebook-save-control label { display: flex; align-items: center; gap: 7px; color: #7a5c1a; font-size: 9px; font-weight: 800; }
.ratebook-save-control select { grid-column: 1 / -1; min-height: 38px; padding: 0 10px; background: white; border: 1px solid #ddca9f; border-radius: 8px; }
.form-safety-note { margin-top: 16px; padding: 11px 12px; color: var(--ink-600); background: #f5f8f9; border-left: 3px solid var(--blue-500); border-radius: 6px; font-size: 9px; line-height: 1.5; }

.detail-dialog { width: min(1180px, calc(100vw - 32px)); }
.detail-dialog[open] { display: flex; flex-direction: column; }
.detail-dialog > .dialog-header { flex: 0 0 auto; }
.detail-dialog > .dialog-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.detail-section { margin-bottom: 22px; }
.detail-section:last-child { margin-bottom: 0; }
.detail-section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.detail-section h3 { margin: 0; font-size: 12px; }
.detail-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.detail-stat { padding: 12px; background: #f7f9fa; border: 1px solid #edf1f2; border-radius: 9px; }
.detail-stat small, .detail-stat strong { display: block; }
.detail-stat small { color: var(--ink-400); font-size: 8px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; }
.detail-stat strong { margin-top: 6px; font-size: 11px; }
.notes-box { padding: 13px; color: var(--ink-700); background: #f7f9fa; border: 1px solid #edf1f2; border-radius: 9px; font-size: 11px; line-height: 1.55; white-space: pre-wrap; }
.upload-zone { position: relative; min-height: 96px; display: grid; place-items: center; padding: 15px; color: var(--ink-500); background: #fafcfc; border: 1px dashed #cbd7dc; border-radius: 10px; text-align: center; cursor: pointer; }
.upload-zone:hover { border-color: var(--blue-500); background: #f5fafc; }
.upload-zone input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.upload-zone svg { width: 22px; height: 22px; margin-bottom: 5px; color: var(--blue-600); }
.upload-zone strong { display: block; color: var(--ink-700); font-size: 10px; }
.upload-zone small { display: block; margin-top: 3px; font-size: 9px; }
.file-list { margin-top: 10px; }
.file-row { display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 9px; padding: 9px 0; border-bottom: 1px solid #edf1f2; }
.file-row:last-child { border-bottom: 0; }
.file-icon { width: 29px; height: 29px; display: grid; place-items: center; color: var(--blue-600); background: var(--blue-100); border-radius: 7px; }
.file-icon svg { width: 14px; height: 14px; }
.file-copy strong, .file-copy small { display: block; }
.file-copy strong { font-size: 10px; }
.file-copy small { margin-top: 2px; color: var(--ink-400); font-size: 8px; }

.detail-section-head > div > p { margin: 3px 0 0; color: var(--ink-400); font-size: 9px; }
.estimate-detail-grid { grid-template-columns: repeat(4, 1fr); }
.pricing-summary-grid { grid-template-columns: repeat(6, 1fr); }
.approval-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }
.approval-gate { display: flex; align-items: center; gap: 9px; padding: 11px; background: #f7f9fa; border: 1px solid #e7ecef; border-radius: 9px; }
.approval-gate > span { width: 27px; height: 27px; display: grid; place-items: center; color: var(--ink-400); background: white; border: 1px solid var(--line); border-radius: 50%; }
.approval-gate > span svg { width: 13px; height: 13px; }
.approval-gate small, .approval-gate strong { display: block; }
.approval-gate small { color: var(--ink-400); font-size: 8px; text-transform: uppercase; }
.approval-gate strong { margin-top: 2px; font-size: 10px; }
.gate-approved { background: var(--green-100); border-color: #cfe7dc; }
.gate-approved > span { color: var(--green-600); border-color: #b9dcca; }
.gate-reviewed { background: var(--gold-100); border-color: #ecd9ae; }
.document-upload-row { display: grid; grid-template-columns: 190px 1fr; gap: 10px; }
.document-upload-row > select { min-height: 76px; padding: 0 12px; color: var(--ink-700); background: white; border: 1px solid var(--line); border-radius: 10px; }
.compact-upload { min-height: 76px; }
.takeoff-import-card { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px; background: linear-gradient(135deg, #f3f9fc, #fbfcfc); border: 1px solid #d6e6ed; border-radius: 11px; }
.takeoff-import-card h3 { margin-top: 4px; }
.takeoff-import-card p { max-width: 700px; margin: 5px 0 0; color: var(--ink-500); font-size: 9px; line-height: 1.5; }
.takeoff-import-button { position: relative; flex: 0 0 auto; cursor: pointer; }
.takeoff-import-button input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.regional-pricing-card { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px; background: linear-gradient(135deg, #fff8e9, #fffdf8); border: 1px solid #ecd8a9; border-radius: 11px; }
.regional-pricing-card h3 { margin-top: 4px; }
.regional-pricing-card p { margin: 5px 0 0; color: var(--ink-500); font-size: 9px; line-height: 1.5; }
.regional-pricing-card small { display: block; margin-top: 7px; color: #8f6626; font-size: 8px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.regional-pricing-actions { min-width: 245px; display: grid; gap: 8px; }
.regional-pricing-actions select { min-height: 40px; padding: 0 10px; color: var(--ink-700); background: white; border: 1px solid #ddca9f; border-radius: 8px; }
.regional-pricing-actions button { justify-content: center; }
.regional-pricing-actions .pricing-settings-button { min-height: 30px; color: #7a5c1a; }
.addendum-upload { margin-bottom: 8px; }
.addendum-file-list { margin: 0 0 12px; }
.compact-empty { padding: 15px; font-size: 9px; }
.addenda-table { margin-top: 8px; }
.data-panel.embedded { overflow-x: auto; border-radius: 10px; box-shadow: none; }
.data-panel.embedded .data-table { min-width: 860px; }
.data-panel.embedded .data-table td { height: auto; min-height: 54px; vertical-align: top; }
.table-sub { display: block; margin-top: 3px; color: var(--ink-400); font-size: 8px; }
.loading-state.compact { min-height: 240px; }
.zone-pricing-summary { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-bottom: 8px; }
.zone-pricing-summary > div { padding: 11px; background: #f3f8fa; border: 1px solid #dce9ee; border-radius: 8px; }
.zone-pricing-summary small, .zone-pricing-summary strong { display: block; }
.zone-pricing-summary small { color: var(--ink-400); font-size: 7px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.zone-pricing-summary strong { margin-top: 4px; font-size: 10px; }
.zone-pricing-warning, .zone-pricing-empty { margin-bottom: 10px; padding: 10px 12px; color: #7a5c1a; background: #fff8e9; border: 1px solid #ecd8a9; border-radius: 8px; font-size: 8px; line-height: 1.5; }
.zone-pricing-empty strong, .zone-pricing-empty span { display: block; }
.zone-pricing-empty span { margin-top: 2px; }
.zone-pricing-table .data-table { min-width: 1120px; }
.zone-pricing-table details { min-width: 145px; }
.zone-pricing-table summary { color: var(--blue-700); font-size: 8px; font-weight: 800; cursor: pointer; }
.zone-rate-lines { width: min(760px, 70vw); margin-top: 7px; padding: 8px; background: white; border: 1px solid var(--line); border-radius: 8px; }
.zone-rate-lines table { width: 100%; border-collapse: collapse; }
.zone-rate-lines th, .zone-rate-lines td { height: auto; min-height: 0; padding: 6px; border-bottom: 1px solid #edf1f2; font-size: 8px; text-align: left; }
.zone-rate-lines p { margin: 8px 2px 2px; color: var(--ink-500); font-size: 8px; }
.mapping-missing { color: var(--ink-400); font-size: 8px; font-weight: 700; }
.rfq-scope-picker { display: grid; gap: 8px; margin-top: 18px; padding: 14px; background: #f7f9fa; border: 1px solid var(--line); border-radius: 10px; }
.rfq-scope-picker > div { margin-bottom: 3px; }
.rfq-scope-picker > div strong, .rfq-scope-picker > div small { display: block; }
.rfq-scope-picker > div small { margin-top: 3px; color: var(--ink-400); font-size: 9px; }
.rfq-scope-picker > label { display: flex; align-items: flex-start; gap: 9px; padding: 9px 10px; background: white; border: 1px solid #e4eaed; border-radius: 8px; cursor: pointer; }
.rfq-scope-picker > label:hover { border-color: #bad0db; }
.rfq-scope-picker input { width: auto; margin-top: 2px; }
.rfq-scope-picker label strong, .rfq-scope-picker label small { display: block; }
.rfq-scope-picker label strong { font-size: 10px; }
.rfq-scope-picker label small { margin-top: 2px; color: var(--ink-400); font-size: 8px; }
.contractor-rfq-table details { min-width: 115px; }
.contractor-rfq-table summary { color: var(--blue-700); font-weight: 800; cursor: pointer; }
.rfq-line-table { width: min(720px, 70vw); margin-top: 8px; padding: 8px; background: white; border: 1px solid var(--line); border-radius: 8px; }
.rfq-line-table table { width: 100%; border-collapse: collapse; }
.rfq-line-table th, .rfq-line-table td { height: auto; padding: 6px; border-bottom: 1px solid #edf1f2; font-size: 8px; text-align: left; }
.rfq-line-table p { margin: 8px 2px 2px; color: var(--ink-500); font-size: 8px; }
.rfq-actions { display: grid; gap: 6px; min-width: 95px; }
.compact-button { min-height: 30px; padding: 0 10px; font-size: 9px; }

.quick-menu { position: fixed; z-index: 80; top: 66px; right: 30px; width: 320px; padding: 7px; background: white; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 18px 45px rgba(7,17,26,.17); }
.quick-menu[hidden] { display: none; }
.quick-menu button { width: 100%; display: flex; align-items: center; gap: 11px; padding: 10px; background: transparent; border: 0; border-radius: 9px; text-align: left; cursor: pointer; }
.quick-menu button:hover { background: #f5f8f9; }
.quick-menu button > span:last-child { min-width: 0; }
.quick-menu strong, .quick-menu small { display: block; }
.quick-menu strong { font-size: 11px; }
.quick-menu small { margin-top: 2px; color: var(--ink-400); font-size: 9px; }
.quick-icon { flex: 0 0 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; }
.quick-icon svg { width: 16px; height: 16px; }
.quick-icon.blue { color: var(--blue-600); background: var(--blue-100); }
.quick-icon.gold { color: #8f6626; background: var(--gold-100); }
.quick-icon.green { color: var(--green-600); background: var(--green-100); }
.quick-icon.slate { color: #586d78; background: #eef2f4; }

.toast-region { position: fixed; z-index: 100; right: 18px; bottom: 18px; display: grid; gap: 8px; pointer-events: none; }
.toast { min-width: 280px; max-width: 390px; display: flex; align-items: center; gap: 10px; padding: 12px 14px; color: white; background: var(--navy-800); border: 1px solid rgba(255,255,255,.1); border-radius: 10px; box-shadow: var(--shadow-lg); animation: toast-in .22s ease; }
.toast.error { background: #8d3838; }
.toast svg { flex: 0 0 17px; width: 17px; height: 17px; }
.toast span { font-size: 11px; font-weight: 700; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

.loading-state { min-height: calc(100vh - 140px); display: grid; place-content: center; justify-items: center; color: var(--ink-500); }
.loading-logo { width: 48px; height: 48px; display: grid; place-items: center; transform: rotate(45deg); color: white; background: var(--blue-600); border-radius: 12px; font-size: 20px; font-weight: 900; animation: breathe 1.3s ease-in-out infinite; }
.loading-logo::first-letter { transform: rotate(-45deg); }
.loading-state p { margin-top: 18px; font-size: 11px; font-weight: 700; }
@keyframes breathe { 50% { transform: rotate(45deg) scale(1.06); opacity: .8; } }

.mobile-overlay { display: none; }

@media (max-width: 1120px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .project-grid { grid-template-columns: repeat(2, 1fr); }
  .estimate-grid { grid-template-columns: repeat(2, 1fr); }
  .pricing-summary-grid { grid-template-columns: repeat(3, 1fr); }
  .zone-pricing-summary { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 820px) {
  :root { --sidebar-width: 240px; }
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
  .sidebar.is-open { transform: translateX(0); }
  .mobile-overlay { position: fixed; inset: 0; z-index: 35; display: block; visibility: hidden; opacity: 0; background: rgba(7,17,26,.5); transition: .2s ease; }
  .mobile-overlay.is-open { visibility: visible; opacity: 1; }
  .main-column { width: 100%; margin-left: 0; }
  .topbar { height: 66px; padding: 0 16px; gap: 10px; }
  .mobile-menu { display: inline-grid; }
  .global-search { max-width: none; }
  kbd, .notification-button { display: none; }
  main { min-height: calc(100vh - 66px); padding: 22px 16px 38px; }
  .page-heading { align-items: flex-start; }
  .data-panel { overflow-x: auto; }
  .data-table { min-width: 760px; }
  .quick-menu { top: 58px; right: 12px; width: min(320px, calc(100vw - 24px)); }
}

@media (max-width: 620px) {
  .global-search { width: 40px; flex: 0 0 40px; justify-content: center; padding: 0; }
  .global-search input { position: fixed; top: 64px; left: 12px; right: 12px; z-index: 50; width: calc(100vw - 24px); height: 44px; display: none; padding: 0 14px; background: white; border: 1px solid #bad0db; border-radius: 9px; box-shadow: var(--shadow-lg); }
  .global-search:focus-within input { display: block; }
  .topbar-actions { gap: 2px; }
  .topbar-actions .primary-button { width: 40px; padding: 0; }
  .topbar-actions .primary-button span { display: none; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .metric-card { min-height: 124px; padding: 15px; }
  .metric-value { font-size: 22px; }
  .page-heading { display: block; }
  .page-heading .heading-actions { margin-top: 14px; }
  .page-heading .heading-actions > * { flex: 1; }
  .toolbar { flex-wrap: wrap; }
  .table-search { flex-basis: 100%; }
  .filter-select { flex: 1; min-width: 0; }
  .project-grid { grid-template-columns: 1fr; }
  .estimate-grid { grid-template-columns: 1fr; }
  .pipeline-board { grid-template-columns: repeat(5, 160px); }
  .form-grid { grid-template-columns: 1fr; }
  .ratebook-save-control { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .approval-grid { grid-template-columns: 1fr; }
  .document-upload-row { grid-template-columns: 1fr; }
  .takeoff-import-card { align-items: stretch; flex-direction: column; }
  .takeoff-import-button { justify-content: center; }
  .regional-pricing-card { align-items: stretch; flex-direction: column; }
  .regional-pricing-actions { min-width: 0; }
  .pricing-summary-grid { grid-template-columns: 1fr 1fr; }
  .zone-pricing-summary { grid-template-columns: 1fr 1fr; }
  .record-dialog { width: calc(100vw - 16px); max-height: calc(100vh - 16px); border-radius: 13px; }
  .record-dialog form { max-height: calc(100vh - 16px); }
  .dialog-header, .dialog-body, .dialog-footer { padding-left: 16px; padding-right: 16px; }
}

@media (max-width: 410px) {
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 115px; }
}

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