:root {
  --ink: #172033;
  --ink-strong: #0b1220;
  --blue: #1769e0;
  --blue-dark: #1052b4;
  --navy: #20324d;
  --green: #087a55;
  --red: #c93636;
  --canvas: #f5f7fa;
  --surface: #ffffff;
  --surface-muted: #eef2f6;
  --border: #d8dee8;
  --muted: #5d687a;
  --focus: #0b6fff;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body { min-height: 100dvh; margin: 0; background: var(--canvas); color: var(--ink); line-height: 1.5; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }
a { color: var(--blue-dark); }
button:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible, a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
h1, h2, h3, p { overflow-wrap: anywhere; }
.app-shell, .contractor-shell, .owner-shell { min-height: 100dvh; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.tabular { font-variant-numeric: tabular-nums; }
.helper, .empty-list { margin: 0; color: var(--muted); font-size: 14px; }
.error { color: var(--red); }

.loading, .workspace {
  display: grid;
  width: min(calc(100% - 32px), 520px);
  min-height: 100dvh;
  margin: auto;
  align-content: center;
  gap: 16px;
}
.panel, .auth-card {
  display: grid;
  gap: 20px;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 34px rgb(23 32 51 / 8%);
}
.panel h1, .panel h2, .panel p { margin: 0; }
.panel form { display: grid; gap: 10px; }

.brand, .auth-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand h1, .brand p { margin: 0; }
.brand h1 { color: var(--ink-strong); font-size: 18px; line-height: 1.2; }
.brand p { color: var(--muted); font-size: 13px; }
.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  place-items: center;
  border-radius: 8px;
  background: var(--navy);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
}

.auth-shell { display: grid; min-height: 100dvh; padding: 24px; place-items: center; }
.auth-card { width: min(100%, 430px); }
.auth-brand { color: var(--ink-strong); font-size: 17px; font-weight: 800; }
.auth-brand .brand-mark { width: 38px; height: 38px; flex-basis: 38px; font-size: 14px; }
.auth-intro { display: grid; gap: 6px; }
.auth-intro h1 { margin: 0; color: var(--ink-strong); font-size: 28px; line-height: 1.2; }
.auth-intro p { margin: 0; color: var(--muted); }
.auth-card form, .email-access-body { display: grid; gap: 10px; }
.google-button { position: relative; justify-content: center; border-color: #bdc6d3; background: #fff; color: var(--ink-strong); }
.google-button:hover:not(:disabled) { background: #f8fafc; border-color: #97a3b4; }
.google-mark { width: 20px; height: 20px; flex: 0 0 20px; }
.auth-divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; text-transform: uppercase; }
.auth-divider::before, .auth-divider::after { height: 1px; flex: 1; background: var(--border); content: ""; }
.email-access { border-top: 1px solid var(--border); }
.email-access > summary, .security-details > summary, .activity-details > summary, .disclosure-section > summary {
  min-height: 44px;
  padding: 12px 2px;
  color: var(--navy);
  font-weight: 700;
  cursor: pointer;
}
.email-access-body { padding-top: 8px; }
.auth-mode-switch { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 3px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-muted); }
.auth-mode-switch button { min-height: 44px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); font-weight: 700; }
.auth-mode-switch button.active { background: var(--surface); color: var(--ink-strong); box-shadow: 0 1px 3px rgb(23 32 51 / 12%); }
.auth-message, .contractor-message, .owner-message { margin: 0; padding: 10px 12px; border-left: 3px solid var(--red); background: #fff1f1; color: #8d2020; font-size: 14px; }
.auth-message.notice, .contractor-message.notice, .owner-message.notice { border-color: var(--green); background: #ecf8f3; color: #075b42; }
.auth-legal { margin: 0; color: var(--muted); font-size: 12px; text-align: center; }

.field-label { display: block; margin: 4px 0 6px; color: var(--ink-strong); font-size: 14px; font-weight: 700; }
.input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid #b9c2cf;
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink-strong);
}
.input:hover { border-color: #929daf; }
.input:focus { border-color: var(--focus); }
.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 750;
}
.button.primary { border-color: var(--blue); background: var(--blue); color: #fff; }
.button.primary:hover:not(:disabled) { border-color: var(--blue-dark); background: var(--blue-dark); }
.button.secondary { border-color: #aeb8c6; color: var(--navy); }
.button.secondary:hover:not(:disabled), .button.icon-button:hover:not(:disabled) { background: var(--surface-muted); }
.button.danger { border-color: #dfabab; color: #a92020; }
.button.danger:hover:not(:disabled) { background: #fff1f1; }
.button.full { width: 100%; }
.button.compact { min-height: 44px; padding: 8px 11px; font-size: 13px; }
.icon-button { width: 44px; padding: 0; font-size: 22px; }
.action-row { display: flex; flex-wrap: wrap; gap: 8px; }
.action-row .button { flex: 1 1 140px; }

.contractor-header {
  display: flex;
  width: min(calc(100% - 40px), 1120px);
  min-height: 76px;
  margin: auto;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
}
.account-summary { display: grid; max-width: min(42vw, 320px); justify-items: end; gap: 1px; text-align: right; }
.account-summary strong { max-width: 100%; overflow: hidden; color: var(--ink-strong); font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.account-summary span { color: var(--muted); font-size: 12px; }
.workspace-tabs {
  display: flex;
  width: min(calc(100% - 40px), 1120px);
  gap: 4px;
  margin: 0 auto;
  border-bottom: 1px solid var(--border);
}
.workspace-tab {
  display: inline-flex;
  min-height: 52px;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}
.workspace-tab:hover { color: var(--ink-strong); }
.workspace-tab.active { border-bottom-color: var(--blue); color: var(--blue-dark); }
.ui-icon, .nav-icon { width: 19px; height: 19px; flex: 0 0 19px; }
.workspace-content { display: grid; width: min(calc(100% - 40px), 1120px); gap: 16px; margin: 24px auto 40px; }
.page-heading, .page-title { display: grid; gap: 4px; }
.page-heading h2, .page-heading p, .page-title h2, .page-title p { margin: 0; }
.page-heading h2, .page-title h2 { color: var(--ink-strong); font-size: 24px; line-height: 1.25; }
.page-heading p, .page-title p { color: var(--muted); }
.eyebrow { margin: 0; color: var(--blue-dark); font-size: 12px; font-weight: 800; text-transform: uppercase; }
.section-title { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 12px; }
.section-title h2, .section-title h3 { margin: 0; color: var(--ink-strong); font-size: 18px; line-height: 1.3; }

.contractor-shell, .owner-shell { padding-bottom: max(76px, env(safe-area-inset-bottom)); }
.contractor-state { display: grid; width: min(calc(100% - 32px), 520px); gap: 16px; margin: 40px auto; }
.state-heading h2 { margin: 0; color: var(--ink-strong); font-size: 24px; }
.claim-form, .settings-section form { display: grid; gap: 8px; }
.lookup-layout { display: grid; grid-template-columns: minmax(0, 720px); justify-content: center; }
.lookup-tool, .price-result, .workspace-section {
  display: grid;
  min-width: 0;
  gap: 16px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
.lookup-tool form { display: grid; gap: 8px; }
.input-action { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.scan-button { width: fit-content; }
.camera-preview { width: 100%; aspect-ratio: 4 / 3; border-radius: 6px; background: var(--ink-strong); object-fit: cover; }
.search-results { display: grid; gap: 8px; padding-top: 4px; }
.search-results .section-title h3 { font-size: 15px; }
.catalog-list { display: grid; border-top: 1px solid var(--border); }
.catalog-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: 58px;
  width: 100%;
  align-items: center;
  gap: 12px;
  padding: 10px 2px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--ink);
  text-align: left;
}
.catalog-row:hover { background: #f8fafc; }
.catalog-row span { display: grid; min-width: 0; }
.catalog-row small { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.price-result { padding: 18px; background: #f8fbff; border-color: #c6d9f4; }
.product-heading { display: flex; min-width: 0; align-items: start; justify-content: space-between; gap: 12px; }
.product-heading h2 { margin: 0; color: var(--ink-strong); font-size: 20px; }
.favorite-button {
  min-width: 60px;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--navy);
  font-weight: 700;
}
.favorite-button.active { border-color: var(--green); color: var(--green); }
.favorite-action { display: grid; flex: 0 0 auto; justify-items: end; gap: 8px; }
.favorite-action .contractor-message { max-width: 240px; }
.effective-price { display: grid; gap: 2px; padding: 14px 0; border-top: 1px solid #d9e5f4; border-bottom: 1px solid #d9e5f4; }
.effective-price span, .price-facts dt { color: var(--muted); font-size: 12px; font-weight: 700; }
.effective-price strong { color: var(--navy); font-size: 38px; line-height: 1.1; }
.price-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0; }
.price-facts dt, .price-facts dd { margin: 0; }
.price-facts dd { overflow-wrap: anywhere; color: var(--ink-strong); font-weight: 700; }
.settings-section { align-content: start; }
.password-field { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.password-visibility { min-width: 58px; min-height: 44px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--navy); font-weight: 700; }

.owner-overview { display: grid; gap: 16px; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.kpi { display: grid; min-height: 92px; align-content: space-between; gap: 4px; padding: 14px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.kpi span { color: var(--muted); font-size: 13px; font-weight: 700; }
.kpi strong { color: var(--ink-strong); font-size: 28px; line-height: 1.1; }
.owner-split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 16px; }
.owner-search { margin: 0; }
.result-count { margin-top: -6px; }
.count-badge { display: grid; min-width: 28px; min-height: 28px; padding: 2px 7px; place-items: center; border-radius: 99px; background: var(--surface-muted); color: var(--navy); font-size: 13px; font-weight: 800; }
.table-wrap { width: 100%; overflow-x: auto; }
.owner-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.owner-table th, .owner-table td { padding: 11px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.owner-table th { color: var(--muted); font-size: 12px; text-transform: uppercase; }
.owner-table td strong, .owner-table td small { display: block; }
.owner-table td small { color: var(--muted); }
.table-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.status-pill { display: inline-block; padding: 3px 7px; border: 1px solid var(--border); border-radius: 6px; color: var(--muted); font-size: 12px; font-weight: 700; text-transform: capitalize; }
.status-pill.active { border-color: #8fcab6; color: #075b42; }
.status-pill.inactive { border-color: #dfabab; color: #8d2020; }
.activity-list { display: grid; margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--border); }
.activity-list li { display: flex; min-width: 0; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.activity-list li span { min-width: 0; }
.activity-list strong, .activity-list small { display: block; }
.activity-list small { color: var(--muted); font-size: 12px; }
.activity-list li > span:last-child { flex: 0 0 auto; text-align: right; }
.activity-details { border-top: 1px solid var(--border); }
.activity-details .activity-list { margin-top: 4px; }
.disclosure-section { padding-block: 8px; }
.disclosure-section > summary { font-size: 17px; }
.claim-code-panel { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 12px; align-items: center; padding: 16px; border: 1px solid #96b9e8; border-radius: 8px; background: #f8fbff; }
.claim-code-panel h2 { margin: 0; font-size: 18px; }
.claim-code { padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); font-weight: 800; }
.import-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.file-input { padding: 7px; }
.textarea { min-height: 100px; resize: vertical; }
.settings-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr); gap: 16px; align-items: start; }
.settings-options { display: grid; gap: 2px; margin: 6px 0; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; }
.settings-options legend { padding: 0 4px; color: var(--ink-strong); font-size: 13px; font-weight: 700; }
.check-row { display: flex; min-height: 44px; align-items: center; gap: 8px; font-weight: 650; }
.check-row input { width: 20px; height: 20px; accent-color: var(--blue); }
.security-details form { padding-top: 8px; }
.confirm-backdrop { position: fixed; inset: 0; z-index: 30; display: grid; padding: 16px; place-items: center; background: rgb(11 18 32 / 56%); }
.confirm-dialog { display: grid; width: min(100%, 440px); gap: 16px; padding: 20px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); box-shadow: 0 20px 60px rgb(0 0 0 / 20%); }
.confirm-dialog h2, .confirm-dialog p { margin: 0; }

.legal-shell { width: min(calc(100% - 32px), 760px); margin: 0 auto; padding: 40px 0 64px; }
.legal-page { padding: 28px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.legal-page h1 { margin: 8px 0 0; color: var(--ink-strong); font-size: 30px; }
.legal-page h2 { margin: 28px 0 6px; color: var(--ink-strong); font-size: 18px; }
.legal-page p { margin: 8px 0; }
.legal-updated { color: var(--muted); font-size: 14px; }
.legal-back { display: inline-flex; min-height: 44px; align-items: center; font-weight: 700; }

.mobile-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  min-height: max(64px, calc(54px + env(safe-area-inset-bottom)));
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid var(--border);
  background: rgb(255 255 255 / 96%);
  box-shadow: 0 -4px 16px rgb(23 32 51 / 7%);
}
.mobile-nav button { display: grid; min-width: 0; min-height: 56px; padding: 6px 2px; place-items: center; align-content: center; gap: 2px; border: 0; background: transparent; color: var(--muted); font-size: 11px; font-weight: 700; }
.mobile-nav button.active { color: var(--blue-dark); }
.mobile-nav button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (min-width: 768px) {
  .contractor-shell, .owner-shell { padding-bottom: 0; }
  .mobile-nav { display: none; }
}

@media (max-width: 767px) {
  .auth-shell { padding: 16px; place-items: start center; }
  .auth-card { margin-top: max(12px, 6dvh); padding: 22px 18px; gap: 18px; }
  .auth-intro h1 { font-size: 24px; }
  .contractor-header { width: min(calc(100% - 28px), 1120px); min-height: 68px; }
  .brand-mark { width: 38px; height: 38px; flex-basis: 38px; font-size: 14px; }
  .brand h1 { font-size: 16px; }
  .brand p { max-width: 145px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .account-summary { max-width: 42vw; }
  .workspace-tabs { display: none; }
  .workspace-content { width: min(calc(100% - 24px), 1120px); gap: 12px; margin: 14px auto 24px; }
  .lookup-tool, .price-result, .workspace-section { padding: 15px; gap: 14px; }
  .page-heading h2, .page-title h2 { font-size: 22px; }
  .input-action { grid-template-columns: 1fr; }
  .input-action .button, .scan-button { width: 100%; }
  .product-heading { align-items: start; }
  .effective-price strong { font-size: 34px; }
  .price-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .price-facts div:last-child { grid-column: 1 / -1; }
  .contractor-state { margin: 28px auto; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi { min-height: 82px; padding: 12px; }
  .kpi strong { font-size: 24px; }
  .owner-split, .import-form, .settings-grid { grid-template-columns: 1fr; }
  .claim-code-panel { grid-template-columns: 1fr; }
  .claim-code-panel .button { width: 100%; }
  .section-title { align-items: start; }
  .owner-table, .owner-table tbody, .owner-table tr, .owner-table td { display: block; width: 100%; }
  .owner-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .owner-table tr { padding: 7px 0; border-bottom: 1px solid var(--border); }
  .owner-table td { display: grid; grid-template-columns: minmax(92px, .7fr) minmax(0, 1.3fr); gap: 8px; padding: 7px 0; border: 0; }
  .owner-table td::before { content: attr(data-label); color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; }
  .table-actions { justify-content: start; }
  .table-actions .button { flex: 1; }
  .activity-list li { align-items: start; }
  .legal-shell { padding: 12px 0 32px; }
  .legal-page { padding: 20px 16px; }
}

@media (max-width: 359px) {
  .auth-shell { padding: 10px; }
  .auth-card { padding: 18px 14px; }
  .contractor-header { width: calc(100% - 20px); }
  .workspace-content { width: calc(100% - 16px); }
  .brand p { max-width: 112px; }
  .account-summary strong { font-size: 12px; }
  .lookup-tool, .workspace-section { padding: 13px; }
  .mobile-nav button { font-size: 10px; }
}

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