:root {
  --ink: #111110;
  --paper: #f6f5f2;
  --card: #ffffff;
  --line: #e4e2dc;
  --mut: #77756e;
  --green: #1d7a4f;
  --green-bg: #e3f2ea;
  --amber: #a2660a;
  --amber-bg: #faeeda;
  --red: #b3261e;
  --red-bg: #fceceb;
  --blue: #1f5fa8;
  --blue-bg: #e8f0fa;
  --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
}
.hidden { display: none !important; }

/* ---------- wordmark ---------- */
.wordmark {
  font-family: 'Archivo Black', sans-serif;
  font-size: 40px;
  letter-spacing: -1px;
  color: var(--ink);
}
.wordmark span { color: var(--mut); }
.wordmark.sm { font-size: 28px; }
.wordmark.xs { font-size: 18px; }

/* ---------- login / pending ---------- */
.view { min-height: 100dvh; }
#view-login, #view-register, #view-pending {
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
#view-login.hidden, #view-register.hidden, #view-pending.hidden { display: none; }
.login-box {
  width: 100%; max-width: 380px; background: var(--card);
  border: 1px solid var(--line); border-radius: 16px;
  padding: 36px 28px; text-align: center;
  display: flex; flex-direction: column; gap: 16px;
}
.login-sub { color: var(--mut); font-size: 15px; }
.pending-icon { font-size: 42px; }

/* ---------- buttons ---------- */
.btn {
  font-family: inherit; font-size: 15px; font-weight: 600;
  border: none; border-radius: var(--radius); padding: 12px 18px;
  cursor: pointer; transition: opacity .15s;
}
.btn:active { opacity: .75; }
.btn-lg { padding: 15px 20px; font-size: 16px; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-dark { background: var(--ink); color: #fff; }
.btn-green { background: var(--green); color: #fff; }
.btn-red { background: var(--red); color: #fff; }
.btn-ghost { background: transparent; color: var(--mut); }
.btn-line { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.btn:disabled { opacity: .4; cursor: default; }

/* ---------- forms ---------- */
.field { text-align: left; display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--mut); }
input, select, textarea {
  font-family: inherit; font-size: 15px; color: var(--ink);
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 12px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--ink); outline-offset: -1px; }
.hint { font-size: 13px; color: var(--mut); }
.error { font-size: 13px; color: var(--red); }

/* ---------- app shell ---------- */
#view-app { display: flex; flex-direction: column; min-height: 100dvh; }
#view-app.hidden { display: none; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.topbar-right { display: flex; align-items: center; gap: 8px; }
.chip {
  font-size: 12px; font-weight: 600; background: var(--paper);
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px;
  max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.branchbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px; background: var(--card); border-bottom: 1px solid var(--line);
  font-size: 13px; font-weight: 600; color: var(--mut);
}
.branchbar select { width: auto; padding: 7px 10px; font-size: 14px; }

main { flex: 1; padding: 18px; padding-bottom: 90px; max-width: 720px; width: 100%; margin: 0 auto; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); z-index: 10;
}
.tab {
  flex: 1; text-align: center; padding: 12px 4px 10px;
  font-size: 12px; font-weight: 600; color: var(--mut);
  background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; gap: 3px; align-items: center;
}
.tab .ico { font-size: 20px; line-height: 1; }
.tab.active { color: var(--ink); }
.tab .badge {
  position: absolute; transform: translate(14px, -4px);
  background: var(--red); color: #fff; font-size: 10px; font-weight: 700;
  border-radius: 999px; min-width: 16px; height: 16px; line-height: 16px;
}

/* ---------- content blocks ---------- */
.page-title { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.page-sub { font-size: 13px; color: var(--mut); margin-bottom: 18px; }
.section-title { font-size: 14px; font-weight: 700; color: var(--mut); margin: 22px 0 10px; text-transform: uppercase; letter-spacing: .04em; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
}
.card h4 { font-size: 16px; font-weight: 600; }
.card .meta { font-size: 13px; color: var(--mut); margin-top: 2px; }
.card-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

.empty { text-align: center; color: var(--mut); padding: 40px 20px; font-size: 14px; }

/* ---------- task states ---------- */
.task { border-left: 4px solid var(--line); }
.task.s-pending { border-left-color: var(--blue); }
.task.s-open { border-left-color: var(--amber); }
.task.s-done { border-left-color: var(--green); background: var(--green-bg); }
.task.s-late { border-left-color: var(--amber); background: var(--amber-bg); }
.task.s-missed { border-left-color: var(--red); background: var(--red-bg); }
.pill {
  display: inline-block; font-size: 11px; font-weight: 700;
  border-radius: 999px; padding: 3px 9px; text-transform: uppercase; letter-spacing: .03em;
}
.pill.p-pending { background: var(--blue-bg); color: var(--blue); }
.pill.p-open { background: var(--amber-bg); color: var(--amber); }
.pill.p-done { background: var(--green-bg); color: var(--green); }
.pill.p-late { background: var(--amber-bg); color: var(--amber); }
.pill.p-missed { background: var(--red-bg); color: var(--red); }
.pill.p-mult { background: var(--paper); color: var(--mut); border: 1px solid var(--line); }
.task-time { font-family: 'Inter'; font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px; }
.task-photo { width: 54px; height: 54px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); cursor: pointer; }

/* ---------- modal ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(17,17,16,.5);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
.modal.hidden { display: none; }
.modal-box {
  background: var(--card); border-radius: 16px; padding: 24px;
  width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 14px;
}
.modal-actions { display: flex; flex-direction: column; gap: 8px; }
.photo-preview { width: 100%; border-radius: 10px; border: 1px solid var(--line); }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; font-size: 14px; font-weight: 600;
  padding: 11px 18px; border-radius: 999px; z-index: 60;
  max-width: 90vw; text-align: center;
}

/* ---------- tables (admin lists) ---------- */
.list-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.list-row:last-child { border-bottom: none; }
.list-main { min-width: 0; }
.list-main .t { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-main .s { font-size: 12px; color: var(--mut); }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.inline-form .field { flex: 1; min-width: 120px; }

@media (max-width: 420px) {
  main { padding: 14px; padding-bottom: 90px; }
}
