:root {
  --black: #000000;
  --black-2: #050814;
  --dark-blue: #09173f;
  --navy: #0d2258;
  --blue: #1e56ac;
  --sky: #96c0f3;
  --ice: #e8f3ff;
  --orange: #FFA500;
  --orange-dark: #c45e00;
  --bg: #09173f;
  --card: #10244f;
  --text: #e8f3ff;
  --muted: #96c0f3;
  --line: #1e56ac;
  --danger: #d64545;
  --ok: #2f9e6a;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  --radius: 16px;
  --nav-h: 92px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--dark-blue);
  color: var(--ice);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--orange); }

#app { min-height: 100dvh; }

.screen {
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-h) + var(--safe-b) + 140px);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--black-2);
  color: var(--ice);
  padding: calc(10px + var(--safe-t)) 10px 12px;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  border-bottom: 1px solid var(--blue);
}
.top-side { display: flex; align-items: center; min-height: 40px; }
.top-side.left { justify-content: flex-start; }
.top-side.right { justify-content: flex-end; }
.top-center { text-align: center; min-width: 0; }
.topbar h1 {
  font-size: 28px;
  margin: 0;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: var(--orange);
  text-shadow: 2px 2px 4px rgba(0,0,0,0.65);
}
.topbar .sub {
  font-size: 12px;
  color: var(--sky);
  margin-top: 2px;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.7);
}
.icon-btn {
  background: var(--navy);
  border: 1px solid var(--blue);
  color: var(--ice);
  width: 40px; height: 40px;
  border-radius: 12px;
  display: grid; place-items: center;
  font-size: 18px;
}
.icon-btn.back { font-size: 28px; font-weight: 500; }

.page { padding: 14px 14px 0; max-width: 760px; margin: 0 auto; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--blue);
  padding: 14px;
  margin-bottom: 10px;
  color: var(--ice);
}
.job-card {
  display: flex;
  gap: 12px;
  align-items: stretch;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  will-change: transform;
}
.job-stripe { width: 7px; flex: none; background: var(--sky); }
.job-body { padding: 12px 14px 12px 4px; min-width: 0; flex: 1; }
.job-top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.job-body h3 { margin: 6px 0 2px; font-size: 16px; color: var(--ice); }
.addr, .meta { margin: 0; font-size: 13px; color: var(--sky); }
.meta { margin-top: 4px; }

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 3px 8px;
  border-radius: 999px;
  background: linear-gradient(to bottom, #0a1838, #1e56ac);
  color: var(--sky);
  border: 1px solid var(--blue);
}
.t-asap { background: linear-gradient(to bottom, #3d0909, #c44747); color: #ffd0d0; border-color: #c44; }
.t-parts { background: linear-gradient(to bottom, #082414, #3ecf7e); color: #d4ffe4; border-color: #2f9e6a; }
.t-wait { background: linear-gradient(to bottom, #2a1c06, #e08a12); color: #ffd48a; border-color: var(--orange-dark); }
.t-follow { background: linear-gradient(to bottom, #101848, #5b7cff); color: #e0e7ff; border-color: var(--blue); }
.t-install { background: linear-gradient(to bottom, #072830, #2fd0e0); color: #d6fbff; border-color: #1e90aa; }
.t-clean { background: linear-gradient(to bottom, #0c4aa8, #5eb0ff); color: #f2f8ff; border-color: #8ec8ff; }
.t-check { background: linear-gradient(to bottom, #050814, #5a6d88); color: #e2e8f0; border-color: #556; }
.t-other { background: linear-gradient(to bottom, #2a0e30, #d45aa3); color: #ffe0f3; border-color: #814; }
.addin { background: linear-gradient(to bottom, #8a3d00, #ffb347); color: #fff; border-color: var(--orange); }
.needs { background: linear-gradient(to bottom, #5a1010, #e09020); color: #ffe7b8; border-color: var(--orange); }
.for-who { background: linear-gradient(to bottom, #0d2258, #4f8eef); color: #fff; border-color: var(--sky); }
.t-reminder { background: linear-gradient(to bottom, #3b2a0a, #d4b45a); color: #fff8dc; border-color: #c4a35a; }

.section-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sky);
  margin: 16px 4px 8px;
  text-shadow: 1px 1px 3px #000;
}
.empty {
  text-align: center;
  color: var(--sky);
  padding: 28px 16px;
  font-size: 15px;
}

.nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--black);
  border-top: 2px solid var(--blue);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  z-index: 30;
}
.nav button {
  background: none; border: 0;
  color: var(--sky);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  white-space: nowrap;
  padding: 0 2px;
  text-shadow: 0 2px 4px #000, 0 1px 0 #000;
}
.nav button span {
  white-space: nowrap;
}
.nav button.on {
  color: #fff;
  background: var(--orange-dark);
  text-shadow: 0 2px 3px rgba(0,0,0,0.7);
}
.nav .count {
  position: absolute;
  top: 8px;
  margin-left: 28px;
  background: var(--orange);
  color: var(--black);
  font-size: 11px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  padding: 0 4px;
  display: grid; place-items: center;
  text-shadow: none;
}
.nav-item { position: relative; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  border: 0; border-radius: 12px;
  padding: 12px 16px;
  font-weight: 700;
  background: var(--blue);
  color: var(--ice);
  text-decoration: none;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}
.btn:active { transform: scale(0.98); }
.btn.block { width: 100%; }
.btn.ghost { background: var(--navy); color: var(--sky); border: 1px solid var(--blue); }
.btn.danger { background: var(--danger); }
.btn.ok { background: var(--ok); }
.btn.light {
  background: var(--black-2);
  color: var(--ice);
  border: 1px solid var(--blue);
}
.row-actions { display: grid; gap: 8px; margin-top: 12px; }
.row-actions.two { grid-template-columns: 1fr 1fr; }
.row-actions.three { grid-template-columns: 1fr 1fr 1fr; }

.field { margin-bottom: 12px; }
.field label {
  display: block;
  font-size: 12px; font-weight: 700;
  color: var(--sky);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--blue);
  background: var(--black-2);
  border-radius: 12px;
  padding: 12px 12px;
  font-size: 16px;
  color: var(--ice);
}
.field input::placeholder, .field textarea::placeholder,
input::placeholder, textarea::placeholder {
  color: #8aa8c4;
  font-style: italic;
  font-weight: 400;
}
.date-line {
  display: flex;
  align-items: center;
  gap: 8px;
}
.date-line input[type="date"] { flex: 1; }
.today-tag {
  color: var(--orange);
  font-style: italic;
  font-weight: 700;
  white-space: nowrap;
  font-size: 14px;
}
.field textarea { min-height: 110px; resize: vertical; }

.today-now {
  text-align: center;
  color: var(--orange);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-shadow: 1px 1px 3px #000;
  margin: 4px 0 12px;
}
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; -webkit-overflow-scrolling: touch; }
.chip {
  border: 1px solid var(--blue);
  background: var(--navy);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px; font-weight: 700;
  color: var(--sky);
  white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip.on { background: var(--orange-dark); color: #fff; border-color: var(--orange); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

.select-heading {
  font-size: 22px;
  font-weight: 800;
  color: var(--orange);
  text-align: center;
  margin: 6px 0 16px;
  text-shadow: 1px 1px 3px #000;
}
.job-card.loc-card { flex-wrap: wrap; }
.job-footer {
  flex: 1 0 100%;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 12px 10px;
}
.job-footer .btn { padding: 8px 12px; font-size: 13px; }
.fab {
  position: fixed;
  right: 14px;
  bottom: calc(var(--nav-h) + var(--safe-b) + 12px);
  height: auto;
  padding: 10px 12px;
  border-radius: 14px;
  border: 0;
  background: var(--orange-dark);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
  max-width: 46%;
  box-shadow: 0 8px 20px rgba(0,0,0,0.45);
  z-index: 25;
  width: auto;
  text-shadow: 0 1px 2px #000;
}
.fab-danger {
  left: 14px;
  right: auto;
  background: var(--danger);
  max-width: 42%;
}
.fab-reminder {
  bottom: calc(var(--nav-h) + var(--safe-b) + 70px);
  background: var(--navy);
  border: 1px solid var(--orange);
  color: var(--orange);
}

/* Login */
.login {
  min-height: 100dvh;
  background: linear-gradient(180deg, #000 0%, #09173f 45%, #1e56ac 100%);
  color: var(--ice);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: calc(24px + var(--safe-t)) 24px calc(24px + var(--safe-b));
}
.login h1 { margin: 0 0 28px; font-size: 28px; text-shadow: 2px 2px 6px #000; }
.login .field { width: 100%; max-width: 320px; }
.login .field input { background: rgba(9,23,63,0.7); border-color: var(--blue); color: var(--ice); text-align: center; }
.login .field input::placeholder { color: #8aa8c4; font-style: italic; }
.login .field label { color: var(--sky); text-align: center; }
.pin-dots { display: flex; gap: 10px; justify-content: center; margin: 8px 0 18px; }
.pin-dots span {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--sky);
}
.pin-dots span.on { background: var(--orange); border-color: var(--orange); }
.pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  max-width: 320px;
  margin: 0 auto;
  width: 100%;
}
.pad button {
  height: 64px;
  border-radius: 18px;
  border: 0;
  background: #3a0408;
  color: var(--ice);
  font-size: 24px;
  font-weight: 600;
}
.pad button.ghost { font-size: 16px; background: #3a0408; }
.login-error { text-align: center; color: #ffb4b4; min-height: 24px; margin: 10px 0; }

.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-head h2 { margin: 0; font-size: 18px; color: var(--ice); text-shadow: 1px 1px 3px #000; }
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0;
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--blue);
  overflow: hidden;
  margin-bottom: 12px;
}
.cal-grid > * {
  border-bottom: 1px solid rgba(150, 192, 243, 0.28);
  border-right: 1px solid rgba(30, 86, 172, 0.22);
}
.cal-grid > :nth-child(7n) { border-right: 0; }
.cal-grid > :nth-child(7n+2),
.cal-grid > :nth-child(7n+4),
.cal-grid > :nth-child(7n+6) {
  background: rgba(0, 0, 0, 0.28);
}
.cal-dow { text-align: center; font-size: 11px; color: var(--sky); font-weight: 700; padding: 8px 0; }
.cal-pad { min-height: 48px; }
.cal-day {
  border-top: 0; border-left: 0;
  background: transparent;
  border-radius: 0;
  padding: 8px 0 6px;
  min-height: 48px;
  color: var(--ice);
}
.cal-day.out { color: #4a6288; }
.cal-grid > .cal-day.on { background: var(--orange-dark); color: #fff; }
.cal-day.today:not(.on) { box-shadow: inset 0 0 0 1.5px var(--orange); }
.cal-num { font-size: 13px; font-weight: 700; display: block; }
.cal-dots { display: flex; justify-content: center; gap: 2px; min-height: 8px; margin-top: 3px; }
.cal-dots i { width: 6px; height: 6px; border-radius: 50%; display: block; }

.link-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.link-row a, .link-row button {
  text-decoration: none;
  background: var(--navy);
  color: var(--sky);
  border: 1px solid var(--blue);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px; font-weight: 700;
}

.phone-stack { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; }
.phone-link {
  color: var(--orange);
  font-weight: 700;
  font-size: 16px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.loc-card { display: flex; gap: 10px; align-items: stretch; }
.loc-main { flex: 1; min-width: 0; }
.loc-order {
  display: flex;
  flex-direction: column;
  gap: 6px;
  justify-content: center;
}
.loc-order button {
  width: 40px; height: 40px;
  border-radius: 10px;
  border: 1px solid var(--blue);
  background: var(--navy);
  color: var(--ice);
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
}

.modal-back {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 50;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: calc(12px + var(--safe-t)) 16px 16px;
  overflow-y: auto;
}
.modal {
  background: var(--card);
  color: var(--ice);
  width: 100%;
  max-width: 560px;
  border-radius: 20px;
  border: 1px solid var(--blue);
  padding: 18px 16px 18px;
  margin-top: 8vh;
}
.modal h3 { margin: 0 0 8px; }
.modal p { margin: 0 0 16px; color: var(--sky); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + var(--safe-b) + 18px);
  transform: translateX(-50%);
  background: var(--black);
  color: var(--ice);
  border: 1px solid var(--blue);
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 14px;
  z-index: 80;
  max-width: 90%;
}
.or-split {
  text-align: center;
  margin: 18px 0 14px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--sky);
  text-shadow: 1px 1px 3px #000;
}
.search-hit { padding: 12px; border-bottom: 1px solid var(--blue); cursor: pointer; }
.search-hit:last-child { border-bottom: 0; }
.search-hit strong { display: block; color: var(--ice); }
.warn {
  background: #3b2a0a;
  border: 1px solid var(--orange-dark);
  color: #ffd48a;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 10px;
}
.history { border-top: 1px solid var(--blue); margin-top: 8px; }
.history-item { padding: 10px 0; border-bottom: 1px solid var(--blue); }
.history-item:last-child { border-bottom: 0; }
.muted { color: var(--sky); font-size: 13px; }
.grow { flex: 1; min-width: 0; }
.user-row { display: flex; align-items: center; gap: 12px; }
.user-swatch { width: 16px; height: 16px; border-radius: 50%; }
.menu-pop {
  position: absolute;
  right: 12px;
  top: calc(56px + var(--safe-t));
  background: var(--card);
  color: var(--ice);
  border: 1px solid var(--blue);
  border-radius: 12px;
  box-shadow: var(--shadow);
  min-width: 180px;
  overflow: hidden;
  z-index: 40;
}
.menu-pop button {
  display: block; width: 100%;
  text-align: left;
  background: none; border: 0;
  padding: 12px 14px;
  font-weight: 600;
  color: var(--ice);
}
.menu-pop button:active { background: var(--navy); }

@media (min-width: 800px) {
  .modal { margin-top: 12vh; }
}
