/* =========================================================================
   AI-绩效-全员工作成果 · 全站样式
   设计语言沿用 interview 项目：绿色主色 #55BB61、克制留白、语义组件。
   纯本地样式，无外部字体 / 图标 / CDN。
   ========================================================================= */

/* --- 设计令牌 ----------------------------------------------------------- */
:root {
  /* 品牌色 */
  --primary: #55BB61;
  --primary-deep: #3A9A47;
  --primary-ink: #2F7D3A;          /* 白底小字可读的深绿 */
  --primary-bg: #F0FAF2;
  --primary-glow: rgba(85, 187, 97, .10);

  /* 语义色 */
  --ok: #34c759;
  --warn: #ff9f0a;
  --err: #ff3b30;
  --accent: #f0b429;
  --ok-bg: #eaf9ee;
  --ok-ink: #1d7a35;
  --warn-bg: #fff6e6;
  --warn-ink: #9a5b00;
  --err-bg: #fdeceb;
  --err-ink: #a5231b;

  /* 文本 */
  --tx: #1d1d1f;
  --tx2: #86868b;
  --tx3: #aeaeb2;
  --tx-soft: #5c5c61;              /* 次要正文，满足 4.5:1 对比度 */

  /* 背景与线条 */
  --bg: #f5f5f7;
  --bg-sub: #eeeef2;
  --surface: #fff;
  --line: #e8e8ed;
  --line-strong: #d7d7de;

  /* 形状与阴影 */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .06), 0 8px 24px rgba(0, 0, 0, .04);
  --shadow-hover: 0 2px 6px rgba(0, 0, 0, .07), 0 14px 32px rgba(0, 0, 0, .07);

  /* 间距阶梯 */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 20px;
  --s6: 24px;
  --s7: 32px;

  --topbar-h: 60px;
  --ease: cubic-bezier(.4, 0, .2, 1);
}

/* --- 基础 --------------------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--tx);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary-ink); }
a:hover { color: var(--primary-deep); }

h1 { font-size: 24px; line-height: 1.3; margin: 0 0 var(--s2); letter-spacing: -.01em; }
h2 { font-size: 20px; line-height: 1.35; margin: var(--s5) 0 var(--s2); }
h3 { font-size: 16px; line-height: 1.4; margin: 0 0 var(--s1); }

p { margin: 0 0 var(--s3); }

img, svg { max-width: 100%; }

.hidden { display: none !important; }

.muted { color: var(--tx-soft); font-size: 14px; }
.hint { color: var(--err-ink); font-size: 13px; margin-top: var(--s1); }

:focus-visible {
  outline: 2px solid var(--primary-deep);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: var(--primary-glow); }

/* --- 顶栏 --------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  min-height: var(--topbar-h);
  padding: var(--s2) var(--s5);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  color: var(--tx);
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -.01em;
}
.brand:hover { color: var(--tx); }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: var(--primary-bg);
  color: var(--primary-deep);
  font-size: 16px;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s4);
  font-size: 14px;
}
.nav a {
  color: var(--tx-soft);
  text-decoration: none;
  padding: var(--s1) 0;
  border-bottom: 2px solid transparent;
}
.nav a:hover { color: var(--tx); }
.nav a.is-active {
  color: var(--primary-ink);
  border-bottom-color: var(--primary);
  font-weight: 600;
}
.who {
  color: var(--tx-soft);
  font-weight: 600;
  padding-right: var(--s1);
}

/* --- 页面容器 ----------------------------------------------------------- */
.page {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: var(--s6) var(--s5) 72px;
}
/* 管理端表格列多，单独放宽；员工端保持窄栏阅读 */
.page-wide { max-width: 1440px; }

.page-head,
.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s3);
  margin-bottom: var(--s4);
}
.page-head h1,
.section-head h1 { margin-bottom: 0; }
.section-head h2 { margin: 0; }
.page-head .sub,
.section-head .sub { margin: var(--s1) 0 0; }
.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2);
}

/* --- 卡片 --------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--s5);
  margin-bottom: var(--s5);
  box-shadow: var(--shadow);
}
.card.narrow,
.login-card { max-width: 480px; margin-left: auto; margin-right: auto; }
.card > :last-child { margin-bottom: 0; }

.card-sub {
  background: var(--bg-sub);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: var(--s4);
}

/* --- 按钮 --------------------------------------------------------------- */
.btn,
.button,
.btn-p,
button.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s1);
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--tx);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background .18s var(--ease), border-color .18s var(--ease),
    color .18s var(--ease), box-shadow .18s var(--ease);
}
.btn:hover,
.button:hover,
.btn-p:hover,
button.primary:hover {
  border-color: var(--primary);
  color: var(--primary-ink);
  box-shadow: 0 2px 10px var(--primary-glow);
}

.btn-p,
.button.primary,
button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}
.btn-p:hover,
.button.primary:hover,
button.primary:hover {
  background: var(--primary-deep);
  border-color: var(--primary-deep);
  color: #fff;
}

.btn-s { min-height: 32px; padding: 4px 10px; font-size: 13px; border-radius: 8px; }

.btn-danger {
  color: var(--err-ink);
  border-color: #f2c4c0;
  background: var(--err-bg);
}
.btn-danger:hover { color: var(--err-ink); border-color: var(--err); }

.btn:disabled,
.button:disabled,
button:disabled,
.btn.is-loading,
.button.is-loading {
  opacity: .62;
  cursor: not-allowed;
  box-shadow: none;
}

.link-button {
  display: inline;
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--primary-ink);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
}
.link-button:hover { color: var(--primary-deep); text-decoration: underline; }
.link-button.danger { color: var(--err-ink); }
.link-button.danger:hover { color: #8a1c15; }

.inline-form { display: inline; }

/* --- 表单 --------------------------------------------------------------- */
.form { display: grid; gap: var(--s4); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s4);
}
.form-grid .span-2 { grid-column: 1 / -1; }

.form-section {
  grid-column: 1 / -1;
  margin: 0;
  padding: var(--s4);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.form-section > legend {
  padding: 0 var(--s2);
  font-size: 14px;
  font-weight: 700;
  color: var(--tx);
}
.form-section .form-grid { margin-top: var(--s1); }

.field { display: grid; gap: 6px; }
.field > span,
.field > label,
.field legend {
  font-size: 13px;
  font-weight: 600;
  color: var(--tx-soft);
  line-height: 1.35;
}
.field .req { color: var(--err); margin-left: 2px; }

.field input[type="text"],
.field input[type="tel"],
.field input[type="password"],
.field input[type="number"],
.field input[type="date"],
.field input[type="datetime-local"],
.field input[type="file"],
.field select,
.field textarea,
.input {
  width: 100%;
  min-height: 40px;
  padding: 8px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--tx);
  font: inherit;
  font-size: 14px;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.field input:hover,
.field select:hover,
.field textarea:hover,
.input:hover { border-color: #bdbdc6; }
.field input:focus,
.field select:focus,
.field textarea:focus,
.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.field input:disabled,
.field select:disabled,
.field textarea:disabled,
.field input[readonly],
.field select[readonly] {
  background: var(--bg-sub);
  color: var(--tx-soft);
  cursor: not-allowed;
}
.field textarea { min-height: 96px; resize: vertical; line-height: 1.55; }
.field input[type="file"] { padding: 6px 8px; }

.field-error {
  color: var(--err-ink);
  font-size: 12px;
}
.form-error {
  display: flex;
  align-items: flex-start;
  gap: var(--s2);
  padding: 10px 14px;
  border: 1px solid #f2c4c0;
  border-radius: var(--radius-sm);
  background: var(--err-bg);
  color: var(--err-ink);
  font-size: 14px;
}

.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2) var(--s5);
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.radio-group legend { padding: 0 4px; }
.radio-group label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 400;
  color: var(--tx);
  cursor: pointer;
}
.radio-group input[type="radio"] { width: 16px; height: 16px; accent-color: var(--primary-deep); }

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--tx-soft);
  cursor: pointer;
}
.check input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary-deep); }

/* --- 筛选栏 / 工具栏 ---------------------------------------------------- */
.filter-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 0 0 var(--s4);
}
.filter-form input[type="text"],
.filter-form input[type="number"],
.filter-form input[type="date"],
.filter-form select {
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--tx);
  font: inherit;
  font-size: 14px;
  max-width: 100%;
}
.filter-form input[type="text"] { min-width: 180px; }
.filter-form input:focus,
.filter-form select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.filter-form.filter-rows {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  align-items: end;
  padding: var(--s4);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.filter-form.filter-rows .filter-actions {
  display: flex;
  align-items: center;
  gap: var(--s2);
}
.filter-form.filter-rows .check { min-height: 38px; }

.table-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  margin-bottom: var(--s3);
}

.batch-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2);
  margin-bottom: var(--s3);
  padding: 10px 12px;
  border: 1px solid #f0dfb6;
  border-radius: var(--radius-sm);
  background: var(--warn-bg);
}
.batch-bar .batch-title { font-weight: 600; color: var(--warn-ink); }
.batch-bar input[type="text"] {
  flex: 1 1 220px;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid #e5c98b;
  border-radius: 9px;
  background: var(--surface);
  font: inherit;
}

/* --- 表格 --------------------------------------------------------------- */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-sm);
}

table,
.key-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

table thead th,
.key-table thead th {
  position: relative;
  padding: 10px 12px;
  background: var(--bg-sub);
  color: var(--tx-soft);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}

table tbody td,
.key-table tbody td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  overflow-wrap: anywhere;
}
table tbody tr:last-child td { border-bottom: 0; }
table tbody tr:hover td,
.key-table tbody tr:hover td { background: #fafafb; }

table td .muted,
.key-table td .muted { font-size: 12px; }

.row-deleted { opacity: .55; }
.row-actions { white-space: nowrap; }
.row-actions a,
.row-actions .link-button { margin-right: 10px; }
.row-actions > *:last-child { margin-right: 0; }

/* 宽表：容器内横向滚动，短字段不逐字换行 */
.entries-table { min-width: 1160px; }
.employees-table { min-width: 820px; }
.projects-table { min-width: 880px; }
.periods-table { min-width: 720px; }
.requests-table { min-width: 900px; }
.departments-table { min-width: 640px; }
.dashboard-table { min-width: 720px; }
.stats-person { min-width: 1080px; }
.stats-dept { min-width: 980px; }
.stats-project { min-width: 960px; }

.entries-table th:first-child,
.entries-table td:first-child { width: 42px; }

.entries-table td:nth-child(2),
.entries-table td:nth-child(5),
.entries-table td:nth-child(7),
.entries-table td:nth-child(8),
.entries-table td:nth-child(9),
.entries-table td:nth-child(10),
.employees-table td:nth-child(1),
.employees-table td:nth-child(2),
.employees-table td:nth-child(3),
.employees-table td:nth-child(4),
.employees-table td:nth-child(6),
.employees-table td:nth-child(7),
.projects-table td:nth-child(1),
.projects-table td:nth-child(2),
.projects-table td:nth-child(3),
.projects-table td:nth-child(4),
.projects-table td:nth-child(5),
.projects-table td:nth-child(6),
.projects-table td:nth-child(7),
.projects-table td:nth-child(8),
.periods-table td,
.requests-table td:nth-child(1),
.requests-table td:nth-child(2),
.requests-table td:nth-child(3),
.requests-table td:nth-child(6),
.departments-table td:nth-child(2),
.departments-table td:nth-child(3),
.dashboard-table td:nth-child(1),
.dashboard-table td:nth-child(4),
.dashboard-table td:nth-child(5),
.stats-person td,
.stats-dept td:nth-child(1),
.stats-dept td:nth-child(3),
.stats-dept td:nth-child(4),
.stats-dept td:nth-child(5),
.stats-project td:nth-child(1),
.stats-project td:nth-child(2),
.stats-project td:nth-child(3),
.stats-project td:nth-child(4),
.stats-project td:nth-child(5) {
  white-space: nowrap;
}

/* --- 状态标记 ----------------------------------------------------------- */
.tag,
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.6;
  vertical-align: middle;
  white-space: nowrap;
}
.badge { background: var(--bg-sub); color: var(--tx-soft); }
.badge.open,
.tag-ok { background: var(--ok-bg); border-color: #c6ebd0; color: var(--ok-ink); }
.badge.closed,
.tag-warn { background: var(--warn-bg); border-color: #f2ddb2; color: var(--warn-ink); }
.tag-err { background: var(--err-bg); border-color: #f2c4c0; color: var(--err-ink); }
.tag-muted { background: var(--bg-sub); color: var(--tx-soft); }

/* --- 提示 / 空态 --------------------------------------------------------- */
.flash {
  padding: 10px 14px;
  margin-bottom: var(--s4);
  border: 1px solid #c6ebd0;
  border-radius: var(--radius-sm);
  background: var(--ok-bg);
  color: var(--ok-ink);
  font-size: 14px;
}
.flash.error {
  border-color: #f2c4c0;
  background: var(--err-bg);
  color: var(--err-ink);
}

.empty,
.empty-state {
  color: var(--tx-soft);
  font-size: 14px;
}
.empty { padding: var(--s6) 0; text-align: center; }

.empty-state {
  display: grid;
  justify-items: center;
  gap: var(--s2);
  padding: var(--s7) var(--s4);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
}
.empty-state .empty-icon { font-size: 28px; line-height: 1; }
.empty-state .empty-title { font-size: 16px; font-weight: 700; color: var(--tx); }
.empty-state .empty-desc { max-width: 440px; margin: 0; color: var(--tx-soft); }
.empty-state .actions { justify-content: center; margin-top: var(--s1); }

/* --- Toast -------------------------------------------------------------- */
.toast-stack {
  position: fixed;
  top: calc(var(--topbar-h) + 12px);
  right: var(--s5);
  z-index: 1000;
  display: grid;
  gap: 10px;
  width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--s2);
  padding: 12px 12px 12px 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-hover);
  color: var(--tx);
  font-size: 14px;
  pointer-events: auto;
  animation: toast-in .22s var(--ease);
  transition: opacity .18s var(--ease), transform .18s var(--ease);
}
.toast-ok { border-left-color: var(--ok); }
.toast-err { border-left-color: var(--err); }
.toast-text { flex: 1; overflow-wrap: anywhere; }
.toast-close {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--tx-soft);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.toast-close:hover { background: var(--bg-sub); color: var(--tx); }
.toast.is-hiding { opacity: 0; transform: translateY(-6px); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- 指标卡 ------------------------------------------------------------- */
.stat-grid,
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--s3);
  margin: var(--s3) 0 var(--s4);
}

.stat,
.metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.metric { position: relative; overflow: hidden; }
.metric::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--primary);
  opacity: .75;
}
.metric-hero {
  background: linear-gradient(180deg, var(--primary-bg), var(--surface));
  border-color: #cdebd3;
}

.stat-value,
.metric-value {
  font-size: 24px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -.02em;
}
.stat-label,
.metric-label {
  font-size: 12px;
  color: var(--tx-soft);
}
.stat-label a,
.metric-label a { color: var(--primary-ink); font-weight: 600; }
.metric-note { font-size: 12px; color: var(--tx2); }

/* --- 管理端布局与侧栏 --------------------------------------------------- */
.layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: var(--s6);
  align-items: start;
}

.sidebar {
  position: sticky;
  top: calc(var(--topbar-h) + var(--s5));
  max-height: calc(100dvh - var(--topbar-h) - 40px);
  overflow-y: auto;
  padding: var(--s3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.sidebar-nav { display: grid; gap: var(--s2); }

.sidebar-group {
  display: grid;
  gap: 2px;
  padding-bottom: var(--s2);
  border-bottom: 1px solid var(--line);
}
.sidebar-group:last-child { padding-bottom: 0; border-bottom: 0; }

.sidebar-title {
  padding: var(--s1) var(--s2);
  color: var(--tx2);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.sidebar-link {
  display: flex;
  align-items: center;
  min-height: 36px;
  padding: 6px 10px;
  border-radius: 9px;
  color: var(--tx-soft);
  font-size: 14px;
  text-decoration: none;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.sidebar-link:hover { background: var(--bg-sub); color: var(--tx); }
.sidebar-link.is-active {
  background: var(--primary-bg);
  color: var(--primary-ink);
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--primary);
}

.main { min-width: 0; }

/* 兼容旧版横向管理导航 */
.admin-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  margin-bottom: var(--s4);
}
.admin-nav a {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--tx-soft);
  font-size: 13px;
  text-decoration: none;
}
.admin-nav a:hover { border-color: var(--primary); color: var(--primary-ink); }

/* --- 折叠面板 / 行内详情 ------------------------------------------------ */
details.inline-details,
.inline-details {
  display: inline-block;
  margin-left: 6px;
  vertical-align: top;
}
details.inline-details[open],
.inline-details[open] {
  display: block;
  margin: var(--s2) 0 0;
  padding: var(--s3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-sub);
}
.inline-details summary {
  color: var(--primary-ink);
  font-size: 13px;
  cursor: pointer;
  list-style-position: inside;
}
.inline-details summary:hover { color: var(--primary-deep); }
.inline-details > form { margin-top: var(--s2); }

/* --- 登录 / 改密 -------------------------------------------------------- */
.auth-wrap {
  display: grid;
  place-items: center;
  min-height: calc(100dvh - var(--topbar-h) - 120px);
  padding: var(--s4) 0;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  padding: var(--s6);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.auth-card .brand-mark { width: 44px; height: 44px; border-radius: 14px; font-size: 22px; }
.auth-head { display: grid; justify-items: center; gap: var(--s2); margin-bottom: var(--s5); text-align: center; }
.auth-head h1 { margin: 0; font-size: 22px; }
.auth-head p { margin: 0; font-size: 13px; }
.auth-card .form { gap: var(--s4); }
.auth-card .field input { min-height: 44px; }
.auth-card .btn-p,
.auth-card .button.primary { width: 100%; min-height: 44px; font-size: 15px; }

/* --- 员工端 ------------------------------------------------------------- */
.period-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  padding: 16px 18px;
  margin-bottom: var(--s5);
  border: 1px solid #cdebd3;
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--primary-bg), #fff);
}
.period-banner h2 { margin: 0 0 2px; font-size: 18px; }
.period-banner .muted { margin: 0; }
.period-banner.is-closed {
  border-color: #f2ddb2;
  background: linear-gradient(180deg, var(--warn-bg), #fff);
}

.entry-list { display: grid; gap: var(--s3); }
.entry-card {
  display: grid;
  gap: 10px;
  padding: var(--s4);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.entry-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s2);
}
.entry-card h3 { margin: 0; font-size: 16px; overflow-wrap: anywhere; }
.entry-card p { margin: 0; }
.entry-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s1) var(--s4);
  color: var(--tx-soft);
  font-size: 13px;
}
.entry-meta b { color: var(--tx); font-weight: 600; }
.entry-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2);
}
.entry-card .hint { margin: 0; }

.timeline { display: grid; gap: var(--s3); }
.timeline-item {
  position: relative;
  padding-left: var(--s5);
  border-left: 2px solid var(--line);
}
.timeline-item::before {
  content: "";
  position: absolute;
  top: 6px;
  left: -6px;
  width: 10px;
  height: 10px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--primary);
}
.timeline-item.is-closed::before { background: var(--warn); }
.timeline-item h2 { margin: 0 0 var(--s2); font-size: 17px; }
.history-group {
  margin-top: var(--s5);
  padding-top: var(--s3);
  border-top: 1px solid var(--line);
}
.history-group:first-of-type { margin-top: var(--s3); padding-top: 0; border-top: 0; }

.sticky-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s2);
  margin-top: var(--s2);
}
.sticky-actions .btn,
.sticky-actions .button { min-width: 140px; }

/* --- 日志 --------------------------------------------------------------- */
.log-json {
  max-width: 280px;
  color: var(--tx-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
  word-break: break-word;
}
pre.log-json {
  max-width: none;
  margin: 0 0 var(--s2);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-sub);
  white-space: pre-wrap;
}
.auth-card .form-section { width: 100%; }
.log-list { display: grid; gap: var(--s3); }
.log-card {
  display: grid;
  gap: var(--s2);
  padding: var(--s4);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.log-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  color: var(--tx-soft);
  font-size: 13px;
}
.log-card-title { color: var(--tx); font-size: 14px; font-weight: 600; }
.log-card-body { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); font-size: 13px; }

/* --- 分页 --------------------------------------------------------------- */
.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--s3);
  margin-top: var(--s5);
  font-size: 14px;
}
.pager-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 4px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--tx-soft);
  text-decoration: none;
}
.pager-link:hover { border-color: var(--primary); color: var(--primary-ink); }
.pager-link.is-disabled { opacity: .45; pointer-events: none; }
.pager-status { color: var(--tx-soft); font-size: 13px; }

/* --- 两列布局 ----------------------------------------------------------- */
.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s3);
}

/* --- 响应式：701–1099px 折叠侧栏为横向导航 ------------------------------ */
@media (max-width: 1099px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: var(--s4); }
  .sidebar {
    position: static;
    max-height: none;
    overflow: visible;
    padding: var(--s2) var(--s3);
  }
  .sidebar-nav { display: flex; flex-wrap: wrap; gap: var(--s2); }
  .sidebar-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    padding: 0;
    border: 0;
  }
  .sidebar-title { padding: 0 6px 0 0; white-space: nowrap; }
  .sidebar-link { min-height: 32px; padding: 4px 10px; }
  .sidebar-link.is-active { box-shadow: inset 0 -2px 0 var(--primary); }

  .entries-table th:nth-child(2),
  .entries-table td:nth-child(2),
  .employees-table th:nth-child(1),
  .employees-table td:nth-child(1),
  .projects-table th:nth-child(1),
  .projects-table td:nth-child(1),
  .periods-table th:nth-child(1),
  .periods-table td:nth-child(1),
  .dashboard-table th:nth-child(1),
  .dashboard-table td:nth-child(1),
  .departments-table th:nth-child(1),
  .departments-table td:nth-child(1) {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--surface);
    box-shadow: 1px 0 0 var(--line);
  }
  .entries-table thead th:nth-child(2),
  .employees-table thead th:nth-child(1),
  .projects-table thead th:nth-child(1),
  .periods-table thead th:nth-child(1),
  .dashboard-table thead th:nth-child(1),
  .departments-table thead th:nth-child(1) { background: var(--bg-sub); z-index: 3; }
}

/* --- 响应式：≤700px 单列移动端 ------------------------------------------ */
@media (max-width: 700px) {
  body { font-size: 14px; }

  .topbar { padding: var(--s2) var(--s3); }
  .brand { font-size: 15px; }
  .nav { gap: var(--s3); font-size: 13px; }

  .page { padding: var(--s4) var(--s3) 88px; }
  .card { padding: var(--s4); border-radius: var(--radius-sm); }
  h1 { font-size: 20px; }

  .page-head,
  .section-head { flex-direction: column; align-items: stretch; }
  .actions { width: 100%; }
  .actions .btn,
  .actions .button { flex: 1 1 auto; }

  .form-grid,
  .two-col { grid-template-columns: minmax(0, 1fr); }

  .field input,
  .field select,
  .field textarea,
  .filter-form input,
  .filter-form select { min-height: 44px; }
  .auth-card .field input { min-height: 44px; }

  .filter-form { display: grid; grid-template-columns: minmax(0, 1fr); }
  .filter-form input[type="text"] { min-width: 0; }
  .filter-form .btn,
  .filter-form .button { width: 100%; }

  .table-toolbar { flex-direction: column; align-items: stretch; }

  .toast-stack {
    top: calc(var(--topbar-h) + 8px);
    right: var(--s3);
    left: var(--s3);
    width: auto;
  }

  .metric-grid,
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-value,
  .stat-value { font-size: 21px; }

  .entry-actions .button,
  .entry-actions .btn { min-height: 44px; }

  .row-actions a,
  .row-actions .link-button { display: inline-flex; min-height: 32px; align-items: center; }

  .sticky-actions {
    position: sticky;
    bottom: 0;
    z-index: 30;
    margin: var(--s3) calc(-1 * var(--s3)) calc(-1 * var(--s4));
    padding: 12px var(--s3) calc(12px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, .96);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(8px);
  }
  .sticky-actions { flex-wrap: nowrap; }
  .sticky-actions .btn,
  .sticky-actions .button,
  .sticky-actions .btn-p { flex: 1 1 0; width: auto; min-width: 0; min-height: 46px; }

  .period-banner { padding: 14px; }
  .auth-wrap { min-height: auto; padding: 0; }
  .auth-card { padding: var(--s5); }

  .timeline-item { padding-left: var(--s4); }
}

/* --- 动效降级 ----------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* --- 打印 --------------------------------------------------------------- */
@media print {
  .topbar,
  .sidebar,
  .toast-stack,
  .pager,
  .actions,
  .row-actions { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border-color: #ccc; }
}
