/* ==========================================================================
   Marsh K&B Services - field tech web app
   Utility theme: brand sand + slate, tuned for outdoor legibility and
   large touch targets. The logo carries the brand; content stays quiet.
   ========================================================================== */

:root {
  --sand:        #d4c8a6;
  --sand-deep:   #c3b793;
  --ink:         #44464a;   /* logo slate */
  --ink-soft:    #5f6166;
  --paper:       #f7f5ef;   /* warm off-white content bg */
  --white:       #ffffff;
  --line:        #e4dfd2;

  --steel:       #2f6f8f;   /* scheduled */
  --rust:        #b4532f;   /* overdue */
  --green:       #3f7d4f;   /* complete */
  --amber:       #9a7d22;   /* incomplete */

  --r:           10px;
  --tap:         52px;      /* minimum touch target */
  --shadow:      0 1px 3px rgba(0,0,0,.10);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  font-size: 17px;            /* readable default on phones */
}

a { color: var(--steel); }

/* ---- App header ---- */
.app-header {
  background: var(--sand);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .85rem 1rem;
  position: sticky;
  top: 0;
  z-index: 30;
  padding-top: calc(.85rem + env(safe-area-inset-top));
}
.app-header .brand img { height: 100px; display: block; }
.iconbtn {
  background: none; border: 0; color: var(--ink);
  min-width: var(--tap); min-height: var(--tap);
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r); line-height: 0;
}
.iconbtn:active { background: rgba(0,0,0,.06); }

/* ---- Login ---- */
.login-wrap {
  min-height: 100dvh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 2rem 1.5rem;
  background: var(--sand);
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--white);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,.12);
  padding: 2rem 1.5rem 1.75rem;
}
.login-logo { display: block; width: 220px; max-width: 80%; margin: 0 auto 1.75rem; }
.login-card h1 { font-size: 1.1rem; font-weight: 600; margin: 0 0 1.25rem; color: var(--ink-soft); text-align: center; }

/* ---- Form controls (shared) ---- */
.field { margin-bottom: 1rem; }
.field label {
  display: block; font-size: .8rem; font-weight: 600;
  letter-spacing: .04em; text-transform: uppercase;
  color: var(--ink-soft); margin-bottom: .35rem;
}
.field .control,
.app-input {
  width: 100%;
  min-height: var(--tap);
  border: 1.5px solid var(--line);
  border-radius: var(--r);
  padding: .6rem .85rem;
  font-size: 1.05rem;
  color: var(--ink);
  background: var(--white);
}
.field .control:focus,
.app-input:focus {
  outline: none;
  border-color: var(--steel);
  box-shadow: 0 0 0 3px rgba(47,111,143,.18);
}
textarea.app-input { min-height: 120px; resize: vertical; line-height: 1.4; }

/* ---- Buttons ---- */
.btn-app {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: var(--tap);
  width: 100%;
  border: 0; border-radius: var(--r);
  font-size: 1.05rem; font-weight: 600;
  padding: .7rem 1rem; cursor: pointer;
}
.btn-primary-app { background: var(--ink); color: var(--white); }
.btn-primary-app:active { background: #34363a; }
.btn-green  { background: var(--green); color: #fff; }
.btn-amber  { background: var(--amber); color: #fff; }
.btn-ghost  { background: var(--white); color: var(--ink); border: 1.5px solid var(--line); }
.btn-app:disabled { opacity: .5; }

.form-msg { font-size: .9rem; margin-top: .5rem; min-height: 1.1em; }
.form-msg.error { color: var(--rust); }
.form-msg.ok    { color: var(--green); }

/* ---- Work order list ---- */
.wo-list { padding: .5rem .75rem 6rem; }
.wo-card {
  display: block;
  position: relative;
  background: var(--white);
  border: 1px solid var(--line);
  border-left: 6px solid var(--steel);   /* status rail */
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: .9rem 1rem .9rem 1.1rem;
  margin: .6rem .25rem;
  text-decoration: none;
  color: inherit;
}
.wo-card:active { background: #fbfaf6; }
.wo-card.status-scheduled  { border-left-color: var(--steel); }
.wo-card.status-overdue    { border-left-color: var(--rust); }
.wo-card.status-complete   { border-left-color: var(--green); }
.wo-card.status-incomplete { border-left-color: var(--amber); }

.wo-top { display: flex; justify-content: space-between; gap: .75rem; }
.wo-job { font-weight: 600; font-size: 1.08rem; line-height: 1.25; }
.wo-loc { color: var(--ink-soft); font-size: .98rem; margin-top: .15rem; }
.wo-when { text-align: right; white-space: nowrap; }
.wo-date { font-weight: 600; font-size: .98rem; }
.wo-time { color: var(--ink-soft); font-size: .92rem; margin-top: .15rem; }

.pill {
  display: inline-block; margin-top: .6rem;
  font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: .2rem .55rem; border-radius: 999px;
}
.pill-scheduled  { background: rgba(47,111,143,.14); color: var(--steel); }
.pill-overdue    { background: rgba(180,83,47,.14);  color: var(--rust); }
.pill-complete   { background: rgba(63,125,79,.16);  color: var(--green); }
.pill-incomplete { background: rgba(154,125,34,.16); color: var(--amber); }

.list-empty { text-align: center; color: var(--ink-soft); padding: 4rem 1.5rem; }

/* ---- Detail page ---- */
.detail-wrap { padding: 0 0 6.5rem; }
.detail-head {
  background: var(--white); border-bottom: 1px solid var(--line);
  padding: 1rem 1.1rem 1.1rem;
}
.detail-head .wo-job { font-size: 1.25rem; }
.detail-head .wo-loc { font-size: 1.02rem; }
.detail-when {
  display: flex; gap: 1.25rem; margin-top: .6rem;
  font-size: .98rem; color: var(--ink-soft);
}

/* Accordion built on Bootstrap, restyled to brand */
.accordion { --bs-accordion-border-color: var(--line); padding: .5rem .75rem; }
.accordion-item { border-radius: var(--r) !important; overflow: hidden; margin-bottom: .55rem; border: 1px solid var(--line); }
.accordion-button {
  font-weight: 600; font-size: 1.02rem; color: var(--ink);
  background: var(--white); min-height: var(--tap);
}
.accordion-button:not(.collapsed) { color: var(--ink); background: #fbf9f3; box-shadow: none; }
.accordion-button:focus { box-shadow: 0 0 0 3px rgba(47,111,143,.18); }
.accordion-button::after { filter: grayscale(1); }
.accordion-body { background: var(--white); }

/* Field rows inside sections */
.kv { display: grid; grid-template-columns: 1fr; gap: .15rem; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv .k { font-size: .76rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-soft); }
.kv .v { font-size: 1.05rem; color: var(--ink); }
.kv .v.blank { color: #b6b1a3; }
.freeform { font-size: 1.05rem; line-height: 1.45; white-space: pre-wrap; }

.yn { display: inline-block; font-weight: 700; padding: .1rem .5rem; border-radius: 6px; font-size: .9rem; }
.yn-yes { background: rgba(63,125,79,.16); color: var(--green); }
.yn-no  { background: rgba(180,83,47,.14); color: var(--rust); }

/* Media + documents */
.media-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.media-grid figure { margin: 0; }
.media-grid img { width: 100%; height: 120px; object-fit: cover; border-radius: var(--r); border: 1px solid var(--line); }
.media-grid figcaption { font-size: .82rem; color: var(--ink-soft); margin-top: .25rem; }
.doc-row {
  display: flex; align-items: center; gap: .6rem;
  min-height: var(--tap); padding: .5rem .25rem;
  border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink);
}
.doc-row:last-child { border-bottom: 0; }

/* Sticky action bar */
.action-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: var(--white); border-top: 1px solid var(--line);
  padding: .65rem .75rem calc(.65rem + env(safe-area-inset-bottom));
  display: grid; grid-template-columns: 1fr 1fr; gap: .55rem;
  box-shadow: 0 -2px 10px rgba(0,0,0,.06);
}
.action-bar .btn-app { font-size: 1rem; }
.action-bar .full { grid-column: 1 / -1; }

/* Upload progress list */
.upload-list { margin-top: .75rem; }
.upload-item { display: flex; align-items: center; gap: .6rem; font-size: .9rem; padding: .35rem 0; }
.upload-bar { flex: 1; height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; }
.upload-bar > span { display: block; height: 100%; width: 0; background: var(--steel); transition: width .2s; }

.back-link { color: var(--ink); text-decoration: none; font-size: .95rem; display: inline-flex; align-items: center; gap: .35rem; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
