:root {
  --ink: #1b2733;
  --ink-soft: #55606d;
  --line: #d8dee6;
  --bg: #eff2f6;
  --surface: #fff;
  --accent: #0f6e5c;
  --accent-dark: #0b5445;
  --danger: #b42318;
  --warn: #9a6700;
  --radius: 6px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

h2 { font-size: 17px; margin: 0 0 4px; }
h3 { font-size: 14px; color: var(--ink-soft); font-weight: 600; margin: 0 0 8px; }

/* ---------- top bar ---------- */
.topbar { background: #23384d; color: #fff; }
.topbar-in { max-width: 1180px; margin: 0 auto; padding: 12px 20px 0; }
.brand { display: flex; align-items: baseline; gap: 12px; }
.brand-name { font-size: 19px; font-weight: 700; letter-spacing: .04em; }
.brand-org { font-size: 13px; color: #a9bdd2; }

.tabs { display: flex; gap: 4px; margin-top: 10px; flex-wrap: wrap; }
.tabs button {
  background: none; border: 0; color: #c3d3e2; font: inherit; font-size: 14px;
  padding: 8px 14px; cursor: pointer; border-radius: var(--radius) var(--radius) 0 0;
}
.tabs button:hover { color: #fff; background: rgba(255,255,255,.08); }
.tabs button.on { background: var(--bg); color: var(--ink); font-weight: 600; }

/* ---------- layout ---------- */
.page { max-width: 1180px; margin: 18px auto 60px; padding: 0 20px; }
.panel, .board {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px;
}
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.hint { color: var(--ink-soft); font-size: 13px; margin: 4px 0 12px; max-width: 68ch; }
.formrow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.formrow label { font-size: 13px; color: var(--ink-soft); }
.spacer { flex: 1; }
.hide { display: none !important; }
.inline { font-size: 13px; color: var(--ink-soft); display: inline-flex; gap: 6px; align-items: center; }

/* ---------- date bar ---------- */
.datebar {
  position: sticky; top: 0; z-index: 20;
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px;
}
.datebar input[type=date] { font-size: 16px; font-weight: 600; }

/* ---------- controls ---------- */
button, input, select {
  font-family: inherit; font-size: 14px;
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 7px 10px; background: #fff; color: var(--ink);
}
button { cursor: pointer; background: #f6f8fa; }
button:hover { background: #e9edf2; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--accent-dark); }
button.danger { background: #fff; border-color: #e6b3ae; color: var(--danger); }
button.danger:hover { background: #fdf0ef; }
button.ghost { padding: 7px 11px; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.mini { padding: 4px 9px; font-size: 13px; }

.badge {
  background: #fdf4e3; border: 1px solid #e4c98a; color: var(--warn);
  border-radius: 999px; padding: 3px 12px; font-size: 13px; font-weight: 600;
}

/* ---------- count board ---------- */
.board-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 10px; }
.totals { display: flex; gap: 18px; font-size: 14px; color: var(--ink-soft); }
.totals b { font-size: 22px; color: var(--ink); font-variant-numeric: tabular-nums; margin-left: 4px; }
.period { margin-top: 14px; }
.blocks { display: flex; flex-wrap: wrap; gap: 10px; }

.block {
  border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: var(--radius); padding: 9px 14px; min-width: 165px;
  background: #fbfcfd; cursor: pointer; text-align: left; font: inherit; display: block;
}
.block:hover { background: #f2f6f9; }
.block .loc { font-size: 12px; color: var(--ink-soft); }
.block .meal { font-weight: 600; }
.block .n { font-size: 24px; font-variant-numeric: tabular-nums; float: right; line-height: 1.1; }
.block .names { clear: both; font-size: 12px; color: var(--ink-soft); padding-top: 8px; border-top: 1px dashed var(--line); margin-top: 6px; }
.blocks .none { color: var(--ink-soft); font-size: 13px; }

.summary { border-collapse: collapse; margin-top: 18px; font-size: 14px; }
.summary th, .summary td { border: 1px solid var(--line); padding: 5px 14px; text-align: right; }
.summary th:first-child, .summary td:first-child { text-align: left; }
.summary thead th { background: #f2f5f8; }
.summary tfoot td { font-weight: 700; background: #f8fafb; }
.summary td { font-variant-numeric: tabular-nums; }

/* ---------- tables ---------- */
.grid { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 14px; }
.grid th, .grid td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; }
.grid thead th { background: #f2f5f8; font-weight: 600; position: sticky; top: 0; }
.grid tbody tr:nth-child(even) { background: #fafbfc; }
.grid input, .grid select { width: 100%; padding: 4px 6px; }
.grid td.acts { white-space: nowrap; }
.scroll { max-height: 65vh; overflow: auto; border-radius: var(--radius); }

.tag { font-size: 12px; border-radius: 4px; padding: 2px 7px; background: #eef2f6; color: var(--ink-soft); }
.tag.punch { background: #e6f2ee; color: var(--accent-dark); }
.tag.lunch { background: #eaf0f7; color: #23384d; }
.tag.dinner { background: #f2ecf7; color: #5b3f7a; }

.empty { color: var(--ink-soft); font-size: 14px; padding: 14px 0; }
.absent { background: #fdf9ef; border: 1px solid #ecdcb4; border-radius: var(--radius); padding: 10px 14px; font-size: 13px; margin-top: 10px; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(20,30,40,.45); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal-box { background: #fff; border-radius: 8px; padding: 20px 22px; width: min(620px, 100%); max-height: 84vh; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.datepick { display: block; padding: 6px 4px; border-bottom: 1px solid var(--line); font-size: 14px; }
.datepick:last-child { border-bottom: 0; }
.datepick small { color: var(--ink-soft); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: #23384d; color: #fff; padding: 11px 20px; border-radius: 6px;
  font-size: 14px; z-index: 200; max-width: 90vw; box-shadow: 0 6px 18px rgba(0,0,0,.2);
}
.toast.err { background: var(--danger); }

@media (max-width: 720px) {
  .page { padding: 0 12px; }
  .brand { flex-direction: column; gap: 0; }
  .grid { font-size: 13px; }
}
