:root {
  /* Kanto 品牌色：金 #AD9356 / 暖灰 #6C6763（取自官方 logo 原稿）
     整体走「estetica minimalista」——暖中性底 + 金色点缀，红只留给异常状态 */
  --bg: #f6f5f2;
  --panel: #ffffff;
  --ink: #1f1d1a;
  --ink-2: #57534e;
  --ink-3: #a8a29a;
  --line: #e7e4de;
  --brand: #AD9356;
  --brand-2: #8f7842;
  --brand-soft: #f3eee2;
  --accent: #6C6763;
  --ok: #059669;
  --warn: #d97706;
  --bad: #dc2626;
  --sidebar: #1f1d1a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(31,29,26,.05), 0 1px 3px rgba(31,29,26,.08);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", Inter, system-ui, sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }

/* ───────── login ───────── */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(155deg, #2b2823 0%, #1f1d1a 55%, #14120f 100%);
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 390px; background: #fdfcfa; border-radius: 4px;
  padding: 44px 36px 34px; box-shadow: 0 30px 70px rgba(0,0,0,.42);
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; letter-spacing: .5px; }
.login-card .sub { color: var(--ink-3); margin: 0 0 22px; font-size: 13px; text-align: center; }

/* ── 品牌标识 ── */
.logo-block { text-align: center; margin-bottom: 26px; }
.logo-block svg { display: block; margin: 0 auto; }
.logo-block .wordmark {
  font-size: 26px; font-weight: 600; letter-spacing: .42em;
  text-indent: .42em; color: var(--ink); line-height: 1;
}
.logo-block .wordrule {
  width: 34px; height: 1px; background: var(--brand);
  margin: 20px auto 12px;
}
.logo-block .wordsub {
  font-size: 10px; letter-spacing: .26em; text-indent: .26em;
  color: var(--ink-3); text-transform: uppercase; font-weight: 500;
}
.brand-mark { display: inline-flex; flex: 0 0 auto; }
.brand-mark svg { display: block; border-radius: 8px; }
.brand-txt { min-width: 0; }

/* ───────── layout ───────── */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 208px; flex: 0 0 208px; background: var(--sidebar); color: #d1d5db;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { padding: 16px 16px 14px; border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: 10px; }
.brand b { color: #f2efe8; font-size: 15px; letter-spacing: 3px; display: block; }
.brand span { font-size: 10px; color: #8b8579; letter-spacing: 1.4px; text-transform: uppercase; }
.nav { flex: 1; overflow-y: auto; padding: 10px 8px; }
.nav a {
  display: flex; align-items: center; gap: 9px; padding: 9px 11px; border-radius: 8px;
  color: #b5afa4; font-size: 13.5px; margin-bottom: 2px;
}
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.on { background: var(--brand); color: #fff; font-weight: 600; }
.nav .ico { width: 17px; text-align: center; font-size: 14px; }
.nav .group { font-size: 10.5px; color: #6b6459; padding: 14px 12px 5px; letter-spacing: 1.2px; text-transform: uppercase; }
.sidefoot { padding: 12px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; color: #8b8579; }
.sidefoot b { color: #e8e4db; display: block; font-size: 13px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--panel); border-bottom: 1px solid var(--line); padding: 10px 18px;
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 30;
}
.topbar h2 { margin: 0; font-size: 16px; font-weight: 650; margin-right: auto; }
.content { padding: 18px; flex: 1; }

/* ───────── controls ───────── */
select, input[type=text], input[type=date], input[type=number], input[type=password],
input[type=email], input[type=time], textarea {
  padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
  outline: none; max-width: 100%;
}
select:focus, input:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(173,147,86,.16); }
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 13px; font-weight: 500;
  white-space: nowrap;
}
.btn:hover { background: #f8f6f2; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 4px; font-weight: 500; }
.field input, .field select, .field textarea { width: 100%; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 12px; }

/* ───────── cards / tables ───────── */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; }
.card > h3 { margin: 0; padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 14px; display: flex; align-items: center; gap: 8px; }
.card > h3 .right { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.card .body { padding: 14px 16px; }
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 7px 9px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: #faf9f6; font-weight: 600; font-size: 12px; color: var(--ink-2); position: sticky; top: 0; z-index: 2; }
tbody tr:hover { background: #fbfaf7; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tfoot td { font-weight: 700; background: #f8f6f2; border-top: 2px solid var(--line); }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.tile .k { font-size: 11.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .6px; }
.tile .v { font-size: 25px; font-weight: 680; margin-top: 5px; font-variant-numeric: tabular-nums; }
.tile .d { font-size: 12px; color: var(--ink-2); margin-top: 3px; }

.pill { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 600; }
.pill.ok { background: #d1fae5; color: #065f46; }
.pill.warn { background: #fef3c7; color: #92400e; }
.pill.bad { background: #fee2e2; color: #991b1b; }
.pill.info { background: #dbeafe; color: #1e40af; }
.pill.mute { background: #f0eee9; color: #57534e; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }

/* ───────── attendance grid ───────── */
.att-grid td, .att-grid th { padding: 0; border: 1px solid var(--line); }
.att-grid .name { padding: 4px 8px; position: sticky; left: 0; background: #fff; z-index: 1; min-width: 150px; white-space: nowrap; }
.att-grid th.name { background: #faf9f6; z-index: 3; }
.att-grid .cell {
  width: 30px; height: 30px; text-align: center; cursor: pointer; font-size: 13px;
  user-select: none; position: relative;
}
.att-grid .cell:hover { outline: 2px solid var(--accent); outline-offset: -2px; }
.att-grid .cell.we { background: #fffbeb; }
.att-grid .cell.absent { background: #fee2e2; color: #991b1b; font-weight: 700; }
.att-grid .cell.present { color: #047857; }
.att-grid .cell.half { color: #b45309; }
.att-grid .cell.rest { color: #6b7280; }
.att-grid .cell.leave, .att-grid .cell.sick { color: #1d4ed8; background: #eff6ff; }
.att-grid .cell.half_am { color: #0369a1; background: #f0f9ff; }
.att-grid .cell.half_pm { color: #6d28d9; background: #f5f3ff; }
.att-grid .cell.issue { box-shadow: inset 0 0 0 2px var(--bad); }
.att-grid .cell.edited::after {
  content: ''; position: absolute; top: 1px; right: 1px; width: 4px; height: 4px;
  background: var(--warn); border-radius: 50%;
}
.att-grid .flags { font-size: 8px; position: absolute; bottom: 0; left: 0; right: 0; color: var(--bad); line-height: 1; }
.att-grid th.day { width: 30px; text-align: center; font-size: 11px; padding: 2px 0; }
.att-grid th.day small { display: block; font-weight: 400; color: var(--ink-3); font-size: 9.5px; }
.att-grid th.day.we { background: #fef3c7; }
.att-grid td.sum { text-align: center; font-size: 12px; background: #faf9f6; min-width: 34px; font-variant-numeric: tabular-nums; }

/* ───────── schedule ───────── */
.sched td, .sched th { border: 1px solid var(--line); vertical-align: top; padding: 3px; }
.sched .name { position: sticky; left: 0; background: #fff; min-width: 150px; padding: 6px 8px; }
.sched .slot { min-width: 108px; height: 52px; cursor: pointer; border-radius: 6px; }
.sched .slot:hover { background: #f0fdfa; }
.sched .chip { border-radius: 6px; padding: 4px 6px; font-size: 11.5px; line-height: 1.35; color: #fff; height: 100%; }
.sched .chip.rest { background: #9ca3af; }
.sched .chip .h { font-weight: 700; }
.sched .weektot { background: #faf9f6; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.sched th.we { background: #fef3c7; }

/* ───────── modal / toast ───────── */
.modal-bg {
  position: fixed; inset: 0; background: rgba(17,24,39,.5); display: flex;
  align-items: center; justify-content: center; z-index: 100; padding: 16px;
}
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 560px; max-height: 88vh;
  overflow: auto; box-shadow: 0 24px 60px rgba(0,0,0,.3);
}
.modal h3 { margin: 0; padding: 15px 18px; border-bottom: 1px solid var(--line); font-size: 15px; }
.modal .body { padding: 16px 18px; }
.modal .foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; position: sticky; bottom: 0; background: #fff; }
#toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 200;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.toast {
  background: #111827; color: #fff; padding: 10px 16px; border-radius: 9px; font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: 90vw;
}
.toast.bad { background: var(--bad); }
.toast.ok { background: var(--ok); }
.empty { padding: 36px; text-align: center; color: var(--ink-3); }
.legend { font-size: 11.5px; color: var(--ink-2); display: flex; gap: 12px; flex-wrap: wrap; padding: 8px 16px; border-top: 1px solid var(--line); }

/* ───────── responsive ───────── */
@media (max-width: 820px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; }
  .brand { display: flex; align-items: baseline; gap: 8px; padding: 12px 14px; }
  .brand span { font-size: 10px; }
  .nav { display: flex; overflow-x: auto; padding: 6px; gap: 4px; }
  .nav a { white-space: nowrap; padding: 7px 11px; }
  .nav .group, .sidefoot { display: none; }
  .content { padding: 12px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .topbar { padding: 8px 12px; }
  .topbar h2 { width: 100%; }
}
@media print {
  .sidebar, .topbar, .btn { display: none !important; }
  .content { padding: 0; }
  .card { break-inside: avoid; box-shadow: none; }
}

/* 可点击排序的表头 */
.att-grid th.sortable { cursor: pointer; user-select: none; }
.att-grid th.sortable:hover { background: #f0ece3; }
.sort-ind {
  display: inline-block; margin-left: 5px; padding: 1px 5px; border-radius: 4px;
  background: var(--brand); color: #fff; font-size: 9.5px; font-weight: 700;
  letter-spacing: .3px; vertical-align: 1px;
}
