@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@latest/dist/web/variable/pretendardvariable.min.css');

:root {
  --bg-outer: #e8edf6;
  --bg-panel: #f4f8fd;
  --text-main: #1f2a3a;
  --text-sub: #5e6d82;
  --text-faint: #93a0b3;
  --accent: #0b7a55;
  --accent-pressed: #095f42;
  --accent-track: rgba(11, 122, 85, 0.14);
  --error: #b3261e;
  --error-track: rgba(179, 38, 30, 0.1);
  --line: rgba(31, 42, 58, 0.09);
  --line-strong: rgba(31, 42, 58, 0.16);
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg-outer);
  color: var(--text-main);
  font-family: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, system-ui, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

::selection {
  background: var(--accent-track);
  color: var(--text-main);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.table-scroll {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.table-scroll::-webkit-scrollbar {
  height: 8px;
  width: 8px;
}

.table-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.table-scroll::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 999px;
}

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px clamp(16px, 4vw, 32px);
  background: var(--bg-panel);
  border-bottom: 1px solid var(--line-strong);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
  align-self: center;
}

.brand-name {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand-sub {
  font-size: 13px;
  color: var(--text-sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: none;
}

.updated-at {
  font-size: 12.5px;
  color: var(--text-sub);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 40px;
  padding: 0 16px;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 120ms ease, transform 80ms ease;
}

.refresh-btn:hover {
  background: var(--accent-pressed);
}

.refresh-btn:active {
  transform: scale(0.97);
}

.refresh-btn:disabled {
  background: var(--accent);
  opacity: 0.55;
  cursor: default;
  transform: none;
}

.refresh-icon {
  width: 16px;
  height: 16px;
  flex: none;
}

.refresh-btn.is-loading .refresh-icon {
  animation: spin 900ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .refresh-btn.is-loading .refresh-icon {
    animation: none;
  }
}

/* ---------- Main / status ---------- */

main {
  flex: 1;
  padding: clamp(16px, 4vw, 32px);
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
}

.status-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
}

.status-bar.is-loading {
  background: var(--accent-track);
  color: var(--accent-pressed);
}

.status-bar.is-error {
  background: var(--error-track);
  color: var(--error);
}

.status-spinner {
  width: 15px;
  height: 15px;
  flex: none;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  animation: spin 700ms linear infinite;
}

.status-retry {
  margin-left: auto;
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
}

.status-retry:hover {
  background: rgba(179, 38, 30, 0.08);
}

/* ---------- Table ---------- */

.table-scroll {
  background: var(--bg-panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  overflow: auto;
}

.report-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 14px;
}

.report-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg-panel);
  text-align: left;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-sub);
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}

.report-table tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--text-main);
  vertical-align: top;
  line-height: 1.5;
}

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

.report-table tbody tr:hover {
  background: rgba(11, 122, 85, 0.045);
}

.report-table tbody tr:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.cell-empty {
  color: var(--text-faint);
}

.cell-num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cell-note {
  min-width: 220px;
  max-width: 360px;
  white-space: pre-line;
}

.badge-low-confidence {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--error-track);
  color: var(--error);
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
  vertical-align: 1px;
}

.empty-state {
  margin: 40px 0 0;
  text-align: center;
  color: var(--text-sub);
  font-size: 14px;
}

/* ---------- Responsive: stacked cards on narrow viewports ---------- */

@media (max-width: 640px) {
  .table-scroll {
    overflow: visible;
    border: none;
    background: transparent;
  }

  .report-table {
    min-width: 0;
  }

  .report-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .report-table,
  .report-table tbody,
  .report-table tr,
  .report-table td {
    display: block;
    width: 100%;
  }

  .report-table tbody tr {
    background: var(--bg-panel);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    padding: 6px 4px;
    margin-bottom: 12px;
  }

  .report-table tbody td {
    display: flex;
    gap: 12px;
    justify-content: space-between;
    align-items: baseline;
    padding: 9px 14px;
    border-bottom: 1px solid var(--line);
    min-height: 24px;
  }

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

  .report-table tbody td::before {
    content: attr(data-label);
    flex: none;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-sub);
  }

  .cell-note {
    max-width: none;
    text-align: right;
  }
}
