:root {
  --bg: #eef2f0;
  --ink: #1a2220;
  --muted: #5a6660;
  --panel: #ffffff;
  --line: #cfd8d3;
  --accent: #1f5c45;
  --snap: #2a5a8a;
  --danger: #8b2e2e;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 10% 0%, #dceee6 0%, transparent 45%),
    radial-gradient(ellipse at 90% 10%, #d9e4f0 0%, transparent 40%),
    var(--bg);
  color: var(--ink);
}
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(6px);
}
.brand {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: -0.02em;
}
nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
nav a {
  text-decoration: none;
  color: var(--ink);
  padding: 0.35rem 0.65rem;
}
nav a:hover { text-decoration: underline; }
.nav-form { display: inline; margin: 0; }
button.linkish {
  background: transparent;
  color: var(--ink);
  border: none;
  padding: 0;
  margin-left: 1rem;
  cursor: pointer;
  font: inherit;
  text-decoration: none;
}
button.linkish:hover { text-decoration: underline; }
main { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }
h1 { margin: 0 0 0.35rem; font-size: 1.8rem; }
.lede { color: var(--muted); margin-top: 0; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin: 1.25rem 0;
}
.stat, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem;
}
.stat .label { display: block; color: var(--muted); font-size: 0.85rem; }
.stat strong { font-size: 1.2rem; }
.muted { color: var(--muted); font-size: 0.9rem; }
.actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin: 1rem 0; }
button, .button {
  appearance: none;
  border: none;
  background: var(--accent);
  color: #f7fff9;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  text-decoration: none;
  display: inline-block;
}
button.secondary, .button.secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
button.active { outline: 2px solid var(--accent); }
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
th, td {
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.95rem;
  vertical-align: middle;
}
th {
  background: #e6eeea;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tag,
.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 7.25rem;
  height: 1.65rem;
  padding: 0 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1;
  color: #fff;
  background: #4a5568;
  white-space: nowrap;
  box-sizing: border-box;
}
.status-pill.new { background: #2a5a8a; }
.status-pill.needs_review { background: #8a6a00; color: #fff; }
.status-pill.in_progress { background: #1f5c45; }
.status-pill.done,
.status-pill.archived { background: #4a5568; }
.status-pill.kno2-processed { background: #1f5c45; }
.status-pill.kno2-received { background: #5a6570; }
.status-pill.kno2-unknown { background: #3d4450; color: #c5ccd4; }
.aprima-yes { color: #1f5c45; font-weight: 600; }
.aprima-no { color: var(--muted); }
.chips {
  margin: 0 0 1rem;
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  align-items: center;
}
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 5.5rem;
  height: 2rem;
  padding: 0 0.85rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  text-decoration: none;
  color: var(--ink);
  background: var(--panel);
  font-size: 0.82rem;
  line-height: 1;
  white-space: nowrap;
  box-sizing: border-box;
}
.chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.stack label { display: block; margin-bottom: 0.6rem; }
.stack input[type="text"], .stack input:not([type]), .stack input[type="file"] {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font: inherit;
}
.meta { display: grid; grid-template-columns: 10rem 1fr; gap: 0.35rem 1rem; }
.meta dt { color: var(--muted); }
.foot {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em; }
.pdf-panel { margin-top: 1rem; }
.pdf-root {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: min(80vh, 900px);
  overflow: auto;
  padding: 0.5rem;
  background: #e2e8e5;
  border-radius: 8px;
}
.pdf-page {
  width: 100%;
  height: auto;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}
.clip { max-width: 28rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alert-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  margin: 1.25rem 0;
}
.alert-tile {
  display: block;
  text-decoration: none;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--tile, var(--accent));
  border-radius: 10px;
  padding: 1rem;
  min-height: 7rem;
}
.alert-tile:hover { border-color: var(--tile, var(--accent)); }
.alert-tile strong { display: block; font-size: 1.8rem; margin: 0.2rem 0; }
.event-list { list-style: none; padding: 0; margin: 0; }
.event-list li {
  display: grid;
  grid-template-columns: 13.5rem 1fr;
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
}
.event-list .when {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}
.event-list .body { min-width: 0; }
.sev {
  font-size: 0.7rem;
  text-transform: uppercase;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: #cfd8d3;
}
.sev.warn { background: #c9b458; }
.sev.critical, .sev.error { background: #e8a0a0; }
.error { color: var(--danger); }
.ok { color: #1f5c45; font-weight: 600; }
.stack label { display: block; margin-bottom: 0.75rem; }
.stack input {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  background: #fff;
}
