:root {
  --bg: #f4f6f4; --panel: #fff; --ink: #1d2420; --muted: #66706a; --line: #dfe4e0;
  --accent: #1f6f43; --accent-2: #2e8b57; --accent-soft: #e3f2e8;
  --work: #cdebd3; --work-ink: #14532d; --off: #f2b8b8; --pending: #fbe3e3;
  --sat: #8cbfff; --sun: #a5e5a5; --warn: #b45309; --warn-bg: #fff4e0; --bad: #b91c1c; --bad-bg: #fde8e8;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.05);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 15px; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0 0 .6em; line-height: 1.2; }
h1 { font-size: 1.35rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .75rem; }

/* layout */
.top { position: sticky; top: 0; z-index: 30; background: var(--accent); color: #fff; display: flex; align-items: center; gap: .75rem;
  padding: .55rem 1rem; padding-top: calc(.55rem + env(safe-area-inset-top)); }
.top .brand { font-weight: 700; letter-spacing: .2px; white-space: nowrap; }
.top nav { display: flex; gap: .25rem; overflow-x: auto; flex: 1; scrollbar-width: none; }
.top nav a { color: #e9f5ee; text-decoration: none; padding: .4rem .7rem; border-radius: 8px; white-space: nowrap; font-size: .93rem; }
.top nav a.on, .top nav a:hover { background: rgba(255,255,255,.17); color: #fff; }
.top .who { font-size: .85rem; opacity: .9; white-space: nowrap; }
.top button { background: rgba(255,255,255,.15); color: #fff; border: 0; border-radius: 8px; padding: .35rem .7rem; cursor: pointer; }
main { padding: 1rem; max-width: 1600px; margin: 0 auto; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); margin-bottom: 1rem; }

/* controls */
.btn { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: .45rem .85rem; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #b9c4bd; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: .25rem .55rem; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: default; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: transparent; padding: .42rem .75rem; cursor: pointer; }
.seg button.on { background: var(--accent); color: #fff; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=month], select, textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: .45rem .6rem; background: #fff; min-width: 0; }
textarea { width: 100%; min-height: 70px; }
label.f { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; color: var(--muted); }
label.f > input, label.f > select, label.f > textarea { color: var(--ink); font-size: .95rem; }
label.chk { display: inline-flex; gap: .4rem; align-items: center; cursor: pointer; }
.pill { display: inline-block; border-radius: 99px; padding: .1rem .55rem; font-size: .78rem; background: var(--accent-soft); color: var(--accent); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.grey { background: #eceeed; color: var(--muted); }

/* tables */
table.list { border-collapse: collapse; width: 100%; }
table.list th, table.list td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list th { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
table.list td.num, table.list th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tablewrap { overflow-x: auto; }

/* schedule grid */
.gridwrap { overflow: auto; max-height: calc(100vh - 230px); border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table.sched { border-collapse: separate; border-spacing: 0; font-size: .82rem; font-variant-numeric: tabular-nums; }
table.sched th, table.sched td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 0; text-align: center; }
table.sched thead th { position: sticky; background: #5cc85c; color: #10331b; z-index: 3; font-weight: 600; }
table.sched thead tr:first-child th { top: 0; height: 34px; padding: 0 .3rem; white-space: nowrap; }
table.sched thead tr:nth-child(2) th { top: 34px; height: 24px; background: #c7ecc7; font-weight: 500; font-size: .75rem; min-width: 46px; }
table.sched th.emp { border-left: 2px solid #2f3b33; max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
table.sched td.d0, table.sched th.d0 { border-left: 2px solid #2f3b33; }
table.sched .datecol { position: sticky; left: 0; z-index: 2; background: #f1f3f1; min-width: 104px; text-align: right; padding: 0 .55rem; font-weight: 500; white-space: nowrap; }
table.sched thead .datecol { z-index: 4; background: #5cc85c; }
table.sched tr.sat .datecol { background: var(--sat); }
table.sched tr.sun .datecol { background: var(--sun); }
table.sched .wd { color: var(--muted); font-size: .72rem; margin-right: .3rem; }
table.sched td.c { height: 30px; min-width: 46px; cursor: pointer; position: relative; user-select: none; }
table.sched td.c:hover { outline: 2px solid var(--accent); outline-offset: -2px; }
table.sched td.c.w { background: var(--work); color: var(--work-ink); }
table.sched td.c.x { background: var(--off); }
table.sched td.c.p { background: repeating-linear-gradient(45deg, var(--pending), var(--pending) 5px, #fff 5px, #fff 10px); }
table.sched td.c.lk::before { content: ""; position: absolute; left: 0; top: 0; border-top: 8px solid #1f6f43; border-right: 8px solid transparent; }
table.sched td.c.bad { box-shadow: inset 0 0 0 2px var(--bad); }
table.sched td.c.mine { box-shadow: inset 0 0 0 2px var(--accent); }
table.sched td.cnt { min-width: 52px; font-size: .75rem; background: #fafbfa; cursor: pointer; }
table.sched td.cnt.bad { background: var(--bad-bg); color: var(--bad); font-weight: 700; }
table.sched tfoot td { position: sticky; bottom: 0; background: #e6eee8; font-weight: 700; height: 30px; z-index: 2; }
table.sched tfoot td.datecol { z-index: 3; background: #e6eee8; }
table.sched tfoot td.lo { color: var(--bad); } table.sched tfoot td.hi { color: var(--warn); }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .82rem; color: var(--muted); }
.legend i { display: inline-block; width: 16px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: .3rem; border: 1px solid var(--line); }
.warnings { max-height: 180px; overflow: auto; font-size: .85rem; margin: 0; padding-left: 1.1rem; }
.warnings li { margin: .15rem 0; }

/* weekday matrix */
table.wm { border-collapse: collapse; }
table.wm td, table.wm th { padding: .25rem .5rem; text-align: center; border: 1px solid var(--line); font-size: .85rem; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15,25,20,.45); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 4vh 12px; overflow-y: auto; }
.modal { background: #fff; border-radius: 14px; padding: 1.2rem; width: min(680px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal .actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; }

/* toast */
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(120px); background: #1d2420; color: #fff; padding: .7rem 1.1rem; border-radius: 10px; transition: transform .25s; z-index: 200; max-width: 92vw; }
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--bad); }

/* login */
.login { max-width: 380px; margin: 10vh auto; }
.login .card { padding: 1.6rem; }
.login input { width: 100%; margin-bottom: .7rem; padding: .7rem; }
.login .btn { width: 100%; padding: .7rem; }

/* kiosk */
body.kiosk { background: #0f1a14; color: #eef5f0; }
.k-wrap { min-height: 100vh; display: flex; flex-direction: column; padding: 16px; padding-top: calc(16px + env(safe-area-inset-top)); }
.k-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.k-clock { font-size: 2.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.k-date { color: #9fb8a8; }
.k-title { color: #9fb8a8; font-size: .95rem; margin: 6px 0 10px; }
.k-names { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.k-name { background: #1b2a21; border: 1px solid #284033; color: #eef5f0; border-radius: 14px; padding: 16px 12px; text-align: left; cursor: pointer; min-height: 78px; }
.k-name b { display: block; font-size: 1.05rem; }
.k-name span { font-size: .8rem; color: #9fb8a8; }
.k-name.today { border-color: #3fa66b; }
.k-name.open { background: #1f4d33; border-color: #5cd18f; }
.k-name.open span { color: #b8f0cc; }
.k-pad { position: fixed; inset: 0; background: rgba(5,10,7,.94); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.k-pad h2 { font-size: 1.5rem; margin-bottom: .3rem; }
.k-dots { display: flex; gap: 14px; margin: 18px 0 22px; min-height: 22px; }
.k-dots i { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #5cd18f; }
.k-dots i.f { background: #5cd18f; }
.k-keys { display: grid; grid-template-columns: repeat(3, 84px); gap: 14px; }
.k-keys button { height: 84px; border-radius: 50%; border: 0; background: #1f3428; color: #fff; font-size: 1.8rem; cursor: pointer; }
.k-keys button:active { background: #2f5a40; }
.k-keys button.ok { background: #2e8b57; font-size: 1.1rem; font-weight: 700; }
.k-keys button.del { font-size: 1.2rem; }
.k-cancel { margin-top: 20px; background: transparent; border: 1px solid #3a5545; color: #cfe3d6; border-radius: 10px; padding: .6rem 1.4rem; font-size: 1rem; }
.k-result { text-align: center; max-width: 520px; }
.k-result .big { font-size: 4rem; }
.k-result p { font-size: 1.35rem; }
.k-err { color: #ff9b9b; min-height: 1.4em; }

@media (max-width: 720px) {
  main { padding: .75rem; }
  .top { flex-wrap: wrap; }
  .top nav { order: 3; flex-basis: 100%; }
  .gridwrap { max-height: none; }
}
@media print {
  .top, .noprint, #toast { display: none !important; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  .card { border: 0; box-shadow: none; padding: 0; }
  .gridwrap { max-height: none; overflow: visible; border: 0; }
  table.sched { font-size: 9px; }
  table.sched td.c { height: 18px; min-width: 26px; }
  table.sched thead th, table.sched tfoot td, table.sched .datecol { position: static; }
  @page { size: A4 landscape; margin: 8mm; }
}
