:root {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #64748b;
  --line: #d8dee8;
  --primary: #1d4ed8;
  --primary-dark: #1e40af;
  --danger: #b91c1c;
  --success: #047857;
  --warning: #b45309;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a {
  color: var(--primary);
  text-decoration: none;
}

.topbar {
  background: #0f172a;
  color: white;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
}

.brand {
  font-size: 17px;
  font-weight: 700;
}

.topbar nav {
  display: flex;
  gap: 16px;
  align-items: center;
}

.topbar a,
.link-button {
  color: #e2e8f0;
}

.link-button {
  border: 0;
  background: transparent;
  cursor: pointer;
  font: inherit;
  padding: 0;
}

.container {
  width: min(1180px, calc(100vw - 32px));
  margin: 28px auto 48px;
}

.auth-card {
  width: min(420px, calc(100vw - 32px));
  margin: 80px auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 12px 36px rgba(15, 23, 42, 0.08);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 4px;
}

.auth-tab {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-weight: 750;
}

.auth-tab.active {
  background: white;
  color: var(--primary);
  box-shadow: 0 1px 6px rgba(15, 23, 42, 0.08);
}

.auth-pane {
  display: none;
}

.auth-pane.active {
  display: block;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 18px;
}

.danger-zone {
  border-color: #fecaca;
  background: #fffafa;
}

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

h1 {
  font-size: 24px;
  margin: 0 0 4px;
}

h2 {
  font-size: 18px;
  margin: 0 0 14px;
}

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

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

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field.full {
  grid-column: 1 / -1;
}

label {
  font-weight: 650;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  font: inherit;
  background: white;
}

input[readonly] {
  background: #f8fafc;
  color: #475569;
}

textarea {
  min-height: 180px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.checks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}

.employee-checks {
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 6px;
  max-height: 180px;
  padding: 8px;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.check-item input {
  width: auto;
}

.employee-check {
  min-height: 42px;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: #f8fafc;
}

.employee-check:has(input:checked) {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.employee-text {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 1px;
  line-height: 1.2;
}

.employee-name {
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.employee-phone {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
}

.employee-cell {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  line-height: 1.2;
  white-space: nowrap;
}

.employee-cell span {
  font-weight: 700;
}

.employee-cell small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.filename-preview-field {
  min-width: 210px;
}

.filename-preview {
  min-height: 38px;
  display: flex;
  align-items: center;
  overflow-wrap: anywhere;
  border: 1px dashed #93c5fd;
  border-radius: 6px;
  background: #eff6ff;
  color: #1e3a8a;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  padding: 8px 10px;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 16px;
}

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

.package-actions {
  display: grid;
  gap: 7px;
  min-width: 300px;
  max-width: 520px;
}

.package-actions .inline-actions {
  flex-wrap: wrap;
}

.download-link-text {
  max-width: 520px;
  overflow: hidden;
  color: var(--muted);
  direction: rtl;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.35;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.package-tip {
  font-size: 12px;
  white-space: normal;
}

.link-primary {
  border: 0;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  font: inherit;
  padding: 0;
}

.link-danger {
  border: 0;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
  font: inherit;
  padding: 0;
}

.inline-edit-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.inline-edit-form input {
  max-width: 320px;
}

.inline-edit-form select {
  min-width: 180px;
}


.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: white;
  color: var(--text);
  cursor: pointer;
  font-weight: 650;
}

.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

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

.btn.danger {
  color: var(--danger);
}

.btn.compact {
  min-height: 30px;
  padding: 4px 10px;
  font-size: 13px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

.employee-table input {
  min-width: 180px;
}

.record-table {
  min-width: 1420px;
}

.record-table th,
.record-table td {
  padding: 7px 7px;
  vertical-align: middle;
}

.record-table .employee-cell {
  max-width: 180px;
}

.condition-cell {
  max-width: 320px;
  min-width: 220px;
  white-space: normal;
}

.condition-brief {
  max-width: 280px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.condition-detail-trigger {
  display: inline-flex;
  margin-bottom: 3px;
  font-weight: 750;
}

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin: -4px 0 18px;
}

.tab {
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 7px 7px 0 0;
  color: var(--muted);
  font-weight: 750;
  margin-bottom: -1px;
  padding: 10px 16px;
}

.tab.active {
  background: white;
  border-color: var(--line);
  color: var(--primary);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.compact-head {
  align-items: center;
}

.pagination-bar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: -4px 0 12px;
}

.pagination-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.pagination-form label {
  color: var(--muted);
  font-size: 13px;
}

.pagination-form select {
  width: auto;
  min-width: 94px;
  padding: 6px 8px;
}

.pagination-form input[type="number"] {
  width: 74px;
  padding: 6px 8px;
}

.page-status {
  color: #334155;
  font-weight: 700;
}

.btn.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 28px;
}

.help-page p {
  margin: 0;
  color: #475569;
}

.help-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.help-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 14px;
}

.help-card h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.help-steps {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 22px;
}

.help-steps li {
  padding-left: 4px;
}

.help-table th,
.help-table td {
  white-space: normal;
  vertical-align: top;
}

.help-table td:first-child {
  min-width: 110px;
  font-weight: 700;
}

.callout {
  border-left: 4px solid var(--primary);
  background: #eff6ff;
  border-radius: 6px;
  color: #1e3a8a;
  font-weight: 650;
  margin-bottom: 12px;
  padding: 12px 14px;
}

.compact-callout {
  margin: 8px 0 0;
  padding: 9px 11px;
}

.warning-callout {
  border-left-color: var(--warning);
  background: #fffbeb;
  color: #92400e;
}

.modal {
  display: none;
}

.modal.open {
  display: block;
}

.modal-backdrop {
  position: fixed;
  z-index: 50;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
}

.modal-panel {
  position: fixed;
  z-index: 51;
  top: 50%;
  left: 50%;
  width: min(680px, calc(100vw - 32px));
  max-height: min(76vh, 760px);
  overflow: auto;
  transform: translate(-50%, -50%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: 0 22px 70px rgba(15, 23, 42, 0.26);
}

.modal-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: white;
  padding: 16px 18px;
}

.modal-head h3 {
  margin: 0;
  font-size: 17px;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--muted);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.condition-detail-list {
  display: grid;
  gap: 0;
  padding: 6px 18px 18px;
}

.condition-detail-item {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 14px;
  border-bottom: 1px solid #eef2f7;
  padding: 11px 0;
}

.condition-detail-item strong {
  color: #334155;
}

.condition-detail-item span {
  min-width: 0;
  overflow-wrap: anywhere;
  white-space: normal;
}

.employee-table td {
  white-space: normal;
}

.employee-action-col {
  width: 96px;
}

.icon-add {
  font-size: 15px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--danger);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

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

.select-col {
  width: 42px;
  text-align: center;
}

.select-col input {
  width: auto;
}

th {
  background: #f8fafc;
  color: #334155;
  font-size: 13px;
}

.badge {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
}

.badge.success {
  background: #dcfce7;
  color: var(--success);
}

.badge.danger {
  background: #fee2e2;
  color: var(--danger);
}

.badge.warning {
  background: #fef3c7;
  color: var(--warning);
}

.alert {
  padding: 11px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
}

.alert.success {
  background: #ecfdf5;
  border-color: #bbf7d0;
  color: var(--success);
}

.alert.error {
  background: #fef2f2;
  border-color: #fecaca;
  color: var(--danger);
}

.filters {
  display: grid;
  grid-template-columns: 1.25fr 0.8fr 0.8fr 0.8fr 0.9fr 0.9fr 0.9fr;
  gap: 14px;
}

.radio-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.radio-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  background: #f8fafc;
  font-weight: 600;
}

.radio-pill input {
  width: auto;
}

@media (max-width: 760px) {
  .topbar,
  .page-head {
    flex-direction: column;
    height: auto;
    align-items: flex-start;
    padding: 16px;
  }

  .form-grid,
  .filters {
    grid-template-columns: 1fr;
  }
}
