:root {
  --navy: #0e2a4c;
  --navy-deep: #081a31;
  --navy-soft: #1a3d66;
  --gold: #e9a92a;
  --gold-deep: #c98a12;
  --gold-soft: #fbe8bd;
  --bg: #f3f5f9;
  --card: #ffffff;
  --ink: #122034;
  --muted: #65748b;
  --line: #e2e7ef;
  --green: #1f9d55;
  --green-soft: #dcf5e6;
  --red: #d64545;
  --red-soft: #fde3e3;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(14, 42, 76, .10);
  --font-display: 'Archivo', 'Inter', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
h1, h2, h3 { font-family: var(--font-display); margin: 0; letter-spacing: -.01em; }

/* ---------- Layout ---------- */
.screen { min-height: 100dvh; display: flex; flex-direction: column; }
.hero {
  background: linear-gradient(160deg, var(--navy-deep) 0%, var(--navy) 55%, var(--navy-soft) 100%);
  color: #fff;
  padding: calc(28px + env(safe-area-inset-top)) 20px 28px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; inset: auto -40% -60% -40%; height: 70%;
  background: radial-gradient(ellipse at center, rgba(233,169,42,.22), transparent 60%);
  pointer-events: none;
}
.hero img { width: 84px; height: auto; filter: drop-shadow(0 8px 18px rgba(0,0,0,.35)); }
.hero h1 { font-size: 26px; font-weight: 900; text-transform: uppercase; letter-spacing: .04em; margin-top: 10px; }
.hero .sub { color: var(--gold); font-weight: 700; font-size: 12px; letter-spacing: .22em; text-transform: uppercase; margin-top: 4px; }
.hero .sub::before, .hero .sub::after { content: " — "; color: var(--gold); }
.hero.small { padding: calc(14px + env(safe-area-inset-top)) 20px 16px; text-align: left; display: flex; align-items: center; gap: 14px; }
.hero.small img { width: 46px; }
.hero.small h1 { font-size: 17px; margin: 0; }
.hero.small .sub { font-size: 10px; margin: 2px 0 0; }
.hero.small .sub::before, .hero.small .sub::after { content: none; }
.hero.small .spacer { flex: 1; }
.hero .clock { font-family: var(--font-display); font-weight: 700; font-size: 15px; opacity: .9; text-align: right; }
.hero .clock small { display: block; font-size: 11px; opacity: .7; font-weight: 500; }

.content { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 20px 16px calc(32px + env(safe-area-inset-bottom)); }
.content.wide { max-width: 1040px; }
.section-title { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; margin: 22px 0 10px; display: flex; align-items: center; justify-content: space-between; }
.section-title:first-child { margin-top: 4px; }

/* ---------- Cards & buttons ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 12px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 18px; border-radius: 14px; font-weight: 700; font-size: 15px;
  background: var(--navy); color: #fff; transition: transform .08s, filter .15s; white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.gold { background: var(--gold); color: var(--navy-deep); }
.btn.green { background: var(--green); }
.btn.red { background: var(--red); }
.btn.ghost { background: transparent; color: var(--navy); border: 2px solid var(--line); }
.btn.ghost:hover { background: #fff; border-color: var(--navy); }
.btn.sm { padding: 8px 12px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn.big { padding: 20px; font-size: 20px; border-radius: 18px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

/* ---------- Name picker ---------- */
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.person {
  background: var(--card); border-radius: var(--radius); padding: 18px 12px; text-align: center;
  box-shadow: var(--shadow); border: 2px solid transparent; transition: transform .1s, border-color .15s;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.person:hover { transform: translateY(-2px); border-color: var(--gold); }
.person:active { transform: scale(.97); }
.avatar {
  width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 900; font-size: 20px; color: #fff;
  background: linear-gradient(140deg, var(--navy-soft), var(--navy-deep));
}
.avatar.manager { background: linear-gradient(140deg, var(--gold), var(--gold-deep)); color: var(--navy-deep); }
.avatar.sm { width: 38px; height: 38px; font-size: 14px; }
.person .name { font-weight: 700; font-size: 15px; }
.person .meta { font-size: 12px; color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--line); color: var(--muted); }
.pill.on { background: var(--green-soft); color: var(--green); }
.pill.on::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--green); animation: pulse 1.6s infinite; }
.pill.gold { background: var(--gold-soft); color: var(--gold-deep); }
.pill.new { background: #e8f0ff; color: #2b5fd9; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .35 } }

/* ---------- PIN pad ---------- */
.pin-wrap { max-width: 360px; margin: 0 auto; text-align: center; }
.pin-wrap .who { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 8px; }
.pin-wrap h2 { font-size: 22px; }
.pin-wrap p { color: var(--muted); margin: 6px 0 18px; }
.dots { display: flex; justify-content: center; gap: 16px; margin: 10px 0 24px; }
.dots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--navy); transition: background .1s; }
.dots span.on { background: var(--navy); }
.dots.shake { animation: shake .4s; }
.dots.shake span { border-color: var(--red); background: var(--red); }
@keyframes shake { 0%,100% { transform: translateX(0) } 20%,60% { transform: translateX(-8px) } 40%,80% { transform: translateX(8px) } }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.pad button {
  height: 68px; border-radius: 18px; background: var(--card); box-shadow: var(--shadow);
  font-family: var(--font-display); font-size: 26px; font-weight: 700; color: var(--navy);
  transition: transform .06s, background .1s;
}
.pad button:active { transform: scale(.94); background: var(--gold-soft); }
.pad button.fn { font-size: 15px; font-family: var(--font-body); color: var(--muted); background: transparent; box-shadow: none; }

/* ---------- Employee dashboard ---------- */
.status {
  border-radius: var(--radius); padding: 22px; color: #fff; text-align: center;
  background: linear-gradient(150deg, var(--navy), var(--navy-deep)); box-shadow: var(--shadow);
}
.status.on { background: linear-gradient(150deg, #1f9d55, #136b39); }
.status .label { font-size: 12px; text-transform: uppercase; letter-spacing: .18em; opacity: .8; font-weight: 700; }
.status .big { font-family: var(--font-display); font-size: 44px; font-weight: 900; margin: 6px 0; font-variant-numeric: tabular-nums; }
.status .where { font-size: 15px; opacity: .9; }
.status .btn { margin-top: 16px; }
.sites { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.site-btn {
  text-align: left; background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
  border: 2px solid transparent; display: flex; flex-direction: column; gap: 4px; transition: transform .1s, border-color .15s;
}
.site-btn:hover { border-color: var(--gold); transform: translateY(-2px); }
.site-btn .n { font-weight: 700; font-size: 16px; font-family: var(--font-display); }
.site-btn .a { font-size: 12px; color: var(--muted); }
.site-btn .go { color: var(--green); font-weight: 700; font-size: 13px; margin-top: 6px; }
.task { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.task:first-child { border-top: 0; padding-top: 0; }
.task:last-child { padding-bottom: 0; }
.check { width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--line); flex: none; display: grid; place-items: center; color: #fff; font-size: 15px; transition: background .1s; }
.task.done .check { background: var(--green); border-color: var(--green); }
.task.done .t { text-decoration: line-through; color: var(--muted); }
.task .t { font-weight: 600; }
.task .s { font-size: 12px; color: var(--muted); }
.entry { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.entry:first-child { border-top: 0; padding-top: 0; }
.entry .d { font-weight: 600; }
.entry .m { color: var(--muted); font-size: 12px; }
.entry .h { font-weight: 700; font-family: var(--font-display); font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { color: var(--muted); text-align: center; padding: 18px; font-size: 14px; }

/* ---------- Manager ---------- */
.tabs { display: flex; gap: 6px; background: #e7ebf2; padding: 5px; border-radius: 14px; margin-bottom: 18px; overflow-x: auto; }
.tabs button { flex: 1; padding: 10px 12px; border-radius: 10px; font-weight: 700; font-size: 14px; color: var(--muted); white-space: nowrap; }
.tabs button.active { background: #fff; color: var(--navy); box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat .v { font-family: var(--font-display); font-size: 30px; font-weight: 900; color: var(--navy); }
.stat .l { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.list-item:first-child { border-top: 0; padding-top: 0; }
.list-item:last-child { padding-bottom: 0; }
.list-item .n { font-weight: 700; }
.list-item .m { font-size: 12px; color: var(--muted); }
.list-item.inactive { opacity: .5; }
.timer { font-family: var(--font-display); font-weight: 700; font-variant-numeric: tabular-nums; color: var(--green); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.input, select.input, textarea.input {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--line); background: #fff; font-size: 15px; outline: none;
}
.input:focus { border-color: var(--navy); }
textarea.input { resize: vertical; min-height: 70px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 480px) { .form-row { grid-template-columns: 1fr; } }
.filters { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 640px) { .filters { grid-template-columns: 1fr 1fr; } }
.filters .field { margin: 0; }
.hint { font-size: 12px; color: var(--muted); }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); padding: 8px 10px; border-bottom: 2px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
tr.total td { font-weight: 700; background: var(--gold-soft); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.link { color: var(--navy); font-weight: 600; text-decoration: underline; padding: 0; }
.link.danger { color: var(--red); }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(8,26,49,.55); display: grid; place-items: end center; z-index: 50; padding: 0; animation: fade .15s; }
@media (min-width: 600px) { .modal-bg { place-items: center; padding: 20px; } }
.modal { background: var(--card); width: 100%; max-width: 480px; border-radius: 22px 22px 0 0; padding: 22px 20px calc(22px + env(safe-area-inset-bottom)); max-height: 92dvh; overflow-y: auto; animation: up .2s; }
@media (min-width: 600px) { .modal { border-radius: 22px; } }
.modal h2 { font-size: 20px; margin-bottom: 16px; }
@keyframes fade { from { opacity: 0 } }
@keyframes up { from { transform: translateY(30px); opacity: 0 } }

/* ---------- Toast ---------- */
#toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: var(--navy-deep); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 600; font-size: 14px; opacity: 0; transition: .2s; pointer-events: none; z-index: 100; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--red); }
#toast.ok { background: var(--green); }
