:root {
  --green: #1f6b4a; --green-dark: #164f37; --green-soft: #e6f2ec;
  --ink: #1d2421; --muted: #5d6b64; --line: #d6e0da; --bg: #f5f7f6; --card: #ffffff;
  --red: #b3261e; --red-soft: #fbe9e7; --amber: #8a5a00; --amber-soft: #fff4dc;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--ink);
       background: var(--bg); font-size: 16px; line-height: 1.4; }
header { background: var(--green); color: #fff; padding: 12px 16px; display: flex; align-items: center;
         justify-content: space-between; gap: 8px; }
header h1 { font-size: 18px; margin: 0; font-weight: 600; }
header .who { font-size: 13px; opacity: .9; }
header a, header button.link { color: #fff; font-size: 14px; background: none; border: 0; text-decoration: underline; cursor: pointer; }
main { max-width: 1100px; margin: 0 auto; padding: 16px; }
.narrow { max-width: 440px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.card h2 { font-size: 16px; margin: 0 0 12px; }
label { display: block; font-size: 14px; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea { width: 100%; padding: 12px; font-size: 16px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
input:focus, select:focus { outline: 2px solid var(--green); border-color: var(--green); }
button { font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--green); padding: 10px 14px;
         background: #fff; color: var(--green); }
button.primary { background: var(--green); color: #fff; }
button.primary:hover { background: var(--green-dark); }
button.danger { border-color: var(--red); color: var(--red); }
button:disabled { opacity: .5; cursor: default; }
button.block { width: 100%; margin-top: 16px; padding: 14px; }
.big-button { width: 100%; padding: 28px; font-size: 26px; font-weight: 700; border-radius: 14px; margin: 8px 0; }
.msg { padding: 10px 12px; border-radius: 8px; margin: 10px 0; font-size: 15px; }
.msg.error { background: var(--red-soft); color: var(--red); }
.msg.warn { background: var(--amber-soft); color: var(--amber); }
.msg.ok { background: var(--green-soft); color: var(--green-dark); }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 14px; }
.big { font-size: 22px; font-weight: 600; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > * { flex: 1 1 auto; }
.checkbox { display: flex; gap: 10px; align-items: flex-start; margin: 14px 0; font-size: 16px; color: var(--ink); }
.checkbox input { width: 24px; height: 24px; flex: 0 0 24px; margin-top: 2px; }
.terms { max-height: 180px; overflow: auto; font-size: 14px; color: var(--muted); border: 1px solid var(--line);
         border-radius: 8px; padding: 10px; background: #fafcfb; white-space: pre-wrap; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 13px; }
td .actions { display: flex; gap: 6px; flex-wrap: wrap; }
td button { padding: 6px 10px; font-size: 14px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: var(--green-soft); color: var(--green-dark); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs button { flex: 0 0 auto; }
.tabs button.active { background: var(--green); color: #fff; }
.count { font-weight: 700; }
dialog { border: 0; border-radius: 12px; padding: 0; width: min(440px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog .card { margin: 0; border: 0; }
.scroll { overflow-x: auto; }
@media (max-width: 640px) {
  th.hide-sm, td.hide-sm { display: none; }
}

/* Trip tickets dashboard */
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.filters label { display: flex; flex-direction: column; font-size: 13px; color: var(--muted); margin: 0; min-width: 130px; }
.filters label.grow { flex: 1 1 220px; }
.filters input, .filters select { margin-top: 4px; }
.counters { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.counters div { background: var(--green-soft); border-radius: 10px; padding: 10px; text-align: center; }
.counters b { display: block; font-size: 22px; color: var(--green-dark); }
.counters span { font-size: 12px; color: var(--muted); }
@media (max-width: 600px) { .counters { grid-template-columns: repeat(2, 1fr); } .filters label { min-width: 46%; } }
table.tk td { vertical-align: top; }
tr.click { cursor: pointer; }
tr.click:hover { background: var(--green-soft); }
.badge.grey { background: #eceff1; color: #455a64; }
dialog { max-width: 640px; width: calc(100% - 32px); }

/* Show password button inside the password box */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 76px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); padding: 6px 12px;
             font-size: 14px; background: var(--green-soft); color: var(--green-dark); border: 0; border-radius: 6px; cursor: pointer; }

/* Forms in two columns on a PC, one on a phone */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 600px) { .grid2 { grid-template-columns: 1fr; } }
dialog .card { max-height: 85vh; overflow-y: auto; }
.members { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 4px 12px; }
.members label.checkbox { margin: 4px 0; }
button.dl { flex: 0 0 auto; }
.row > h2 ~ button, .row > h2 ~ input + button { flex: 0 0 auto; }

/* Charging (Release 3) */
.bays { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.bay { border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.bay.ok { background: var(--green-soft); }
.bay.busy { background: var(--amber-soft); }
.bay.off { background: var(--red-soft); }
.qr { width: min(80vw, 340px); margin: 8px auto; }
.qr svg { width: 100%; height: auto; display: block; }

/* Driver's trip ticket card */
.ticket-card { padding-top: 0; overflow: hidden; }
.ticket-head { margin: 0 -16px 12px; padding: 8px 16px; background: var(--green); color: #fff; font-weight: 600; letter-spacing: .08em; font-size: 14px; }
table.ticket-sheet { margin-bottom: 12px; font-size: 16px; }
table.ticket-sheet th { text-align: left; width: 40%; color: var(--muted); font-weight: 500; padding: 7px 0; border-bottom: 1px dashed var(--line); }
table.ticket-sheet td { font-weight: 600; padding: 7px 0; border-bottom: 1px dashed var(--line); }

/* Release 4: applicant form and hiring */
.apply h3 { font-size: 15px; margin: 16px 0 6px; }
.rowbox { border: 1px dashed var(--line); border-radius: 8px; padding: 8px; margin: 8px 0; display: grid; gap: 6px; }
.rowbox label { margin: 2px 0 0; }
.link-btn { border: 0; background: none; color: var(--red); padding: 4px 0; justify-self: start; text-decoration: underline; }
.codes { display: flex; flex-wrap: wrap; gap: 6px; }
.codes .code { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 8px;
               padding: 8px 12px; margin: 0; color: var(--ink); font-size: 16px; }
.codes .code input { width: 20px; height: 20px; }
.qr-big { width: min(70vw, 300px); margin: 8px auto; }
.qr-big svg { width: 100%; height: auto; display: block; }
.intake-url { word-break: break-all; font-size: 13px; color: var(--muted); text-align: center; }
dialog.wide { width: min(820px, calc(100vw - 32px)); }
.detail h3 { font-size: 14px; margin: 14px 0 4px; color: var(--green-dark); }
.detail table td:first-child { color: var(--muted); width: 38%; }
#printArea { display: none; }
@media print {
  @page { size: A4 portrait; margin: 14mm; }
  body { background: #fff; }
  body > header, body > main, dialog { display: none !important; }
  #printArea { display: block; text-align: center; font-family: system-ui, Arial, sans-serif; color: #000; }
  #printArea h1 { font-size: 30pt; margin: 6mm 0 2mm; }
  #printArea .sub { font-size: 18pt; margin: 0 0 8mm; }
  #printArea .pqr { width: 120mm; margin: 0 auto; }
  #printArea .pqr svg { width: 100%; height: auto; }
  #printArea .valid { font-size: 20pt; font-weight: 700; margin: 8mm 0 3mm; }
  #printArea .small { font-size: 11pt; color: #333; margin-top: 4mm; word-break: break-all; }
}
.shift-sel { width: auto; padding: 8px; font-size: 14px; flex: 0 1 auto; }
.app-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 8px; }
.app-photo { width: 110px; height: 130px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
             display: flex; align-items: center; justify-content: center; background: #fafcfb; flex: 0 0 110px; text-align: center; }
.app-photo img { width: 100%; height: 100%; object-fit: cover; }
.stage-form { border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin: 8px 0; background: #fafcfb; }
.stage-form > b { display: block; margin-bottom: 6px; }
.cam video, .cam img { width: 100%; max-height: 60vh; object-fit: contain; border-radius: 8px; background: #000; display: block; }
.detail h3 small { font-weight: 400; }

/* Release 4 parts 2 and 3: trip history, pay */
.trip-tk { border-top: 1px solid var(--line); padding: 10px 0; }
.trip-day { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.trip-day > span:first-child { min-width: 100px; }
.trip-day button { margin-left: auto; padding: 6px 10px; }
.trip-row { display: grid; grid-template-columns: 24px 1fr 1fr 28px; gap: 6px; align-items: center; margin: 6px 0; }
.trip-row .link-btn { font-size: 20px; text-decoration: none; }
.trip-shot { width: 100%; max-height: 220px; object-fit: contain; margin-top: 6px; border: 1px solid var(--line); border-radius: 6px; }
.pay-row { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; padding: 6px 0; border-bottom: 1px solid var(--line); }
.pay-row span { flex: 1 1 auto; }
.num { text-align: right; white-space: nowrap; }
input.cell { padding: 6px 8px; font-size: 14px; width: 100%; min-width: 70px; }
.photos { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.photos img { height: 220px; border: 1px solid var(--line); border-radius: 6px; }
