/* ============ TruCoast Field ============ */

:root {
  --navy: #00297a;
  --navy-deep: #0a1b4a;
  --royal: #051aae;
  --ink: #1c2333;
  --slate: #5a6478;
  --mist: #f4f7fc;
  --mist-2: #e8eef8;
  --line: #dbe4f0;
  --white: #fff;
  --green: #1d9e55;
  --green-bg: #e6f6ec;
  --amber: #b07d10;
  --amber-bg: #fdf3dd;
  --red: #c53030;
  --red-bg: #fdecec;
  --radius: 14px;
  --shadow-sm: 0 1px 3px rgba(10,27,74,.08);
  --shadow-md: 0 8px 28px rgba(10,27,74,.16);
  --font-head: "Montserrat", "Segoe UI", sans-serif;
  --font-body: "Inter", "Segoe UI", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-body);
  background: var(--mist);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

h1, h2, h3 { font-family: var(--font-head); color: var(--navy); }
button { font: inherit; cursor: pointer; }
a { color: var(--royal); text-decoration: none; }
input, textarea, select { font: inherit; }

/* ---------- Login ---------- */

.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(150deg, var(--navy-deep) 0%, var(--navy) 60%, var(--royal) 100%);
  padding: 24px;
}
.login-card {
  background: var(--white); border-radius: 18px; box-shadow: var(--shadow-md);
  width: 100%; max-width: 380px; padding: 36px 28px;
}
.login-card img { height: 72px; margin: 0 auto 8px; display: block; }
.login-card h1 { text-align: center; font-size: 1.2rem; margin-bottom: 4px; }
.login-card .sub { text-align: center; color: var(--slate); font-size: .88rem; margin-bottom: 24px; }
.login-card label { display: block; font-weight: 600; font-size: .82rem; color: var(--navy); margin: 14px 0 6px; }
.login-card input {
  width: 100%; padding: 13px 14px; border: 1px solid var(--line); border-radius: 10px; font-size: 1rem;
}
.login-card input:focus { outline: none; border-color: var(--royal); box-shadow: 0 0 0 3px rgba(5,26,174,.1); }

/* ---------- App shell ---------- */

.app { display: none; min-height: 100vh; min-height: 100dvh; flex-direction: column; }
.app.active { display: flex; }

.topbar {
  background: var(--navy-deep); color: #fff; padding: 16px 18px;
  padding-top: max(16px, env(safe-area-inset-top));
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-family: var(--font-head); font-weight: 800; font-size: 1.1rem; }
.icon-btn {
  background: rgba(255,255,255,.12); border: 0; color: #fff; border-radius: 10px;
  width: 38px; height: 38px; display: flex; align-items: center; justify-content: center;
}
.icon-btn svg { width: 19px; height: 19px; }

.view { flex: 1; padding: 16px 16px calc(90px + env(safe-area-inset-bottom)); max-width: 640px; width: 100%; margin: 0 auto; }

.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  background: var(--white); border-top: 1px solid var(--line);
  display: flex; padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 10px rgba(10,27,74,.06);
}
.bottom-nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 10px 0 8px; color: var(--slate); font-size: .72rem; font-weight: 600;
}
.bottom-nav-item svg { width: 22px; height: 22px; }
.bottom-nav-item.active { color: var(--royal); }

/* ---------- Shared bits ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 18px; border-radius: 11px; border: 0; font-weight: 700; font-size: .92rem;
}
.btn-primary { background: var(--royal); color: #fff; }
.btn-ghost { background: var(--mist-2); color: var(--navy); }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; }

.form-err { color: var(--red); background: var(--red-bg); border-radius: 8px; padding: 10px 14px; font-size: .86rem; margin-top: 14px; display: none; }
.form-err.show { display: block; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--slate); }
.empty-state h4 { color: var(--navy); margin-bottom: 6px; font-size: 1.02rem; }

.chip {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px;
  font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .02em;
  background: var(--mist-2); color: var(--slate);
}
.chip.scheduled { background: #e8eef8; color: var(--royal); }
.chip.in_progress { background: var(--amber-bg); color: var(--amber); }
.chip.completed { background: var(--green-bg); color: var(--green); }
.chip.cancelled { background: var(--red-bg); color: var(--red); }

/* ---------- Date nav ---------- */

.date-nav {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px;
}
.date-nav button {
  background: var(--white); border: 1px solid var(--line); border-radius: 10px;
  width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; color: var(--navy);
}
.date-nav .date-label { text-align: center; }
.date-nav .date-label strong { display: block; font-family: var(--font-head); font-size: 1rem; color: var(--navy); }
.date-nav .date-label span { font-size: .78rem; color: var(--slate); }

/* ---------- Job cards ---------- */

.job-card {
  background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 16px; margin-bottom: 12px; display: block; color: inherit;
}
.job-card:active { transform: scale(.99); }
.job-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.job-card-time { font-family: var(--font-head); font-weight: 800; color: var(--navy); font-size: 1.05rem; }
.job-card-customer { font-weight: 700; font-size: 1rem; margin-bottom: 2px; }
.job-card-address { color: var(--slate); font-size: .88rem; }
.job-card-title { color: var(--slate); font-size: .86rem; margin-top: 6px; }

/* ---------- Job detail ---------- */

.detail-back { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: .88rem; margin-bottom: 14px; }
.detail-card {
  background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 20px; margin-bottom: 14px;
}
.detail-card h2 { font-size: 1.15rem; margin-bottom: 2px; }
.detail-card .customer-line { color: var(--slate); font-size: .92rem; margin-bottom: 12px; }
.detail-row { display: flex; gap: 10px; padding: 10px 0; border-top: 1px solid var(--mist-2); }
.detail-row:first-of-type { border-top: 0; }
.detail-row svg { width: 19px; height: 19px; flex: none; margin-top: 1px; color: var(--slate); }
.detail-row .label { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--slate); margin-bottom: 2px; }
.detail-row .value { font-size: .95rem; }
.detail-row .value a { font-weight: 600; }

.item-row { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--mist-2); font-size: .9rem; }
.item-row:first-of-type { border-top: 0; }
.item-row .qty { color: var(--slate); }

.action-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0 14px; }
.action-row .btn { flex: 1; min-width: 140px; }

/* ---------- Modal ---------- */

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10,27,74,.5); z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: var(--white); border-radius: 18px 18px 0 0; box-shadow: var(--shadow-md);
  width: 100%; max-width: 480px; max-height: 88vh; display: flex; flex-direction: column; overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}
.modal-head { padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { font-size: 1.02rem; }
.modal-close { background: none; border: 0; font-size: 1.5rem; color: var(--slate); line-height: 1; padding: 4px; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-body label.fl { display: block; font-weight: 600; font-size: .8rem; color: var(--navy); margin: 12px 0 5px; }
.modal-body label.fl:first-child { margin-top: 0; }
.modal-body input, .modal-body textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 9px; font-size: .95rem;
}
.modal-body textarea { resize: vertical; min-height: 70px; }
.modal-check { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: .9rem; margin-top: 14px; }
.modal-check input { width: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; }
.modal-foot .btn { flex: 1; }

#toast-wrap { position: fixed; bottom: calc(90px + env(safe-area-inset-bottom)); left: 16px; right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--navy-deep); color: #fff; padding: 13px 16px; border-radius: 11px; font-size: .9rem;
  box-shadow: var(--shadow-md); animation: toast-in .18s ease;
}
.toast.err { background: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Route Planning (owner-only skeleton) ---------- */

.plan-tech { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow-sm); margin-bottom: 12px; overflow: hidden; }
.plan-tech-head { padding: 12px 16px; background: var(--mist); font-weight: 700; display: flex; justify-content: space-between; }
.plan-job-row { padding: 10px 16px; border-top: 1px solid var(--mist-2); font-size: .88rem; display: flex; justify-content: space-between; gap: 10px; }
.plan-job-row:first-of-type { border-top: 0; }

@media (min-width: 640px) {
  .view { padding: 24px 20px calc(90px + env(safe-area-inset-bottom)); }
}
