:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #0f172a;
  --danger: #b91c1c;
  --chip: #e2e8f0;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, sans-serif;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card,
.modal-card,
.table-wrap,
.toolbar,
.topbar {
  background: var(--card);
}

.login-card {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 12px;
  display: grid;
  gap: 12px;
}

.login-card h1,
.modal-head h2 {
  margin: 0;
  font-size: 1.35rem;
}

label {
  display: grid;
  gap: 6px;
  font-size: 0.9rem;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
}

.btn,
.login-card button[type="submit"] {
  border: 1px solid var(--line);
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
}

.btn.ghost {
  background: #fff;
  color: var(--text);
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.error {
  color: var(--danger);
  font-size: 0.9rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
}

.page {
  padding: 20px 24px 40px;
  max-width: 1280px;
  margin: 0 auto;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px 12px 0 0;
  position: sticky;
  top: 0;
  z-index: 5;
}

.toolbar-right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.id-cell {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  white-space: nowrap;
}

.table-wrap {
  position: relative;
  border: 1px solid var(--line);
  border-top: 0;
  overflow: auto;
  max-height: calc(100vh - 220px);
}

.table-wrap.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.55);
  pointer-events: none;
}

.loading-inline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 16px 0 0;
  color: var(--muted);
}

.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 1;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: #f8fafc;
}

.count {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
}

.summary-cell {
  min-width: 280px;
  max-width: 520px;
  color: #334155;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 0;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

.modal-card {
  position: relative;
  margin: 4vh auto;
  width: min(960px, calc(100% - 24px));
  max-height: 92vh;
  overflow: auto;
  border-radius: 12px;
  padding: 20px;
}

.modal-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.88);
  z-index: 2;
}

.modal-card:has(#modal-loading:not([hidden])) {
  min-height: 280px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}

.tab {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  padding: 10px 12px;
  cursor: pointer;
}

.tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.modal-summary {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
  white-space: pre-wrap;
}

.card {
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 8px;
  overflow: hidden;
}

.accordion-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #fff;
  border: 0;
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
}

.accordion-head:hover {
  background: #f8fafc;
}

.accordion-head h3 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 600;
}

.accordion-chevron {
  color: var(--muted);
  flex-shrink: 0;
}

.card.open .accordion-chevron {
  transform: rotate(180deg);
}

.accordion-body {
  padding: 0 14px 14px;
  border-top: 1px solid var(--line);
}

.card h3 {
  margin: 0;
  font-size: 1.05rem;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 8px;
}

.chip {
  background: var(--chip);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.75rem;
}

.card p {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

.evidence {
  margin-top: 8px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 10px;
  font-size: 0.9rem;
}

.evidence p {
  margin: 0 0 6px;
}

.empty {
  color: var(--muted);
}
