:root {
  --brand: #1f5d3a;
  --brand-2: #2f8a55;
  --brand-soft: #e6f2ea;
  --ink: #1d2a22;
  --muted: #66756b;
  --line: #dde5df;
  --bg: #f5f7f2;
  --card: #ffffff;
  --red: #c0392b;
  --red-soft: #fdecea;
  --amber: #b7791f;
  --amber-soft: #fdf3e1;
  --blue: #2563a8;
  --blue-soft: #e8f0fa;
  --radius: 12px;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body { font-size: 15px; line-height: 1.45; padding-bottom: 76px; }
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 21px; margin: 0 0 14px; }
h2 { font-size: 16px; margin: 22px 0 10px; }
small, .muted { color: var(--muted); }
img { max-width: 100%; }

.top { background: var(--brand); color: #fff; position: sticky; top: 0; z-index: 1000; }
.top .bar { display: flex; align-items: center; gap: 16px; padding: 0 16px; height: 52px; max-width: 1280px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 8px; color: #fff; font-weight: 700; font-size: 16px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand .dot { width: 24px; height: 24px; border-radius: 7px; background: linear-gradient(135deg, #8fd19e, #2f8a55); display: inline-block; }
.nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.nav a { color: #d8eadf; padding: 6px 10px; border-radius: 8px; font-size: 14px; white-space: nowrap; }
.nav a:hover { background: #ffffff1a; text-decoration: none; }
.nav a.on { background: #ffffff; color: var(--brand); font-weight: 600; }
.badge { background: var(--red); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 6px; margin-left: 3px; font-weight: 700; }
.who { display: flex; align-items: center; gap: 10px; font-size: 13px; color: #d8eadf; margin-left: auto; }
.who a { color: #d8eadf; }
.who form { margin: 0; }
.who button { background: none; border: 1px solid #ffffff55; color: #fff; border-radius: 7px; padding: 4px 9px; cursor: pointer; font-size: 13px; }

.bottomnav { display: none; }
@media (max-width: 860px) {
  .nav, .who .name { display: none; }
  .bottomnav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--line); z-index: 1000; padding-bottom: env(safe-area-inset-bottom); }
  .bottomnav a { flex: 1; text-align: center; padding: 7px 2px 8px; font-size: 11px; color: var(--muted); position: relative; }
  .bottomnav a .ic { display: block; font-size: 20px; line-height: 1.25; }
  .bottomnav a.on { color: var(--brand); font-weight: 600; }
  .bottomnav a:hover { text-decoration: none; }
  .bottomnav .badge { position: absolute; top: 3px; right: 50%; margin-right: -22px; }
}

main { max-width: 1280px; margin: 0 auto; padding: 16px 16px 30px; }
main.narrow { max-width: 640px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.card h2:first-child { margin-top: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.two { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
@media (max-width: 860px) { .two { grid-template-columns: 1fr; } }

.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat b { display: block; font-size: 24px; line-height: 1.2; }
.stat span { color: var(--muted); font-size: 13px; }

label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 4px; color: #3b4a40; }
input, select, textarea { width: 100%; font: inherit; padding: 10px 11px; border: 1px solid #cfd9d2; border-radius: 9px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid #2f8a5540; border-color: var(--brand-2); }
textarea { min-height: 70px; }
input[type=checkbox] { width: auto; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.fields { display: grid; gap: 0 12px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }

.btn { display: inline-block; background: var(--brand-2); color: #fff; border: 0; border-radius: 9px; padding: 10px 16px; font: inherit; font-weight: 600; cursor: pointer; text-align: center; }
.btn:hover { background: var(--brand); text-decoration: none; }
.btn.light { background: var(--brand-soft); color: var(--brand); }
.btn.red { background: var(--red); }
.btn.grey { background: #e9ece9; color: var(--ink); }
.btn.small { padding: 5px 10px; font-size: 13px; font-weight: 600; }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: .6; cursor: wait; }
form.inline { display: inline; margin: 0; }

.error { background: var(--red-soft); color: var(--red); border-radius: 9px; padding: 10px 12px; margin: 10px 0; }
.ok { background: var(--brand-soft); color: var(--brand); border-radius: 9px; padding: 10px 12px; margin: 10px 0; }
.note { background: var(--amber-soft); color: #7a4f0d; border-radius: 9px; padding: 10px 12px; margin: 10px 0; font-size: 14px; }

table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { text-align: left; padding: 8px 9px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 14px; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #fafcfa; }
td.num, th.num { text-align: right; white-space: nowrap; }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.tablewrap table { border: 0; }

.pill { display: inline-block; border-radius: 20px; padding: 1px 9px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.duty { background: var(--brand-soft); color: var(--brand); }
.pill.done { background: var(--blue-soft); color: var(--blue); }
.pill.absent { background: var(--red-soft); color: var(--red); }
.pill.leave, .pill.pending { background: var(--amber-soft); color: var(--amber); }
.pill.off { background: #eef0ee; color: var(--muted); }
.pill.late { background: var(--red-soft); color: var(--red); }
.pill.approved, .pill.paid { background: var(--brand-soft); color: var(--brand); }
.pill.rejected, .pill.unpaid { background: #eef0ee; color: var(--muted); }

/* Duty screen */
.punch { text-align: center; padding: 22px 16px; }
.punch .big { display: block; width: 100%; max-width: 360px; margin: 10px auto 6px; padding: 22px 10px; font-size: 21px; border-radius: 16px; }
.punch .state { font-size: 15px; color: var(--muted); }
.track { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 13px; color: var(--muted); margin-top: 8px; }
.track .live { width: 10px; height: 10px; border-radius: 50%; background: #aab5ad; }
.track .live.on { background: #2fbf63; box-shadow: 0 0 0 0 #2fbf6380; animation: pulse 1.8s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 9px #2fbf6300; } 100% { box-shadow: 0 0 0 0 #2fbf6300; } }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions a { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 10px; text-align: center; color: var(--ink); font-weight: 600; }
.actions a .ic { display: block; font-size: 24px; }
.actions a:hover { text-decoration: none; border-color: var(--brand-2); }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }

/* Maps */
.map { height: 420px; border-radius: var(--radius); border: 1px solid var(--line); z-index: 1; }
.map.tall { height: 520px; }
@media (max-width: 860px) { .map, .map.tall { height: 330px; } }
.who-tag { background: #fff; border: 1px solid var(--brand); color: var(--brand); border-radius: 6px; padding: 1px 5px; font-size: 11px; font-weight: 700; white-space: nowrap; }

/* Calendar and register */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .h { font-size: 11px; color: var(--muted); text-align: center; }
.cal a, .cal span.blank { display: block; border-radius: 8px; padding: 5px 2px; text-align: center; font-size: 12px; min-height: 44px; border: 1px solid var(--line); background: #fff; color: var(--ink); }
.cal a b { display: block; font-size: 14px; }
.cal a.sel { outline: 2px solid var(--brand); }
.cal span.blank { border: 0; background: none; }
.c-P { background: #e3f4e8 !important; } .c-H { background: #fff1d6 !important; } .c-A { background: #fde3e0 !important; }
.c-L { background: #e4edfa !important; } .c-U { background: #ececec !important; } .c-W { background: #f2f2ee !important; color: #8a948d !important; }
.reg td, .reg th { padding: 4px 3px; text-align: center; font-size: 12px; min-width: 24px; }
.reg td:first-child, .reg th:first-child { text-align: left; min-width: 120px; position: sticky; left: 0; background: #fff; }
.legend span { display: inline-block; padding: 1px 7px; border-radius: 6px; margin: 2px 4px 2px 0; font-size: 12px; }
.thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }

.login { max-width: 380px; margin: 40px auto; }
.login .brand { color: var(--brand); justify-content: center; font-size: 21px; margin-bottom: 12px; }

@media print {
  .top, .bottomnav, .noprint { display: none !important; }
  body { padding: 0; background: #fff; }
  .card { border: 0; padding: 0; }
}
