* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --blue: #2e6bff;
  --blue-dark: #1d4fd7;
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1a2233;
  --muted: #6b7590;
  --border: #e3e8f2;
  --green: #17b26a;
  --red: #e5484d;
  --amber: #f59e0b;
  --radius: 14px;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea {
  font: inherit; width: 100%; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 10px; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); border-color: transparent; }
a { color: var(--blue); }

.screen { max-width: 640px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }

/* ---- login ---- */
.login { justify-content: center; padding: 24px; gap: 24px; }
.logo { text-align: center; }
.logo h1 { font-size: 32px; letter-spacing: -0.5px; }
.logo h1 span { color: var(--blue); }
.logo p { color: var(--muted); margin-top: 4px; }
.roster { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.roster button {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 12px; display: flex; flex-direction: column; align-items: center; gap: 10px;
  transition: transform .1s;
}
.roster button:active { transform: scale(.97); }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; color: #fff; font-weight: 700;
  display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0;
}
.roster .role { font-size: 12px; color: var(--muted); }
.pinpad { background: var(--card); border-radius: var(--radius); padding: 24px; text-align: center; }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 18px 0 24px; }
.pin-dots span { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border); }
.pin-dots span.filled { background: var(--blue); border-color: var(--blue); }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 260px; margin: 0 auto; }
.pad button { background: var(--bg); border-radius: 12px; padding: 16px 0; font-size: 20px; font-weight: 600; }
.pad button:active { background: var(--border); }
.error { color: var(--red); font-size: 14px; min-height: 20px; margin-top: 10px; }
.link { color: var(--blue); font-weight: 600; }

/* ---- app shell ---- */
header {
  background: var(--card); padding: 14px 18px; display: flex; align-items: center;
  justify-content: space-between; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
header h2 { font-size: 18px; }
header .who { display: flex; align-items: center; gap: 10px; font-size: 14px; }
main { flex: 1; padding: 16px 16px 96px; }
nav {
  position: fixed; bottom: 0; left: 0; right: 0; background: var(--card);
  border-top: 1px solid var(--border); display: flex; justify-content: space-around;
  padding: 8px 0 max(8px, env(safe-area-inset-bottom)); z-index: 10;
}
nav button {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; color: var(--muted); padding: 4px 10px; border-radius: 10px;
}
nav button.active { color: var(--blue); font-weight: 600; }
nav button .ico { font-size: 20px; position: relative; }
.badge {
  position: absolute; top: -4px; right: -10px; background: var(--red); color: #fff;
  font-size: 10px; font-weight: 700; min-width: 16px; height: 16px; border-radius: 99px;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}
.badge.inline { position: static; display: inline-flex; margin-top: 4px; }

/* ---- cards / shared ---- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.card h3 { font-size: 15px; margin-bottom: 10px; }
.row { display: flex; gap: 10px; align-items: flex-start; }
.row > * { flex: 1; }
.btn {
  background: var(--blue); color: #fff; font-weight: 600; border-radius: 10px;
  padding: 11px 16px; text-align: center; width: 100%;
}
.btn:active { background: var(--blue-dark); }
.btn:disabled { opacity: .6; }
.btn.secondary { background: var(--bg); color: var(--text); }
.btn.danger { background: var(--red); }
.btn.green { background: var(--green); }
.btn.small { width: auto; padding: 7px 12px; font-size: 13px; }
.muted { color: var(--muted); font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 32px 0; }
.section-title { display: flex; justify-content: space-between; align-items: center; margin: 18px 0 10px; }
.section-title h3 { font-size: 16px; }
.chip { font-size: 12px; padding: 3px 10px; border-radius: 99px; background: var(--bg); color: var(--muted); }
.title { font-weight: 600; font-size: 14px; }
.meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
form .field { margin-bottom: 10px; }
form label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
label.check input { width: 20px; height: 20px; accent-color: var(--green); }
.warn-box {
  background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412;
  padding: 10px 12px; border-radius: 10px; font-size: 13px; margin-top: 10px;
}
.conflict-warn {
  background: #fff7ed; border: 1px solid #fdba74; color: #9a3412;
  padding: 11px 13px; border-radius: 10px; font-size: 13.5px; line-height: 1.4; text-align: left;
}
.nextday { font-size: 11px; color: var(--amber); font-weight: 700; }

/* ---- toast ---- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 100px;
  background: var(--text); color: #fff; padding: 11px 18px; border-radius: 99px;
  font-size: 14px; font-weight: 500; z-index: 100; max-width: 90vw; text-align: center;
  animation: pop .2s ease-out;
}
.toast.err { background: var(--red); }
.toast.warn { background: var(--amber); }
@keyframes pop { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ---- schedule ---- */
.week-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.week-nav strong { font-size: 15px; }
.week-nav button { font-size: 18px; padding: 6px 14px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; }
.day-group { margin-bottom: 14px; }
.day-group h4 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 6px; }
.day-group h4.today { color: var(--blue); }
.shift {
  background: var(--card); border: 1px solid var(--border); border-left: 4px solid var(--blue);
  border-radius: 10px; padding: 10px 12px; margin-bottom: 6px;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.shift.open { background: #fffbeb; }
.shift .t { font-weight: 600; font-size: 14px; }
.shift .s { font-size: 13px; color: var(--muted); }
.nextday { font-size: 11px; font-weight: 700; color: #7c3aed; background: #f3e8ff; padding: 1px 6px; border-radius: 6px; margin-left: 2px; white-space: nowrap; }
.shift-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }

/* ---- time clock ---- */
.clock-face { text-align: center; padding: 28px 16px; }
.clock-face .big { font-size: 44px; font-weight: 700; font-variant-numeric: tabular-nums; }
.clock-face .status { margin: 8px 0 12px; font-size: 14px; }
.status .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.geo-note { font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.timesheet-entry { display: flex; justify-content: space-between; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.timesheet-entry:last-child { border-bottom: none; }
.flag { color: var(--amber); font-size: 12px; }

/* ---- tasks ---- */
.task { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--border); }
.task:last-child { border-bottom: none; }
.task input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--green); flex-shrink: 0; margin-top: 1px; }
.task.done .title { text-decoration: line-through; color: var(--muted); }

/* ---- feed ---- */
.post { margin-bottom: 12px; }
.post .head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.post .head .avatar { width: 34px; height: 34px; font-size: 14px; }
.post .name { font-weight: 600; font-size: 14px; }
.post .time { font-size: 12px; color: var(--muted); }
.post .body { font-size: 14px; white-space: pre-wrap; }
.composer textarea { resize: none; min-height: 70px; margin-bottom: 8px; }

/* ---- more menu ---- */
.menu { padding: 4px 0; }
.menu-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 14px 16px; border-bottom: 1px solid var(--border); text-align: left;
}
.menu-item:last-child { border-bottom: none; }
.menu-item:active { background: var(--bg); }
.mi-ico { font-size: 20px; width: 26px; text-align: center; }
.mi-label { display: block; font-weight: 600; font-size: 14px; }
.mi-sub { display: block; font-size: 12px; color: var(--muted); margin-top: 1px; }

/* ---- chat ---- */
.thread-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.thread { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.thread:last-child { border-bottom: none; }
.thread .name { font-weight: 600; font-size: 14px; }
.thread .preview { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread .time { font-size: 11px; color: var(--muted); }
.msgs { display: flex; flex-direction: column; gap: 10px; padding-bottom: 12px; }
.msg { max-width: 78%; align-self: flex-start; }
.msg.mine { align-self: flex-end; }
.msg .bubble {
  background: var(--card); border: 1px solid var(--border); padding: 9px 13px;
  border-radius: 16px 16px 16px 4px; font-size: 14px; white-space: pre-wrap; word-break: break-word;
}
.msg.mine .bubble { background: var(--blue); color: #fff; border-color: var(--blue); border-radius: 16px 16px 4px 16px; }
.msg .time { font-size: 11px; color: var(--muted); margin-top: 3px; padding: 0 6px; }
.msg.mine .time { text-align: right; }
.dm-composer {
  position: fixed; bottom: 74px; left: 0; right: 0; max-width: 640px; margin: 0 auto;
  background: var(--card); border-top: 1px solid var(--border);
  padding: 10px 16px; display: flex; gap: 8px; align-items: center;
}
.dm-composer input { flex: 1; }

/* ---- availability ---- */
.avail-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.avail-row:last-child { border-bottom: none; }
.avail-btns { display: flex; gap: 6px; }
.pill {
  width: 38px; height: 38px; border-radius: 10px; background: var(--bg);
  border: 1px solid var(--border); font-size: 16px; opacity: .45;
}
.pill.on { opacity: 1; }
.pill.on.available { background: #dcfce7; border-color: var(--green); }
.pill.on.preferred { background: #fef3c7; border-color: var(--amber); }
.pill.on.unavailable { background: #fee2e2; border-color: var(--red); }
.pill.note-btn { opacity: 1; color: var(--muted); }
.pill.note-btn.has-note { background: #eef3ff; border-color: var(--blue); color: var(--blue); }

/* ---- swaps ---- */
.swap { display: flex; gap: 10px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.swap:last-child { border-bottom: none; }

/* ---- forms / documents ---- */
.doc-row { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.doc-row:last-child { border-bottom: none; }
.field-builder { display: flex; gap: 6px; margin-bottom: 8px; align-items: center; }
.field-builder input { flex: 2; }
.field-builder select { flex: 1; }

/* ---- admin ---- */
.emp-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.emp-row:last-child { border-bottom: none; }
.emp-row .n { flex: 1; font-weight: 600; font-size: 14px; }

/* ---- modal ---- */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: flex-end; justify-content: center; z-index: 50; }
.modal { background: var(--card); border-radius: 18px 18px 0 0; padding: 20px; width: 100%; max-width: 640px; max-height: 85vh; overflow-y: auto; }
.modal h3 { margin-bottom: 14px; }
@media (min-width: 640px) {
  .modal-bg { align-items: center; }
  .modal { border-radius: 18px; }
}
