: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); }

/* ─── Kanban board ─────────────────────────────────────────────────── */
.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  align-items: start;
}
.column {
  background: #eef1f5;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem;
  min-height: 8rem;
}
.column h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0.25rem 0.25rem 0.75rem;
  display: flex;
  justify-content: space-between;
}
.column h2 .count { color: var(--ink); }
.kard {
  display: block;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  margin-bottom: 0.6rem;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 1px 1px rgba(0,0,0,0.03);
}
.kard:hover { border-color: #c7d2e0; }
.kard .who { font-weight: 700; font-size: 0.92rem; }
.kard .meta { color: var(--muted); font-size: 0.78rem; margin-top: 0.15rem; }
.kard .tags { margin-top: 0.5rem; display: flex; gap: 0.35rem; flex-wrap: wrap; }
.pill { font-size: 0.72rem; padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--border); color: var(--ink); }
.pill.flag { background: var(--warn-bg); color: var(--warn-ink); }
.pill.rej  { background: var(--err-bg); color: var(--err-ink); }
.pill.assignee { background: #e0e7ff; color: #3730a3; }
.empty-col { color: var(--muted); font-size: 0.8rem; padding: 0.5rem 0.25rem; }

@media (max-width: 820px) { .board { grid-template-columns: 1fr; } }

/* ─── Case detail ──────────────────────────────────────────────────── */
.case-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.case-actions .spacer { flex: 1; }
.event-list { list-style: none; padding: 0; margin: 0; }
.event-list li { padding: 0.4rem 0; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
.event-list .who { font-weight: 600; }
.event-list .when { color: var(--muted); font-size: 0.78rem; }
.role-chip { font-size: 0.72rem; padding: 0.1rem 0.5rem; border-radius: 999px; background: #e0e7ff; color: #3730a3; margin-left: 0.4rem; }

/* ─── Users table ──────────────────────────────────────────────────── */
table.users { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.users th, table.users td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); }
table.users th { color: var(--muted); font-weight: 600; }
select.mini, input.mini { padding: 0.35rem 0.5rem; border: 1px solid var(--border); border-radius: 7px; font: inherit; }
.inactive { opacity: 0.5; }

/* Assign-to-other control on the case page */
#assign-row { display: inline-flex; gap: 0.4rem; align-items: center; }
#assign-row[hidden] { display: none !important; }
