/* ===== Design tokens ===== */
:root {
  color-scheme: light;
  --bg:            #f4f5f1;
  --surface:       #ffffff;
  --text:          #1c1c1c;
  --text-muted:    #556055;
  --accent:        #2d6a2d;
  --accent-light:  #e5f0e5;
  --danger:        #c0392b;
  --border:        #d0d8cc;

  --header-h:    52px;
  --tab-h:       60px;
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --touch:  48px;
  --radius: 6px;
  --gap:    16px;
}

/* ===== Reset ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

[hidden] { display: none !important; }

html {
  height: 100%;
  /* visible at desktop widths outside the 480px column */
  background: #1c1c1c;
}

body {
  height: 100%;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

/* ===== Focus ===== */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ===== 480px centered column =====
   All fixed chrome elements are constrained to a phone-width column so
   the app looks identical on a laptop and on the phone. The dark html
   background fills the surround. No breakpoints — this is always on. */
.app-header,
.tab-bar,
.update-bar,
.screen,
.sheet,
.app-loader {
  left:  max(0px, calc(50vw - 240px));
  right: max(0px, calc(50vw - 240px));
}

.due-fab {
  right: max(var(--gap), calc(50vw - 240px + var(--gap)));
}

/* ===== Loader ===== */
.app-loader {
  position: fixed;
  top: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 1rem;
  z-index: 9999;
}
.app-loader-hint {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ===== Update banner ===== */
.update-bar {
  position: fixed;
  top: calc(var(--header-h) + var(--safe-top));
  height: 52px;
  background: #1a4a1a;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--gap);
  font-size: 0.9375rem;
  font-weight: 600;
  z-index: 90;
}

.update-bar-btn {
  background: #fff;
  color: #1a4a1a;
  border: none;
  border-radius: var(--radius);
  padding: 0 16px;
  min-height: 40px;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 700;
  cursor: pointer;
}

body.has-update-bar.signed-in .screen {
  top: calc(var(--header-h) + var(--safe-top) + 52px);
}

/* ===== App header ===== */
.app-header {
  position: fixed;
  top: 0;
  height: calc(var(--header-h) + var(--safe-top));
  padding: var(--safe-top) var(--gap) 0;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 100;
}

.app-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  min-width: 0;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  margin-left: 8px;
}

.header-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.375rem;
  min-width: var(--touch);
  min-height: var(--touch);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: var(--radius);
  line-height: 1;
}

.header-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* Owed button in the header summary */
.header-owed-btn {
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.4);
  border-radius: var(--radius);
  color: #fff;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 2px 8px;
  min-height: 28px;
  cursor: pointer;
}

/* Sync pending count badge */
.sync-badge {
  background: #1a4a1a;
  color: #fff;
  font-size: 0.875rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 24px;
  height: 24px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

/* ===== Main screen area ===== */
.screen {
  position: fixed;
  top: 0;
  bottom: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--gap);
}

body.signed-in .screen {
  top: calc(var(--header-h) + var(--safe-top));
  bottom: calc(var(--tab-h) + var(--safe-bottom));
}

/* ===== Tab bar ===== */
.tab-bar {
  position: fixed;
  bottom: 0;
  height: calc(var(--tab-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--surface);
  border-top: 2px solid var(--border);
  display: flex;
  z-index: 100;
}

.tab {
  flex: 1;
  min-height: var(--touch);
  background: none;
  border: none;
  border-top: 3px solid transparent;
  color: var(--text-muted);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tab[aria-current="page"] {
  color: var(--accent);
  font-weight: 700;
  border-top-color: var(--accent);
}

.tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* ===== Auth screen ===== */
.auth-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  gap: 20px;
  padding: 40px var(--gap);
  text-align: center;
}

.auth-logo {
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.02em;
}

.auth-tagline {
  color: var(--text-muted);
  font-size: 1rem;
  max-width: 28ch;
}

.auth-error {
  color: var(--danger);
  font-size: 0.9375rem;
  max-width: 32ch;
  padding: 12px 16px;
  background: #fdf2f2;
  border-radius: var(--radius);
  border: 1px solid #f5c6c6;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--touch);
  padding: 0 24px;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
  max-width: 320px;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  width: 100%;
}

/* ===== Settings sheet ===== */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 200;
}

.sheet {
  position: fixed;
  bottom: 0;
  background: var(--surface);
  border-top: 2px solid var(--border);
  padding: 20px var(--gap) calc(var(--gap) + var(--safe-bottom));
  z-index: 201;
  max-height: 80vh;
  overflow-y: auto;
}

.sheet-title {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 20px;
}

.settings-rows {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 28px;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9375rem;
}

.settings-row:first-child {
  border-top: 1px solid var(--border);
}

.settings-row dt {
  color: var(--text-muted);
  font-weight: 500;
}

.settings-row dd {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* ===== Screen toolbar (sticky search + action button) ===== */
.screen-toolbar {
  position: sticky;
  top: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 12px;
  z-index: 10;
}

.search-input {
  flex: 1;
  min-width: 0;
  height: var(--touch);
  padding: 0 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  -webkit-appearance: none;
}

.search-input:focus {
  border-color: var(--accent);
  outline: none;
}

.btn-add {
  width: var(--touch);
  height: var(--touch);
  min-width: var(--touch);
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ===== Item list (clients, pickers) ===== */
.item-list {
  list-style: none;
  margin: 0 calc(-1 * var(--gap));
}

.item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--gap);
  min-height: 56px;
  gap: var(--gap);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: background 120ms;
}

.item-row:first-child {
  border-top: 1px solid var(--border);
}

.item-row:active {
  background: var(--accent-light);
}

.item-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.item-meta {
  font-size: 0.9375rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ===== Empty states ===== */
.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 48px var(--gap);
  font-size: 0.9375rem;
}

.empty-due {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 8px;
  text-align: center;
  padding: var(--gap);
  color: var(--text-muted);
}

.empty-due p:first-child {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
}

/* ===== Detail view ===== */
.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  margin-bottom: 4px;
}

.detail-name {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
  line-height: 1.2;
}

.detail-dl {
  margin-bottom: 20px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  gap: var(--gap);
}

.detail-row:first-child {
  border-top: 1px solid var(--border);
}

.detail-row dt {
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  flex-shrink: 0;
  min-width: 72px;
}

.detail-row dd {
  text-align: right;
  word-break: break-word;
  font-size: 0.9375rem;
}

.detail-section {
  margin-top: 24px;
}

.detail-section h3 {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.detail-notes {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 0.9375rem;
  white-space: pre-wrap;
  line-height: 1.5;
}

/* ===== Back / text buttons ===== */
.btn-back {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  min-height: var(--touch);
  min-width: var(--touch);
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
}

.btn-text {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  min-height: var(--touch);
  min-width: var(--touch);
  padding: 0;
  cursor: pointer;
  text-align: right;
}

/* ===== Client / job forms ===== */
.form-header {
  position: sticky;
  top: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  z-index: 10;
}

.form-header h2 {
  font-size: 1rem;
  font-weight: 700;
}

.client-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-bottom: 40px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
}

.field input,
.field textarea {
  width: 100%;
  min-height: var(--touch);
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  -webkit-appearance: none;
}

.field textarea {
  min-height: 80px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--accent);
  outline: none;
}

.field input.invalid {
  border-color: var(--danger);
}

.field-error {
  color: var(--danger);
  font-size: 0.875rem;
}

/* ===== Screen placeholder ===== */
.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 1rem;
}

/* ===== Detail section with action button ===== */
.detail-section-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.detail-section-hdr h3 {
  margin-bottom: 0;
}

.btn-new-job {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.9375rem;
  font-weight: 600;
  font-family: inherit;
  min-height: var(--touch);
  padding: 0 4px;
  cursor: pointer;
}

/* ===== Job rows (in client detail) ===== */
.job-list {
  margin-top: 0;
}

.job-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--gap);
  padding: 12px var(--gap);
  min-height: var(--touch);
  transition: background 120ms;
}

.job-row:active {
  background: var(--accent-light);
}

.job-row-left {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.job-date {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.job-desc {
  font-size: 0.9375rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.job-row-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.job-price {
  font-size: 1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.job-status {
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: var(--radius);
}

.status-paid      { background: #d4edda; color: #1a5e2a; }
.status-done      { background: #fef9e7; color: #7a5c00; }
.status-scheduled { background: var(--accent-light); color: var(--accent); }
.status-part      { background: #fde8d8; color: #954500; }

/* ===== Job form ===== */
.field-display {
  padding: 10px 14px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  color: var(--text-muted);
  min-height: var(--touch);
  display: flex;
  align-items: center;
}

.form-more {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.form-more-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  list-style: none;
  padding: 14px;
  font-weight: 600;
  font-size: 0.9375rem;
  cursor: pointer;
  user-select: none;
  min-height: var(--touch);
  -webkit-tap-highlight-color: transparent;
}

.form-more-summary::-webkit-details-marker { display: none; }

.form-more-summary::after {
  content: '›';
  font-size: 1.25rem;
  color: var(--text-muted);
  display: inline-block;
  transition: transform 150ms;
}

.form-more[open] .form-more-summary::after {
  transform: rotate(90deg);
}

.form-more-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-top: 1px solid var(--border);
}

.field-row {
  display: flex;
  gap: 12px;
}

.field-row .field {
  flex: 1;
  min-width: 0;
}

.btn-calc {
  background: var(--accent-light);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius);
  color: var(--accent);
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  padding: 10px 14px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  min-height: var(--touch);
}

/* ===== Costs section ===== */
.field-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}

.costs-existing {
  display: flex;
  flex-direction: column;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.cost-existing {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  font-size: 0.9375rem;
  border-bottom: 1px solid var(--border);
  gap: var(--gap);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.cost-existing:last-child { border-bottom: none; }

.cost-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cost-desc {
  flex: 1;
  min-width: 0;
  height: var(--touch);
  padding: 0 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 0.9375rem;
  font-family: inherit;
  -webkit-appearance: none;
}

.cost-amount {
  width: 88px;
  flex-shrink: 0;
  height: var(--touch);
  padding: 0 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 0.9375rem;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  -webkit-appearance: none;
}

.cost-desc:focus,
.cost-amount:focus {
  border-color: var(--accent);
  outline: none;
}

.cost-remove {
  min-width: var(--touch);
  min-height: var(--touch);
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-add-cost {
  background: none;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  color: var(--accent);
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  min-height: var(--touch);
  cursor: pointer;
  width: 100%;
}

/* ===== Paid checkbox ===== */
.field-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1rem;
  font-weight: 500;
  padding: 4px 0;
  cursor: pointer;
  min-height: var(--touch);
}

.field-checkbox input[type="checkbox"] {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-radius: 5px;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: var(--accent);
}

/* ===== Owed screen ===== */
.owed-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--accent);
  color: #fff;
  padding: 16px var(--gap);
  border-radius: var(--radius);
  margin-bottom: 20px;
  margin-left: calc(-1 * var(--gap));
  margin-right: calc(-1 * var(--gap));
  margin-top: calc(-1 * var(--gap));
}

.owed-total-label {
  font-size: 0.9375rem;
  font-weight: 500;
  color: #d4edd4;
}

.owed-total-amount {
  font-size: 1.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.owed-list {
  list-style: none;
  margin: 0 calc(-1 * var(--gap));
}

.owed-client-item {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.owed-client-item:first-child {
  border-top: 1px solid var(--border);
}

.owed-client-row {
  width: 100%;
  background: none;
  border: none;
  padding: 0 var(--gap);
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  transition: background 120ms;
}

.owed-client-row:active {
  background: var(--accent-light);
}

.owed-client-name {
  font-weight: 600;
  color: var(--text);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.owed-client-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.owed-amount {
  font-size: 1.125rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.owed-age {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.owed-chevron {
  color: var(--text-muted);
  font-size: 1.125rem;
  display: inline-block;
  transition: transform 150ms;
}

.owed-jobs {
  list-style: none;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.owed-job {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px var(--gap);
  border-bottom: 1px solid var(--border);
}

.owed-job:last-child { border-bottom: none; }

.owed-job-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.owed-job-date {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.owed-job-desc {
  font-size: 0.9375rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.owed-job-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.owed-job-price {
  font-size: 1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.owed-job-balance {
  font-size: 0.9375rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.btn-mark-paid {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  min-height: var(--touch);
  padding: 0 14px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-mark-paid:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ===== Due screen ===== */
.due-section {
  margin-bottom: 24px;
}

.due-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.due-section-est {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.75rem;
}

.due-list {
  list-style: none;
  margin: 0 calc(-1 * var(--gap));
}

.due-item {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.due-item:first-child {
  border-top: 1px solid var(--border);
}

/* Two-line row: name+amount / description+badge */
.due-row {
  width: 100%;
  background: none;
  border: none;
  padding: 10px var(--gap);
  text-align: left;
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: var(--touch);
  transition: background 120ms;
}

.due-row:active {
  background: var(--accent-light);
}

/* Line 1: client name (left) + amount (right) */
.due-row-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.due-client {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.due-amount {
  font-size: 1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  flex-shrink: 0;
}

/* Line 2: description (left) + last date + badge (right) */
.due-row-bot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.due-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.due-row-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.due-last {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Overdue severity badges */
.due-badge {
  font-size: 0.8125rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 2px 8px;
  border-radius: var(--radius);
  white-space: nowrap;
}

.badge-never        { background: #e4e8e4; color: #444; }
.badge-overdue-low  { background: #fef0c7; color: #92400e; }
.badge-overdue-mid  { background: #fed7aa; color: #7c2d12; }
.badge-overdue-high { background: #fecaca; color: #7f1d1d; }
.badge-due          { background: #d4edda; color: #1a5e2a; }
.badge-sched        { background: var(--accent-light); color: var(--accent); }

/* ===== FAB — circle, no shadow ===== */
.due-fab {
  position: fixed;
  bottom: calc(var(--tab-h) + var(--safe-bottom) + 16px);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  transition: background 120ms;
}

.due-fab:active {
  background: #1e4f1e;
}

/* ===== Recurrences in client detail ===== */
.rec-list {
  margin-top: 4px;
}

.rec-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
}

.rec-row-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.rec-interval {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.preset-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.preset-btn {
  min-height: var(--touch);
  padding: 0 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-family: inherit;
  font-size: 0.9375rem;
  cursor: pointer;
  color: var(--text);
}

.preset-btn.preset-active {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 700;
}

.field-custom-interval {
  width: 100%;
  min-height: var(--touch);
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  margin-top: 10px;
  -webkit-appearance: none;
}

.field-custom-interval:focus {
  border-color: var(--accent);
  outline: none;
}

/* ===== Clients — list rows with meta =====  */
.client-row {
  align-items: stretch;
  padding: 0;
}

.client-row-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
  padding: 10px var(--gap);
  justify-content: center;
}

.client-row-meta {
  font-size: 0.875rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.client-row-selected {
  background: var(--accent-light) !important;
  border-left: 3px solid var(--accent);
}

/* ===== Master-detail pane structure ===== */
.clients-screen {
  padding: 0;
}

.cp-list,
.cp-detail {
  padding: var(--gap);
}

/* Mobile: one pane at a time */
@media (max-width: 899px) {
  .cp-list,
  .cp-detail {
    min-height: 100%;
  }
  .clients-screen.has-detail .cp-list   { display: none; }
  .clients-screen:not(.has-detail) .cp-detail { display: none; }
}

/* ===== Detail empty state ===== */
.detail-empty-msg {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  height: 100%;
  color: var(--text-muted);
  font-size: 1rem;
}

/* ===== Jobs table ===== */
.jobs-table-wrap {
  overflow-x: auto;
  margin-top: 4px;
}

.jobs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

.jobs-table th,
.jobs-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.jobs-table th {
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--bg);
  position: sticky;
  top: 0;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.jobs-table th:hover {
  color: var(--accent);
}

.jobs-table tbody tr {
  cursor: pointer;
  transition: background 120ms;
}

.jobs-table tbody tr:hover { background: var(--accent-light); }
.jobs-table tbody tr:active { background: #d4edda; }

.jobs-table .col-r {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.job-table-desc {
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sort-none   { color: var(--border); font-size: 0.875rem; }
.sort-active { color: var(--accent); }

/* ===== Utilities ===== */
.num {
  font-variant-numeric: tabular-nums;
}

/* ===== Motion — functional only =====
   Short tap feedback and chevron rotation are information.
   Everything else stays instant. */
@media (prefers-reduced-motion: reduce) {
  .item-row,
  .job-row,
  .due-row,
  .due-fab,
  .owed-client-row,
  .jobs-table tbody tr,
  .form-more-summary::after,
  .owed-chevron {
    transition: none !important;
  }
}

/* ===== 900px+ desktop layout =====
   At this breakpoint the 480px phone column opens up into a real desktop
   surface: left nav rail, master-detail content area, two-column forms. */
@media (min-width: 900px) {
  :root { --rail-w: 210px; }

  /* 1. Cancel the 480px column constraint — everything goes full-width */
  .app-header,
  .update-bar,
  .screen,
  .sheet,
  .app-loader {
    left: 0;
    right: 0;
  }

  .due-fab {
    right: var(--gap);
    bottom: var(--gap);
  }

  /* 2. Tab bar becomes a left nav rail */
  .tab-bar {
    top: calc(var(--header-h) + var(--safe-top));
    right: auto;
    bottom: 0;
    width: var(--rail-w);
    height: auto;
    flex-direction: column;
    border-top: none;
    border-right: 1px solid var(--border);
    padding-bottom: 0;
  }

  .tab {
    flex: 0 0 auto;
    height: 52px;
    border-top: none;
    border-left: 3px solid transparent;
    justify-content: flex-start;
    padding: 0 20px;
    font-size: 0.9375rem;
  }

  .tab[aria-current="page"] {
    border-top-color: transparent;
    border-left-color: var(--accent);
    background: var(--accent-light);
  }

  /* 3. Screen and sheet occupy the area right of the nav rail */
  .screen {
    left: var(--rail-w);
  }

  body.signed-in .screen {
    bottom: 0;
  }

  .sheet {
    left: var(--rail-w);
  }

  .update-bar {
    left: var(--rail-w);
  }

  /* 4. Clients master-detail split */
  .screen.clients-screen {
    overflow: hidden;
    display: flex;
    align-items: stretch;
  }

  .cp-list {
    width: 360px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    overflow-y: auto;
    height: 100%;
    padding: var(--gap);
  }

  .cp-detail {
    flex: 1;
    min-width: 0;
    max-width: 860px;
    overflow-y: auto;
    height: 100%;
    padding: var(--gap) 40px;
  }

  /* Back button only needed on mobile */
  .detail-back { display: none; }

  /* 5. New-client button shows text label on desktop */
  .btn-add-icon  { display: none; }
  .btn-add-label { display: inline; }
  .btn-add {
    width: auto;
    height: var(--touch);
    padding: 0 16px;
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: 0.01em;
  }

  /* 6. Two-column client form */
  .client-form .form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px 24px;
  }

  .client-form .form-grid .field-full {
    grid-column: 1 / -1;
  }
}
