/* 天昱考勤：简洁浅色界面。颜色只用一种主色，其余靠灰度区分层级。 */
:root {
  color-scheme: light;
  --ink: #1f2937;
  --muted: #6b7280;
  --faint: #9ca3af;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --canvas: #f6f7f9;
  --surface: #ffffff;
  --hover: #f3f4f6;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-soft: #eef3ff;
  --green: #15803d;
  --green-soft: #ecfdf3;
  --amber: #b45309;
  --amber-soft: #fff7e6;
  --red: #dc2626;
  --red-soft: #fef2f2;
  --violet: #7c3aed;
  --radius: 8px;
  font-family: "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 14px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; color: var(--ink); background: var(--canvas); display: flex; flex-direction: column; min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; font-weight: 600; }

/* 登录 */
.login-view { flex: 1; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: min(380px, 100%);
  padding: 32px 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.login-title { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.login-title h1 { font-size: 20px; }
.login-title p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.login-card .connection-status { align-self: center; }

.brand-mark {
  width: 40px; height: 40px; flex: 0 0 40px;
  display: inline-grid; place-items: center;
  color: #fff; background: var(--accent);
  border-radius: 10px;
  font-size: 18px; font-weight: 700;
}
.brand-mark.small { width: 28px; height: 28px; flex-basis: 28px; border-radius: 7px; font-size: 14px; }

/* 表单 */
label { display: flex; flex-direction: column; gap: 6px; color: var(--ink); }
label > span { color: var(--muted); font-size: 12px; }
input, select, textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  outline: none;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12); }

/* 按钮 */
.button {
  min-height: 38px;
  padding: 8px 14px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  font-weight: 500;
  white-space: nowrap;
}
.button:hover:not(:disabled) { background: var(--hover); }
.button:disabled { cursor: not-allowed; opacity: 0.55; }
.button.primary { color: #fff; background: var(--accent); border-color: var(--accent); }
.button.primary:hover:not(:disabled) { background: var(--accent-dark); }
.button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.button.ghost:hover:not(:disabled) { color: var(--ink); background: var(--hover); }
.button.neutral { color: var(--ink); }
.button.danger-outline { color: var(--red); border-color: #f3c2c2; }
.button.danger-outline:hover:not(:disabled) { background: var(--red-soft); }
.button.wide { width: 100%; }
.button.compact { min-height: 32px; padding: 5px 10px; font-size: 13px; }
.button.action { min-width: 112px; min-height: 42px; }

.connection-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; white-space: nowrap; }
.connection-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.connection-status.online { color: var(--green); }
.connection-status.offline { color: var(--red); }

/* 框架 */
.app-shell { flex: 1; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: 52px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar-brand { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.topbar time { margin-right: 8px; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.identity { display: inline-flex; align-items: baseline; gap: 6px; padding: 0 8px; }
.identity strong { font-size: 13px; font-weight: 600; }
.identity span { color: var(--muted); font-size: 12px; }

.workspace { flex: 1; display: grid; grid-template-columns: 176px minmax(0, 1fr); }
.sidebar { padding: 14px 10px; background: var(--surface); border-right: 1px solid var(--line); }
.sidebar nav { position: sticky; top: 66px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  min-height: 38px;
  padding: 8px 12px;
  display: flex; align-items: center; justify-content: space-between;
  color: #4b5563;
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-size: 14px;
  text-align: left;
  text-decoration: none;
}
.nav-item:hover { color: var(--ink); background: var(--hover); }
.nav-item.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.nav-count { min-width: 20px; padding: 1px 6px; color: #fff; background: var(--red); border-radius: 10px; font-size: 11px; text-align: center; }

.main-content { min-width: 0; padding: 20px 24px 32px; }
.page-heading { min-height: 40px; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.page-heading h2 { font-size: 20px; }
.page-actions { display: flex; align-items: center; gap: 8px; }
.page { display: none; }
.page.active { display: block; }

/* 卡片与数字 */
.surface { margin-bottom: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.metric { padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.metric span { display: block; color: var(--muted); font-size: 12px; }
.metric strong { display: block; margin-top: 4px; font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.metric.attention strong { color: var(--red); }
.metric.good strong { color: var(--green); }

.status-board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.status-card { padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.status-card-heading { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 13px; }
.status-card-heading span::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--faint); }
.status-card.working .status-card-heading span::before { background: var(--green); }
.status-card.resting .status-card-heading span::before { background: var(--accent); }
.status-card.warning .status-card-heading span::before { background: #f59e0b; }
.status-card.overtime .status-card-heading span::before { background: var(--violet); }
.status-card-heading strong { color: var(--ink); font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.status-people { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.status-people span { padding: 2px 7px; color: #374151; background: var(--hover); border-radius: 4px; font-size: 12px; }
.status-people small { color: var(--faint); }

.attendance-actions { padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.attendance-actions h3 { font-size: 15px; }
.attendance-actions .muted { margin-top: 4px; font-size: 13px; }
.action-buttons { display: flex; gap: 8px; }
.muted { margin: 0; color: var(--muted); }
.section-header { padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.section-header h3 { font-size: 15px; }

/* 筛选条 */
.filter-bar, .toolbar {
  margin-bottom: 12px;
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px;
}
.filter-bar label { width: 160px; }
.filter-bar > .muted { align-self: center; font-size: 13px; }
.spacer { flex: 1; }

/* 表格 */
.table-wrap { width: 100%; overflow: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { padding: 10px 14px; border-bottom: 1px solid #f0f1f3; text-align: left; vertical-align: middle; }
th { position: sticky; top: 0; z-index: 1; color: var(--muted); background: #fafafa; font-size: 12px; font-weight: 500; border-bottom-color: var(--line); }
td { font-size: 13px; }
td.wrap { white-space: normal; min-width: 160px; max-width: 320px; }
tbody tr:hover { background: #fafbfc; }
tbody tr:last-child td { border-bottom: 0; }
tr.inactive td { color: var(--faint); }
.empty-row td { padding: 32px 14px; color: var(--faint); text-align: center; }
.cell-main, .cell-sub { display: block; }
.cell-main { font-weight: 500; }
.cell-sub { margin-top: 2px; color: var(--faint); font-size: 12px; }
.cell-time { font-variant-numeric: tabular-nums; }
.cell-note { display: block; color: var(--muted); font-size: 12px; }
.cell-time + .cell-note { margin-top: 1px; }
.cell-note.warn { color: var(--amber); }
.cell-note.bad { color: var(--red); }
.table-actions { display: flex; gap: 6px; }
.inline-select { width: auto; min-width: 88px; min-height: 30px; padding: 3px 8px; font-size: 13px; }
.action-menu { color: var(--accent); }

.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 500; }
.badge.normal, .badge.approved { color: var(--green); background: var(--green-soft); }
.badge.late, .badge.pending { color: var(--amber); background: var(--amber-soft); }
.badge.error, .badge.rejected { color: var(--red); background: var(--red-soft); }
.badge.neutral { color: var(--muted); background: var(--hover); }

/* 弹窗 */
.modal {
  width: min(600px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(17, 24, 39, 0.18);
}
.modal.wide-modal { width: min(720px, calc(100vw - 32px)); }
.modal.small-modal { width: min(420px, calc(100vw - 32px)); }
.modal::backdrop { background: rgba(17, 24, 39, 0.4); }
.modal form { max-height: calc(100vh - 42px); display: flex; flex-direction: column; }
.modal header { padding: 14px 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.modal header h3 { font-size: 16px; }
.modal footer { padding: 12px 18px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--line); }
.form-grid { padding: 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; overflow-y: auto; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid .muted { font-size: 12px; align-self: center; }
.form-stack { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.checkbox-field { min-height: 38px; flex-direction: row; align-items: center; gap: 8px; }
.checkbox-field input { width: 16px; min-height: 16px; height: 16px; }
.checkbox-field span { color: var(--ink); font-size: 13px; }
.icon-close { width: 30px; height: 30px; padding: 0; color: var(--muted); background: transparent; border: 0; border-radius: 6px; font-size: 20px; line-height: 1; }
.icon-close:hover { color: var(--ink); background: var(--hover); }
.field-note { margin: -4px 0 0; color: var(--muted); font-size: 12px; }

.toast {
  position: fixed; right: 20px; bottom: 44px; z-index: 100;
  min-width: 240px; max-width: min(420px, calc(100vw - 40px));
  padding: 11px 14px;
  color: #fff; background: #1f2937;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(17, 24, 39, 0.2);
}
.toast.error { background: #b91c1c; }
.toast.success { background: #166534; }

/* 备案号：每个页面底部都要显示 */
.icp-footer { padding: 10px 0 14px; text-align: center; font-size: 12px; }
.icp-footer a { color: var(--faint); text-decoration: none; }
.icp-footer a:hover { text-decoration: underline; }

@media (max-width: 1000px) {
  .status-board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .topbar { padding: 0 12px; }
  .topbar time, .identity span { display: none; }
  .workspace { display: block; }
  .sidebar { position: sticky; top: 52px; z-index: 15; padding: 6px 8px; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
  .sidebar nav { position: static; flex-direction: row; min-width: max-content; }
  .nav-item { min-height: 34px; padding: 6px 12px; gap: 6px; }
  .main-content { padding: 14px 12px 24px; }
  .attendance-actions { align-items: stretch; flex-direction: column; }
  .action-buttons { width: 100%; }
  .button.action { flex: 1; min-width: 0; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-bar label { flex: 1 1 140px; width: auto; }
  .filter-bar .spacer { display: none; }
  th, td { padding: 9px 10px; }
}

@media (max-width: 480px) {
  .identity { display: none; }
  .status-board { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
}

/* 考勤异常未写原因的提醒条 */
.notice-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 14px; padding: 10px 14px;
  color: var(--red); background: var(--red-soft);
  border: 1px solid #fecaca; border-radius: var(--radius);
  font-weight: 600;
}
.explanation-list { display: flex; flex-direction: column; gap: 12px; max-height: 60vh; overflow: auto; }
.explanation-item { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); }
.explanation-item strong { display: block; margin-bottom: 2px; }
.explanation-item .cell-note { margin-bottom: 8px; }
.explanation-item textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 6px; resize: vertical; }
.cell-note.explain { color: var(--ink); }

/* 工资 */
.salary-surface:empty { display: none; }
.salary-empty { margin: 0; padding: 18px 16px; }
.salary-card { padding: 16px; max-width: 420px; }
.salary-card h3 { margin-bottom: 10px; }
.salary-lines { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; }
.salary-lines dt { color: var(--muted); }
.salary-lines dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.salary-lines .total { font-weight: 700; color: var(--ink); }
.salary-table td.num, .salary-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.salary-table th, .salary-table td { padding-left: 6px; padding-right: 6px; }
.salary-table input { width: 76px; padding: 4px 6px; border: 1px solid var(--line-strong); border-radius: 4px; text-align: right; }
.salary-table input.name-input, .salary-table input.note-input { width: 84px; text-align: left; }
.salary-toolbar { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.salary-toolbar .spacer { flex: 1; }

/* tz6.5：各模块一种颜色（考勤绿、申请橙、扣分红、员工蓝、工资金、电脑&服务器紫），侧栏分组，页面标题带同色竖条 */
:root { --m-att: #15803d; --m-req: #c2410c; --m-score: #dc2626; --m-team: #2563eb; --m-pay: #a16207; --m-pc: #7c3aed; }
.nav-group { margin: 12px 12px 4px; color: var(--faint); font-size: 11px; letter-spacing: .08em; }
.nav-group:first-child { margin-top: 2px; }
.nav-item { justify-content: flex-start; gap: 9px; }
.nav-item::before { content: ""; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--nav-color, var(--faint)); }
.nav-item .nav-count { margin-left: auto; }
.m-att { --nav-color: var(--m-att); --nav-soft: #ecfdf3; }
.m-req { --nav-color: var(--m-req); --nav-soft: #fff4ec; }
.m-score { --nav-color: var(--m-score); --nav-soft: #fef2f2; }
.m-team { --nav-color: var(--m-team); --nav-soft: #eef3ff; }
.m-pay { --nav-color: var(--m-pay); --nav-soft: #fefbe8; }
.m-pc { --nav-color: var(--m-pc); --nav-soft: #f3efff; border-top: 1px dashed var(--line); border-radius: 0 0 6px 6px; }
.nav-item.active { color: var(--nav-color, var(--accent)); background: var(--nav-soft, var(--accent-soft)); }
.page-heading h2 { padding-left: 12px; border-left: 4px solid var(--accent); line-height: 1.2; }
.page-heading h2[data-module="overview"], .page-heading h2[data-module="attendance"], .page-heading h2[data-module="monthly"] { border-left-color: var(--m-att); }
.page-heading h2[data-module="requests"] { border-left-color: var(--m-req); }
.page-heading h2[data-module="scores"] { border-left-color: var(--m-score); }
.page-heading h2[data-module="team"] { border-left-color: var(--m-team); }
.page-heading h2[data-module="salary"] { border-left-color: var(--m-pay); }
.role-tag { display: inline-block; margin-top: 3px; padding: 0 6px; border-radius: 4px; font-size: 11px; line-height: 18px; color: var(--muted); background: var(--hover); }
.role-warehouse { color: #b45309; background: #fff7e6; }
.role-assistant { color: #1d4ed8; background: #eef3ff; }
.role-admin { color: #15803d; background: #ecfdf3; }
tbody tr:nth-child(even) { background: #fbfcfd; }
tbody tr:nth-child(even):hover, tbody tr:hover { background: #f3f6fb; }
@media (max-width: 760px) { .nav-group { display: none; } .m-pc { border-top: 0; } }

/* tz6.6：消除异常按钮单独一行，不贴着说明文字 */
.anomaly-btn { display: block; margin: 6px 0 0; }
