:root {
  --navy: #043271;
  --navy-deep: #032454;
  --ink: #10203a;
  --mist: #5c6b84;
  --water: #eef4fb;
  --pool: #1b7fd4;
  --sun: #ff8a3d;
  --line: rgba(4, 50, 113, 0.12);
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: "General Sans", system-ui, -apple-system, sans-serif;
  background: #f6f9fd;
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2 { font-family: "Clash Display", "General Sans", sans-serif; color: var(--navy); line-height: 1.1; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* ---- top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 22px;
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  padding: 12px 20px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { height: 30px; width: auto; }
.brand span {
  font-size: 11px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--mist); border-left: 1px solid var(--line); padding-left: 10px;
}
.topbar nav { display: flex; gap: 16px; margin-left: auto; font-size: 15px; font-weight: 500; color: var(--mist); }
.topbar nav a.on { color: var(--navy); }
.logout button {
  background: none; border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 14px; font: inherit; font-size: 13px; color: var(--mist); cursor: pointer;
  transition: border-color 0.4s var(--ease), color 0.4s var(--ease);
}
.logout button:hover { border-color: var(--navy); color: var(--navy); }

main.app { max-width: 760px; margin: 0 auto; padding: 26px 20px 80px; }
main.bare { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }

/* ---- login ---- */
.login-card {
  width: 100%; max-width: 380px; background: #fff;
  border: 1px solid var(--line); border-radius: 22px;
  padding: 38px 32px; box-shadow: 0 30px 70px -40px rgba(4,50,113,0.4);
}
.login-logo { height: 54px; width: auto; margin: 0 auto 22px; }
.login-card h1 { font-size: 24px; text-align: center; margin-bottom: 22px; }
.login-card label {
  display: block; font-size: 12px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--mist); margin: 14px 0 6px;
}
.login-card input {
  width: 100%; font: inherit; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 12px; background: #fff;
  transition: border-color 0.35s var(--ease), box-shadow 0.35s var(--ease);
}
.login-card input:focus { outline: none; border-color: var(--pool); box-shadow: 0 0 0 4px rgba(27,127,212,0.12); }
.login-card .btn { width: 100%; justify-content: center; margin-top: 22px; }
.error {
  background: #fdecea; color: #b3261e; border-radius: 10px;
  padding: 10px 12px; font-size: 14px; margin-bottom: 6px;
}

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 999px; padding: 12px 22px;
  font: inherit; font-weight: 600; font-size: 15px; cursor: pointer;
  transition: transform 0.4s var(--ease), box-shadow 0.4s var(--ease);
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--sun); color: #3a1c04; box-shadow: 0 16px 30px -16px rgba(255,138,61,0.7); }
.btn-primary:hover { transform: translateY(-1px); }
.btn-ghost { background: #fff; border: 1px solid var(--line); color: var(--navy); }
.btn-ghost:hover { border-color: var(--navy); }

/* ---- page bits ---- */
.page-head { margin-bottom: 18px; }
.page-head h1 { font-size: 30px; }
.page-head .sub { color: var(--mist); font-size: 15px; margin-top: 4px; }
.back { display: inline-block; color: var(--mist); font-size: 14px; margin-bottom: 14px; }
.back:hover { color: var(--navy); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 22px; }

.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 18px; }
.tabs a {
  white-space: nowrap; background: #fff; border: 1px solid var(--line);
  border-radius: 999px; padding: 8px 15px; font-size: 14px; font-weight: 500; color: var(--mist);
  transition: border-color 0.35s var(--ease), color 0.35s var(--ease);
}
.tabs a.on { border-color: var(--navy); color: var(--navy); font-weight: 600; }
.tabs a span { opacity: 0.6; margin-left: 5px; font-variant-numeric: tabular-nums; }

/* ---- lead list ---- */
.lead-list { list-style: none; display: grid; gap: 10px; }
.lead-list a {
  display: block; background: #fff; border: 1px solid var(--line);
  border-radius: 16px; padding: 15px 17px;
  transition: transform 0.4s var(--ease), box-shadow 0.4s var(--ease), border-color 0.4s var(--ease);
}
.lead-list a:hover {
  transform: translateY(-2px); border-color: rgba(4,50,113,0.28);
  box-shadow: 0 18px 36px -24px rgba(4,50,113,0.5);
}
.lead-list .row1 { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.lead-list .row1 strong { font-size: 17px; color: var(--navy); }
.lead-list .row2 { color: var(--mist); font-size: 14px; margin-top: 3px; }
.lead-list .row3 {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: 13px; color: var(--mist); margin-top: 8px;
}
.pill {
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  border-radius: 999px; padding: 4px 10px;
}
.s-new { background: #fff1e6; color: #b4560f; }
.s-contacted { background: var(--water); color: var(--navy); }
.s-won { background: #e6f6ec; color: #14713a; }
.s-lost { background: #f1f2f4; color: #6b7280; }

/* ---- cards ---- */
.card {
  background: #fff; border: 1px solid var(--line);
  border-radius: 18px; padding: 22px; margin-bottom: 16px;
}
.card h2 { font-size: 15px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--mist); margin-bottom: 14px; }
.detail { display: grid; grid-template-columns: 116px 1fr; gap: 10px 14px; font-size: 15px; }
.detail dt { color: var(--mist); font-size: 13px; padding-top: 1px; }
.detail dd.msg { white-space: pre-wrap; }

.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.seg button {
  background: #fff; border: 1px solid var(--line);
  border-radius: 12px; padding: 11px 8px; font: inherit; font-size: 14px;
  text-transform: capitalize; color: var(--mist); cursor: pointer;
  transition: border-color 0.35s var(--ease), color 0.35s var(--ease), background 0.35s var(--ease);
}
.seg button:hover { border-color: var(--pool); color: var(--navy); }
.seg button.on { background: var(--water); border-color: var(--pool); color: var(--navy); font-weight: 600; }

.note-form textarea {
  width: 100%; font: inherit; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 12px; resize: vertical;
  transition: border-color 0.35s var(--ease), box-shadow 0.35s var(--ease);
}
.note-form textarea:focus { outline: none; border-color: var(--pool); box-shadow: 0 0 0 4px rgba(27,127,212,0.12); }
.note-form .btn { margin-top: 10px; }
.notes { list-style: none; margin-top: 20px; display: grid; gap: 12px; }
.notes li { border-top: 1px solid var(--line); padding-top: 12px; }
.notes p { white-space: pre-wrap; font-size: 15px; }
.notes time { display: block; font-size: 12px; color: var(--mist); margin-top: 4px; }

.empty {
  background: #fff; border: 1px dashed var(--line); border-radius: 18px;
  padding: 44px 24px; text-align: center; color: var(--mist);
}
.empty .hint { font-size: 14px; margin-top: 6px; }
.empty a { color: var(--pool); font-weight: 600; }

@media (max-width: 560px) {
  .topbar { gap: 14px; padding: 10px 14px; }
  .brand span { display: none; }
  .detail { grid-template-columns: 1fr; gap: 2px 0; }
  .detail dd { margin-bottom: 8px; }
  .actions .btn { flex: 1; white-space: nowrap; }
  .actions .btn:first-child { flex-basis: 100%; }
  .seg { grid-template-columns: repeat(2, 1fr); }
}

/* ---- phase 2: today, schedule, customers ---- */
.page-head.row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 20px; }
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: 16px;
  padding: 16px; text-align: center;
  transition: border-color 0.4s var(--ease), transform 0.4s var(--ease);
}
a.stat:hover { border-color: var(--navy); transform: translateY(-2px); }
.stat .n {
  display: block; font-family: "Clash Display", sans-serif;
  font-size: 26px; font-weight: 600; color: var(--navy); line-height: 1.1;
}
.stat .l { display: block; font-size: 12px; color: var(--mist); margin-top: 4px; }

.alert {
  background: #fff6ed; border: 1px solid #ffd9b8; border-radius: 14px;
  padding: 14px 16px; margin-bottom: 20px; font-size: 14px;
}
.alert strong { color: #a1560d; display: block; margin-bottom: 6px; }
.alert ul { list-style: none; display: grid; gap: 3px; }
.alert a { color: var(--navy); font-weight: 500; text-decoration: underline; }

.section-title {
  font-size: 14px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--mist); margin: 26px 0 12px;
  display: flex; justify-content: space-between; align-items: baseline;
}
.section-title span { font-size: 13px; letter-spacing: 0; text-transform: none; }

.stop-list { list-style: none; display: grid; gap: 10px; }
.stop {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 15px 17px;
  transition: opacity 0.4s var(--ease), border-color 0.4s var(--ease);
}
.stop.done { opacity: 0.55; border-color: rgba(20,113,58,0.3); }
.stop.done .stop-name { text-decoration: line-through; }
.stop-main { min-width: 0; }
.stop-name { font-size: 17px; font-weight: 600; color: var(--navy); }
.stop-meta { font-size: 13px; color: var(--mist); margin-top: 2px; }
.stop-note { font-size: 13px; color: var(--ink); margin-top: 6px; white-space: pre-wrap; }
.stop-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.icon-btn {
  border: 1px solid var(--line); border-radius: 999px; padding: 9px 14px;
  font-size: 13px; font-weight: 600; color: var(--navy); background: #fff;
}
.icon-btn:hover { border-color: var(--navy); }
.btn-done {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 9px 16px; font: inherit; font-size: 13px; font-weight: 600;
  color: var(--mist); cursor: pointer; white-space: nowrap;
  transition: background 0.35s var(--ease), color 0.35s var(--ease), border-color 0.35s var(--ease);
}
.btn-done:hover { border-color: var(--pool); color: var(--navy); }
.btn-done.on { background: #e6f6ec; border-color: #9fd7b4; color: #14713a; }

.week-nav { display: flex; gap: 8px; margin-bottom: 18px; }
.week-nav .btn { padding: 9px 16px; font-size: 14px; }
.week { display: grid; gap: 10px; }
.day { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; }
.day.blank { background: transparent; border-style: dashed; opacity: 0.6; }
.day.today { border-color: var(--pool); box-shadow: 0 0 0 3px rgba(27,127,212,0.1); }
.day-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.day-head .dow { font-weight: 600; color: var(--navy); }
.day-head .dnum { font-size: 13px; color: var(--mist); }
.day-head .count {
  margin-left: auto; font-size: 12px; color: var(--mist);
  background: var(--water); border-radius: 999px; padding: 2px 9px;
}
.day ul { list-style: none; display: grid; gap: 6px; }
.day li { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.day li.done { opacity: 0.5; text-decoration: line-through; }
.day li a { color: var(--ink); }
.day li a:hover { color: var(--pool); }
.tag { font-size: 12px; color: var(--mist); }

.search { display: flex; gap: 8px; margin-bottom: 16px; }
.search input {
  flex: 1; font: inherit; padding: 11px 15px;
  border: 1px solid var(--line); border-radius: 999px; background: #fff;
}
.search input:focus { outline: none; border-color: var(--pool); box-shadow: 0 0 0 4px rgba(27,127,212,0.12); }
.search button {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 11px 20px; font: inherit; font-weight: 600; color: var(--navy); cursor: pointer;
}
.search button:hover { border-color: var(--navy); }
.rate { font-size: 14px; font-weight: 600; color: var(--pool); }

.stack-form { display: grid; gap: 14px; }
.stack-form .field label, .book-form label {
  display: block; font-size: 12px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--mist); margin-bottom: 6px;
}
.stack-form input, .stack-form select, .stack-form textarea,
.book-form input, .book-form select {
  width: 100%; font: inherit; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink);
  transition: border-color 0.35s var(--ease), box-shadow 0.35s var(--ease);
}
.stack-form input:focus, .stack-form select:focus, .stack-form textarea:focus,
.book-form input:focus, .book-form select:focus {
  outline: none; border-color: var(--pool); box-shadow: 0 0 0 4px rgba(27,127,212,0.12);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.book-form { display: grid; gap: 10px; }
.book-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.visit-list { list-style: none; display: grid; gap: 10px; }
.visit-list li {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  border-top: 1px solid var(--line); padding-top: 10px; font-size: 15px;
}
.visit-list li:first-child { border-top: 0; padding-top: 0; }
.link-btn {
  background: none; border: 0; font: inherit; font-size: 13px;
  color: var(--mist); cursor: pointer; text-decoration: underline; padding: 0;
}
.link-btn:hover { color: var(--navy); }
.muted { color: var(--mist); font-size: 15px; }
.map-tip { font-size: 13px; color: var(--mist); text-align: center; margin-top: 16px; }

@media (max-width: 560px) {
  .stats { grid-template-columns: 1fr; }
  .stat { display: flex; align-items: baseline; justify-content: space-between; text-align: left; padding: 13px 16px; }
  .stat .n { font-size: 21px; }
  .stat .l { margin-top: 0; }
  .field-row, .book-row { grid-template-columns: 1fr; }
  .stop { flex-direction: column; align-items: stretch; gap: 12px; }
  .stop-actions { justify-content: stretch; }
  .stop-actions form, .stop-actions .btn-done { width: 100%; }
  .icon-btn { flex: 1; text-align: center; }
  .page-head.row .btn { width: 100%; }
}

/* ---- phone: nav moves to a thumb-reachable bottom bar ---- */
@media (max-width: 640px) {
  /* backdrop-filter would make .topbar a containing block for the fixed nav,
     pinning it to the header instead of the viewport. Solid white instead. */
  .topbar {
    gap: 12px; padding: 10px 14px;
    background: #fff; backdrop-filter: none; -webkit-backdrop-filter: none;
  }
  .brand img { height: 26px; }
  .logout { margin-left: auto; }
  .logout button { white-space: nowrap; padding: 7px 12px; }
  .topbar nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    margin: 0; gap: 0;
    display: grid; grid-template-columns: repeat(5, 1fr);
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--line);
    padding: 8px 2px calc(8px + env(safe-area-inset-bottom));
    font-size: 12px;
  }
  .topbar nav a {
    text-align: center; padding: 8px 2px; border-radius: 10px;
    transition: background 0.35s var(--ease), color 0.35s var(--ease);
  }
  .topbar nav a.on { background: var(--water); color: var(--navy); font-weight: 600; }
  main.app { padding-bottom: 96px; }
}

/* ---- invoices (admin) ---- */
.flash {
  background: #e6f6ec; border: 1px solid #9fd7b4; color: #14713a;
  border-radius: 12px; padding: 12px 15px; font-size: 14px; margin-bottom: 18px;
}
.small { font-size: 13px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-form input[type="month"] {
  font: inherit; padding: 11px 14px; border: 1px solid var(--line);
  border-radius: 12px; background: #fff; color: var(--ink);
}
.inline-form input:focus { outline: none; border-color: var(--pool); box-shadow: 0 0 0 4px rgba(27,127,212,0.12); }
details.card summary { cursor: pointer; list-style: none; color: var(--mist); }
details.card summary::-webkit-details-marker { display: none; }
details.card summary::after { content: " +"; font-weight: 600; }
details.card[open] summary::after { content: " −"; }
.copy-row { display: flex; gap: 8px; }
.copy-row input {
  flex: 1; font: inherit; font-size: 13px; padding: 11px 14px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--water); color: var(--mist);
}
.pay-seg { grid-template-columns: repeat(3, 1fr); }
.paid-line { color: #14713a; font-weight: 600; margin-bottom: 10px; }

/* ---- public invoice / receipt document ---- */
.doc-body { background: #eef2f7; padding: 30px 16px 60px; }
.doc {
  max-width: 760px; margin: 0 auto; background: #fff;
  border: 1px solid var(--line); border-radius: 20px;
  padding: 40px 44px 34px;
  box-shadow: 0 40px 90px -50px rgba(4,50,113,0.5);
}
.doc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.doc-logo { height: 62px; width: auto; }
.doc-meta { text-align: right; }
.doc-type {
  display: block; font-family: "Clash Display", sans-serif;
  font-size: 26px; font-weight: 600; color: var(--navy); line-height: 1.1;
}
.doc-type.paid { color: #14713a; }
.doc-num { font-size: 13px; color: var(--mist); }
.paid-banner {
  background: #e6f6ec; border: 1px solid #9fd7b4; color: #14713a;
  border-radius: 12px; padding: 12px 16px; font-weight: 600; font-size: 15px;
  text-align: center; margin-bottom: 26px;
}
.doc-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin-bottom: 24px; }
.doc-parties > div { display: grid; gap: 2px; font-size: 15px; }
.doc-parties strong { color: var(--navy); }
.doc-parties a { color: var(--pool); }
.lbl {
  font-size: 10px; font-weight: 600; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--mist); margin-bottom: 4px;
}
.doc-dates { display: flex; gap: 18px; font-size: 14px; color: var(--mist); margin-bottom: 22px; }
.doc-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.doc-table th {
  text-align: left; font-size: 10px; font-weight: 600; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--mist);
  border-bottom: 1px solid var(--line); padding: 0 0 9px;
}
.doc-table td { padding: 13px 0; border-bottom: 1px solid var(--line); }
.doc-table .num { text-align: right; white-space: nowrap; padding-left: 14px; }
.doc-total {
  display: flex; justify-content: flex-end; align-items: baseline; gap: 22px;
  padding: 18px 0 0; font-size: 16px;
}
.doc-total span { color: var(--mist); }
.doc-total strong { font-family: "Clash Display", sans-serif; font-size: 26px; color: var(--navy); }
.doc-block { margin-top: 24px; display: grid; gap: 2px; }
.doc-block p { font-size: 15px; white-space: pre-wrap; }
.doc-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 30px; }
.doc-foot { text-align: center; color: var(--mist); font-size: 14px; margin-top: 26px; }

@media (max-width: 560px) {
  .doc { padding: 26px 20px; border-radius: 16px; }
  .doc-parties { grid-template-columns: 1fr; }
  .doc-logo { height: 46px; }
  .doc-type { font-size: 21px; }
  .pay-seg { grid-template-columns: repeat(2, 1fr); }
  .doc-actions .btn { flex: 1; }
}

@media print {
  .doc-body { background: #fff; padding: 0; }
  .doc { border: 0; box-shadow: none; max-width: none; padding: 0; }
  .doc-actions { display: none; }
}
