/* Quality Interior DFW app. Phone first: large touch targets, readable in sunlight, light and dark mode. */
:root {
  --brand: #1F3864;
  --brand-bright: #2F5597;
  --on-brand: #FFFFFF;
  --bg: #F3F5F9;
  --surface: #FFFFFF;
  --ink: #18202E;
  --muted: #5A6476;
  --line: #DFE3EA;
  --focus: #2F6FE0;
  --danger: #B3261E;
  --radius: 14px;
  --tap: 48px;
  color-scheme: light dark;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E131B;
    --surface: #172030;
    --ink: #EDF1F7;
    --muted: #9BA6B9;
    --line: #283449;
    --focus: #6E9BFF;
    --danger: #FF8A80;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 17px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: var(--tap) 1fr auto;
  align-items: center;
  gap: 4px;
  padding: calc(env(safe-area-inset-top) + 6px) 8px 6px;
  background: var(--brand);
  color: var(--on-brand);
}
.topbar-title { margin: 0; font-size: 19px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; gap: 4px; }
.icon-btn {
  width: var(--tap);
  height: var(--tap);
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}
.icon-btn:active { background: rgba(255, 255, 255, 0.16); }
.icon { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.is-spinning .icon { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.18);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* ---------- layout and text ---------- */
.content { max-width: 720px; margin: 0 auto; padding: 12px 16px calc(24px + env(safe-area-inset-bottom)); }
.toolbar { display: grid; gap: 10px; }
.stack { display: grid; gap: 12px; }
.muted { color: var(--muted); }
.label { font-size: 15px; font-weight: 600; color: var(--muted); }
.version { margin-top: 28px; text-align: center; font-size: 13px; color: var(--muted); }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }
.status-line { margin: 12px 2px 8px; font-size: 14px; color: var(--muted); }

/* ---------- form controls ---------- */
.field {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  font-size: 18px;   /* 16px or more stops iPhone zooming in on focus */
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.field:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px rgba(47, 111, 224, 0.25); }
.field-code { font-size: 28px; letter-spacing: 0.35em; text-align: center; font-variant-numeric: tabular-nums; }
.btn {
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 650;
  cursor: pointer;
}
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-primary { background: var(--brand); color: var(--on-brand); }
.btn-secondary { background: var(--surface); color: var(--ink); border: 1.5px solid var(--line); }
@media (prefers-color-scheme: dark) { .btn-primary { background: var(--brand-bright); } }
.link { min-height: var(--tap); padding: 12px 4px; border: 0; background: none; color: var(--focus); font-size: 16px; cursor: pointer; }
.row-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.form-error { margin: 0; color: var(--danger); font-size: 15px; }
.form-error:empty { display: none; }
.hint {
  margin: 0;
  padding: 12px 14px;
  font-size: 15px;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 12px;
}

/* ---------- sign-in ---------- */
.signin { min-height: 100vh; min-height: 100dvh; }
.signin-hero {
  padding: calc(env(safe-area-inset-top) + 48px) 24px 32px;
  background: var(--brand);
  color: var(--on-brand);
  text-align: center;
}
.signin-hero h1 { margin: 14px 0 4px; font-size: 25px; }
.signin-hero p { margin: 0; opacity: 0.85; }
.brand-mark { width: 76px; height: 76px; border-radius: 18px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25); }
.signin-body {
  display: grid;
  gap: 20px;
  max-width: 440px;
  margin: 0 auto;
  padding: 28px 20px calc(24px + env(safe-area-inset-bottom));
}

/* ---------- project list ---------- */
.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 3px;
  padding: 3px;
  border-radius: 12px;
  background: var(--line);
}
.segment {
  min-height: 40px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.segment.is-on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }
.list { display: grid; gap: 8px; }
.card {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
}
.card:active { transform: scale(0.99); }
.card-main { flex: 1; min-width: 0; }
.card-title { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pnum { margin-right: 6px; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.card-sub { margin-top: 2px; font-size: 15px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-side { display: grid; justify-items: end; gap: 6px; text-align: right; }
.amount { font-weight: 650; font-variant-numeric: tabular-nums; }

/* ---------- status chips ---------- */
.chip { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 650; background: #E7EDF8; color: #23406F; }
.chip-won { background: #E2F3E6; color: #1D6A34; }
.chip-complete { background: #ECEEF2; color: #4A5263; }
.chip-lost { background: #FBE5E3; color: #9A2A21; }
.chip-on-hold { background: #FFF0D6; color: #865700; }
@media (prefers-color-scheme: dark) {
  .chip { background: rgba(110, 155, 255, 0.18); color: #C5D6FF; }
  .chip-won { background: rgba(76, 175, 80, 0.2); color: #A8E5AC; }
  .chip-complete { background: rgba(255, 255, 255, 0.1); color: #C7CDD8; }
  .chip-lost { background: rgba(244, 67, 54, 0.2); color: #FFB4AB; }
  .chip-on-hold { background: rgba(255, 179, 0, 0.18); color: #FFD88A; }
}

/* ---------- one project ---------- */
.panel { padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.detail-title { margin: 0; font-size: 22px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 10px 16px; margin: 16px 0 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 550; overflow-wrap: anywhere; }

/* ---------- messages ---------- */
.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(env(safe-area-inset-bottom) + 16px);
  z-index: 50;
  max-width: 480px;
  margin: 0 auto;
  padding: 14px 16px;
  border-radius: 12px;
  background: #18202E;
  color: #FFFFFF;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}
