/* Palette matches the Android app: summitproservices.com brand colours. */
:root {
  --navy: #243673;
  --navy-dark: #1A2755;
  --navy-light: #3B4E96;
  --blue: #0084D6;
  --blue-dark: #0075BE;
  --blue-soft: #BFD1FF;
  --sand: #E8E5DE;

  --bg: #F7F6F3;
  --surface: #FFFFFF;
  --sunken: #EFEDE8;
  --outline: #DFDCD5;

  --text: #1B1D22;
  --text-2: #5F636E;
  --text-3: #8B909C;

  --ok: #15803D;
  --warn: #B26A00;
  --danger: #B3261E;

  --radius: 14px;
  --shadow: 0 1px 2px rgba(27,29,34,.06), 0 8px 24px rgba(27,29,34,.06);

  /*
   * Declares that both themes are handled here. Without it the browser assumes
   * a light-only page and auto-darkens it, which inverts these tokens into mud
   * and leaves brand colours untouched beside them.
   */
  color-scheme: light dark;
}

/* Dark palette. Only the neutrals flip — navy and blue stay put, matching the
   Android app's values-night. */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101218;
    --surface: #181B23;
    --sunken: #1F232C;
    --outline: #2C313C;

    --text: #F2F3F5;
    --text-2: #A2A8B5;
    --text-3: #7A808D;

    --ok: #5CC47E;
    --warn: #E8A33D;
    --danger: #F2857C;

    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  }

  .pill.requested { background:#252932; color:#A2A8B5; }
  .pill.priced,
  .pill.pending   { background:#3A2E1B; color:#E8A33D; }
  .pill.paid      { background:#152E42; color:#4FB0EE; }
  .pill.assigned  { background:#2A2340; color:#A98CF5; }
  .pill.picked_up { background:#16332E; color:#4FBBAA; }
  .pill.delivered,
  .pill.verified  { background:#183021; color:#5CC47E; }
  .pill.cancelled,
  .pill.rejected  { background:#3B1F1D; color:#F2857C; }

  .login-card { box-shadow: 0 20px 60px rgba(0,0,0,.55); }
}

/*
 * The hidden attribute must beat every layout rule below. Without this,
 * `.modal { display: grid }` and `.shell { display: grid }` override the UA
 * stylesheet's [hidden] { display: none } and both render regardless of the
 * attribute — which showed the empty modal on top of the login screen.
 */
[hidden] { display: none !important; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; letter-spacing: -.02em; }
.muted { color: var(--text-2); margin: 0; }
.small { font-size: 13px; }
.error { color: var(--danger); min-height: 20px; font-size: 13px; margin: 0; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--navy), var(--navy-light));
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border-radius: 20px; padding: 32px;
  display: grid; gap: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-card h1 { font-size: 22px; }
.brand-mark {
  width: 52px; height: 52px; border-radius: 14px;
  background: linear-gradient(135deg, var(--navy), var(--blue));
  color: #fff; display: grid; place-items: center;
  font-weight: 800; letter-spacing: .02em;
}
.brand-mark.small { width: 38px; height: 38px; border-radius: 11px; font-size: 14px; }

label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-2); }
input, select, textarea {
  font: inherit; color: var(--text);
  padding: 11px 12px;
  border: 1px solid var(--outline); border-radius: 10px;
  background: var(--surface); width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0,132,214,.15);
}

/* ---------- Buttons ---------- */
.btn {
  font: inherit; font-weight: 700;
  padding: 10px 16px; border-radius: 10px;
  border: 1px solid transparent; cursor: pointer;
  background: var(--sunken); color: var(--text);
  transition: filter .12s ease;
}
.btn:hover:not(:disabled) { filter: brightness(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--blue); color: #fff; }
.btn.navy { background: var(--navy); color: #fff; }
.btn.ok { background: var(--ok); color: #fff; }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--outline); }
.btn.ghost { background: transparent; border-color: var(--outline); color: var(--text-2); }
.btn.small { padding: 6px 12px; font-size: 13px; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100%; }
.sidebar {
  background: linear-gradient(170deg, var(--navy), var(--navy-dark));
  color: #fff; padding: 20px 14px;
  display: flex; flex-direction: column; gap: 22px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.sidebar-brand strong { display: block; font-size: 15px; }
.sidebar-brand .muted { color: rgba(255,255,255,.6); }

nav { display: grid; gap: 4px; flex: 1; }
.nav-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font: inherit; font-weight: 600; text-align: left;
  padding: 10px 12px; border-radius: 10px;
  background: transparent; border: 0; color: rgba(255,255,255,.72);
  cursor: pointer;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.16); color: #fff; }

.badge {
  min-width: 22px; padding: 1px 7px; border-radius: 100px;
  background: rgba(255,255,255,.22); font-size: 12px; font-weight: 700;
  text-align: center;
}
.badge:empty { display: none; }
.badge.warn { background: #F0A62E; color: #3A2400; }

.sidebar-foot {
  display: grid; gap: 8px; padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,.14);
}
.sidebar-foot .muted { color: rgba(255,255,255,.6); word-break: break-all; }
.sidebar-foot .btn.ghost { color: #fff; border-color: rgba(255,255,255,.3); }

.content { padding: 28px 32px 60px; max-width: 1180px; }
.view-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 20px;
}
.view-head h2 { font-size: 24px; }

.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font: inherit; font-size: 13px; font-weight: 600;
  padding: 6px 13px; border-radius: 100px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--outline); color: var(--text-2);
}
.chip.active { background: var(--navy); border-color: var(--navy); color: #fff; }

/* ---------- Cards ---------- */
.cards { display: grid; gap: 12px; }
.card {
  background: var(--surface); border: 1px solid var(--outline);
  border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow);
}
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.card-title { font-weight: 700; font-size: 16px; }
.amount { font-size: 20px; font-weight: 800; letter-spacing: -.02em; color: var(--navy); }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 14px; }
.kv div span { display: block; font-size: 12px; color: var(--text-3); }
.kv div strong { font-weight: 600; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.route { color: var(--text-2); font-size: 14px; margin-top: 6px; }

.pill {
  display: inline-block; padding: 4px 11px; border-radius: 100px;
  font-size: 12px; font-weight: 700;
}
.pill.requested { background:#ECEDF0; color:#5F636E; }
.pill.priced    { background:#FDF0DC; color:#B26A00; }
.pill.paid      { background:#DDEEFB; color:#0075BE; }
.pill.assigned  { background:#E9E2FB; color:#5B3FBF; }
.pill.picked_up { background:#DCF0EC; color:#0F7A6B; }
.pill.delivered { background:#DEF3E4; color:#15803D; }
.pill.cancelled { background:#FBE3E1; color:#B3261E; }
.pill.pending   { background:#FDF0DC; color:#B26A00; }
.pill.verified  { background:#DEF3E4; color:#15803D; }
.pill.rejected  { background:#FBE3E1; color:#B3261E; }

.proof { max-width: 220px; border-radius: 10px; border: 1px solid var(--outline); margin-top: 12px; display: block; }
.empty { padding: 48px; text-align: center; color: var(--text-3); }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(20,22,28,.55);
  display: grid; place-items: center; padding: 20px; z-index: 50;
}
.modal-card {
  background: var(--surface); border-radius: 18px; padding: 24px;
  width: 100%; max-width: 440px; display: grid; gap: 14px;
  box-shadow: 0 24px 70px rgba(0,0,0,.3);
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 12px 20px;
  border-radius: 100px; font-weight: 600; z-index: 60;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  nav { grid-auto-flow: column; overflow-x: auto; }
  .content { padding: 20px 16px 60px; }
}

/* ---------- Messaging ---------- */
.chat-wrap { display: grid; grid-template-columns: 320px 1fr; gap: 16px; align-items: start; }
.chat-panel { display: flex; flex-direction: column; min-height: 460px; max-height: 70vh; padding: 0; }
.chat-head { padding: 16px 18px; border-bottom: 1px solid var(--outline); font-weight: 700; }
.chat-log { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.chat-form { display: flex; gap: 8px; padding: 14px; border-top: 1px solid var(--outline); }
.chat-form input { flex: 1; }

.bubble { max-width: 78%; padding: 10px 14px; border-radius: 16px; font-size: 14px; line-height: 1.45; }
.bubble .who { display: block; font-size: 11px; font-weight: 700; opacity: .65; margin-bottom: 3px; }
.bubble .when { display: block; font-size: 11px; opacity: .55; margin-top: 4px; }
.bubble.them { align-self: flex-start; background: var(--sunken); border-bottom-left-radius: 4px; }
.bubble.us { align-self: flex-end; background: var(--navy); color: #fff; border-bottom-right-radius: 4px; }

.thread { cursor: pointer; }
.thread.active { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(0,132,214,.18); }
.thread .preview { color: var(--text-2); font-size: 13px; margin-top: 4px;
                   overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 900px) { .chat-wrap { grid-template-columns: 1fr; } }
