:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --line: #dde3ea;
  --line-strong: #c8d2dc;
  --text: #1f2933;
  --muted: #64748b;
  --accent: #176b87;
  --accent-dark: #10566d;
  --accent-soft: #e6f3f7;
  --accent-2: #1f7a4d;
  --accent-2-soft: #e7f5ee;
  --danger: #b42318;
  --danger-soft: #fff1f0;
  --shadow: 0 10px 26px rgba(15, 23, 42, 0.07);
  --shadow-soft: 0 6px 16px rgba(15, 23, 42, 0.05);
  --radius: 8px;
  --space: 16px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: linear-gradient(180deg, #eef4f7 0, var(--bg) 220px), var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.55;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); }

button, .button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
  padding: 7px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  font-weight: 600;
  box-shadow: 0 2px 4px rgba(23, 107, 135, 0.12);
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.08s ease;
}
button:hover, .button:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  color: white;
  box-shadow: 0 6px 14px rgba(23, 107, 135, 0.18);
}
button:active, .button:active {
  transform: translateY(1px);
  box-shadow: none;
}
.secondary {
  background: white;
  color: var(--accent);
  box-shadow: none;
}
.secondary:hover {
  background: var(--accent-soft);
  border-color: #9cc9d8;
  color: var(--accent-dark);
}
.danger-button {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #e6b8b0;
  box-shadow: none;
}
.danger-button:hover {
  background: #fee4df;
  color: #8f1c13;
  border-color: #d9988e;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px 9px;
  min-height: 34px;
  background: white;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 107, 135, 0.13);
}
input::placeholder, textarea::placeholder { color: #94a3b8; }

.topbar {
  display: grid;
  grid-template-columns: auto 1fr 220px auto;
  gap: 18px;
  align-items: center;
  min-height: 56px;
  padding: 0 20px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 8px rgba(15, 23, 42, 0.04);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-weight: 700; color: #12343b; }
nav { display: flex; gap: 14px; }
nav a {
  color: #334155;
  padding: 6px 0;
  font-weight: 600;
}
nav a:hover { color: var(--accent); }
.user { color: var(--muted); white-space: nowrap; }
.page { padding: 24px 18px; }

.login-panel, .form-page, .settings-page, .dashboard, .system-home, .employees-page, .attendance-page {
  max-width: 1180px;
  margin: 0 auto;
}
.login-panel {
  max-width: 360px;
  margin-top: 80px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.alert {
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid #ffd6cf;
  padding: 10px 12px;
  border-radius: var(--radius);
  margin-bottom: 12px;
}
.notice {
  color: #1f4b36;
  background: var(--accent-2-soft);
  border: 1px solid #b9dfc7;
  padding: 10px 12px;
  border-radius: var(--radius);
  margin-bottom: 12px;
}
.muted { color: var(--muted); }
.empty {
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 18px;
  background: var(--panel-soft);
  text-align: center;
}

.toolbar, .batch, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space);
  margin-bottom: var(--space);
  box-shadow: var(--shadow-soft);
}
.module-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: var(--space);
  padding: 4px 0;
}
.module-head h1 {
  margin: 0 0 6px;
  font-size: 26px;
  line-height: 1.25;
  letter-spacing: 0;
}
.module-head p,
.module-head .muted { margin: 0; }

.module-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space);
}
.module-card {
  min-height: 150px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  display: grid;
  align-content: center;
  gap: 10px;
  box-shadow: var(--shadow-soft);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.08s ease;
}
.module-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.module-card strong {
  font-size: 22px;
  color: #12343b;
}
.module-card span {
  color: var(--muted);
  line-height: 1.6;
}
.quick-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.export-inline {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.export-inline select { width: 190px; }
.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}
.list-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.filters, .inline-form {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 8px;
  align-items: end;
}
.actions, .batch { display: flex; gap: 8px; align-items: center; }
.batch select, .batch input { max-width: 220px; }

.export-dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  width: min(760px, calc(100vw - 32px));
  padding: 16px;
  box-shadow: var(--shadow);
}
.export-dialog::backdrop { background: rgba(15, 23, 42, 0.35); }
.dialog-head, .dialog-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}
.dialog-actions { justify-content: flex-end; }
.icon-button {
  min-width: 32px;
  width: 32px;
  justify-content: center;
  padding: 0;
}
fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
}
.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.table-wrap {
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  margin-bottom: var(--space);
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 0;
}
.table-wrap table { min-width: 980px; }
.dashboard .table-wrap table,
.settings-page .panel table { min-width: 0; }
th, td {
  border-bottom: 1px solid var(--line);
  padding: 0 10px;
  height: 44px;
  line-height: 44px;
  vertical-align: middle;
  white-space: nowrap;
}
th {
  background: #eef3f6;
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 1;
  color: #334155;
  font-weight: 700;
}
tbody tr:hover { background: #f8fbfc; }
tbody tr:last-child td { border-bottom: 0; }
.dashboard table th:last-child,
.dashboard table td:last-child {
  text-align: right;
  width: 120px;
}
.sort-link {
  color: #12343b;
  display: inline-flex;
  gap: 4px;
  align-items: center;
  height: 42px;
  line-height: 42px;
}
.sort-link:hover { color: var(--accent); text-decoration: underline; }
.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  height: 42px;
  line-height: normal;
}
.row-actions button {
  background: white;
  color: var(--danger);
  border-color: #e6b8b0;
  min-height: 24px;
  padding: 1px 7px;
  box-shadow: none;
}
.table-wrap input[type="checkbox"] {
  display: block;
  width: 20px;
  height: 20px;
  min-height: 20px;
  padding: 0;
  margin: 0;
}
.table-wrap th:first-child input[type="checkbox"],
.table-wrap td:first-child input[type="checkbox"] { margin: 0 auto; }

.grid-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space);
  box-shadow: var(--shadow-soft);
}
.compact-form {
  box-shadow: none;
  padding: 0;
  border: 0;
}
label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 600;
}
.wide { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 8px; }
.picker-actions {
  margin-top: 10px;
  flex-wrap: wrap;
}
.picker-actions button {
  min-height: 28px;
  padding: 3px 10px;
}
.stack { display: grid; gap: 10px; }
.check { display: flex; gap: 7px; align-items: center; color: var(--text); }
.check input { width: auto; min-height: auto; }
.is-hidden { display: none !important; }
.employee-picker {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: var(--panel-soft);
}
.employee-picker summary {
  cursor: pointer;
  font-weight: 700;
}
.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  padding-top: 10px;
}
.exception-row { background: #fff8f0; }
.exception-row:hover { background: #fff3e5; }
.progress-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.38);
  padding: 18px;
}
.progress-overlay[hidden] { display: none; }
.progress-box {
  width: min(460px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.progress-box h2 {
  margin: 0 0 14px;
  font-size: 20px;
}
.progress-bar {
  height: 16px;
  background: #e8eef3;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.progress-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.25s ease;
}
.progress-percent {
  margin-top: 10px;
  font-size: 24px;
  font-weight: 700;
  color: var(--accent-2);
}
#progress-confirm {
  margin-top: 14px;
  width: 100%;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.stats div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--panel);
  box-shadow: var(--shadow-soft);
  color: var(--muted);
  font-weight: 600;
}
.stats strong {
  display: block;
  font-size: 26px;
  line-height: 1.2;
  color: var(--accent-2);
  margin-top: 4px;
  word-break: break-word;
  white-space: normal;
}
.factory-profile-form { margin-bottom: 12px; }
.factory-profile-form input[readonly] {
  background: #f1f4f7;
  color: var(--muted);
}
.profile-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}
.calendar-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}
.calendar-workday-row td {
  background: #ffffff;
}
.calendar-weekend-row td {
  background: #fff3bf;
}
.calendar-remark-select {
  font-weight: 600;
}
.calendar-remark-plain {
  background: #ffffff;
}
.calendar-remark-weekend {
  background: #fff3bf;
}
.calendar-remark-holiday {
  background: #d8f5a2;
}
.columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
textarea { font-family: Consolas, "Microsoft YaHei", monospace; }

@media (max-width: 900px) {
  .topbar { grid-template-columns: 1fr; padding: 12px; }
  nav { flex-wrap: wrap; gap: 10px; }
  .toolbar, .columns, .module-head { display: block; }
  .actions, .batch, .form-actions { flex-wrap: wrap; }
  .module-grid, .calendar-layout { grid-template-columns: 1fr; }
  .filters, .inline-form, .grid-form { grid-template-columns: 1fr; }
  .page { padding: 18px 12px; }
}
