/* ===== Neon-console inspired, mobile-first ===== */
:root {
  --bg: #0b0c0c;
  --surface: #161717;
  --surface-2: #0f1010;
  --surface-3: #1e1f1f;
  --border: #2a2b2b;
  --border-soft: #202121;
  --text: #f2f4f3;
  --text-muted: #9098958f;
  --muted: #8b918e;
  --dim: #6b706e;
  --green: #00e599;
  --green-soft: rgba(0, 229, 153, 0.13);
  --blue: #6ba5ff;
  --purple: #b98aff;
  --purple-soft: rgba(185, 138, 255, 0.16);
  --amber: #ffca57;
  --amber-soft: rgba(255, 202, 87, 0.15);
  --red: #ff6b6b;
  --red-soft: rgba(255, 107, 107, 0.14);
  --radius: 14px;
  --radius-sm: 10px;
  --appbar-h: 56px;
  --maxw: 720px;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
h1, h2 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
svg.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; }

/* ===== app bar ===== */
.appbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--appbar-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  padding-top: env(safe-area-inset-top);
  background: rgba(11, 12, 12, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-soft);
}
.appbar-title {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
  font-size: 1.02rem;
}
.logo-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--green-soft);
  color: var(--green);
}
.logo-mark svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; }
.logo-mark.lg { width: 38px; height: 38px; }
.logo-mark.lg svg { width: 22px; height: 22px; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.icon-btn:active { background: var(--surface-3); }
.icon-btn.ghost { border-color: transparent; background: transparent; }
.icon-btn.primary { border-color: transparent; background: var(--green); color: #06251b; }
.icon-btn.primary .ic { stroke-width: 2.4; }

/* ===== drawer ===== */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.55);
}
.drawer {
  position: fixed;
  z-index: 60;
  top: 0;
  left: 0;
  height: 100%;
  width: min(84vw, 320px);
  background: var(--surface-2);
  border-right: 1px solid var(--border);
  transform: translateX(-102%);
  transition: transform 0.24s cubic-bezier(0.2, 0.7, 0.2, 1);
  display: flex;
  flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 14px) 12px 16px;
  overflow-y: auto;
}
.drawer.open { transform: translateX(0); }
.drawer-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 6px 14px;
}
.drawer-title { font-weight: 600; }
.drawer-sub { font-size: 0.78rem; color: var(--muted); }
.drawer-head .icon-btn { margin-left: auto; width: 34px; height: 34px; }

.nav-group { padding: 6px 0; }
.nav-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--dim);
  padding: 8px 8px 6px;
  font-weight: 600;
}
.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 10px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
}
.nav-item .ic { width: 19px; height: 19px; }
.nav-item:active { background: var(--surface-3); }
.nav-item.active { background: var(--surface-3); color: var(--text); }
.nav-item.active .ic { color: var(--green); }

.drawer-promo {
  margin-top: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.promo-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.9rem;
}
.promo-title .ic { width: 16px; height: 16px; color: var(--amber); }
.drawer-promo p { margin: 8px 0 0; font-size: 0.8rem; color: var(--muted); }

/* ===== layout ===== */
main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 16px 14px 48px;
  display: block;
}
.view { display: flex; flex-direction: column; gap: 14px; }
.view[hidden] { display: none; }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; }
.view-head h1 { font-size: 1.6rem; }
.view-sub { margin: 3px 0 0; color: var(--muted); font-size: 0.86rem; }

/* ===== cards ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.card.info p { margin: 0 0 8px; font-size: 0.88rem; color: var(--muted); }
.card.info p:last-child { margin-bottom: 0; }
.card.info strong { color: var(--text); }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.card-head h2 { font-size: 1.02rem; }
.muted-tag {
  font-size: 0.72rem;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 999px;
}
.link-btn {
  background: none;
  border: none;
  color: var(--blue);
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  padding: 2px 4px;
}

/* ===== stats (single compact card, divided) ===== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.stat {
  padding: 12px 14px;
  border-left: 1px solid var(--border-soft);
  min-width: 0;
}
.stat:first-child { border-left: none; }
.stat-label {
  font-size: 0.72rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-label .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); flex: none; }
.stat-value {
  font-size: 1.2rem;
  font-weight: 650;
  margin-top: 4px;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.stat-foot {
  font-size: 0.68rem;
  color: var(--dim);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== form ===== */
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field:nth-child(4) { grid-column: 1 / -1; }
.field > span {
  font-size: 0.76rem;
  color: var(--muted);
  font-weight: 500;
}
.field > span em { color: var(--dim); font-style: normal; }
.field input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 11px 12px;
  font-size: 0.95rem;
  font-family: inherit;
  width: 100%;
  min-width: 0;
}
.field input::-webkit-calendar-picker-indicator { filter: invert(0.7); }
.field input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
}
.btn {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 11px 18px;
  font-size: 0.92rem;
  font-weight: 550;
  font-family: inherit;
  cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--green); color: #06251b; border-color: transparent; font-weight: 650; }
.btn.ghost { background: transparent; }

/* ===== auth screens ===== */
.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
}
.auth-screen[hidden] { display: none; }
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.auth-card .field { margin-bottom: 14px; }
.auth-card .field input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 11px 12px;
  font-size: 0.95rem;
  font-family: inherit;
  width: 100%;
}
.auth-card .field input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.btn.full { width: 100%; margin-top: 6px; }

/* app chrome hidden state */
body.locked .appbar,
body.locked main,
body.locked .drawer,
body.locked .scrim { display: none !important; }

/* ===== drawer footer ===== */
.drawer-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-soft);
}
.who { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.who-avatar {
  width: 34px; height: 34px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--purple-soft); color: var(--purple);
  font-weight: 700; text-transform: uppercase;
}
.who-meta { display: flex; flex-direction: column; min-width: 0; }
.who-name { font-weight: 600; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; }
.who-role { font-size: 0.72rem; color: var(--muted); text-transform: capitalize; }

/* ===== user management ===== */
.user-row { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--border-soft); }
.user-row:last-child { border-bottom: none; }
.user-av {
  width: 36px; height: 36px; flex: none; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; text-transform: uppercase;
  background: var(--surface-3); color: var(--muted);
}
.user-main { flex: 1; min-width: 0; }
.user-name { font-weight: 600; font-size: 0.92rem; }
.user-sub { font-size: 0.76rem; color: var(--dim); }
.role-badge { font-size: 0.68rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.role-admin { background: var(--purple-soft); color: var(--purple); }
.role-user { background: var(--surface-3); color: var(--muted); }
.user-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }

/* select styled like inputs */
select#new-role {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 11px 12px;
  font-size: 0.95rem;
  font-family: inherit;
  width: 100%;
}
select#new-role:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }

/* credential box */
.cred-note { font-size: 0.8rem; color: var(--muted); margin: 4px 0 14px; }
.cred-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px 14px; }
.cred-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border-soft); }
.cred-row:last-child { border-bottom: none; }
.cred-label { font-size: 0.78rem; color: var(--muted); }
.cred-val { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 1rem; font-weight: 600; color: var(--green); }

/* ===== db storage ===== */
.db-total { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.db-total-val { font-size: 1.6rem; font-weight: 650; letter-spacing: -0.02em; }
.db-total-lbl { font-size: 0.78rem; color: var(--muted); }
.db-usebar { height: 10px; background: var(--surface-3); border-radius: 999px; overflow: hidden; margin: 4px 0 8px; }
.db-usebar span { display: block; height: 100%; background: var(--green); border-radius: 999px; transition: width 0.3s; }
.db-usebar.warn span { background: var(--amber); }
.db-usebar.bad span { background: var(--red); }
.db-sub { font-size: 0.72rem; color: var(--dim); margin-bottom: 14px; }
.db-table { display: flex; align-items: center; gap: 12px; padding: 9px 0; }
.db-name { width: 92px; flex: none; font-size: 0.84rem; }
.db-name small { display: block; color: var(--dim); font-size: 0.7rem; }
.db-bar { flex: 1; height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.db-bar span { display: block; height: 100%; background: var(--green); border-radius: 999px; }
.db-size { width: 74px; flex: none; text-align: right; font-size: 0.82rem; font-weight: 600; }

/* ===== activity log ===== */
.act-row { display: flex; align-items: center; gap: 11px; padding: 10px 4px; border-bottom: 1px solid var(--border-soft); }
.act-row:last-child { border-bottom: none; }
.act-dot {
  width: 28px; height: 28px; flex: none; border-radius: 8px;
  display: grid; place-items: center; font-size: 0.72rem; font-weight: 700;
  background: var(--surface-3); color: var(--muted);
}
.act-dot.good { background: var(--green-soft); color: var(--green); }
.act-dot.warn { background: var(--amber-soft); color: var(--amber); }
.act-dot.bad { background: var(--red-soft); color: var(--red); }
.act-dot.info { background: rgba(107,165,255,0.16); color: var(--blue); }
.act-main { flex: 1; min-width: 0; }
.act-title { font-size: 0.88rem; }
.act-title b { font-weight: 600; }
.act-detail { font-size: 0.76rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.act-time { font-size: 0.72rem; color: var(--dim); flex: none; text-align: right; }

/* ===== user guide ===== */
.guide { padding: 4px 2px 8px; }
.guide-lead { font-size: 0.92rem; color: var(--text); margin: 6px 0 4px; }
.guide h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 20px 0 8px;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
}
.guide p { font-size: 0.88rem; color: var(--muted); margin: 8px 0; }
.guide b { color: var(--text); font-weight: 600; }
.guide ul, .guide ol { margin: 8px 0; padding-left: 20px; }
.guide li { font-size: 0.88rem; color: var(--muted); margin: 6px 0; }
.guide li .shift-chip { margin-right: 4px; }
.guide-note { font-size: 0.82rem; color: var(--dim); }

/* ===== entry modal ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal[hidden] { display: none; }
.modal-scrim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  animation: fade 0.18s ease;
}
.modal-sheet {
  position: relative;
  width: 100%;
  max-width: var(--maxw);
  max-height: 92vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  padding: 8px 16px calc(env(safe-area-inset-bottom) + 18px);
  animation: sheet-up 0.26s cubic-bezier(0.2, 0.75, 0.2, 1);
}
.modal-head { position: sticky; top: 0; background: var(--surface); padding-top: 8px; z-index: 1; }
.modal-grip {
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: var(--border);
  margin: 0 auto 12px;
}
.modal-head-right { display: flex; align-items: center; gap: 8px; }
.modal-head .card-head { padding-bottom: 14px; border-bottom: 1px solid var(--border-soft); }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

@media (min-width: 640px) {
  .modal { align-items: center; padding: 20px; }
  .modal-sheet {
    max-width: 520px;
    border-radius: 16px;
    animation: pop 0.2s ease;
  }
  .modal-grip { display: none; }
  @keyframes pop { from { transform: scale(0.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
}

/* off-day toggle */
.switch-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  padding: 12px 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.switch { position: relative; display: inline-flex; flex: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  transition: background 0.18s, border-color 0.18s;
  display: inline-flex;
  align-items: center;
  padding: 0 2px;
}
.switch-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.18s, background 0.18s;
}
.switch input:checked + .switch-track { background: var(--green-soft); border-color: var(--green); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(18px); background: var(--green); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 3px var(--green-soft); }
.switch-text { display: flex; flex-direction: column; line-height: 1.3; }
.switch-text strong { font-size: 0.9rem; font-weight: 600; }
.switch-text em { font-style: normal; font-size: 0.76rem; color: var(--muted); }

.shift-chip.off { background: var(--red-soft); color: var(--red); }

/* segmented control (calculator) */
.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 14px;
  padding: 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.seg-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 550;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.seg-btn em { font-style: normal; color: var(--dim); font-size: 0.8rem; }
.seg-btn.active { background: var(--surface-3); color: var(--text); }
.seg-btn.active em { color: var(--green); }

/* calculator breakdown */
#calc-breakdown { margin-top: 12px; }
#calc-breakdown .period-name { color: var(--muted); }
#calc-total { font-size: 1.9rem; margin-top: 4px; }
.calc-note { margin: 12px 0 0; font-size: 0.78rem; color: var(--dim); }

.msg { margin: 12px 0 0; font-size: 0.84rem; }
.msg.ok { color: var(--green); }
.msg.error { color: var(--red); }

/* ===== shift chips ===== */
.shift-chip {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  white-space: nowrap;
}
.shift-chip.morning { background: var(--amber-soft); color: var(--amber); }
.shift-chip.evening { background: rgba(107, 165, 255, 0.16); color: var(--blue); }
.shift-chip.night { background: var(--purple-soft); color: var(--purple); }

/* ===== entry list ===== */
.entry-list { display: flex; flex-direction: column; }
.entry {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 4px;
  border-bottom: 1px solid var(--border-soft);
}
.entry:last-child { border-bottom: none; }
.entry-main { flex: 1; min-width: 0; }
.entry-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
}
.entry-date { font-weight: 600; font-size: 0.92rem; }
.entry-times { font-size: 0.8rem; color: var(--muted); }
.entry-times .sep { color: var(--dim); margin: 0 5px; }
.entry-ot { text-align: right; }
.entry-ot-val { font-weight: 650; font-size: 0.98rem; }
.entry-ot-lbl { font-size: 0.68rem; color: var(--dim); }
.entry-menu {
  background: none;
  border: none;
  color: var(--dim);
  cursor: pointer;
  padding: 6px;
  font-size: 1.1rem;
  line-height: 1;
}
.pos { color: var(--green); }
.neg { color: var(--red); }
.zero { color: var(--muted); }

.entry-actions { display: flex; gap: 4px; }
.mini-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 0.74rem;
  font-family: inherit;
  cursor: pointer;
}
.mini-btn.danger { color: var(--red); border-color: transparent; }

/* ===== period (reports) list ===== */
.period-list { display: flex; flex-direction: column; }
.period {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border-soft);
}
.period:last-child { border-bottom: none; }
.period-name { font-size: 0.9rem; }
.period-name small { display: block; color: var(--dim); font-size: 0.72rem; }
.period-val { font-weight: 650; font-size: 1rem; }

/* ===== shift reference ===== */
.shift-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 4px;
  border-bottom: 1px solid var(--border-soft);
}
.shift-row:last-child { border-bottom: none; }
.shift-time { font-weight: 600; font-size: 0.92rem; }
.shift-detect { margin-left: auto; font-size: 0.76rem; color: var(--dim); }

.empty { text-align: center; color: var(--dim); padding: 22px 0; font-size: 0.88rem; }
.empty.error { color: var(--red); }

/* ===== larger screens ===== */
@media (min-width: 900px) {
  .drawer {
    transform: none;
    border-right: 1px solid var(--border);
  }
  .scrim { display: none !important; }
  body { padding-left: 320px; }
  .appbar { padding-left: calc(320px + 12px); }
  #menu-btn, #drawer-close { display: none; }
}
