:root {
  --blue: #1f3b8b;
  --green: #1e8449;
  --red: #c0392b;
  --ink: #1a1a1a;
  --muted: #666;
  --line: #dcdcdc;
  --bg: #f4f6fb;
  --card: #ffffff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Header */
#topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 14px 10px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
#logo { width: 40px; height: 40px; border-radius: 8px; }
.head-text { flex: 1; min-width: 0; }
#brand { font-weight: 700; color: var(--blue); font-size: 17px; }
#status { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link { background: none; border: none; color: var(--blue); font-size: 14px; padding: 6px; }

main { flex: 1; padding: 14px; display: flex; flex-direction: column; gap: 14px; }
section { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
#recentSection { flex: 1; display: flex; flex-direction: column; min-height: 160px; }

.muted { color: var(--muted); font-size: 14px; margin: 0 0 12px; line-height: 1.4; }
.help { color: var(--muted); font-size: 12px; margin: 2px 0 12px; line-height: 1.35; }

/* Buttons — big tap targets */
button {
  font-size: 15px;
  padding: 11px 14px;
  border: 1px solid var(--blue);
  border-radius: 10px;
  background: #fff;
  color: var(--blue);
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.4; }
button.primary { background: var(--blue); color: #fff; }
button.big { width: 100%; padding: 15px; font-size: 16px; margin-top: 4px; }
button.block { display: block; width: 100%; margin-top: 6px; text-align: left; }
button.ghost { border-color: var(--line); color: var(--muted); }

/* Active view */
.cur-label { font-size: 17px; font-weight: 700; }
.cur-timer { color: var(--green); font-variant-numeric: tabular-nums; margin-top: 4px; font-size: 15px; }
.day-timer { color: var(--muted); font-variant-numeric: tabular-nums; margin: 2px 0 10px; font-size: 13px; }

.fld-label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
textarea, select, input {
  width: 100%;
  font-size: 16px; /* 16px avoids iOS zoom-on-focus */
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-family: inherit;
}
textarea { resize: vertical; }

.quick { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.quick-label { font-size: 13px; color: var(--muted); }
.quick button { padding: 9px 12px; font-size: 14px; }

.mainbtns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.mainbtns #next { flex: 1 1 100%; }
.mainbtns #clockout, .mainbtns #edit { flex: 1; }

/* Recent list */
.section-title { font-size: 14px; margin: 0 0 8px; color: var(--ink); }
.recent-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.recent-list li { display: flex; align-items: center; gap: 8px; }
.recent-list li.muted { display: block; }
button.resume { padding: 7px 10px; font-size: 13px; white-space: nowrap; }
.entry-text { font-size: 13px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Segmented control */
.segmented { display: flex; flex-wrap: wrap; gap: 6px; }
.segmented button { flex: 1 1 auto; padding: 9px 10px; font-size: 13px; border-color: var(--line); color: var(--muted); }
.segmented button.sel { background: var(--blue); color: #fff; border-color: var(--blue); }

.row { display: flex; gap: 8px; }
.row select { flex: 1; }
.mini { width: 44px; padding: 10px 0; text-align: center; }
.mini-wide { white-space: nowrap; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: flex-end; justify-content: center; z-index: 50;
}
.sheet {
  background: var(--card); width: 100%; max-width: 560px;
  border-radius: 16px 16px 0 0; padding: 16px;
  padding-bottom: calc(env(safe-area-inset-bottom) + 16px);
  max-height: 90vh; overflow-y: auto;
  animation: slideUp 0.18s ease-out;
}
@keyframes slideUp { from { transform: translateY(30px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.sheet h2 { font-size: 18px; margin: 0 0 8px; color: var(--blue); }
.sheet-btns { display: flex; gap: 10px; margin-top: 16px; }
.sheet-btns button { flex: 1; }

/* Spinner */
.spinner {
  width: 28px; height: 28px; margin: 8px auto 10px;
  border: 3px solid var(--line); border-top-color: var(--blue);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 80px);
  background: #222; color: #fff; padding: 11px 16px; border-radius: 10px;
  font-size: 14px; max-width: 90%; opacity: 0; transition: transform 0.25s, opacity 0.25s; z-index: 60;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.error { background: var(--red); }

[hidden] { display: none !important; }

/* -- Team Directory sheet ---------------------------------------------- */
.dir-sheet { max-height: 88vh; display: flex; flex-direction: column; }
.dir-search {
  width: 100%; padding: 10px 12px; margin: 8px 0;
  border: 1px solid #d7dbe6; border-radius: 10px; font-size: 16px;
}
.dir-list { overflow-y: auto; flex: 1; min-height: 120px; }
.dir-office {
  margin: 12px 0 4px; font-size: 13px; color: #5a6272;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.dir-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 2px; border-bottom: 1px solid #eef0f5;
}
.dir-avatar {
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  color: #fff; font-weight: 700; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  background-size: cover; background-position: center;
}
.dir-info { flex: 1; min-width: 0; }
.dir-name { font-weight: 700; }
.dir-sub {
  color: #5a6272; font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dir-actions { display: flex; gap: 14px; font-size: 20px; }
.dir-actions a { text-decoration: none; }

.dir-controls { display: flex; gap: 8px; margin: 8px 0; }
.dir-view {
  flex: none; padding: 10px 8px; border: 1px solid #d7dbe6;
  border-radius: 10px; font-size: 15px; background: #fff;
}
.dir-controls .dir-search { flex: 1; margin: 0; }
.dir-badge { color: #5a6272; font-size: 13px; align-self: center; }
.dir-org-child { border-left: 2px solid #d7dbe6; }

.trip-odo {
  font-size: 44px; font-weight: 800; text-align: center; margin: 12px 0;
  font-variant-numeric: tabular-nums;
}
