:root {
  --bg: #f3f4f6;
  --card: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --ok-bg: #dcfce7;
  --ok-ink: #166534;
  --warn-bg: #fef9c3;
  --warn-ink: #854d0e;
  --err-bg: #fee2e2;
  --err-ink: #991b1b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  font-weight: 700;
  font-size: 1.1rem;
  padding: 0 0.5rem;
  margin-bottom: 2rem;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 0.25rem; }
.sidebar-nav a {
  display: block;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
}
.sidebar-nav a:hover { background: var(--bg); }
.sidebar-nav a.active { background: var(--ok-bg); color: var(--ok-ink); }
.sidebar-user {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem 0.5rem 0;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--muted);
  min-width: 0;
}
/* Truncate long emails to one line; full address shows on hover (title attr). */
.sidebar-user #user-email {
  display: block;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user a { color: var(--muted); }

.content { flex: 1; min-width: 0; }

main {
  max-width: 46rem;
  margin: 2rem auto;
  padding: 0 1.25rem;
}

@media (max-width: 640px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: auto;
    height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar-brand { margin-bottom: 0; }
  .sidebar-nav { flex-direction: row; }
  .sidebar-user { margin-top: 0; margin-left: auto; flex-direction: row; align-items: center; gap: 0.5rem; padding: 0; border-top: none; max-width: 45%; }
  main { margin: 1.5rem auto; }
}

h1 { font-size: 1.5rem; margin: 0 0 0.25rem; }
.subtitle { color: var(--muted); margin: 0 0 1.5rem; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

label { display: block; font-weight: 600; font-size: 0.9rem; margin: 0.75rem 0 0.25rem; }
.hint { font-weight: 400; color: var(--muted); font-size: 0.8rem; }

input[type=text], input[type=search], textarea, select {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: #fff;
}
textarea { min-height: 8rem; resize: vertical; }
input[type=file] { width: 100%; font: inherit; margin-top: 0.25rem; }

.row { display: flex; gap: 0.75rem; }
.row > * { flex: 1; }

button {
  margin-top: 1rem;
  padding: 0.6rem 1.1rem;
  border: none;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
button:hover { background: var(--brand-dark); }
button:disabled { opacity: 0.6; cursor: default; }
button.secondary { background: #fff; color: var(--brand); border: 1px solid var(--brand); }

.badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}
.badge.active { background: var(--ok-bg); color: var(--ok-ink); }
.badge.lapsed { background: var(--warn-bg); color: var(--warn-ink); }
.badge.other  { background: var(--border); color: var(--ink); }

.result-name { font-size: 1.1rem; font-weight: 700; margin: 0 0 0.5rem; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 0.2rem 1rem; margin: 0.5rem 0 0; }
dl.kv dt { color: var(--muted); font-size: 0.85rem; }
dl.kv dd { margin: 0; font-size: 0.9rem; }

.notice { padding: 0.8rem 1rem; border-radius: 8px; margin-top: 1rem; font-size: 0.9rem; }
.notice.ok   { background: var(--ok-bg);  color: var(--ok-ink); }
.notice.warn { background: var(--warn-bg); color: var(--warn-ink); }
.notice.err  { background: var(--err-bg); color: var(--err-ink); }
.notice a { color: inherit; font-weight: 700; }

.hidden { display: none; }

/* ─── Login screen ─────────────────────────────────────────────────── */
.login-body {
  min-height: 100vh;
  margin: 0;
  display: flex;
  background: linear-gradient(160deg, #ffffff 0%, #eef7f2 45%, #cdeadd 100%);
}
.login-screen {
  margin: auto;
  width: 100%;
  max-width: 22rem;
  padding: 2rem 1.5rem;
}
.login-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.login-logo {
  width: 108px;
  height: 108px;
  object-fit: contain;
  margin-bottom: 1rem;
}
.login-name {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 2.5rem;
}
.login-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.8rem 1rem;
  border-radius: 999px;
  background: #a7e8c9;
  color: #0f3d2b;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  transition: background 0.15s ease, transform 0.05s ease;
}
.login-btn:hover { background: #93e0bc; }
.login-btn:active { transform: translateY(1px); }
.login-btn .g-icon { width: 20px; height: 20px; background: #fff; border-radius: 50%; padding: 2px; box-sizing: content-box; }

/* ─── Progress stepper ─────────────────────────────────────────────── */
.stepper {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  padding: 0;
  margin: 0 0 1rem;
}
.stepper li {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.stepper .dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--border);
  box-shadow: 0 0 0 3px transparent;
}
.stepper li.done { color: var(--ink); }
.stepper li.done .dot { background: var(--ok-ink); }
.stepper li.active { color: var(--ink); font-weight: 600; }
.stepper li.active .dot { background: var(--brand); box-shadow: 0 0 0 3px #dbeafe; animation: pulse 1.2s infinite; }
.stepper li.failed .dot { background: var(--err-ink); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ─── Findings table ───────────────────────────────────────────────── */
table.findings { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.findings th, table.findings td {
  text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.findings th { color: var(--muted); font-weight: 600; }
table.findings .num, table.findings td.num { text-align: right; white-space: nowrap; }
.badge.err-badge { background: var(--err-bg); color: var(--err-ink); }

/* ─── Claim status list ────────────────────────────────────────────── */
.filters { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: flex-end; }
.filters .field { display: flex; flex-direction: column; gap: 0.25rem; }
.filters label { font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.filters input, .filters select {
  padding: 0.45rem 0.55rem; border: 1px solid var(--border);
  border-radius: 8px; font: inherit; background: #fff;
}
.filters .grow { flex: 1; min-width: 10rem; }

table.claims { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.claims th, table.claims td {
  text-align: left; padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--border);
}
table.claims th { color: var(--muted); font-weight: 600; white-space: nowrap; }
table.claims tr.row-link { cursor: pointer; }
table.claims tbody tr:hover { background: #f7fafc; }
table.claims a { color: var(--brand); text-decoration: none; }

.st { display: inline-block; padding: 0.15rem 0.6rem; border-radius: 999px;
      font-size: 0.78rem; font-weight: 700; white-space: nowrap; }
.st.processing  { background: var(--border); color: var(--ink); }
.st.to_review   { background: #e0e7ff; color: #3730a3; }
.st.in_progress { background: var(--warn-bg); color: var(--warn-ink); }
.st.done        { background: var(--ok-bg); color: var(--ok-ink); }

.pager { display: flex; align-items: center; gap: 0.75rem; margin-top: 1rem; }
.pager .spacer { flex: 1; }
.pager button { margin: 0; padding: 0.4rem 0.8rem; }
.pager button:disabled { opacity: 0.5; }
.pager .count { color: var(--muted); font-size: 0.85rem; }
