:root {
  --bg: #fdf6f0;
  --card: #ffffff;
  --ink: #3a2b2f;
  --muted: #8a7a7e;
  --line: #f0e2dc;
  --pink: #e8628f;
  --pink-soft: #fde4ec;
  --green: #2f8a3c;
  --green-soft: #def3df;
  --amber: #d98a12;
  --amber-soft: #fdf0d6;
  --red: #c8433a;
  --red-soft: #fbe1de;
  --grey-soft: #efe9e7;
  --radius: 18px;
  --shadow: 0 4px 18px rgba(90, 50, 60, .08);
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
.brand { font-weight: 800; letter-spacing: -.02em; color: var(--pink); }
.brand small { display: block; font-size: .45em; font-weight: 600; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }

/* ---------- Buttons / Inputs */
.btn {
  border: 0; border-radius: 12px; padding: 10px 16px; background: var(--grey-soft); color: var(--ink);
  font-weight: 600; transition: transform .08s ease, filter .15s ease;
}
.btn:active { transform: scale(.97); }
.btn:hover { filter: brightness(.97); }
.btn.primary { background: var(--pink); color: #fff; }
.btn.green { background: var(--green); color: #fff; }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn.small { padding: 6px 10px; font-size: .9em; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: default; }
.input {
  width: 100%; padding: 11px 13px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff;
  outline: none; transition: border-color .15s;
}
.input:focus { border-color: var(--pink); }
label.field { display: block; font-size: .85em; font-weight: 600; color: var(--muted); margin-bottom: 12px; }
label.field .input { margin-top: 5px; font-size: 1.05rem; color: var(--ink); font-weight: 400; }

/* ---------- Status-Chips */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: .82em; font-weight: 700; }
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.chip.in { background: var(--green-soft); color: var(--green); }
.chip.break { background: var(--amber-soft); color: var(--amber); }
.chip.out { background: var(--grey-soft); color: var(--muted); }

/* ---------- Login */
.login-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--card); border-radius: 24px; box-shadow: var(--shadow); padding: 32px 26px; }
.login-card .brand { font-size: 2.2rem; text-align: center; margin-bottom: 24px; }
.check { display: flex; align-items: center; gap: 10px; margin: 6px 0 20px; font-size: .95em; }
.check input { width: 20px; height: 20px; accent-color: var(--pink); }
.err { color: var(--red); font-size: .9em; min-height: 1.3em; margin-bottom: 8px; }
.hint { color: var(--muted); font-size: .8em; margin-top: 16px; line-height: 1.45; text-align: center; }

/* ---------- Terminal */
.term { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.term-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 8px; gap: 12px; }
.term-head .brand { font-size: 1.8rem; line-height: 1; }
.clock { text-align: right; }
.clock .time { font-size: 2.4rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.clock .date { color: var(--muted); font-size: .9em; margin-top: 4px; }
.term-sub { padding: 4px 22px 12px; color: var(--muted); font-size: 1rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; padding: 4px 22px 22px; }
.emp {
  background: var(--card); border: 2px solid transparent; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 16px; text-align: left; min-height: 120px; display: flex; flex-direction: column; gap: 10px;
  transition: transform .08s ease;
}
.emp:active { transform: scale(.97); }
.emp.in { border-color: #b9e3bc; }
.emp.break { border-color: #f4d79b; }
.emp .avatar {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 1.1rem;
  background: var(--pink-soft); color: var(--pink);
}
.emp .name { font-size: 1.15rem; font-weight: 700; word-break: break-word; }
.emp .since { color: var(--muted); font-size: .82em; }
.term-foot { margin-top: auto; padding: 12px 22px 18px; display: flex; justify-content: space-between; color: var(--muted); font-size: .85em; }
.term-foot a, .term-foot button { color: var(--muted); background: none; border: 0; text-decoration: none; padding: 6px; }
.empty { padding: 40px 22px; text-align: center; color: var(--muted); }

.overlay { position: fixed; inset: 0; background: rgba(58, 43, 47, .45); display: grid; place-items: center; padding: 16px; z-index: 10; }
.sheet { background: var(--card); border-radius: 26px; width: 100%; max-width: 520px; padding: 28px 24px 24px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.sheet .who { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.sheet .who .avatar { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 1.4rem; background: var(--pink-soft); color: var(--pink); }
.sheet h2 { margin: 0; font-size: 1.6rem; }
.sheet .meta { color: var(--muted); margin: 14px 0 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sheet .meta div { background: var(--bg); border-radius: 14px; padding: 12px; }
.sheet .meta b { display: block; color: var(--ink); font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.actions { display: grid; gap: 12px; }
.big {
  border: 0; border-radius: 18px; padding: 24px 16px; font-size: 1.35rem; font-weight: 800; color: #fff;
  display: flex; align-items: center; justify-content: center; gap: 12px; transition: transform .08s ease;
}
.big:active { transform: scale(.98); }
.big.in { background: var(--green); }
.big.break { background: var(--amber); }
.big.resume { background: var(--green); }
.big.out { background: var(--red); }
.big svg { width: 28px; height: 28px; }
.sheet .cancel { margin-top: 14px; width: 100%; background: none; border: 0; color: var(--muted); padding: 12px; font-size: 1rem; }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 16px 24px; border-radius: 16px; font-size: 1.15rem; font-weight: 600; z-index: 20; box-shadow: 0 10px 30px rgba(0,0,0,.25);
  max-width: calc(100% - 32px); text-align: center;
}
.toast.ok { background: var(--green); }
.toast.bad { background: var(--red); }

/* ---------- Admin */
.admin-head { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.admin-head .bar { max-width: 1200px; margin: 0 auto; display: flex; align-items: center; gap: 16px; padding: 12px 16px; flex-wrap: wrap; }
.admin-head .brand { font-size: 1.4rem; line-height: 1; margin-right: auto; }
.tabs { display: flex; gap: 4px; overflow-x: auto; max-width: 1200px; margin: 0 auto; padding: 0 16px; scrollbar-width: none; }
.tabs button { background: none; border: 0; padding: 10px 14px; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs button.active { color: var(--pink); border-bottom-color: var(--pink); }
main.admin { max-width: 1200px; margin: 0 auto; padding: 20px 16px 60px; }
.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px; }
.panel h3 { margin: 0 0 14px; font-size: 1.1rem; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row .grow { flex: 1; min-width: 160px; }
.seg { display: inline-flex; background: var(--grey-soft); border-radius: 12px; padding: 3px; }
.seg button { border: 0; background: none; padding: 7px 12px; border-radius: 9px; font-weight: 600; color: var(--muted); }
.seg button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.period-label { font-weight: 700; min-width: 180px; text-align: center; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.kpi .l { color: var(--muted); font-size: .85em; font-weight: 600; }
.kpi .v { font-size: 1.7rem; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .95em; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: .85em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.total td { font-weight: 800; border-bottom: 0; }
tr.open td { background: #fff8e8; }
.bar-cell { min-width: 120px; }
.minibar { height: 8px; border-radius: 4px; background: var(--pink); }
.minibar.pause { background: var(--amber); }
.muted { color: var(--muted); }
.live-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.live-item { border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.live-item .n { font-weight: 700; }
dialog { border: 0; border-radius: 22px; padding: 0; width: min(560px, calc(100% - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(58, 43, 47, .45); }
dialog form { padding: 22px; }
dialog h3 { margin: 0 0 16px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.break-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: end; margin-bottom: 8px; }
.break-row .input { font-size: .95rem; }
.dlg-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.dlg-actions .left { margin-right: auto; }
.notice { background: var(--amber-soft); color: #7a4c06; border-radius: 12px; padding: 10px 14px; margin-bottom: 16px; font-size: .92em; }

@media (max-width: 600px) {
  .term-head { padding: 14px 16px 6px; }
  .term-head .brand { font-size: 1.4rem; }
  .clock .time { font-size: 1.8rem; }
  .term-sub { padding: 4px 16px 10px; }
  .grid { padding: 4px 16px 16px; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .emp { min-height: 104px; padding: 14px 12px; }
  .big { padding: 20px 14px; font-size: 1.2rem; }
  .two, .break-row { grid-template-columns: 1fr; }
  .period-label { min-width: 0; flex: 1; }
}
