:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef2f6;
  --text: #172033;
  --muted: #6b7280;
  --line: #dce2ea;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --green: #0f9f6e;
  --amber: #c77803;
  --red: #db3b45;
  --blue: #1e78c6;
  --shadow: 0 18px 45px rgba(22, 34, 51, .08);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
}

button, input, select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  background: #101827;
  color: #f8fafc;
}

.brand, .profile-mini {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark, .avatar {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #2dd4bf;
  color: #062a30;
  font-weight: 800;
}

.brand small, .profile-mini small {
  display: block;
  margin-top: 4px;
  color: #a8b3c7;
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 6px;
  margin-top: 34px;
}

.nav-item {
  height: 44px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  color: #cbd5e1;
  background: transparent;
  text-align: left;
}

.nav-item span {
  width: 22px;
  text-align: center;
  font-weight: 800;
}

.nav-item.active, .nav-item:hover {
  background: #22304a;
  color: #ffffff;
}

.profile-mini {
  margin-top: auto;
  padding: 14px;
  border-radius: 8px;
  background: rgba(255,255,255,.07);
}

.avatar {
  background: #facc15;
  color: #392b00;
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 13px;
}

h1, h2, p {
  margin: 0;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 18px;
}

.top-actions, .toolbar, .inline-form {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-box {
  height: 42px;
  width: min(360px, 42vw);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.search-box input, .inline-form input, select, dialog input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.icon-btn, .primary-btn, .outline-btn, .ghost-btn {
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 700;
}

.icon-btn {
  width: 42px;
  padding: 0;
  background: var(--surface);
  border-color: var(--line);
}

.primary-btn {
  color: #fff;
  background: var(--primary);
}

.primary-btn:hover {
  background: var(--primary-dark);
}

.outline-btn {
  background: var(--surface);
  border-color: var(--line);
}

.ghost-btn {
  background: transparent;
  color: var(--primary);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric, .panel, .clock-panel, .person-card, .task-column {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 92px;
  padding: 18px;
}

.metric-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-weight: 900;
}

.metric strong {
  display: block;
  font-size: 24px;
}

.metric small {
  color: var(--muted);
}

.tone-green { background: #dcfce7; color: var(--green); }
.tone-amber { background: #fef3c7; color: var(--amber); }
.tone-blue { background: #dbeafe; color: var(--blue); }
.tone-red { background: #fee2e2; color: var(--red); }

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, .8fr);
  gap: 14px;
  margin-top: 14px;
}

.panel {
  padding: 18px;
}

.panel.wide {
  grid-row: span 2;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.timeline, .notice-list, .record-list, .doc-list {
  display: grid;
  gap: 10px;
}

.timeline-item, .notice-list article, .record-item, .doc-item, .task-card {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.timeline-item {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 68px;
  height: 26px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.status.pending { color: #8a5200; background: #fef3c7; }
.status.approved { color: #05704f; background: #d9fbe9; }
.status.rejected { color: #a51d2a; background: #fee2e2; }

.notice-list p, .timeline-item p, .record-item p, .doc-item p, .person-card p, .task-card p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.quick-grid button {
  height: 78px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  font-weight: 800;
}

.quick-grid span {
  display: block;
  margin-bottom: 6px;
  font-size: 20px;
}

.toolbar {
  justify-content: space-between;
  margin-bottom: 14px;
}

.segmented {
  display: inline-flex;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.segmented button {
  height: 34px;
  min-width: 72px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.segmented button.active {
  color: var(--text);
  background: var(--surface-2);
  font-weight: 800;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
}

th, td {
  padding: 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 13px;
  background: #fbfcfe;
}

td button + button {
  margin-left: 6px;
}

.attendance-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 14px;
}

.doc-layout {
  display: grid;
  grid-template-columns: minmax(340px, 380px) minmax(0, 1fr);
  align-items: start;
  gap: 14px;
}

.clock-panel {
  padding: 22px;
}

.clock-face {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  align-content: center;
  border-radius: 8px;
  background: #e8eef7;
}

.clock-face span {
  font-size: 42px;
  font-weight: 900;
}

.clock-face small {
  margin-top: 8px;
  color: var(--muted);
}

.clock-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.record-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.inline-form {
  min-width: min(560px, 100%);
}

.inline-form input, .inline-form select, dialog label {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 0 12px;
}

.kanban {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.task-column {
  min-height: 360px;
  padding: 14px;
}

.task-column h2 {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 15px;
}

.task-list {
  display: grid;
  gap: 10px;
}

.task-card {
  background: #fff;
}

.task-card footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
}

.task-card button {
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

.doc-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.doc-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cache-toggle {
  height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.cache-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.doc-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.doc-stats article {
  min-height: 64px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.doc-stats strong {
  display: block;
  font-size: 22px;
  line-height: 1;
}

.doc-stats span, .doc-count {
  color: var(--muted);
  font-size: 13px;
}

.doc-panel {
  min-height: 560px;
  max-height: calc(100vh - 260px);
  display: flex;
  flex-direction: column;
}

.preview-panel {
  min-height: 560px;
  padding: 14px;
}

.doc-panel .panel-head {
  flex: 0 0 auto;
}

.doc-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.doc-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
  padding: 12px;
}

.doc-item > div:first-child {
  min-width: 0;
}

.doc-item strong, .doc-item p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-item.active {
  border-color: var(--primary);
  background: #eff6ff;
}

.doc-item-meta {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  justify-content: end;
  gap: 6px;
}

.doc-badge, .doc-cache-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  color: #075985;
  background: #e0f2fe;
  font-size: 12px;
  font-weight: 800;
}

.doc-cache-badge {
  color: #166534;
  background: #dcfce7;
}

.doc-delete-btn {
  grid-column: 1 / -1;
  height: 26px;
  padding: 0 8px;
  border: 1px solid #fecdd3;
  border-radius: 6px;
  color: #be123c;
  background: #fff1f2;
  font-size: 12px;
  font-weight: 800;
}

.doc-delete-btn:hover {
  border-color: #fb7185;
  background: #ffe4e6;
}

.doc-preview {
  height: 100%;
  min-height: 532px;
  display: flex;
}

.doc-content-viewer {
  width: 100%;
  height: calc(100vh - 292px);
  min-height: 532px;
  max-height: none;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  text-align: left;
}

.doc-file-frame {
  width: 100%;
  height: 100%;
  min-height: 532px;
  display: block;
  border: 0;
  background: #ffffff;
}

.doc-page, .word-render {
  width: min(720px, calc(100% - 28px));
  min-height: 360px;
  margin: 14px auto;
  padding: 28px 34px;
  border: 1px solid #d7dde8;
  border-radius: 6px;
  background: #ffffff;
  box-shadow: 0 12px 28px rgba(15, 23, 42, .08);
  color: #1f2937;
  line-height: 1.75;
}

.doc-page header {
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
  text-align: center;
}

.doc-page header span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  height: 28px;
  margin-bottom: 10px;
  border-radius: 6px;
  color: #ffffff;
  background: var(--primary);
  font-weight: 800;
}

.doc-page h3, .word-render h1, .word-render h2 {
  margin: 0;
  color: var(--text);
}

.doc-page header p {
  margin-top: 8px;
  color: var(--muted);
}

.doc-page h4 {
  margin: 18px 0 8px;
  color: var(--text);
  font-size: 16px;
}

.doc-page p, .word-render p {
  margin: 8px 0;
}

.doc-note, .doc-loading {
  padding: 12px;
  border-radius: 8px;
  color: #075985;
  background: #e0f2fe;
}

.doc-loading {
  margin: 14px;
  text-align: center;
}

.doc-empty {
  display: grid;
  min-height: 300px;
  place-items: center;
  color: var(--muted);
}

.people-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.person-card {
  padding: 16px;
}

.person-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.person-head .avatar {
  flex: 0 0 auto;
}

.person-meta {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

dialog {
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .28);
}

dialog::backdrop {
  background: rgba(15, 23, 42, .42);
}

.dialog-card {
  width: min(460px, calc(100vw - 32px));
  padding: 18px;
  display: grid;
  gap: 14px;
}

.dialog-head, .dialog-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

dialog label {
  height: auto;
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  padding: 12px 16px;
  border-radius: 8px;
  color: #fff;
  background: #101827;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: .2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  .brand div, .profile-mini div, .nav-item b {
    display: none;
  }

  .sidebar {
    padding: 18px 12px;
  }

  .nav-item {
    justify-content: center;
  }

  .metrics-grid, .people-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid, .attendance-layout, .doc-layout {
    grid-template-columns: 1fr;
  }

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

  .doc-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .doc-panel {
    max-height: none;
  }

  .doc-content-viewer {
    height: 520px;
  }
}

@media (max-width: 680px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
  }

  .brand, .profile-mini {
    display: none;
  }

  .nav-list {
    display: flex;
    margin-top: 0;
  }

  .nav-item {
    min-width: 44px;
  }

  .workspace {
    padding: 16px;
  }

  .topbar, .toolbar, .inline-form {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
  }

  .search-box {
    width: 100%;
  }

  .metrics-grid, .kanban, .people-grid, .doc-stats {
    grid-template-columns: 1fr;
  }

  .doc-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .doc-actions button, .cache-toggle {
    width: 100%;
    justify-content: center;
  }

  .doc-content-viewer, .doc-file-frame {
    min-height: 460px;
    height: 460px;
  }

  .timeline-item {
    grid-template-columns: 1fr;
  }
}
