* { box-sizing: border-box; margin: 0; -webkit-tap-highlight-color: transparent; }
:root {
  --bg: #f1f4f9; --card: #fff; --ink: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --accent: #2f56d9; --accent-soft: #e8edfc; --green: #16a34a; --green-soft: #e6f6ec;
  --amber: #d97706; --amber-soft: #fdf1de; --blue: #0284c7; --blue-soft: #e3f3fb;
  --gray-soft: #eef1f5; --purple: #7c3aed; --purple-soft: #f1eafd; --red: #dc2626; --red-soft: #fdeaea;
}
html, body { height: 100%; }
body { font-family: -apple-system, system-ui, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--ink); font-size: 16px; }
#app { max-width: 760px; margin: 0 auto; min-height: 100%; padding-bottom: 84px; }
button { font: inherit; border: 0; cursor: pointer; background: none; color: inherit; }
input, select { font: inherit; color: inherit; }
h1 { font-size: 20px; } h2 { font-size: 17px; }

/* login */
.login { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 24px; }
.login .logo { font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
.login .logo span { color: var(--accent); }
.login .sub { color: var(--muted); font-size: 14px; margin-top: -14px; }
.pin-dots { display: flex; gap: 14px; height: 18px; }
.pin-dots i { width: 15px; height: 15px; border-radius: 50%; background: var(--line); transition: background .12s; }
.pin-dots i.on { background: var(--accent); }
.pin-dots.err i { background: var(--red); }
.pad { display: grid; grid-template-columns: repeat(3, 76px); gap: 14px; }
.pad button { height: 76px; border-radius: 50%; background: var(--card); font-size: 26px; font-weight: 600; box-shadow: 0 1px 3px rgba(15,23,42,.08); transition: transform .05s, background .1s; }
.pad button:active { transform: scale(.93); background: var(--accent-soft); }
.pad button.ghost { background: none; box-shadow: none; font-size: 15px; color: var(--muted); }

/* layout */
.topbar { position: sticky; top: 0; z-index: 20; background: linear-gradient(135deg, #1e293b, #263c63); color: #fff; padding: 14px 18px calc(12px); display: flex; align-items: center; justify-content: space-between; }
.topbar .brand { font-weight: 800; font-size: 17px; }
.topbar .brand span { color: #8fb0ff; }
.topbar .who { font-size: 13px; opacity: .85; display: flex; align-items: center; gap: 10px; }
.topbar .who button { opacity: .8; font-size: 12px; border: 1px solid rgba(255,255,255,.35); padding: 4px 10px; border-radius: 20px; }
main { padding: 16px 14px 20px; display: flex; flex-direction: column; gap: 14px; }

.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: var(--card); border-top: 1px solid var(--line); display: flex; justify-content: center; gap: 6px; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
.tabs button { flex: 1; max-width: 170px; padding: 9px 4px; border-radius: 12px; font-size: 12.5px; font-weight: 600; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 3px; }
.tabs button .ic { font-size: 20px; line-height: 1; }
.tabs button.on { color: var(--accent); background: var(--accent-soft); }

.card { background: var(--card); border-radius: 16px; padding: 14px; box-shadow: 0 1px 3px rgba(15,23,42,.06); }
.row { display: flex; align-items: center; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.emps { gap: 10px; }
.ts-head, .ts-top { display: flex; flex-direction: column; gap: 12px; }
.side-brand, .side-foot { display: none; }
.cash-grid, .cash-left { display: flex; flex-direction: column; gap: 14px; }
.grow { flex: 1; }
.muted { color: var(--muted); font-size: 13px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { white-space: nowrap; padding: 8px 14px; border-radius: 20px; background: var(--card); font-size: 13.5px; font-weight: 600; color: var(--muted); box-shadow: 0 1px 2px rgba(15,23,42,.06); }
.chip.on { background: var(--accent); color: #fff; }

.btn { background: var(--accent); color: #fff; font-weight: 700; padding: 12px 18px; border-radius: 12px; font-size: 15px; transition: transform .05s; }
.btn:active { transform: scale(.97); }
.btn.sec { background: var(--accent-soft); color: var(--accent); }
.btn.green { background: var(--green); }
.btn.sm { padding: 8px 12px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .5; }

/* date nav */
.datenav { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.datenav .d { font-weight: 700; font-size: 15.5px; text-align: center; flex: 1; text-transform: capitalize; }
.datenav .d small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; text-transform: none; }
.datenav button { width: 42px; height: 42px; border-radius: 12px; background: var(--card); font-size: 18px; box-shadow: 0 1px 2px rgba(15,23,42,.06); }
.datenav input[type=date] { position: absolute; opacity: 0; pointer-events: none; }

/* timesheet rows */
.emp { padding: 12px 14px; }
.emp .name { font-weight: 700; font-size: 15px; }
.emp .pos { font-size: 12px; color: var(--muted); }
.seg { display: flex; gap: 5px; margin-top: 9px; }
.seg button { flex: 1; padding: 9px 2px; border-radius: 10px; background: var(--gray-soft); font-size: 12.5px; font-weight: 700; color: var(--muted); }
.seg button.s-full.on { background: var(--green); color: #fff; }
.seg button.s-half.on { background: var(--amber); color: #fff; }
.seg button.s-hours.on { background: var(--blue); color: #fff; }
.seg button.s-off.on { background: #475569; color: #fff; }
.seg button.s-vacation.on { background: var(--purple); color: #fff; }
.seg button.s-sick.on { background: var(--red); color: #fff; }
.hoursrow { display: flex; gap: 10px; margin-top: 9px; }
.hoursrow label { flex: 1; display: flex; align-items: center; gap: 8px; background: var(--gray-soft); border-radius: 10px; padding: 7px 12px; font-size: 13px; color: var(--muted); }
.hoursrow input { width: 100%; border: 0; background: none; font-size: 15px; font-weight: 700; text-align: right; outline: none; }

/* month grid */
.mgrid-wrap { overflow-x: auto; border-radius: 14px; }
table.mgrid { border-collapse: collapse; background: var(--card); font-size: 11.5px; min-width: 100%; }
.mgrid th, .mgrid td { border: 1px solid var(--line); padding: 4px 3px; text-align: center; }
.mgrid th { background: #f8fafc; font-size: 10.5px; color: var(--muted); position: sticky; top: 0; }
.mgrid td.nm { text-align: left; padding: 4px 8px; font-weight: 600; white-space: nowrap; position: sticky; left: 0; background: var(--card); font-size: 12px; }
.mgrid td.we { background: #f8fafc; }
.mgrid .c-full { background: var(--green-soft); color: var(--green); font-weight: 800; }
.mgrid .c-half { background: var(--amber-soft); color: var(--amber); font-weight: 800; }
.mgrid .c-hours { background: var(--blue-soft); color: var(--blue); font-weight: 800; }
.mgrid .c-off { background: var(--gray-soft); color: var(--muted); }
.mgrid .c-vacation { background: var(--purple-soft); color: var(--purple); font-weight: 800; }
.mgrid .c-sick { background: var(--red-soft); color: var(--red); font-weight: 800; }
.mgrid td.tot { font-weight: 800; background: #f8fafc; }

/* cash */
.acc-card { border-radius: 16px; padding: 16px; color: #fff; background: linear-gradient(135deg, #1e293b, #334f7d); display: flex; flex-direction: column; gap: 4px; }
.acc-card .nm { font-size: 13px; opacity: .8; }
.acc-card .bal { font-size: 28px; font-weight: 800; letter-spacing: -.5px; }
.acc-card .bal.neg { color: #fda4af; }
.acc-row { display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.acc-row::-webkit-scrollbar { display: none; }
.acc-mini { min-width: 170px; border-radius: 14px; padding: 12px 14px; background: var(--card); box-shadow: 0 1px 3px rgba(15,23,42,.06); border: 2px solid transparent; }
.acc-mini.on { border-color: var(--accent); }
.acc-mini .nm { font-size: 12px; color: var(--muted); font-weight: 600; }
.acc-mini .bal { font-size: 19px; font-weight: 800; }
.acc-mini .bal.neg { color: var(--red); }

.field { display: flex; flex-direction: column; gap: 5px; }
.field span { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field input, .field select { border: 1.5px solid var(--line); border-radius: 11px; padding: 11px 12px; font-size: 15px; background: #fff; outline: none; width: 100%; }
.field input:focus, .field select:focus { border-color: var(--accent); }
.amount-input input { font-size: 24px; font-weight: 800; text-align: center; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid .full { grid-column: 1 / -1; }

.tx { display: flex; align-items: center; gap: 10px; padding: 11px 2px; border-bottom: 1px solid var(--line); }
.tx:last-child { border-bottom: 0; }
.tx .ic { width: 38px; height: 38px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 17px; flex-shrink: 0; }
.tx .ic.exp { background: var(--red-soft); } .tx .ic.top { background: var(--green-soft); }
.tx .t1 { font-weight: 600; font-size: 14px; }
.tx .t2 { font-size: 12px; color: var(--muted); }
.tx .amt { font-weight: 800; font-size: 15px; white-space: nowrap; }
.tx .amt.exp { color: var(--red); } .tx .amt.top { color: var(--green); }
.tx .del { color: var(--muted); font-size: 17px; padding: 6px; }
.day-h { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin: 10px 2px 2px; }
.tx .grow.clip { min-width: 0; }
.clip .t1, .clip .t2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-inp { border: 1.5px solid var(--line); border-radius: 9px; padding: 5px 8px; font-size: 13px; background: #fff; }

/* admin lists */
.li { display: flex; align-items: center; gap: 10px; padding: 11px 2px; border-bottom: 1px solid var(--line); }
.li:last-child { border-bottom: 0; }
.li .t1 { font-weight: 600; font-size: 14.5px; }
.li .t2 { font-size: 12px; color: var(--muted); }
.li.inactive .t1 { color: var(--muted); text-decoration: line-through; }
.badge { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 8px; background: var(--gray-soft); color: var(--muted); white-space: nowrap; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.purple { background: var(--purple-soft); color: var(--purple); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--card); border-radius: 20px 20px 0 0; width: 100%; max-width: 640px; max-height: 88vh; overflow-y: auto; padding: 18px 16px calc(20px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; animation: up .18s ease; }
@keyframes up { from { transform: translateY(40px); opacity: .6; } }
.modal h2 { display: flex; justify-content: space-between; align-items: center; }
.modal h2 button { color: var(--muted); font-size: 22px; padding: 2px 8px; }
@media (min-width: 640px) { .modal-bg { align-items: center; } .modal { border-radius: 20px; } }

#toast { position: fixed; bottom: 92px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
#toast .t { background: #0f172a; color: #fff; padding: 10px 18px; border-radius: 24px; font-size: 13.5px; font-weight: 600; box-shadow: 0 4px 14px rgba(15,23,42,.3); animation: up .15s ease; }
#toast .t.err { background: var(--red); }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; font-size: 14px; }
.seg-view { display: flex; background: var(--gray-soft); border-radius: 12px; padding: 3px; }
.seg-view button { flex: 1; padding: 8px; border-radius: 10px; font-size: 13.5px; font-weight: 700; color: var(--muted); }
.seg-view button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(15,23,42,.1); }

/* ---------- desktop ---------- */
@media (hover: hover) {
  .btn:hover { filter: brightness(1.08); }
  .btn.sec:hover { filter: none; background: #dbe4fa; }
  .chip:hover:not(.on) { color: var(--ink); }
  .pad button:hover { background: var(--accent-soft); }
  .seg button:hover:not(.on) { background: #e2e8f0; }
  .li:hover, .tx:hover { background: #f8fafc; }
  .acc-mini:hover:not(.on) { border-color: var(--line); }
  .datenav button:hover { background: var(--accent-soft); }
}

@media (min-width: 900px) {
  #app { max-width: none; padding: 0 0 0 240px; }
  .topbar { display: none; }
  main { max-width: 1200px; margin: 0 auto; padding: 28px 32px 40px; gap: 16px; }
  #toast { bottom: 28px; }

  /* bottom tabs -> sidebar */
  .tabs { top: 0; bottom: 0; right: auto; width: 240px; flex-direction: column; justify-content: flex-start; align-items: stretch; gap: 4px; padding: 20px 14px; border-top: 0; background: linear-gradient(180deg, #1e293b, #2b466f); }
  .tabs button { flex: none; max-width: none; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 11px 14px; font-size: 14px; color: rgba(255,255,255,.72); }
  .tabs button .ic { font-size: 18px; }
  .tabs button.on { background: rgba(255,255,255,.14); color: #fff; }
  .tabs button:hover:not(.on) { background: rgba(255,255,255,.07); color: #fff; }
  .side-brand { display: block; color: #fff; font-weight: 800; font-size: 19px; letter-spacing: -.3px; padding: 6px 14px 22px; }
  .side-brand span { color: #8fb0ff; }
  .side-foot { display: flex; margin-top: auto; align-items: center; justify-content: space-between; gap: 8px; color: rgba(255,255,255,.85); font-size: 13px; padding: 14px 14px 4px; border-top: 1px solid rgba(255,255,255,.15); }
  .side-foot button { font-size: 12px; border: 1px solid rgba(255,255,255,.35); padding: 4px 10px; border-radius: 20px; opacity: .85; }
  .side-foot button:hover { opacity: 1; background: rgba(255,255,255,.1); }

  /* timesheet header: chips + view switch in one row */
  .chips { flex-wrap: wrap; overflow: visible; }
  .ts-head { flex-direction: row; align-items: flex-start; }
  .ts-head .chips { flex: 1; }
  .ts-head .seg-view { width: 250px; flex: none; }

  /* day view: date nav + bulk button in a row, dense employee rows */
  .ts-top { flex-direction: row; align-items: stretch; }
  .ts-top .datenav { flex: 1; }
  .ts-top .btn { flex: none; padding: 0 24px; }
  .emps { gap: 8px; }
  .card.emp { display: grid; grid-template-columns: minmax(190px, 250px) minmax(360px, 500px) 1fr; align-items: center; gap: 18px; padding: 10px 16px; }
  .emp .seg { margin-top: 0; }
  .emp .hoursrow { margin-top: 0; max-width: 430px; }

  /* month grid */
  .mgrid { font-size: 12.5px; }
  .mgrid th { font-size: 11px; }
  .mgrid th, .mgrid td { padding: 5px 4px; }

  /* cash: form left, operations right */
  .cash-grid { display: grid; grid-template-columns: 420px minmax(0, 1fr); gap: 16px; align-items: start; }
  .acc-row { flex-wrap: wrap; overflow: visible; }

  .modal { max-height: 82vh; }
}

@media (min-width: 1100px) {
  #plist, #ulist, #alist { display: grid; grid-template-columns: 1fr 1fr; column-gap: 32px; }
}
