*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg: #ffffff;
  --surface: #f8f9fb;
  --navy: #1e3a5f;
  --navy-light: #2c5282;
  --border: #d1d9e6;
  --text: #1a202c;
  --muted: #64748b;
  --approve: #15803d;
  --approve-bg: #dcfce7;
  --reject: #b91c1c;
  --reject-bg: #fee2e2;
  --sidebar-width: 280px;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  min-height: 100vh;
  min-height: 100dvh;
}

input {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  padding: 1.5rem;
}

.login-screen[hidden] {
  display: none;
}

.login-box {
  width: min(360px, 100%);
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 1.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
}

.login-title {
  margin: 0.2rem 0 0;
  color: var(--navy);
  font-size: 1.2rem;
  line-height: 1.3;
}

.login-error {
  min-height: 1.2rem;
  margin: 0;
  color: var(--reject);
  font-size: 0.85rem;
}

.logout-btn {
  width: fit-content;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0;
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
}

.layout {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  height: 100vh;
  height: 100dvh;
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg);
  border-right: 1px solid var(--border);
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.sidebar-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding-bottom: 0.25rem;
}

.logo-block {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.logo-brand {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--muted);
  text-transform: uppercase;
}

.logo {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.panel-title {
  margin: 0 0 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

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

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

select {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}

.btn {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.55rem 1rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.05s;
}

.btn:hover:not(:disabled) {
  opacity: 0.92;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

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

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

.btn-secondary {
  background: #e2e8f0;
  color: var(--navy);
  border: 1px solid #cbd5e1;
}

.btn-approve {
  background: var(--approve-bg);
  color: var(--approve);
  border: 1px solid #86efac;
}

.btn-reject {
  background: var(--reject-bg);
  color: var(--reject);
  border: 1px solid #fca5a5;
}

.progress-panel {
  flex-shrink: 0;
  margin-top: 0;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.progress-wrap {
  position: relative;
  height: 10px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar--fill {
  position: relative;
  z-index: 1;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--navy-light), var(--navy));
  border-radius: 999px;
  transition: width 0.45s ease, background 0.35s ease;
}

.progress-bar--fill.progress-bar--success {
  background: #16a34a;
}

.progress-wrap.is-processing .progress-bar--fill {
  width: 0%;
  opacity: 0.35;
}

.progress-bar--shimmer {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  width: 42%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    rgba(30, 58, 95, 0.1),
    rgba(44, 82, 130, 0.95),
    rgba(30, 58, 95, 0.1)
  );
  animation: progress-slide 1.15s ease-in-out infinite;
  will-change: transform;
}

.progress-wrap.is-done .progress-bar--shimmer {
  display: none !important;
  animation: none;
}

.progress-wrap.is-idle .progress-bar--shimmer,
.progress-wrap.is-failed .progress-bar--shimmer {
  display: none !important;
  animation: none;
}

.progress-wrap.is-failed {
  background: #fee2e2;
}

@keyframes progress-slide {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(320%);
  }
}

.status-text {
  margin: 0.5rem 0 0;
  font-size: 0.88rem;
  color: var(--navy);
  font-weight: 500;
}

.counts {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.35rem;
}

.counts strong {
  color: var(--text);
}

.counts .sep {
  margin: 0 0.25rem;
  color: var(--border);
}

.main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding: 1.25rem 1.5rem 2rem;
  display: flex;
  flex-direction: column;
}

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

.tab {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.65rem 1.25rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  cursor: pointer;
  margin-bottom: -1px;
}

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

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

.main-toolbar {
  margin-bottom: 1rem;
}

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

.card-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  box-shadow: 0 1px 2px rgba(30, 58, 95, 0.06);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.recommend-score {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--approve);
  white-space: nowrap;
}

.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  flex-shrink: 0;
}

.badge-topic {
  background: #dbeafe;
  color: #1d4ed8;
}

.badge-content {
  background: #ede9fe;
  color: #5b21b6;
}

.badge-connector {
  background: #ffedd5;
  color: #c2410c;
}

.badge-default {
  background: #e2e8f0;
  color: #475569;
}

.passage {
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text);
  margin-bottom: 0.75rem;
  padding: 0.65rem 0.75rem;
  background: var(--surface);
  border-radius: 6px;
  cursor: pointer;
  border: 1px dashed transparent;
}

.passage:hover {
  border-color: var(--border);
}

.passage.collapsed {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.passage.expanded {
  display: block;
  -webkit-line-clamp: unset;
}

.question-text {
  font-weight: 600;
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  line-height: 1.5;
}

.options {
  list-style: none;
  margin: 0 0 0.85rem;
  padding: 0;
}

.options li {
  padding: 0.4rem 0.55rem;
  margin-bottom: 0.35rem;
  border-radius: 4px;
  font-size: 0.88rem;
  line-height: 1.45;
  border: 1px solid transparent;
}

.options li.correct {
  background: #ecfdf5;
  border-color: #6ee7b7;
  font-weight: 600;
}

.metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1.25rem;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.65rem;
  align-items: center;
}

.metrics > span:not(.metric-item--tip) {
  white-space: nowrap;
}

.metric-item {
  white-space: nowrap;
}

.metric-item--tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.metric-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.05rem;
  height: 1.05rem;
  padding: 0;
  margin: 0;
  font-size: 0.65rem;
  font-weight: 800;
  font-family: inherit;
  line-height: 1;
  color: var(--navy);
  background: #e2e8f0;
  border: 1px solid #cbd5e1;
  border-radius: 50%;
  cursor: help;
  flex-shrink: 0;
}

.metric-help:hover,
.metric-help:focus {
  background: #cbd5e1;
  outline: none;
}

.tooltip-bubble {
  position: absolute;
  left: 50%;
  bottom: 100%;
  z-index: 5000;
  min-width: 240px;
  max-width: 320px;
  margin-bottom: 8px;
  padding: 10px 12px;
  background: #1e3a5f;
  color: #fff;
  font-size: 13px;
  line-height: 1.5;
  font-weight: 400;
  text-align: left;
  border-radius: 8px;
  white-space: pre-line;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.25);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translateX(-50%) translateY(4px);
  transition: opacity 0.12s ease, visibility 0.12s ease, transform 0.12s ease;
}

.tooltip-bubble::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -6px;
  border: 6px solid transparent;
  border-top-color: #1e3a5f;
}

.metric-item--tip:hover .tooltip-bubble,
.metric-item--tip:focus-within .tooltip-bubble {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.rouge-score {
  font-weight: 600;
}

.rouge-score--ok {
  color: #15803d;
}

.rouge-score--warn {
  color: #c2410c;
}

.rouge-score--bad {
  color: #b91c1c;
}

.rouge-score--na {
  color: var(--muted);
  font-weight: 500;
}

.card-actions {
  display: flex;
  gap: 0.5rem;
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.error-banner {
  background: #fef2f2;
  color: #991b1b;
  padding: 0.65rem 0.85rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.88rem;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.pagination[hidden] {
  display: none !important;
}

.pagination-btn {
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.45rem 0.85rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--navy);
  cursor: pointer;
}

.pagination-btn:hover:not(:disabled) {
  background: var(--surface);
  border-color: var(--navy-light);
}

.pagination-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.pagination-info {
  font-size: 0.85rem;
  color: var(--muted);
  min-width: 12rem;
  text-align: center;
}

.pagination-info strong {
  color: var(--text);
  font-weight: 600;
}

.recommend-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.summary-label {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.76rem;
  color: var(--muted);
}

.summary-wide {
  min-width: 0;
}

.summary-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.summary-chip {
  display: inline-flex;
  align-items: center;
  min-height: 1.55rem;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  background: #eef2f7;
  color: var(--text);
  font-size: 0.78rem;
}

.recommend-explain {
  margin: 0.65rem 0 0;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.5;
}

@media (max-width: 860px) {
  .layout {
    height: auto;
    min-height: 100vh;
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
    overflow: visible;
  }

  .recommend-summary {
    grid-template-columns: 1fr;
  }
}
