:root {
  --bg: #f3efe6;
  --ink: #1c2420;
  --muted: #5c6b63;
  --panel: #fffdf8;
  --line: #d5cdc0;
  --accent: #0f6b4c;
  --accent-ink: #f4fff9;
  --warn: #8a4b12;
  --danger: #8b1e1e;
  --shadow: 0 12px 40px rgba(28, 36, 32, 0.08);
  --font: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: "Avenir Next", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--sans);
  background:
    radial-gradient(circle at 12% 8%, rgba(15, 107, 76, 0.12), transparent 42%),
    radial-gradient(circle at 88% 0%, rgba(138, 75, 18, 0.10), transparent 36%),
    linear-gradient(180deg, #efe8da 0%, var(--bg) 45%, #e7efe9 100%);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  background: rgba(255, 253, 248, 0.72);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  font-family: var(--font);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.brand-block {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  flex-wrap: wrap;
}
.app-version {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink);
  background: #efe8d8;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.15rem 0.45rem;
  line-height: 1.2;
}
.app-version--footer {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  padding: 0;
}
.topbar nav {
  display: flex;
  gap: 1rem;
  align-items: center;
}
.user { color: var(--muted); font-size: 0.9rem; }
.inline-form { display: inline; margin: 0; }
.linkish {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
}
.linkish:hover { text-decoration: underline; }

.page {
  width: min(1120px, calc(100% - 2rem));
  margin: 1.5rem auto 3rem;
}

.hero, .panel, .ticket-table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.hero {
  padding: 3.5rem 2rem;
  text-align: left;
  animation: rise 0.5s ease-out;
}
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.75rem;
  color: var(--accent);
  margin: 0 0 0.75rem;
}
h1, h2, h3 {
  font-family: var(--font);
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem;
}
h1 { font-size: clamp(2rem, 4vw, 3rem); }
.lede { color: var(--muted); max-width: 42rem; line-height: 1.5; }

.page-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1.25rem;
}
.list-bulk-actions {
  text-align: right;
  flex-shrink: 0;
  display: grid;
  gap: 0.5rem;
  justify-items: end;
}
.list-bulk-count {
  margin: 0;
  font-size: 0.9rem;
}
.list-bulk-actions form {
  margin: 0;
}
.type-source {
  font-size: 0.8rem;
  margin-top: 0.15rem;
}
.type-cell {
  min-width: 12rem;
  max-width: 18rem;
}
.type-pick-form {
  margin: 0;
}
.type-select {
  width: 100%;
  min-width: 10rem;
  max-width: 16rem;
  font-size: 0.9rem;
  padding: 0.35rem 0.5rem;
  border-width: 2px;
}
.type-select--accepted {
  background: #e7f3ec;
  border-color: #2f6b4f;
  color: #1d4a35;
}
.type-select--set {
  background: #e8f0f8;
  border-color: #3a6d9b;
  color: #1e3f5c;
}
.type-select--high {
  background: #eef6e8;
  border-color: #5a8f3d;
  color: #2f4f1c;
}
.type-select--medium {
  background: #f7f1e0;
  border-color: #b08a2e;
  color: #5c4814;
}
.type-select--low {
  background: #f6ece8;
  border-color: #a86a55;
  color: #5c3226;
}
.confidence-cell {
  white-space: nowrap;
}
.confidence-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  border: 1px solid var(--line);
}
.confidence-pill--high {
  background: #eef6e8;
  border-color: #5a8f3d;
  color: #2f4f1c;
}
.confidence-pill--medium {
  background: #f7f1e0;
  border-color: #b08a2e;
  color: #5c4814;
}
.confidence-pill--low {
  background: #f6ece8;
  border-color: #a86a55;
  color: #5c3226;
}
.confidence-pill--none {
  background: transparent;
  color: var(--muted);
  font-weight: 400;
}
.confidence-score {
  font-weight: 500;
  opacity: 0.75;
  font-variant-numeric: tabular-nums;
}
.type-cell-meta {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  margin-top: 0.25rem;
}
.type-new-link {
  font-size: 0.8rem;
  white-space: nowrap;
  font-weight: 600;
}
.type-recommended-btn {
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  color: var(--accent);
}
.accept-btn {
  padding: 0.35rem 0.65rem;
  font-size: 0.85rem;
}
.accept-btn.is-accepted {
  background: #e7f3ec;
  border-color: var(--accent);
  color: var(--accent);
}
.back { display: inline-block; margin-bottom: 0.5rem; color: var(--muted); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 0.55rem 0.95rem;
  border-radius: 0.35rem;
  cursor: pointer;
  font: inherit;
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.status-pill {
  background: rgba(255, 253, 248, 0.9);
  border: 1px solid var(--line);
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  color: var(--ink);
  font-size: 0.9rem;
}
.filter-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.input, input, select, textarea {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  padding: 0.55rem 0.7rem;
  background: #fff;
  color: var(--ink);
  width: 100%;
}
.filter-bar .input, .filter-bar input, .filter-bar select {
  width: auto;
  min-width: 12rem;
}

.ticket-table-wrap { overflow-x: auto; }
.ticket-table {
  width: 100%;
  border-collapse: collapse;
}
.ticket-table th, .ticket-table td {
  text-align: left;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.ticket-table th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  white-space: nowrap;
}
.ticket-table th .sort-link {
  color: inherit;
  text-decoration: none;
}
.ticket-table th .sort-link:hover {
  color: var(--ink);
  text-decoration: underline;
}
.ticket-table th.is-sorted .sort-link {
  color: var(--ink);
  font-weight: 600;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.8rem;
  border: 1px solid var(--line);
  background: #f7f2ea;
}
.badge-new { background: #e8f3ff; }
.badge-reviewing { background: #fff4df; }
.badge-tagged { background: #e7f7ee; }
.badge-uploaded { background: #dff7ef; }
.badge-failed { background: #fde8e8; color: var(--danger); }
.tag {
  display: inline-block;
  margin: 0 0.2rem 0.2rem 0;
  padding: 0.1rem 0.45rem;
  border-radius: 0.25rem;
  background: #e8efe9;
  font-size: 0.8rem;
}
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; word-break: break-all; }

.detail-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 1rem;
}
.panel { padding: 1.25rem; }
.panel.narrow { max-width: 36rem; margin: 2rem auto; }
.stack { display: grid; gap: 0.85rem; }
.stack label { display: grid; gap: 0.35rem; font-weight: 600; }
.help { font-weight: 400; color: var(--muted); font-size: 0.85rem; }
.move-files-opt-row {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  font-weight: 500;
}
.move-files-opt-row input { margin-top: 0.25rem; }
.relocate-meta { font-size: 0.85rem; display: grid; gap: 0.25rem; }

.meta {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: 0.4rem 0.75rem;
  margin: 0 0 1.25rem;
}
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }

.storage-panel { margin-bottom: 1rem; }
.storage-lede { margin: 0.35rem 0 1rem; max-width: 42rem; }
.storage-meta { grid-template-columns: 10rem 1fr; margin-bottom: 0; }
.upload-action { text-align: right; max-width: 32rem; }
.upload-pipeline-label {
  display: block;
  text-align: left;
  font-size: 0.85rem;
  margin-bottom: 0.65rem;
}
.upload-pipeline-label select,
.upload-pipeline-label input[type="text"] {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.4rem 0.5rem;
}
.upload-remember {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  text-align: left;
  font-size: 0.8rem;
  line-height: 1.35;
  margin: 0 0 0.75rem;
  color: var(--muted);
}
.upload-remember input { margin-top: 0.15rem; }
.upload-custom-folder.is-hidden { display: none; }
.upload-hint { margin: 0.5rem 0 0; text-align: left; font-size: 0.8rem; line-height: 1.35; }
.upload-destination {
  margin-top: 0.65rem;
  padding: 0.65rem 0.75rem;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  background: #f7f3ea;
}
.upload-destination-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.25rem;
}
.upload-destination-paths {
  list-style: none;
  margin: 0.45rem 0 0;
  padding: 0;
}
.upload-destination-paths li { margin: 0.35rem 0 0; word-break: break-all; }
.storage-loc { margin-top: 0.45rem; }
.storage-loc-label {
  display: inline-block;
  min-width: 6.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
}
.storage-loc-landing .storage-loc-label,
.storage-loc-planned .storage-loc-label { color: var(--accent); }
.storage-uri { font-size: 0.78rem; margin-top: 0.15rem; word-break: break-all; }

.email-body {
  background: #f7f3ea;
  border: 1px solid var(--line);
  padding: 1rem;
  border-radius: 0.35rem;
  white-space: pre-wrap;
  overflow-x: auto;
  max-height: 28rem;
}
.email-body-html {
  white-space: normal;
}
.email-body-html a {
  color: var(--accent, #1a5f4a);
}
.file-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
}
.file-list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
}
.file-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex-shrink: 0;
  align-items: stretch;
}
.file-actions .btn {
  text-align: center;
  white-space: nowrap;
}
.timeline {
  list-style: none;
  padding: 0;
  margin: 0;
}
.timeline li {
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--line);
}

.pipeline-recs {
  list-style: none;
  padding: 0;
  margin: 0 0 1.25rem;
}
.pipeline-rec {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
}
.pipeline-run-files {
  margin: 0.35rem 0 0 1rem;
  padding: 0;
  list-style: disc;
}
.pipeline-run-files li {
  margin: 0.35rem 0;
}

.flash-wrap { width: min(1120px, calc(100% - 2rem)); margin: 1rem auto 0; }
.flash {
  padding: 0.75rem 1rem;
  border-radius: 0.35rem;
  border: 1px solid var(--line);
  background: #fff;
  margin-bottom: 0.5rem;
}
.flash-success, .flash-success { border-color: #9ccbb2; background: #eaf7f0; }
.flash-error, .flash-error { border-color: #e2a0a0; background: #fdeeee; color: var(--danger); }

.footer {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto 2rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.85rem;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 800px) {
  .detail-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; }
}
