:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #1f2937;
  --muted: #667085;
  --line: #d8dee8;
  --brand: #2563eb;
  --ok: #0f9f6e;
  --warn: #b7791f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #eef2f7;
}

.login-screen.hidden {
  display: none;
}

.login-card {
  display: grid;
  gap: 14px;
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.12);
}

.login-brand {
  margin-bottom: 8px;
}

.login-card label {
  display: grid;
  gap: 7px;
  color: var(--muted);
}

.login-card label span {
  font-size: 13px;
}

.remember-row {
  display: flex !important;
  grid-template-columns: none !important;
  align-items: center;
  gap: 8px !important;
  color: var(--ink) !important;
}

.remember-row input {
  width: 16px;
  min-height: 16px;
}

.login-hint {
  color: var(--muted);
  font-size: 13px;
}

.shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.shell.locked {
  display: none;
}

aside {
  background: #111827;
  color: #f8fafc;
  padding: 24px 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--brand);
  font-weight: 700;
}

h1, h2, h3, p {
  margin: 0;
}

h1 {
  font-size: 20px;
}

.brand p,
.side-note span {
  color: #a7b0bd;
  font-size: 13px;
}

nav {
  display: grid;
  gap: 8px;
}

.nav {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 11px 12px;
  text-align: left;
  color: #e5e7eb;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
}

.nav.active {
  background: var(--brand);
  color: white;
}

.side-note {
  display: grid;
  gap: 6px;
  margin-top: 24px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
}

main {
  padding: 28px;
}

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

.topbar h2 {
  font-size: 25px;
  margin-bottom: 8px;
}

.topbar p {
  color: var(--muted);
}

.compact-topbar > div:first-child {
  display: none;
}

.compact-topbar {
  justify-content: flex-end;
  margin-bottom: 12px;
}

.connection {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--warn);
  white-space: nowrap;
}

.connection.ok {
  color: var(--ok);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.current-user {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  white-space: nowrap;
}

.logout-button,
.restart-button,
.new-frontend-button {
  border-color: #cbd5e1;
  background: #ffffff;
  color: var(--ink);
}

.new-frontend-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--brand);
  text-decoration: none;
  white-space: nowrap;
}

.restart-button {
  color: var(--brand);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.stats div,
.panel,
.settings-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.stats div {
  padding: 18px;
}

.stats span {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
}

.stats strong {
  font-size: 30px;
}

.panel {
  padding: 18px;
  min-width: 0;
}

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

.panel-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.panel h3 {
  font-size: 18px;
}

input,
select,
textarea,
button {
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 8px 10px;
  font: inherit;
}

button {
  border-color: var(--brand);
  background: var(--brand);
  color: white;
  cursor: pointer;
}

.secondary-button,
.table-action,
.file-button {
  border-color: #cbd5e1;
  background: #ffffff;
  color: var(--ink);
}

.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
}

.file-button input {
  display: none;
}

.table-action {
  min-height: 30px;
  padding: 4px 10px;
}

.danger-action {
  border-color: #fecaca;
  color: #b42318;
  margin-left: 6px;
}

.batch-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.batch-bar span {
  color: var(--muted);
  min-width: 90px;
}

.field-display-menu,
.employee-filter-menu {
  position: relative;
}

.field-display-panel,
.employee-filter-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 5;
  width: min(360px, calc(100vw - 48px));
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.16);
}

.field-display-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.field-display-head span {
  min-width: 0;
  color: var(--muted);
}

.field-display-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  max-height: 320px;
  overflow: auto;
  padding: 10px 0;
}

.field-display-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--ink);
}

.field-display-option input {
  width: auto;
  min-height: auto;
}

.field-display-option span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field-display-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.employee-filter-panel {
  width: min(620px, calc(100vw - 48px));
}

.employee-filter-list {
  display: grid;
  gap: 10px;
  max-height: 360px;
  overflow: auto;
  padding: 10px 0;
}

.employee-filter-item {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.employee-filter-date {
  grid-template-columns: 112px 110px minmax(0, 1fr) minmax(0, 1fr);
}

.employee-filter-date select,
.employee-filter-date input {
  min-width: 0;
}

.employee-filter-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.36);
}

.modal {
  width: min(1500px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.24);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.modal-head h3 {
  margin: 0;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 34px;
  min-height: 34px;
  padding: 0;
  border-color: #cbd5e1;
  background: #ffffff;
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
}

.modal-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  padding: 20px;
  margin-bottom: 0;
}

.settings-modal {
  width: min(920px, calc(100vw - 48px));
}

.settings-modal-body {
  padding: 20px;
}

.settings-edit-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 0;
}

.form-grid.settings-edit-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 0;
}

.form-grid.employee-field-config-form {
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  align-items: end;
}

.form-span-2 {
  grid-column: 1 / -1;
}

.option-editor-label {
  display: grid;
  gap: 8px;
  color: #172033;
  font-weight: 700;
}

.option-editor-label textarea {
  min-height: 132px;
  resize: vertical;
  line-height: 1.5;
}

.option-editor-label span {
  color: #667085;
  font-size: 13px;
  font-weight: 400;
}

.field-config-label {
  display: grid;
  gap: 8px;
  color: #172033;
  font-weight: 700;
}

.field-config-label input {
  width: 100%;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.field-row.single {
  grid-template-columns: 1fr;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
}

.field span {
  font-size: 13px;
}

.field input,
.field select {
  width: 100%;
}

.employee-profile-form {
  display: grid;
  gap: 20px;
  padding: 26px 34px 24px;
  margin-bottom: 0;
}

.profile-photo-row {
  display: grid;
  grid-template-columns: 80px 126px;
  align-items: start;
  gap: 16px;
}

.profile-label,
.profile-field span {
  color: #334155;
  font-size: 14px;
  line-height: 40px;
  text-align: right;
}

.profile-photo {
  width: 126px;
  height: 126px;
  border: 1px solid #d8e1ee;
  background:
    radial-gradient(circle at 50% 34%, #ffffff 0 24px, transparent 25px),
    radial-gradient(ellipse at 50% 98%, #9fb1c4 0 56px, transparent 57px),
    radial-gradient(ellipse at 50% 34%, #9fb1c4 0 34px, transparent 35px),
    #e7edf5;
}

.employee-profile-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  column-gap: 92px;
  row-gap: 14px;
}

.profile-column {
  display: grid;
  gap: 14px;
}

.profile-field {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  align-items: center;
  gap: 16px;
}

.profile-field input,
.profile-field select {
  width: 100%;
  height: 40px;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 4px;
}

.required-field span::before {
  content: "*";
  color: #ef4444;
  margin-right: 4px;
}

.age-field input {
  max-width: 168px;
}

.profile-remark {
  grid-template-columns: 104px minmax(0, 1fr);
  max-width: calc(50% - 46px);
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  grid-column: 1 / -1;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

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

.event-form {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.table-wrap {
  max-height: 560px;
  overflow: auto;
  scrollbar-gutter: stable;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  table-layout: fixed;
}

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

th:last-child,
td:last-child {
  width: 1%;
}

.row-actions {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-start;
  min-width: max-content;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  font-weight: 700;
}

.resizable-th {
  position: sticky;
  padding-right: 18px;
}

.column-resizer {
  position: absolute;
  top: 0;
  right: 0;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  user-select: none;
}

.column-resizer::after {
  content: "";
  position: absolute;
  top: 9px;
  right: 3px;
  width: 1px;
  height: calc(100% - 18px);
  background: transparent;
}

.resizable-th:hover .column-resizer::after,
.column-resizing .column-resizer::after {
  background: #94a3b8;
}

.column-resizing {
  cursor: col-resize;
  user-select: none;
}

td {
  color: #344054;
}

.text-link {
  min-height: auto;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  color: var(--brand);
  text-align: left;
}

.employee-name-link {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

.employee-name-link:hover {
  text-decoration: underline;
}

.field-config-table-wrap {
  max-width: 100%;
  width: 100%;
  padding-bottom: 10px;
}

.field-config-table {
  width: max-content;
  min-width: 860px;
  table-layout: fixed;
}

.field-config-table .field-col-key,
.field-config-table .field-col-name {
  width: 110px;
}

.field-config-table .field-col-type,
.field-config-table .field-col-position {
  width: 82px;
}

.field-config-table .field-col-flag {
  width: 62px;
}

.field-config-table .field-col-order {
  width: 60px;
}

.field-config-table .field-col-action {
  width: 136px;
}

.field-config-table th,
.field-config-table td {
  padding: 9px 8px;
}

.field-config-table th:last-child,
.field-config-table td:last-child {
  width: 136px;
}

.field-config-link {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

.field-config-link:hover {
  text-decoration: underline;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 16px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.settings-panel {
  margin-bottom: 16px;
}

.settings-split {
  margin-bottom: 16px;
}

.settings-tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.settings-tab {
  border-color: #cbd5e1;
  background: #ffffff;
  color: var(--ink);
}

.settings-tab.active {
  border-color: var(--brand);
  background: var(--brand);
  color: #ffffff;
}

.settings-view {
  display: none;
}

.settings-view.active {
  display: block;
  min-width: 0;
}

.field-config-panel {
  grid-column: 1 / -1;
  min-width: 0;
}

.log-filter-bar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 180px 180px auto auto;
  gap: 10px;
  margin-bottom: 14px;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  color: var(--ink);
}

.checkbox-field input {
  width: auto;
  min-height: auto;
}

.settings-grid div {
  display: grid;
  gap: 8px;
  padding: 16px;
}

.settings-grid span {
  color: var(--muted);
  line-height: 1.6;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: none;
  max-width: 340px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #111827;
  color: white;
}

.toast.show {
  display: block;
}

@media (max-width: 980px) {
  .shell,
  .stats,
  .split,
  .settings-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: block;
  }

  .connection {
    margin-top: 12px;
    display: inline-block;
  }

  .top-actions {
    justify-content: flex-start;
  }

  .panel-head,
  .panel-actions,
  .batch-bar,
  .log-filter-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .log-filter-bar {
    display: flex;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .modal {
    width: min(920px, calc(100vw - 24px));
  }

  .employee-profile-form {
    padding: 20px;
  }

  .employee-profile-grid {
    grid-template-columns: 1fr;
  }

  .profile-photo-row,
  .profile-field,
  .profile-remark {
    grid-template-columns: 86px minmax(0, 1fr);
    max-width: none;
  }
}
