:root {
  --canvas: #edf0ec;
  --surface: #ffffff;
  --surface-subtle: #f7f8f6;
  --surface-strong: #eef2f0;
  --ink: #182321;
  --muted: #66736f;
  --line: #d8dfdc;
  --line-strong: #c4cfca;
  --accent: #0d6f78;
  --accent-hover: #095d64;
  --accent-soft: #e7f3f3;
  --copper: #9a5b2c;
  --copper-soft: #fbf1e8;
  --success: #476b3b;
  --success-soft: #edf5e9;
  --warning: #94651d;
  --warning-soft: #fff5df;
  --danger: #9b3c35;
  --danger-soft: #fff0ee;
  --sidebar: #202827;
  --sidebar-hover: #303b39;
  --shadow: 0 18px 50px rgba(24, 35, 33, 0.12);
  --shadow-soft: 0 8px 24px rgba(24, 35, 33, 0.07);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #0f1513;
  --surface: #18211e;
  --surface-subtle: #131a18;
  --surface-strong: #24302c;
  --ink: #edf3f0;
  --muted: #a8b6b1;
  --line: #35423e;
  --line-strong: #465650;
  --accent: #61b8bf;
  --accent-hover: #78cbd1;
  --accent-soft: #17373a;
  --copper: #d8a16e;
  --copper-soft: #35271d;
  --success: #91bb82;
  --success-soft: #22321f;
  --warning: #e1b461;
  --warning-soft: #392f1c;
  --danger: #e0837b;
  --danger-soft: #3b2322;
  --sidebar: #0d1412;
  --sidebar-hover: #25312d;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  display: grid;
  place-items: center;
  padding: 16px;
}

button,
input,
select,
textarea {
  font: inherit;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

a {
  color: var(--accent);
  font-weight: 760;
}

svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  stroke-width: 2;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 2rem;
  line-height: 1.08;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

h2 {
  font-size: 1.25rem;
  line-height: 1.2;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

h3 {
  font-size: 0.98rem;
  line-height: 1.3;
  letter-spacing: 0;
}

small {
  color: var(--muted);
}

:focus-visible {
  outline: 3px solid rgba(13, 111, 120, 0.28);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  width: min(1440px, calc(100vw - 32px));
  height: calc(100vh - 32px);
  height: calc(100dvh - 32px);
  min-height: 620px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface-subtle);
  box-shadow: var(--shadow);
}

.sidebar {
  min-width: 0;
  padding: 22px 16px;
  background: var(--sidebar);
  color: #f4f6f3;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  padding-right: 38px;
}

.brand-mark,
.portal-masthead-mark {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #f2eadc;
  color: #29312f;
}

.brand-mark svg {
  width: 20px;
  height: 20px;
}

.brand-mark img,
.portal-masthead-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 6px;
  padding: 3px;
  background: #ffffff;
}

.brand-copy {
  min-width: 0;
}

.brand strong,
.brand span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand strong {
  color: #ffffff;
  font-size: 0.98rem;
}

.brand span {
  margin-top: 3px;
  color: #b8c4c0;
  font-size: 0.75rem;
}

.settings-gear {
  position: absolute;
  top: 2px;
  right: 0;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: transparent;
  color: #d7e0dd;
  display: grid;
  place-items: center;
  padding: 0;
}

.settings-gear:hover,
.settings-gear.active {
  border-color: rgba(255, 255, 255, 0.24);
  background: var(--sidebar-hover);
  color: #ffffff;
}

.nav-tabs {
  display: grid;
  gap: 6px;
}

.nav-tab {
  width: 100%;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #bdc8c4;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  font-size: 0.9rem;
  font-weight: 760;
}

.nav-tab:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

.nav-tab.active {
  border-color: rgba(255, 255, 255, 0.1);
  background: var(--sidebar-hover);
  color: #ffffff;
}

.nav-tab.active svg {
  color: #8ec9ca;
}

.sidebar-metric {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 18px;
}

.sidebar-metric strong,
.sidebar-metric p {
  display: block;
}

.sidebar-metric strong {
  margin: 4px 0 6px;
  color: #ffffff;
  font-size: 1.05rem;
}

.sidebar-metric p {
  color: #aebbb7;
  font-size: 0.78rem;
}

main {
  min-width: 0;
  overflow-y: auto;
  padding: 28px 32px 48px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

body.service-portal-signed-in #authPanel {
  display: none !important;
}

body.contractor-locked .settings-gear,
body.contractor-locked .nav-tabs,
body.contractor-locked .sidebar-metric,
body.contractor-locked .topbar,
body.contractor-locked .view {
  display: none !important;
}

body.contractor-locked .app-shell {
  width: min(920px, calc(100vw - 32px));
  grid-template-columns: 260px minmax(0, 1fr);
}

body.contractor-locked main {
  display: grid;
  align-content: center;
  padding: 36px;
}

.auth-panel {
  width: 100%;
  max-width: 520px;
  display: grid;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.auth-panel > div:first-child {
  display: grid;
  gap: 5px;
}

.auth-panel > div:first-child strong {
  font-size: 1.35rem;
}

.auth-panel > div:first-child small {
  line-height: 1.45;
}

.auth-form,
.stacked-form {
  display: grid;
  gap: 13px;
}

.auth-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 2px;
}

.topbar {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
}

.theme-toggle {
  position: relative;
  width: 38px;
  min-height: 38px;
  flex: 0 0 38px;
  padding: 0;
}

.theme-icon-dark {
  display: none;
}

html[data-theme="dark"] .theme-icon-light {
  display: none;
}

html[data-theme="dark"] .theme-icon-dark {
  display: block;
}

body.customer-view-active:not(.customer-portal-mode) .topbar {
  min-height: 48px;
  margin-bottom: 12px;
  padding-bottom: 10px;
}

body.customer-view-active:not(.customer-portal-mode) .topbar .eyebrow {
  display: none;
}

body.customer-view-active:not(.customer-portal-mode) .topbar h1 {
  font-size: 1.35rem;
}

.workspace-access-notice {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  margin: -4px 0 20px;
  border: 1px solid rgba(148, 101, 29, 0.34);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--warning-soft);
  color: var(--warning);
}

.workspace-access-notice > svg {
  margin-top: 1px;
}

.workspace-access-notice span,
.workspace-access-notice strong,
.workspace-access-notice small {
  display: block;
}

.workspace-access-notice small {
  margin-top: 3px;
  color: var(--warning);
  line-height: 1.4;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--copper);
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.primary-button,
.ghost-button,
.danger-button,
.accept-button,
.choice-button,
.icon-button,
.text-button {
  min-width: 0;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 780;
  line-height: 1.2;
  white-space: normal;
}

.primary-button,
.accept-button {
  background: var(--accent);
  color: #ffffff;
}

.primary-button:hover,
.accept-button:hover {
  background: var(--accent-hover);
}

.ghost-button,
.icon-button {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}

.ghost-button:hover,
.icon-button:hover {
  border-color: var(--line-strong);
  background: var(--surface-strong);
}

.danger-button {
  border-color: color-mix(in srgb, var(--danger) 38%, var(--line));
  background: var(--danger-soft);
  color: var(--danger);
}

.text-button {
  justify-self: start;
  min-height: 34px;
  padding: 0;
  background: transparent;
  color: var(--accent);
  text-align: left;
}

.icon-button {
  width: 40px;
  padding: 0;
}

.action-band {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.attention-section {
  display: grid;
  gap: 11px;
  margin-bottom: 16px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 15px 0;
}

.schedule-section {
  display: grid;
  gap: 11px;
  margin-bottom: 16px;
  padding: 2px 0 16px;
}

.upcoming-schedule {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.schedule-row {
  min-width: 0;
  min-height: 66px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 6px;
}

.schedule-row:hover,
.schedule-row.active {
  border-color: rgba(13, 111, 120, 0.4);
  background: var(--accent-soft);
}

.schedule-row-main {
  min-width: 0;
  min-height: 52px;
  justify-content: flex-start;
  gap: 9px;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 4px;
  text-align: left;
}

.schedule-date-block {
  width: 58px;
  min-width: 58px;
  min-height: 46px;
  display: grid;
  place-content: center;
  border-radius: 7px;
  background: var(--copper-soft);
  color: var(--copper);
  text-align: center;
}

.schedule-date-block strong,
.schedule-date-block small,
.schedule-job-copy strong,
.schedule-job-copy small {
  display: block;
}

.schedule-date-block strong {
  font-size: 0.78rem;
}

.schedule-date-block small {
  margin-top: 2px;
  font-size: 0.66rem;
  font-weight: 750;
  white-space: nowrap;
}

.schedule-job-copy {
  min-width: 0;
}

.schedule-job-copy strong,
.schedule-job-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.schedule-job-copy strong {
  font-size: 0.82rem;
}

.schedule-job-copy small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.68rem;
}

.attention-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.attention-queue {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.attention-item {
  min-width: 0;
  min-height: 58px;
  justify-content: flex-start;
  gap: 9px;
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 9px 10px;
  text-align: left;
}

.attention-item:hover,
.attention-item.active {
  border-color: rgba(13, 111, 120, 0.4);
  background: var(--accent-soft);
}

.attention-item.active {
  box-shadow: inset 3px 0 0 var(--accent);
}

.attention-item > span:last-child {
  min-width: 0;
}

.attention-item strong,
.attention-item small {
  display: block;
}

.attention-item strong {
  font-size: 1.05rem;
  line-height: 1;
}

.attention-item small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.2;
}

.attention-icon {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--copper-soft);
  color: var(--copper);
}

.attention-icon svg {
  width: 16px;
  height: 16px;
}

.choice-button {
  min-height: 70px;
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 12px 14px;
  justify-content: flex-start;
  text-align: left;
  box-shadow: var(--shadow-soft);
}

.choice-button:hover {
  border-color: rgba(13, 111, 120, 0.4);
  background: var(--surface-strong);
}

.choice-icon {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  flex: 0 0 auto;
}

.choice-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.choice-copy strong,
.choice-copy small {
  display: block;
}

.choice-copy strong {
  font-size: 0.95rem;
}

.choice-copy small {
  font-size: 0.78rem;
  font-weight: 600;
}

.choice-arrow {
  margin-left: auto;
  color: var(--muted);
}

.work-grid {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--surface);
}

.panel-header,
.dialog-header,
.dialog-actions,
.customer-hero,
.custom-field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.panel-header {
  min-height: 42px;
  margin-bottom: 14px;
}

.job-filter-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  gap: 7px;
  margin-bottom: 11px;
}

.search-control {
  position: relative;
  grid-column: 1 / -1;
}

.search-control svg {
  position: absolute;
  left: 11px;
  top: 50%;
  width: 17px;
  height: 17px;
  pointer-events: none;
  color: var(--muted);
  transform: translateY(-50%);
}

.search-control input {
  padding-left: 36px;
}

.filter-control {
  min-width: 0;
}

.job-filter-bar .icon-button {
  width: 40px;
  min-height: 42px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  clip-path: inset(50%) !important;
}

.job-list,
.document-list,
.custom-field-list {
  display: grid;
  gap: 7px;
}

.job-row {
  width: 100%;
  min-width: 0;
  min-height: 64px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--surface-subtle);
  padding: 11px 12px;
  color: var(--ink);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  text-align: left;
}

.job-row:hover {
  border-color: var(--line-strong);
  background: var(--surface-strong);
}

.job-row.active {
  border-color: rgba(13, 111, 120, 0.34);
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.job-row > span {
  min-width: 0;
}

.job-row strong,
.job-row small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
}

.job-row strong {
  line-height: 1.25;
}

.job-row small {
  margin-top: 4px;
  font-size: 0.78rem;
}

.job-row .job-attention-label {
  color: var(--copper);
  font-size: 0.7rem;
  font-weight: 780;
}

.job-row em,
.document-row em {
  color: var(--success);
  font-size: 0.75rem;
  font-style: normal;
  font-weight: 820;
  white-space: nowrap;
}

.job-status[data-status="Waiting on Customer"],
.status-pill[data-status="Waiting on Customer"],
.job-status[data-status="On Hold"],
.status-pill[data-status="On Hold"] {
  color: var(--warning);
}

.job-status[data-status="Complete"],
.status-pill[data-status="Complete"] {
  color: var(--muted);
}

.status-pill,
.count-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 9px;
  background: var(--surface-strong);
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 820;
  white-space: nowrap;
}

.job-detail {
  display: grid;
  gap: 18px;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-actions .primary-button,
.detail-actions .ghost-button {
  min-height: 38px;
  font-size: 0.82rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.stat-grid div,
.field-readout div {
  min-width: 0;
  min-height: 70px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  background: var(--surface-subtle);
}

.stat-grid span,
.field-readout span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 720;
}

.stat-grid strong,
.field-readout strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 0.88rem;
}

.plain-section {
  display: grid;
  gap: 9px;
  border-top: 1px solid var(--line);
  padding-top: 17px;
}

.plain-section p {
  color: var(--ink);
  line-height: 1.5;
}

.schedule-summary-line {
  display: flex;
  align-items: center;
  gap: 10px;
}

.schedule-summary-line > span:first-child {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
}

.schedule-summary-line strong,
.schedule-summary-line small {
  display: block;
}

.schedule-summary-line small {
  margin-top: 4px;
  color: var(--muted);
}

.weekday-fieldset,
.schedule-fieldset {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.weekday-fieldset legend,
.schedule-fieldset legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 760;
}

.weekday-options {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
}

.weekday-options label {
  position: relative;
  min-width: 0;
  display: block;
  cursor: pointer;
}

.weekday-options input {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.weekday-options span {
  min-height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-subtle);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 780;
}

.weekday-options input:checked + span {
  border-color: rgba(13, 111, 120, 0.5);
  background: var(--accent-soft);
  color: var(--accent);
}

.weekday-options input:focus-visible + span {
  outline: 3px solid rgba(13, 111, 120, 0.2);
  outline-offset: 1px;
}

.schedule-fieldset {
  display: grid;
  gap: 12px;
  background: var(--surface-subtle);
}

.compact-form-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.schedule-repeat-toggle {
  grid-column: 1 / -1;
  background: var(--surface);
}

.recurrence-controls {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  min-width: 0;
}

.schedule-suggestion-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.schedule-suggestion-row small {
  color: var(--muted);
  line-height: 1.35;
}

#scheduleVisitDialog {
  width: min(560px, calc(100vw - 28px));
}

.field-readout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.estimate-summary {
  border: 1px solid rgba(13, 111, 120, 0.2);
  border-radius: 8px;
  padding: 14px;
  background: var(--accent-soft);
}

.estimate-status-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.estimate-status-card > span:first-child {
  min-width: 0;
}

.estimate-status-card strong,
.estimate-status-card small {
  display: block;
  overflow-wrap: anywhere;
}

.estimate-status-card small {
  margin-top: 4px;
}

.estimate-status-card em {
  color: var(--success);
  font-size: 0.76rem;
  font-style: normal;
  font-weight: 820;
  white-space: nowrap;
}

.document-row,
.custom-field-row {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  background: var(--surface-subtle);
}

.document-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  overflow: hidden;
}

.document-row > span:first-child {
  min-width: 0;
}

.document-row strong,
.document-row small,
.custom-field-row strong,
.custom-field-row small {
  display: block;
}

.document-row strong,
.document-row small {
  max-width: 100%;
  overflow-wrap: anywhere;
}

.document-row small + small {
  margin-top: 3px;
}

.document-row-actions {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 9px;
}

.document-open-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 820;
  text-decoration: none;
  white-space: nowrap;
}

.document-open-link:hover {
  text-decoration: underline;
}

.document-pending-link {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.document-archive-button {
  min-height: 30px;
  font-size: 0.76rem;
}

.archive-tools {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.internal-note {
  border-left: 3px solid var(--copper);
  padding-left: 13px;
}

.customer-response-note {
  border-left: 3px solid var(--copper);
  padding: 10px 12px;
  background: var(--copper-soft);
}

.customer-response-note p {
  margin: 4px 0;
}

.action-feedback {
  border: 1px solid rgba(13, 111, 120, 0.22);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 760;
}

.timeline {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
}

.timeline li + li {
  margin-top: 6px;
}

.mileage-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.mileage-total {
  color: var(--accent);
  font-size: 0.86rem;
  font-weight: 820;
  white-space: nowrap;
}

.mileage-entry-form {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(100px, 140px) auto;
  align-items: end;
  gap: 9px;
  margin-top: 12px;
}

.mileage-entry-form .primary-button {
  min-height: 42px;
}

.mileage-list {
  display: grid;
  gap: 7px;
  margin-top: 12px;
}

.mileage-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 34px;
  align-items: center;
  gap: 10px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: var(--surface-subtle);
}

.mileage-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.mileage-row strong {
  color: var(--ink);
  white-space: nowrap;
}

.customer-layout {
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.customer-selector {
  position: sticky;
  top: 0;
  display: grid;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--surface);
}

.customer-selector h2 {
  margin-bottom: 4px;
}

.customer-portal {
  min-width: 0;
  display: grid;
  gap: 12px;
}

.customer-hero {
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--surface);
}

.customer-hero h2 {
  margin-bottom: 6px;
  font-size: 1.55rem;
}

.customer-portal .stat-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.customer-portal .plain-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--surface);
}

.customer-upload-actions,
.accept-row,
.estimate-decision-actions {
  display: grid;
  gap: 8px;
}

.customer-upload-actions {
  grid-template-columns: minmax(0, 240px);
}

.estimate-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-subtle);
}

.estimate-preview strong,
.estimate-preview small {
  display: block;
}

.estimate-pdf-frame {
  width: 100%;
  min-height: 560px;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.accept-button {
  width: 100%;
  min-height: 48px;
}

.acceptance-confirmed {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid rgba(71, 107, 59, 0.28);
  border-radius: 8px;
  padding: 12px;
  background: var(--success-soft);
  color: var(--success);
}

.acceptance-confirmed span {
  color: var(--muted);
  font-size: 0.78rem;
}

.estimate-decision-reject {
  border-color: rgba(155, 60, 53, 0.32);
  background: var(--danger-soft);
  color: var(--danger);
}

.portal-masthead {
  display: none;
}

.subscription-summary {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: var(--surface-subtle);
}

.subscription-summary strong,
.subscription-summary small {
  display: block;
}

.subscription-summary small + small {
  margin-top: 2px;
}

.company-logo-field {
  display: grid;
  gap: 7px;
}

.form-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 760;
}

.company-logo-control {
  display: flex;
  align-items: center;
  gap: 12px;
}

.company-logo-preview {
  width: 72px;
  height: 72px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface-subtle);
  color: var(--muted);
}

.company-logo-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 5px;
  background: #ffffff;
}

.company-logo-preview svg {
  width: 24px;
  height: 24px;
}

.company-logo-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.setting-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
  background: var(--surface-subtle);
  cursor: pointer;
}

.setting-toggle > span {
  min-width: 0;
}

.setting-toggle strong,
.setting-toggle small {
  display: block;
}

.setting-toggle small {
  margin-top: 3px;
  color: var(--muted);
  font-weight: 600;
}

.setting-toggle input[type="checkbox"] {
  appearance: none;
  width: 46px;
  min-width: 46px;
  height: 26px;
  min-height: 26px;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  padding: 2px;
  background: var(--line-strong);
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
}

.setting-toggle input[type="checkbox"]::before {
  content: "";
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(16, 25, 23, 0.25);
  transition: transform 160ms ease;
}

.setting-toggle input[type="checkbox"]:checked {
  border-color: var(--accent);
  background: var(--accent);
}

.setting-toggle input[type="checkbox"]:checked::before {
  transform: translateX(20px);
}

.setting-toggle input[type="checkbox"]:focus-visible {
  outline: 3px solid rgba(13, 111, 120, 0.22);
  outline-offset: 2px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 760;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 10px 11px;
}

input,
select {
  min-height: 42px;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 0.82;
}

input:disabled {
  background: var(--surface-strong);
  color: var(--muted);
}

textarea {
  resize: vertical;
}

.field-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.fine-print {
  margin-top: 8px;
  color: var(--muted) !important;
  font-size: 0.78rem;
  line-height: 1.45;
}

.empty-state {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 16px;
  background: var(--surface-subtle);
  color: var(--muted);
  line-height: 1.45;
}

dialog {
  width: min(840px, calc(100vw - 28px));
  max-height: min(860px, calc(100vh - 28px));
  overflow: auto;
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 26px 90px rgba(16, 25, 23, 0.26);
}

dialog::backdrop {
  background: rgba(20, 29, 27, 0.55);
  backdrop-filter: blur(2px);
}

.dialog-form {
  display: grid;
  gap: 18px;
  padding: 22px;
}

.dialog-header {
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  padding-bottom: 15px;
}

.form-grid,
.custom-field-inputs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.dialog-actions {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.toast-region {
  position: fixed;
  z-index: 100;
  right: 22px;
  bottom: 22px;
  width: min(360px, calc(100vw - 28px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.4;
}

.toast.error {
  border-left-color: var(--danger);
}

.toast.success {
  border-left-color: var(--success);
}

.hidden-file {
  position: fixed;
  inset: auto auto 0 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

body.customer-portal-mode {
  display: block;
  padding: 0;
  background: var(--surface-subtle);
}

body.customer-portal-mode .app-shell {
  display: block;
  width: 100%;
  height: auto;
  min-height: 100vh;
  min-height: 100dvh;
  max-height: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

body.customer-portal-mode .sidebar,
body.customer-portal-mode .topbar,
body.customer-portal-mode #authPanel,
body.customer-portal-mode .customer-selector {
  display: none !important;
}

body.customer-portal-mode main {
  max-width: 780px;
  margin: 0 auto;
  overflow: visible;
  padding: 16px 18px 48px;
}

body.customer-portal-mode .portal-masthead {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 11px;
}

body.customer-portal-mode .portal-masthead-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

body.customer-portal-mode .portal-masthead-copy strong,
body.customer-portal-mode .portal-masthead-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.customer-portal-mode .portal-masthead-copy strong {
  font-size: 0.9rem;
}

body.customer-portal-mode .portal-masthead-copy small {
  font-size: 0.7rem;
}

body.customer-portal-mode .portal-masthead-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
}

body.customer-portal-mode .portal-theme-toggle {
  margin-left: auto;
}

body.customer-portal-mode .portal-masthead-mark {
  background: var(--sidebar);
  color: #ffffff;
}

body.customer-portal-mode .customer-layout {
  display: block;
}

@media (max-width: 1100px) {
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .upcoming-schedule {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  body {
    display: block;
    padding: 0;
  }

  .app-shell,
  body.contractor-locked .app-shell {
    width: 100%;
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    max-height: none;
    grid-template-columns: 1fr;
    overflow: visible;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: minmax(190px, auto) minmax(180px, 1fr);
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
  }

  .sidebar-metric {
    display: none;
  }

  .nav-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nav-tab {
    justify-content: center;
    min-height: 40px;
    padding: 0 10px;
  }

  main,
  body.contractor-locked main {
    overflow: visible;
    padding: 22px 18px 44px;
  }

  body.contractor-locked main {
    display: grid;
    justify-items: center;
    align-content: start;
  }

  body.contractor-locked .sidebar {
    grid-template-columns: 1fr;
  }

  .work-grid,
  .customer-layout {
    grid-template-columns: 1fr;
  }

  .customer-selector {
    position: static;
  }

  .attention-queue {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .compact-form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .sidebar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    padding: 10px 12px;
  }

  .brand {
    padding-right: 36px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
  }

  .brand-copy span {
    display: none;
  }

  .settings-gear {
    top: 1px;
  }

  .nav-tabs {
    gap: 4px;
  }

  .nav-tab {
    width: 42px;
    min-height: 38px;
    padding: 0;
  }

  .nav-tab span {
    display: none;
  }

  main,
  body.contractor-locked main {
    padding: 18px 14px 40px;
  }

  h1 {
    font-size: 1.7rem;
  }

  .topbar {
    min-height: 58px;
    margin-bottom: 14px;
    padding-bottom: 14px;
  }

  body.customer-portal-mode main {
    padding: 10px 12px 32px;
  }

  body.customer-portal-mode .portal-masthead {
    margin-bottom: 9px;
    padding-bottom: 8px;
  }

  body.customer-portal-mode .portal-masthead-mark {
    width: 30px;
    height: 30px;
    flex-basis: 30px;
  }

  body.customer-portal-mode .portal-theme-toggle {
    width: 34px;
    min-height: 34px;
    flex-basis: 34px;
  }

  body.customer-portal-mode .customer-hero {
    padding: 14px;
  }

  body.customer-portal-mode .customer-hero h2 {
    font-size: 1.25rem;
  }

  .workspace-access-notice {
    margin-bottom: 14px;
  }

  .action-band {
    grid-template-columns: 1fr;
  }

  .upcoming-schedule {
    grid-template-columns: 1fr;
  }

  .attention-header {
    align-items: flex-start;
  }

  .choice-button {
    min-height: 64px;
  }

  .panel {
    padding: 14px;
  }

  .panel-header {
    align-items: flex-start;
  }

  .detail-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-actions .primary-button,
  .detail-actions .ghost-button {
    padding: 0 9px;
  }

  .stat-grid,
  .customer-portal .stat-grid,
  .field-readout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .document-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .document-row-actions {
    justify-content: flex-start;
  }

  .mileage-entry-form {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .mileage-entry-form .primary-button {
    grid-column: 1 / -1;
  }

  .estimate-status-card,
  .acceptance-confirmed,
  .customer-hero,
  .custom-field-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .form-grid,
  .custom-field-inputs {
    grid-template-columns: 1fr;
  }

  .weekday-options {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .schedule-suggestion-row {
    align-items: stretch;
    flex-direction: column;
  }

  .recurrence-controls {
    grid-template-columns: 1fr;
  }

  .dialog-form {
    padding: 18px 14px;
  }

  .dialog-actions {
    grid-template-columns: 1fr 1fr;
  }

  .dialog-actions > span {
    display: none;
  }

  .dialog-actions .danger-button {
    grid-column: 1 / -1;
  }

  .auth-panel {
    padding: 18px;
  }

  .auth-actions {
    grid-template-columns: 1fr;
  }

  .estimate-pdf-frame {
    min-height: 440px;
  }

  .toast-region {
    right: 14px;
    bottom: 14px;
  }
}

@media (max-width: 400px) {
  .brand strong {
    font-size: 0.9rem;
  }

  .stat-grid,
  .customer-portal .stat-grid,
  .field-readout,
  .detail-actions {
    grid-template-columns: 1fr;
  }
}

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