:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --success: #16a34a;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.header {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
  color: #fff;
  padding: 1.25rem 1.5rem;
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
}

.header h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 600;
}

.subtitle {
  margin: 0;
  opacity: 0.85;
  font-size: 0.9rem;
}

.status-badge {
  margin-left: auto;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.15);
}

.status-badge.ok {
  background: rgba(22, 163, 74, 0.25);
}

.status-badge.err {
  background: rgba(220, 38, 38, 0.35);
}

.tabs {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.tab {
  border: none;
  background: none;
  padding: 0.55rem 1.25rem;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1.25;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  text-align: center;
}

.tab:hover {
  color: var(--primary);
}

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 2rem;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
  align-items: center;
}

.toolbar-sep {
  color: var(--muted);
  font-size: 0.85rem;
}

.input {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  min-width: 160px;
}

.input:focus {
  outline: 2px solid rgba(37, 99, 235, 0.35);
  border-color: var(--primary);
}

.select {
  min-width: 140px;
}

.textarea {
  width: 100%;
  resize: vertical;
  font-family: inherit;
}

.btn {
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  white-space: nowrap;
}

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

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

.btn-secondary {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--bg);
}

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

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

.btn-sm {
  padding: 0.3rem 0.65rem;
  font-size: 0.82rem;
}

.btn:disabled,
.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

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

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.table th,
.table td {
  padding: 0.65rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.table th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.table tbody tr:hover {
  background: #f8fafc;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.col-actions {
  width: 140px;
  text-align: right !important;
}

.col-actions .btn {
  margin-left: 0.35rem;
}

.desc-cell {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-report-types {
  table-layout: fixed;
  width: 100%;
}

.table-report-types th,
.table-report-types td {
  vertical-align: top;
}

/* description 50%，其余列均分剩余 */
.table-report-types col.col-rt-check {
  width: 6%;
}

.table-report-types col.col-rt-fit,
.table-report-types col.col-rt-name,
.table-report-types col.col-actions {
  width: 9%;
}

.table-report-types col.col-rt-desc {
  width: 49%;
}

.table-report-types .col-rt-check {
  text-align: center;
  vertical-align: middle;
  padding-left: 0.35rem;
  padding-right: 0.35rem;
}

.table-report-types .col-rt-check input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
}

.table-report-types .col-rt-fit,
.table-report-types .col-rt-name,
.table-report-types .col-actions {
  padding-left: 0.45rem;
  padding-right: 0.45rem;
  box-sizing: border-box;
}

.table-report-types .col-rt-fit {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table-report-types .col-rt-name {
  white-space: normal;
}

.table-report-types .col-rt-desc {
  min-width: 0;
  max-width: none;
  white-space: normal;
}

.table-report-types .col-rt-desc.cell-multiline,
.table-report-types .col-rt-name.cell-multiline {
  min-width: 0;
  max-width: none;
}

.table-report-types .col-rt-desc .multiline-body,
.table-report-types .col-rt-name .multiline-body {
  max-height: 280px;
}

.table-report-types .col-actions {
  text-align: right !important;
  white-space: nowrap;
}

.input-code {
  min-width: 100px;
  max-width: 120px;
}

.table-wrap-wide {
  overflow-x: auto;
}

.table-analyses th,
.table-analyses td {
  vertical-align: top;
}

.cell-single {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.col-code {
  max-width: 90px;
}

.col-title {
  min-width: 160px;
  max-width: 280px;
  white-space: normal;
}

.col-summary {
  max-width: 260px;
}

.cell-multiline {
  min-width: 160px;
  max-width: 420px;
  white-space: normal;
}

.cell-datetime {
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  line-height: 1.4;
  vertical-align: middle;
  max-width: none !important;
  min-width: 5em;
  width: 5em;
  box-sizing: content-box;
}

.table-overall th.col-oa-time,
.table-overall td.col-oa-time {
  min-width: 5em;
  width: 5em;
  max-width: none;
  white-space: normal;
}

.datetime-date,
.datetime-time {
  display: block;
  white-space: nowrap;
}

.multiline-body {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
  max-height: 320px;
  overflow-y: auto;
  padding: 0.35rem 0;
}

.table-overall .col-oa-summary,
.table-overall .col-oa-detail {
  min-width: 220px;
  max-width: 480px;
}

.table-overall .col-pdf {
  max-width: 220px;
  white-space: normal;
}

.pdf-link {
  color: var(--primary);
  text-decoration: none;
  word-break: break-all;
}

.pdf-link:hover {
  text-decoration: underline;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.82rem;
  background: #e2e8f0;
  color: var(--text);
}

.badge-yes {
  background: #fef3c7;
  color: #b45309;
}

.badge-no {
  background: #ecfdf5;
  color: #047857;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.pager button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.dialog {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  max-width: 480px;
  width: calc(100% - 2rem);
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.18);
}

.dialog.dialog-analyse {
  max-width: 720px;
  max-height: calc(100vh - 2rem);
  overflow: auto;
}

.field-grid {
  display: grid;
  gap: 0 1rem;
  margin-bottom: 0.25rem;
}

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

.field-grid .field {
  margin-bottom: 0.85rem;
  min-width: 0;
}

.field-grid .field .input,
.field-grid .field .select {
  width: 100%;
  box-sizing: border-box;
}

@media (max-width: 640px) {
  .field-grid-3 {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 420px) {
  .field-grid-3 {
    grid-template-columns: 1fr;
  }
}

.analyse-hint {
  margin: 0 0 0.75rem;
  color: var(--muted);
}

.analyse-progress {
  resize: vertical;
  min-height: 10rem;
  font-family: ui-monospace, "Cascadia Code", "Consolas", monospace;
  font-size: 0.8rem;
  line-height: 1.45;
  white-space: pre-wrap;
  background: #f8fafc;
  color: #0f172a;
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(160deg, #eff6ff 0%, #f8fafc 45%, #e2e8f0 100%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem 1.75rem;
}

.login-card h1 {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  text-align: center;
}

.login-subtitle {
  margin: 0 0 1.5rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.login-form .field {
  margin-bottom: 1rem;
}

.login-error {
  margin: 0 0 0.75rem;
  color: var(--danger);
  font-size: 0.875rem;
}

.btn-block {
  width: 100%;
  margin-top: 0.25rem;
}

.user-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.2);
}

.header .btn-secondary.btn-sm {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
}

.header .btn-secondary.btn-sm:hover {
  background: rgba(255, 255, 255, 0.25);
}

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

.dialog form {
  padding: 1.25rem 1.5rem 1.5rem;
}

.dialog h2 {
  margin: 0 0 1rem;
  font-size: 1.15rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.field span em {
  color: var(--danger);
  font-style: normal;
}

.hint {
  color: var(--muted);
  font-size: 0.8rem;
}

.perm-fieldset {
  border: 1px solid var(--border, #d8dde6);
  border-radius: var(--radius);
  padding: 0.75rem 1rem 1rem;
  margin: 0.75rem 0 0;
}

.perm-fieldset legend {
  padding: 0 0.35rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.check-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.35rem 1rem 0.35rem 0;
  font-size: 0.92rem;
  cursor: pointer;
}

.tab[hidden],
.panel[hidden] {
  display: none !important;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.empty-row td {
  text-align: center;
  color: var(--muted);
  padding: 2rem !important;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius);
  background: #1e293b;
  color: #fff;
  font-size: 0.9rem;
  z-index: 9999;
  max-width: 90vw;
  box-shadow: var(--shadow);
}

.toast.error {
  background: var(--danger);
}

.toast.success {
  background: var(--success);
}

@media (max-width: 640px) {
  .toolbar .input {
    flex: 1 1 100%;
  }

  .col-actions {
    width: auto;
  }
}
