/* Subcontractor App — mobile-first, dark navy / gold / green */
:root {
  --navy: #0e1b2c;
  --navy-2: #16283f;
  --gold: #d9a441;
  --gold-dark: #b8862c;
  --green: #2e9e5b;
  --red: #c94f4f;
  --bg: #f2f4f7;
  --card: #ffffff;
  --ink: #1c2733;
  --muted: #6b7a8c;
  --line: #e1e6ec;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--navy); color: #fff;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.brand { color: var(--gold); font-weight: 700; font-size: 18px; text-decoration: none; letter-spacing: .3px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.topbar-actions button {
  background: var(--navy-2); color: #fff; border: 1px solid rgba(255,255,255,.18);
  border-radius: 8px; padding: 8px 12px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.topbar-actions button.lang { color: var(--gold); border-color: var(--gold-dark); min-width: 46px; }

main { max-width: 640px; margin: 0 auto; padding: 16px 14px calc(env(safe-area-inset-bottom) + 40px); }

/* Cards */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(15,27,44,.06);
}
.card.tappable { cursor: pointer; transition: transform .06s; }
.card.tappable:active { transform: scale(.985); }
.card h3 { margin: 0 0 4px; font-size: 17px; }
.card .sub { color: var(--muted); font-size: 14px; margin: 2px 0; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.spread { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: 14px; }
.spread b { font-weight: 700; }

h2.page-title { font-size: 20px; margin: 4px 0 14px; }
.section-title { font-size: 15px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 20px 0 8px; font-weight: 700; }

/* Status pills */
.pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; letter-spacing: .3px; white-space: nowrap;
}
.pill.open { background: #e8edf3; color: #46586c; }
.pill.accepted { background: #fdf3dd; color: #8a6410; }
.pill.in_progress { background: #e0ecfb; color: #2b5b9e; }
.pill.done { background: #ddf2e4; color: #1c6e3f; }
.pill.blocked { background: #fbe3e3; color: #a03030; }

/* Money */
.money { font-variant-numeric: tabular-nums; font-weight: 700; }
.money.pos { color: var(--green); }
.money.due { color: var(--red); }

/* Forms */
label.field { display: block; margin-bottom: 12px; font-size: 14px; font-weight: 600; color: #3c4c5e; }
label.field span { display: block; margin-bottom: 5px; }
input[type=text], input[type=number], input[type=password], input[type=datetime-local], input[type=date], textarea, select {
  width: 100%; font-size: 16px; padding: 12px; border: 1px solid #c8d1db; border-radius: 10px;
  background: #fff; color: var(--ink); appearance: none;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--gold); border-color: var(--gold); }

/* Buttons */
.btn {
  display: block; width: 100%; text-align: center; padding: 14px; margin: 10px 0 0;
  font-size: 16px; font-weight: 700; border: 0; border-radius: 10px; cursor: pointer;
}
.btn.primary { background: var(--navy); color: #fff; }
.btn.gold { background: var(--gold); color: var(--navy); }
.btn.green { background: var(--green); color: #fff; }
.btn.ghost { background: transparent; color: var(--navy); border: 1.5px solid var(--navy); }
.btn:disabled { opacity: .55; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.btn-row .btn { margin: 0; padding: 12px 6px; font-size: 14px; }

/* Status choice buttons */
.status-choice { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 6px 0 12px; }
.status-choice button {
  padding: 10px 4px; font-size: 13px; font-weight: 700; border-radius: 10px;
  border: 1.5px solid #c8d1db; background: #fff; color: var(--muted); cursor: pointer;
}
.status-choice button.on.accepted { border-color: var(--gold-dark); background: #fdf3dd; color: #8a6410; }
.status-choice button.on.in_progress { border-color: #2b5b9e; background: #e0ecfb; color: #2b5b9e; }
.status-choice button.on.done { border-color: var(--green); background: #ddf2e4; color: #1c6e3f; }
.status-choice button.on.blocked { border-color: var(--red); background: #fbe3e3; color: #a03030; }

/* Thread / feed */
.feed-item { border-left: 4px solid var(--gold); }
.feed-item.kind-office { border-left-color: #2b5b9e; }
.feed-item.kind-done { border-left-color: var(--green); }
.feed-item.kind-blocked { border-left-color: var(--red); }
.feed-item .meta { font-size: 12px; color: var(--muted); margin-top: 6px; }
.feed-item .fact { font-size: 14px; margin: 3px 0; }
.feed-item .fact b { color: #3c4c5e; }
.badge {
  display: inline-block; min-width: 20px; text-align: center; background: var(--red); color: #fff;
  font-size: 12px; font-weight: 800; border-radius: 999px; padding: 2px 6px; margin-left: 6px; vertical-align: 2px;
}

/* Photos */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin-top: 8px; }
.photo-grid a { display: block; }
.photo-grid img, .feed-photo img { width: 100%; border-radius: 10px; border: 1px solid var(--line); display: block; }
.feed-photo img { max-width: 260px; margin-top: 8px; }
.photo-cap { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* PIN login */
.login-wrap { max-width: 340px; margin: 12vh auto 0; text-align: center; }
.login-wrap .lock { font-size: 42px; margin-bottom: 6px; }
.login-wrap h2 { margin: 0 0 16px; }
.login-wrap input { text-align: center; font-size: 22px; letter-spacing: 2px; }
.err { color: var(--red); font-weight: 600; margin-top: 10px; min-height: 1.2em; }

/* Home chooser */
.home-wrap { max-width: 380px; margin: 8vh auto 0; text-align: center; }
.home-wrap .big { font-size: 52px; }
.home-wrap .btn { padding: 20px; font-size: 18px; margin-top: 14px; }

/* Office nav tabs */
.tabs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-bottom: 14px; }
.tabs a {
  text-align: center; padding: 10px 2px; font-size: 13px; font-weight: 700; text-decoration: none;
  color: var(--muted); background: #fff; border: 1px solid var(--line); border-radius: 10px;
}
.tabs a.on { background: var(--navy); color: var(--gold); border-color: var(--navy); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 24px); transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 12px 20px; border-radius: 10px; font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,.3); z-index: 50; max-width: 90vw; text-align: center;
}
.toast.ok { border-left: 4px solid var(--green); }
.toast.bad { border-left: 4px solid var(--red); }

.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.muted { color: var(--muted); }
a.plain { color: var(--navy); }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }

/* Message thread (sub ↔ office chat) */
.msg-thread { display: flex; flex-direction: column; gap: 8px; max-height: 340px; overflow-y: auto; margin-bottom: 10px; }
.msg-bubble { padding: 8px 12px; border-radius: 12px; max-width: 88%; font-size: 14px; }
.msg-bubble b { display: block; font-size: 12px; margin-bottom: 2px; }
.msg-bubble.sub { align-self: flex-start; background: #eef2f7; border: 1px solid var(--line); }
.msg-bubble.office { align-self: flex-end; background: var(--navy); color: #fff; }
.msg-bubble.office b { color: var(--gold); }
.card.unread { border-left: 4px solid var(--red); }
.btn.mini { display: inline-block; width: auto; margin: 0 0 0 8px; padding: 3px 10px; font-size: 12px; border-radius: 8px; }

@media (min-width: 700px) {
  body { font-size: 16px; }
  .status-choice button { font-size: 14px; }
}
