:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --line: #e6eaf0;
  --line-soft: #eef1f6;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --faint: #94a3b8;
  --accent: #2563eb;
  --accent-ink: #1d4ed8;
  --accent-weak: #eff4ff;
  --ok: #059669;
  --ok-weak: #ecfdf5;
  --warn: #b45309;
  --warn-weak: #fffbeb;
  --danger: #dc2626;
  --danger-weak: #fef2f2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 10px 30px -18px rgba(15, 23, 42, .25);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---------------------------------------------------------------- topbar */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 28px;
  height: 60px; padding: 0 24px;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: 9px;
  font-size: 15px; font-weight: 700; letter-spacing: .3px; white-space: nowrap;
}
.brand::before {
  content: "";
  width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  box-shadow: 0 2px 8px -2px rgba(37, 99, 235, .6);
}
.topbar nav { display: flex; gap: 2px; flex: 1; }
.topbar nav a {
  padding: 7px 13px; border-radius: 9px; color: var(--muted);
  text-decoration: none; font-weight: 500; transition: .15s;
}
.topbar nav a:hover { background: #f3f5f9; color: var(--ink); }
.topbar nav a.on { background: var(--accent-weak); color: var(--accent-ink); font-weight: 600; }
.logout button {
  background: none; border: 1px solid var(--line); color: var(--muted);
  padding: 6px 12px; border-radius: 9px; cursor: pointer; font: inherit; font-size: 13px;
  transition: .15s;
}
.logout button:hover { color: var(--danger); border-color: #f6cdcd; background: var(--danger-weak); }

/* ---------------------------------------------------------------- layout */
.wrap { max-width: 1320px; margin: 0 auto; padding: 24px 24px 56px; }

.pagehead {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 18px; flex-wrap: wrap; margin-bottom: 18px;
}
.pagehead h1 { font-size: 22px; line-height: 1.3; margin: 0; letter-spacing: -.2px; }
.pagehead .sub { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.head-actions { display: flex; align-items: center; gap: 10px; }

/* ---------------------------------------------------------------- cards */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card-hint { color: var(--muted); font-size: 13px; margin-top: 10px; line-height: 1.6; }

/* ---------------------------------------------------------------- stats */
.stats { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.stat {
  flex: 1 1 150px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 18px; box-shadow: var(--shadow);
}
.stat-k { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.stat-v { display: block; font-size: 22px; font-weight: 700; letter-spacing: -.4px; font-variant-numeric: tabular-nums; }
.stat-v small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.stat.accent .stat-v { color: var(--accent-ink); }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 10px;
  background: var(--accent); color: #fff; border: 1px solid var(--accent);
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none;
  line-height: 1.2; white-space: nowrap; transition: .15s;
  box-shadow: 0 1px 2px rgba(37, 99, 235, .25);
}
.btn:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn.ghost {
  background: #fff; color: var(--ink-2); border-color: var(--line); box-shadow: none;
}
.btn.ghost:hover { border-color: #c7d2fe; color: var(--accent-ink); background: var(--accent-weak); }
.btn.danger { background: #fff; color: var(--danger); border-color: #f4d4d4; box-shadow: none; }
.btn.danger:hover { background: var(--danger-weak); border-color: #eebbbb; }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }

a.ghost, .ghost { color: var(--muted); text-decoration: none; }

/* ---------------------------------------------------------------- forms */
input[type=text], input[type=password], input[type=month],
input[type=number], select {
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px;
  font: inherit; color: var(--ink); background: #fff; transition: .15s;
  min-height: 38px;
}
input::placeholder { color: var(--faint); }
input:hover, select:hover { border-color: #cfd8e3; }
input:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
select { cursor: pointer; }
.w-name { width: 160px; }
.w-money { width: 110px; }
.w-note { width: 240px; flex: 1; min-width: 160px; }
.w-num { width: 72px; }

.inline-form { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.inline-form label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.check { display: flex; align-items: center; gap: 6px; }
label.check input { min-height: 0; }

/* ---------------------------------------------------------------- flash */
.flash {
  padding: 11px 16px; border-radius: 12px; margin-bottom: 14px;
  border: 1px solid var(--line); background: #fff; font-size: 13.5px;
  display: flex; align-items: center; gap: 8px;
}
.flash::before { font-weight: 700; }
.flash.ok { border-color: #c6ebd7; background: var(--ok-weak); color: #106b45; }
.flash.ok::before { content: "✓"; }
.flash.err { border-color: #f6d0d0; background: var(--danger-weak); color: #a01c1c; }
.flash.err::before { content: "!"; }
.flash.warn { border-color: #f6e0bb; background: var(--warn-weak); color: #92400e; }
.flash.warn::before { content: "!"; }

/* ---------------------------------------------------------------- pills */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 11px; border-radius: 999px;
  background: #f1f5f9; color: var(--muted); font-size: 12px; font-weight: 600;
  white-space: nowrap;
}
.pill.done, .pill.ok { background: var(--ok-weak); color: #0f7a52; }
.pill.left { background: #f8f1f1; color: #9a6a6a; }
.pill::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7;
}

/* ---------------------------------------------------------------- tables */
table { border-collapse: separate; border-spacing: 0; width: 100%; }
.grid th, .grid td { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); text-align: left; }
.grid thead th {
  font-size: 12px; color: var(--muted); font-weight: 600;
  background: #fafbfd; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.grid thead th:first-child { border-top-left-radius: 10px; }
.grid thead th:last-child { border-top-right-radius: 10px; }
.grid tbody tr { transition: background .12s; }
.grid tbody tr:hover { background: #f9fbff; }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid tfoot td { background: #fafbfd; font-weight: 700; border-bottom: 0; }
.right { text-align: right !important; }
.strong { font-weight: 700; }
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, "SF Mono", Consolas, monospace; }
.dim { color: var(--muted); }
.empty-cell { color: var(--muted); text-align: center; padding: 36px !important; }
.actions { display: flex; gap: 6px; justify-content: flex-end; align-items: center; white-space: nowrap; }
.as-form { display: inline; margin: 0; }

/* ---------------------------------------------------------------- 登记表网格 */
.sheet-card { padding: 0; overflow: hidden; }
.grid-scroll { overflow: auto; max-height: calc(100vh - 260px); }

table.presence { border-spacing: 0; min-width: 100%; }
table.presence th, table.presence td { padding: 0; text-align: center; border-bottom: 1px solid var(--line-soft); }

table.presence thead th {
  position: sticky; top: 0; z-index: 20;
  background: #fafbfd; border-bottom: 1px solid var(--line);
  font-weight: 600; color: var(--muted);
}
.c-name {
  position: sticky; left: 0; z-index: 15;
  min-width: 104px; width: 104px; padding: 0 16px !important;
  text-align: left !important; background: inherit;
  font-weight: 600; white-space: nowrap;
}
thead .c-name { z-index: 25; background: #fafbfd; }

.c-day { min-width: 28px; width: 28px; }
.c-day .d { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); padding: 7px 0 0; }
.c-day .wd {
  display: block; width: 100%; margin: 0; padding: 1px 0 6px;
  border: 0; background: none; cursor: pointer;
  font: inherit; font-size: 11px; color: var(--faint); transition: .15s;
}
.c-day .wd:hover { color: var(--accent); }
.c-day.restday { background: #fffbf2; }
.c-day.restday .d { color: var(--warn); }
.c-day.ov .wd { color: var(--accent-ink); font-weight: 700; }
.c-day.ov .wd::after { content: " *"; color: var(--accent); }
.c-day.today { background: var(--accent-weak); }
.c-day.today .d { color: var(--accent-ink); }

.c-sum {
  position: sticky; right: 62px; z-index: 15;
  min-width: 62px; width: 62px; background: inherit;
  font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink-2);
  border-left: 1px solid var(--line-soft);
}
.c-sum.last { right: 0; border-right: 0; }
thead .c-sum { z-index: 25; background: #fafbfd; color: var(--muted); font-size: 12px; }

table.presence tbody tr { background: #fff; }
table.presence tbody tr:nth-child(even) { background: #fcfdfe; }
table.presence tbody tr:hover { background: #f4f8ff; }

td.cell { height: 46px; cursor: pointer; position: relative; }
td.cell .tick {
  display: inline-flex; align-items: center; justify-content: center;
  width: 25px; height: 25px; border-radius: 8px;
  background: #eef2f8; color: transparent;
  font-size: 14px; font-weight: 700; line-height: 1;
  opacity: 0; transition: opacity .12s, background .12s, transform .12s;
}
td.cell:hover .tick { opacity: 1; }
td.cell:active .tick { transform: scale(.9); }
td.cell.on .tick { opacity: 1; background: var(--accent); color: #fff; }
td.cell.on:hover .tick { background: var(--accent-ink); }
td.cell.restday { background: rgba(255, 251, 242, .75); }
td.cell.today { background: rgba(239, 244, 255, .55); }

.legend { display: flex; gap: 20px; flex-wrap: wrap; color: var(--muted); font-size: 12.5px; padding: 12px 20px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; vertical-align: -2px; margin-right: 5px; }

.locked-banner {
  padding: 11px 20px; border-bottom: 1px solid #f6e0bb;
  background: var(--warn-weak); color: #92400e; font-size: 13.5px;
}
.locked-banner a { color: #92400e; font-weight: 600; }

table.presence.locked td.cell { cursor: not-allowed; }
table.presence.locked td.cell .tick { opacity: .55; }
table.presence.locked td.cell:not(.on) .tick { opacity: 0; }
table.presence.locked td.cell:not(.on):hover .tick { opacity: 0; }
table.presence.locked .wd { pointer-events: none; opacity: .55; cursor: default; }

/* ---------------------------------------------------------------- 月份导航 */
.monthnav { display: flex; align-items: center; gap: 4px; }
.monthnav a {
  display: inline-flex; align-items: center; justify-content: center;
  height: 34px; min-width: 34px; padding: 0 10px; border-radius: 9px;
  color: var(--muted); text-decoration: none; border: 1px solid var(--line);
  background: #fff; transition: .15s; font-size: 13px;
}
.monthnav a:hover { color: var(--accent-ink); border-color: #c7d2fe; background: var(--accent-weak); }
.monthnav .now { font-weight: 700; font-size: 15px; padding: 0 6px; min-width: auto; border: 0; background: none; }

/* ---------------------------------------------------------------- 登录 */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: radial-gradient(1200px 600px at 50% -10%, #e8efff, #f4f6fa);
}
.login-box {
  background: #fff; padding: 34px 32px; border-radius: 18px; width: 340px;
  box-shadow: 0 20px 60px -20px rgba(15, 23, 42, .28);
  display: flex; flex-direction: column; gap: 12px; border: 1px solid var(--line);
}
.login-box h1 { margin: 0; font-size: 21px; letter-spacing: -.3px; }
.login-box .hint { margin: 0 0 8px; color: var(--muted); font-size: 13px; }
.login-box input { width: 100%; }
.login-box button {
  padding: 11px; border-radius: 10px; border: 0; background: var(--accent);
  color: #fff; font: inherit; font-weight: 600; cursor: pointer; transition: .15s;
}
.login-box button:hover { background: var(--accent-ink); }

/* ---------------------------------------------------------------- 账单 */
.bill-sheet { max-width: 880px; }
.bill-head h2 { margin: 4px 0 12px; font-size: 19px; text-align: center; letter-spacing: .5px; }
.bill-meta {
  display: flex; gap: 22px; flex-wrap: wrap; color: var(--muted);
  font-size: 13px; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px dashed var(--line);
}
.bill-note { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.bill-table td, .bill-table th { padding: 11px 14px; }
.sign { display: flex; gap: 48px; margin-top: 34px; color: var(--muted); font-size: 13px; }

/* ---------------------------------------------------------------- print */
@media print {
  .no-print, .topbar, .flash, .legend { display: none !important; }
  body { background: #fff; }
  .wrap { max-width: none; padding: 0; }
  .card { border: 0; padding: 0; margin: 0; box-shadow: none; }
  .bill-sheet { max-width: none; }
  .grid th, .grid td { border-bottom: 1px solid #ccc; }
}

/* ---------------------------------------------------------------- narrow */
@media (max-width: 720px) {
  .wrap { padding: 16px 12px 40px; }
  .topbar { gap: 12px; padding: 0 14px; }
  .topbar nav a { padding: 7px 9px; font-size: 13px; }
  .brand { font-size: 14px; }
  .pagehead h1 { font-size: 18px; }
  .c-name { min-width: 76px; width: 76px; padding: 0 10px !important; }
}
