/* Warm matte palette: oat paper, clay rose, sage and plum.
   Light is the default; dark follows the system unless the toggle stored a
   choice (html[data-theme]), so both rules below are needed. */
:root {
  --bg: #F6F0E8; --bg-soft: #EFE5D9; --panel: #FFFCF8; --raise: #FBF5EE;
  --ink: #3A302B; --dim: #8B7C70; --line: #E7DACB;
  --accent: #B26A5C; --accent-soft: #F5E3DD; --accent-ink: #FFFFFF;
  --link: #A0574F;
  --ok: #5A7A52; --ok-bg: #E7EEDF;
  --run: #7B6A9C; --run-bg: #EDE8F4;
  --warn: #99713E; --warn-bg: #F6EADA;
  --bad: #A85043; --bad-bg: #F7E3DE;
  --radius: 14px; --shadow: 0 1px 2px rgba(58,48,43,.05), 0 6px 18px -12px rgba(58,48,43,.25);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1F1A18; --bg-soft: #2A2320; --panel: #272120; --raise: #302826;
    --ink: #F0E6DC; --dim: #A8978A; --line: #3D3330;
    --accent: #D4948A; --accent-soft: #3B2A27; --accent-ink: #241C1A;
    --link: #E0A79C;
    --ok: #A0BE8E; --ok-bg: #2A3324;
    --run: #BFAEE0; --run-bg: #2E2740;
    --warn: #DBB37E; --warn-bg: #3A2E1E;
    --bad: #E59C90; --bad-bg: #3B2422;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 18px -12px rgba(0,0,0,.6);
  }
}
:root[data-theme="dark"] {
  --bg: #1F1A18; --bg-soft: #2A2320; --panel: #272120; --raise: #302826;
  --ink: #F0E6DC; --dim: #A8978A; --line: #3D3330;
  --accent: #D4948A; --accent-soft: #3B2A27; --accent-ink: #241C1A;
  --link: #E0A79C;
  --ok: #A0BE8E; --ok-bg: #2A3324;
  --run: #BFAEE0; --run-bg: #2E2740;
  --warn: #DBB37E; --warn-bg: #3A2E1E;
  --bad: #E59C90; --bad-bg: #3B2422;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 18px -12px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }
input[type=checkbox] { accent-color: var(--accent); }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.55 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-decoration: none; } a:hover { text-decoration: underline; }
main { max-width: 1120px; margin: 0 auto; padding: 26px 18px 70px; }
h1, h2, .brand { font-family: Fraunces, Georgia, serif; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 27px; margin: 0 0 2px; } h2 { font-size: 18px; } h2.sub { margin-top: 38px; }

.topbar { display: flex; align-items: center; gap: 22px; padding: 12px 18px;
  background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; line-height: 0; }
.brand svg { height: 42px; width: auto; display: block;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif; }
.brand:hover { text-decoration: none; opacity: .85; }
.topbar nav { display: flex; gap: 6px; }
.topbar nav a { color: var(--dim); padding: 5px 11px; border-radius: 999px; }
.topbar nav a:hover { background: var(--bg-soft); text-decoration: none; }
.topbar nav a.on { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.topbar .right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.pill { background: var(--run-bg); color: var(--run); border-radius: 999px; padding: 1px 7px; font-size: 12px; }
.pill.live { animation: pulse 2s infinite; } @keyframes pulse { 50% { opacity: .5; } }
button.link { background: none; border: 0; color: var(--dim); cursor: pointer; font: inherit; font-size: 13px; }
.banner { max-width: 1120px; margin: 14px auto 0; padding: 10px 16px; background: var(--accent-soft);
  color: var(--accent); border-radius: var(--radius); font-size: 14px; }

.head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.head-actions { display: flex; gap: 8px; align-items: center; }
.head-actions form { display: inline; }
.meta { display: flex; flex-wrap: wrap; gap: 13px; color: var(--dim); font-size: 13px; }
.meta.big { font-size: 14px; margin-top: 7px; } .meta em { font-style: normal; opacity: .75; }
.src { background: var(--bg-soft); color: var(--dim); border-radius: 999px; padding: 2px 10px; font-size: 12px; }

/* ---- dataset cards ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 11px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 10px; }
.card-head h2 { margin: 0; font-size: 18px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.card-head h2 a { color: var(--ink); }
.card-del { margin-left: 2px; opacity: 0; transition: opacity .15s; }
.card:hover .card-del, .card-del:focus-within { opacity: 1; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.chips form { display: inline-flex; }
/* a chip and its download arrow are one unit - they must wrap together */
.chip-pair { display: inline-flex; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 5px; font: inherit; font-size: 12.5px;
  padding: 5px 11px; border-radius: 999px; background: var(--bg-soft); color: var(--dim);
  border: 1px solid transparent; cursor: pointer; transition: transform .1s, box-shadow .15s, background .15s; }
.chip em { font-style: normal; opacity: .85; font-size: 11.5px; }
button.chip:hover, a.chip:hover { background: var(--accent-soft); color: var(--accent);
  border-color: var(--accent); text-decoration: none; transform: translateY(-1px); }
button.chip:active { transform: none; }
.chip.running { background: var(--run-bg); color: var(--run); }
.chip.done { background: var(--ok-bg); color: var(--ok); }
.chip.queued { background: var(--run-bg); color: var(--run); }
.chip.paused { background: var(--warn-bg); color: var(--warn); }
.chip.off { opacity: .45; cursor: not-allowed; }
.chip-dl { display: inline-flex; align-items: center; padding: 5px 8px; border-radius: 999px;
  background: var(--ok-bg); color: var(--ok); font-size: 12px; margin-left: -4px; }
.chip-dl:hover { text-decoration: none; filter: brightness(.97); }

.icon-btn { background: none; border: 0; color: var(--dim); cursor: pointer; font-size: 13px;
  line-height: 1; padding: 4px 6px; border-radius: 8px; }
.icon-btn:hover { background: var(--bg-soft); color: var(--ink); }
.icon-btn.danger:hover { background: var(--bad-bg); color: var(--bad); }
#theme-toggle { font-size: 15px; }

/* ---- tables ---- */
/* Tables keep their full set of columns on a phone and scroll sideways instead:
   squeezing them past min-width made the headers and cells overlap. */
.scroll-x { overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch;
  padding-bottom: 2px; overscroll-behavior-x: contain; }
.scroll-x > table { min-width: 880px; }
.scroll-x > table.jobs.small { min-width: 620px; }

table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
th, td { text-align: left; padding: 11px 13px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--dim);
  background: var(--bg-soft); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--raise); }
tr.off { opacity: .6; } td.pick { width: 34px; } td.name label { font-weight: 600; cursor: pointer; }
table.scans { table-layout: fixed; }
table.scans th.pick, table.scans td.pick { width: 38px; }
table.scans th:nth-child(2), table.scans td.name { width: 33%; }
table.scans th:nth-child(3), table.scans td.status { width: 9%; }
table.scans th:nth-child(4), table.scans td.progress { width: 13%; }
table.scans th:nth-child(5), table.scans td.result { width: 22%; }
table.scans th:nth-child(6), table.scans td.actions { width: 23%; }
/* every flag the scanner CLI takes, pre-filled with its default */
.params { display: flex; flex-wrap: wrap; gap: 2px 10px; margin-top: 6px; }
.file { display: flex; align-items: center; gap: 2px; max-width: 100%; }
.file a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file .icon-btn { opacity: 0; flex: none; }
td.result:hover .icon-btn, .file:focus-within .icon-btn { opacity: 1; }
details.older { margin-top: 3px; }
details.older summary { cursor: pointer; color: var(--dim); font-size: 11.5px; }
table.scans td.name small { line-height: 1.35; }
td.name small, td.result small, td.progress small { display: block; color: var(--dim); font-size: 12px; }
td.status { white-space: nowrap; } td.status small { display: block; font-size: 11px; margin-top: 2px; }
td.name small.long { white-space: normal; max-width: 330px; }
.inline-param { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--dim); }
.inline-param label { cursor: help; white-space: nowrap; }
.inline-param input[type=text], .inline-param select { font-size: 11.5px; padding: 2px 5px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--ink); }
.inline-param input[type=text] { width: 4.6em; }
.inline-param input::placeholder { color: var(--dim); opacity: .6; }
.form-actions .inline-param { font-size: 12.5px; }
.form-actions .inline-param select, .form-actions .inline-param input { font-size: 12.5px; padding: 4px 7px; }
/* the jobs list: fixed columns, so a long log path cannot push the actions
   column off the page (max-width is ignored on an auto-layout table cell) */
table.jobs:not(.small) { table-layout: fixed; }
table.jobs:not(.small) th:nth-child(1) { width: 46px; }
table.jobs:not(.small) th:nth-child(2) { width: 94px; }
table.jobs:not(.small) th:nth-child(3) { width: 120px; }
table.jobs:not(.small) th:nth-child(4) { width: 17%; }
table.jobs:not(.small) th:nth-child(5) { width: 130px; }
table.jobs:not(.small) th:nth-child(6) { width: 82px; }
table.jobs:not(.small) th:nth-child(8) { width: 112px; }
table.jobs td { overflow: hidden; }
table.jobs td a { overflow-wrap: anywhere; }
.msg { color: var(--dim); font-size: 12px; max-width: 320px; overflow-wrap: anywhere; }
.dim { color: var(--dim); } .warn { color: var(--warn); } .error { color: var(--bad); }

.badge { font-size: 11.5px; padding: 3px 10px; border-radius: 999px; background: var(--bg-soft); color: var(--dim); }
.badge.running, .badge.queued { background: var(--run-bg); color: var(--run); }
.badge.done { background: var(--ok-bg); color: var(--ok); }
.badge.paused, .badge.cancelled { background: var(--warn-bg); color: var(--warn); }
.badge.failed { background: var(--bad-bg); color: var(--bad); }

/* Fills the cell's content box - a min-width wider than the column made the bar
   overflow its own padding on a narrow screen. */
.bar { height: 5px; background: var(--bg-soft); border-radius: 999px; overflow: hidden;
  width: 100%; max-width: 150px; }
.bar span { display: block; height: 100%; background: var(--run); border-radius: 999px; transition: width .4s ease; }
.bar.done span { background: var(--ok); }

.btn { display: inline-block; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 10px; padding: 7px 14px; font: inherit; font-size: 14px; cursor: pointer; white-space: nowrap; }
.btn:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { color: var(--accent-ink); filter: brightness(1.06); }
.btn.small { padding: 4px 10px; font-size: 12px; } .btn.ghost { background: none; }
.btn.danger { color: var(--bad); border-color: var(--line); }
.btn.danger:hover { border-color: var(--bad); background: var(--bad-bg); color: var(--bad); }
/* a table cell, not a flex box: display:flex would drop the cell out of the row.
   The buttons wrap onto their own lines rather than overflowing the column,
   which the table's overflow:hidden would otherwise clip away. */
td.actions { text-align: right; }
td.actions form { display: inline; }
td.actions > *, td.actions form > * { display: inline-block; vertical-align: middle; margin: 2px 0 2px 6px; }
.form-actions { display: flex; align-items: center; gap: 12px; margin-top: 16px; flex-wrap: wrap; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px; max-width: 620px; box-shadow: var(--shadow); }
.panel.narrow { max-width: 360px; margin: 48px auto; }
.field { margin-bottom: 15px; } .field label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 5px; }
.field input:not([type=checkbox]):not([type=radio]), .field select { width: 100%; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); font: inherit; }
.field input:focus, .field select:focus, .inline-param input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.field small { display: block; color: var(--dim); font-size: 12px; margin-top: 4px; }
.field select.narrow, .field input.narrow { width: 8em; }
.blurb { color: var(--dim); margin: 4px 0 0; font-size: 13.5px; }
.tabs { display: flex; gap: 7px; margin: 16px 0 18px; flex-wrap: wrap; }
.tab { padding: 6px 13px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); color: var(--dim); }
.tab:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.tab.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
details.advanced { margin: 8px 0 4px; }
details.advanced summary { cursor: pointer; color: var(--dim); font-size: 13px; margin-bottom: 10px; }
.empty { color: var(--dim); }

.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  color: var(--ink); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); font-size: 13.5px;
  max-width: 340px; animation: rise .2s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.toast.fade { opacity: 0; transition: opacity .4s; }

@media (max-width: 720px) {
  main { padding: 20px 16px 60px; }
  .head-row { flex-direction: column; align-items: stretch; }
  .head-actions { flex-wrap: wrap; }
  .card-del { opacity: 1; }                       /* no hover on touch */
  .topbar { gap: 12px; padding: 10px 14px; }
  .topbar nav { gap: 2px; }
  .topbar nav a { padding: 5px 9px; }
  .brand svg { height: 34px; }
  /* the delete ✕ next to a result file also has no hover to reveal it */
  .file .icon-btn { opacity: 1; }
  .form-actions { gap: 10px; }
}
