:root {
  --brand: #014e8c; --brand-d: #013a69; --brand-l: #e6f0f8;
  --red: #c62828; --amber: #b26a00; --bg: #f2f5f8; --card: #fff;
  --text: #1c2530; --muted: #5f6b78; --line: #dce3ea;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Segoe UI", "Heebo", "Noto Sans Thai", Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 17px;
  padding-bottom: 84px; -webkit-tap-highlight-color: transparent;
}
#top {
  background: var(--brand); color: #fff; padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  position: sticky; top: 0; z-index: 5;
}
#top .title { font-weight: 700; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#top .right { flex: none; }
#top .right { display: flex; gap: 8px; align-items: center; }
#top button, #top select {
  background: rgba(255,255,255,.16); color: #fff; border: 0; border-radius: 8px;
  padding: 8px 10px; font-size: 15px; font-family: inherit;
}
#top select option { color: #000; }
main { max-width: 560px; margin: 0 auto; padding: 14px 16px; }
main.wide { max-width: 1200px; }
.card { background: var(--card); border-radius: 14px; padding: 16px; margin-bottom: 14px; box-shadow: 0 1px 4px rgba(0,0,0,.07); }
h2 { font-size: 19px; margin: 0 0 12px; }
h3 { font-size: 16px; margin: 16px 0 8px; }
.muted { color: var(--muted); font-size: 15px; }
label { display: block; font-weight: 600; margin: 12px 0 5px; font-size: 15px; }
input, select, textarea {
  width: 100%; padding: 12px; font-size: 17px; border: 1px solid #c2ccd6;
  border-radius: 10px; background: #fff; font-family: inherit; color: inherit;
}
textarea { min-height: 70px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
button { font-family: inherit; cursor: pointer; }
.btn {
  display: block; width: 100%; padding: 14px; font-size: 18px; font-weight: 700;
  border: 0; border-radius: 12px; background: var(--brand); color: #fff; margin-top: 14px;
}
.btn.sec { background: #fff; color: var(--brand-d); border: 2px solid var(--brand); }
.btn.small { display: inline-block; width: auto; padding: 8px 12px; font-size: 15px; margin: 0; }
.btn.danger { background: #fff; color: var(--red); border: 1px solid var(--red); }
.btn:disabled { opacity: .55; }
.punch {
  width: 100%; padding: 30px 14px; font-size: 26px; font-weight: 800; border: 0;
  border-radius: 18px; color: #fff; background: var(--brand); margin-top: 12px;
}
.punch.out { background: var(--red); }
.state { font-size: 18px; font-weight: 600; margin-top: 4px; }
.state.on { color: var(--brand-d); }
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.pill.ok { background: var(--brand-l); color: var(--brand-d); }
.pill.warn { background: #fff3e0; color: var(--amber); }
.pill.bad { background: #ffebee; color: var(--red); }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.list li:last-child { border-bottom: 0; }
.users { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.users button {
  padding: 14px 8px; font-size: 17px; border-radius: 12px; border: 2px solid var(--line);
  background: #fff; color: inherit;
}
.users button.sel { border-color: var(--brand); background: var(--brand-l); font-weight: 700; }
.crew { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.crew label { margin: 0; font-weight: 500; display: flex; gap: 8px; align-items: center; padding: 9px; border: 1px solid var(--line); border-radius: 10px; }
.crew input { width: 22px; height: 22px; flex: none; }
.att { margin-top: 8px; }
.att div { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; font-size: 15px; gap: 8px; }
#nav {
  position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--line);
  display: flex; z-index: 5; padding-bottom: env(safe-area-inset-bottom);
}
#nav:empty { display: none; }
#nav button { flex: 1; border: 0; background: none; padding: 10px 4px 12px; font-size: 14px; color: var(--muted); }
#nav button .ic { display: block; font-size: 24px; line-height: 1.1; }
#nav button.sel { color: var(--brand-d); font-weight: 700; }
#toast {
  position: fixed; bottom: 96px; left: 50%; transform: translateX(-50%); background: #1c2530; color: #fff;
  padding: 12px 18px; border-radius: 12px; font-size: 16px; opacity: 0; pointer-events: none;
  transition: opacity .25s; z-index: 20; max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; }
.tabs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; margin-bottom: 12px; }
.tabs button { padding: 9px 4px; border-radius: 99px; border: 1px solid var(--line); background: #fff; font-size: 15px; color: inherit; }
.tabs button.sel { background: var(--brand); color: #fff; border-color: var(--brand); }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; margin-bottom: 12px; }
.filters > div { min-width: 0; }
.filters .f-user, .filters .f-btns { grid-column: 1 / -1; }
.filters .f-btns { display: flex; gap: 10px; }
.filters .f-btns .btn { flex: 1; padding: 12px; font-size: 16px; }
.filters label { margin-top: 0; }
.filters input[type=date] { padding: 12px 8px; font-size: 16px; }
@media (min-width: 800px) {
  .filters { grid-template-columns: 1fr 1fr 1fr auto; }
  .filters .f-user, .filters .f-btns { grid-column: auto; }
}
.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 8px 9px; border-bottom: 1px solid var(--line); text-align: start; white-space: nowrap; }
th { background: var(--brand-l); position: sticky; top: 0; }
td.wrap { white-space: normal; min-width: 160px; }
td input, td select { padding: 7px; font-size: 14px; min-width: 80px; }
a { color: var(--brand-d); }
.consent p { line-height: 1.55; }
/* install screen: covers the page but leaves the header, so the language can still be changed */
#install { position: fixed; inset: 52px 0 0 0; background: var(--bg); z-index: 10; padding: 20px 16px; overflow-y: auto; }
#install[hidden] { display: none; }
#install .card { max-width: 440px; margin: 0 auto; text-align: center; padding: 24px 18px; }
#install img { border-radius: 20px; }
#install h2 { font-size: 22px; margin: 14px 0 8px; }
#install p { line-height: 1.6; font-size: 17px; }
#top { min-height: 52px; }
tr.pending { background: #fff8ec; }
/* login screen: a photo from the orchard behind the form */
body.bg::before { content: ''; position: fixed; inset: 0; z-index: -1;
  background: linear-gradient(rgba(1,58,105,.3), rgba(1,58,105,0) 30%, rgba(0,0,0,.12)), url(login.jpg) center / cover no-repeat; }
body.bg .card { background: rgba(255,255,255,.9); }
.hero { color: #fff; font-size: 26px; font-weight: 800; text-align: center; padding: 26px 8px 22px; text-shadow: 0 2px 8px rgba(0,0,0,.55); }
.greet { font-size: 20px; font-weight: 700; color: var(--brand-d); }
/* dashboard */
.dnav { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.dnav input { flex: 1; min-width: 0; text-align: center; font-weight: 700; padding: 11px 6px; }
.dnav button { flex: none; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: #fff; font-size: 16px; color: var(--brand-d); }
.dnav button.sel { background: var(--brand); color: #fff; border-color: var(--brand); }
.dnav button:disabled { opacity: .35; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
@media (min-width: 800px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: var(--card); border-radius: 14px; padding: 14px; box-shadow: 0 1px 4px rgba(0,0,0,.07); border-inline-start: 5px solid var(--line); }
.kpi b { display: block; font-size: 32px; line-height: 1.1; color: var(--brand-d); }
.kpi span { font-size: 15px; font-weight: 600; }
.kpi small { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }
.kpi.on { border-color: #2e9e5b; } .kpi.on b { color: #1f7a43; }
.kpi.warn { border-color: var(--amber); } .kpi.warn small { color: var(--amber); font-weight: 600; }
.pill:not(.ok):not(.warn):not(.bad) { background: #eceff3; color: var(--muted); }
button.pill { border: 0; font-family: inherit; padding: 6px 12px; font-size: 14px; }
.plist li { align-items: flex-start; }
.plist .muted { line-height: 1.9; }
.hrs { font-size: 18px; white-space: nowrap; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; height: 150px; }
.week button { border: 0; background: none; padding: 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 2px; font-size: 12px; color: var(--muted); }
.week .n { font-weight: 700; color: var(--text); font-size: 13px; }
.week .bar { width: 70%; background: #a9c8e3; border-radius: 6px 6px 0 0; min-height: 3px; }
.week .sel .bar { background: var(--brand); }
.week .sel { color: var(--text); font-weight: 700; }
details { margin-top: 12px; } summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.dfoot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; font-size: 14px; }
@media (max-width: 700px) {
  #top { padding: 10px 12px; }
  #top .title { font-size: 16px; }
  #top button, #top select { padding: 7px 8px; font-size: 14px; }
  .tabs button { font-size: 14px; border-radius: 12px; }
  .scroll { overflow: visible; }
  table, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tbody tr { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; margin-bottom: 10px; }
  td { display: flex; justify-content: space-between; align-items: center; gap: 12px; border: 0; padding: 5px 0; white-space: normal; text-align: end; font-size: 15px; }
  td::before { content: attr(data-label); font-weight: 600; color: var(--muted); flex: none; text-align: start; }
  td:empty { display: none; }
  td.wrap { min-width: 0; }
  td input:not([type=checkbox]), td select { width: 58% !important; min-width: 0; font-size: 16px; padding: 9px; }
}
