:root {
  --blue: #2a78d6; --aqua: #1baf7a; --red: #e34948;
  --ink: #0b0b0b; --ink2: #52514e; --ink3: #8b8a83;
  --grid: #e8e7e3; --bg: #f2f1ee; --panel: #ffffff; --soft: #f6f6f4;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.hidden { display: none !important; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12px; }
.error { color: var(--red); min-height: 18px; margin: 6px 0 0; font-size: 13px; }
.sub { color: var(--ink3); margin: 2px 0 14px; font-size: 13px; }

main { max-width: 1120px; margin: 0 auto; padding: 28px 20px 60px; }
header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
header h1 { font-size: 22px; margin: 0; }
.head-right { display: flex; align-items: center; gap: 12px; }

.card { background: var(--panel); border: 1px solid var(--grid); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
h2 { font-size: 17px; margin: 0 0 2px; }

.form.busy { opacity: .45; pointer-events: none; }
.row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.grow { flex: 1; min-width: 220px; }
.field.end { justify-content: flex-end; align-items: flex-end; }
label { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink3); }
input, select {
  font: inherit; padding: 8px 10px; border: 1px solid var(--grid);
  border-radius: 7px; background: #fff; color: var(--ink); min-width: 150px;
}
input:focus, select:focus { outline: 2px solid var(--blue); outline-offset: -1px; }
.inline { display: flex; gap: 8px; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; }
button {
  font: inherit; padding: 8px 14px; border: 1px solid var(--grid); background: #fff;
  color: var(--ink2); border-radius: 7px; cursor: pointer;
}
button:hover { border-color: var(--ink3); color: var(--ink); }
button.primary { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; padding: 9px 26px; }
button.primary:hover { background: #2569bb; }
button.link { border: none; background: none; color: var(--ink3); padding: 8px 4px; text-decoration: underline; }
button.active { border-color: var(--blue); color: var(--blue); }

.progress-head { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink2); margin-bottom: 8px; }
.bar { height: 8px; background: var(--soft); border-radius: 99px; overflow: hidden; }
#bar-fill { height: 100%; width: 0; background: var(--blue); transition: width .3s ease; }
#progress-msg { color: var(--ink3); margin: 8px 0 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 12.5px; table-layout: fixed; }
th, td { padding: 6px 4px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--grid); }
th:first-child, td:first-child { text-align: left; white-space: normal; width: 11%; }
thead th { font-size: 10px; letter-spacing: .02em; text-transform: uppercase; color: var(--ink3); border-bottom: 1px solid var(--ink3); white-space: normal; cursor: help; }
thead th:hover { color: var(--ink); }
tbody tr:hover { background: var(--soft); }
/* 15 fixed-width columns start clipping their values below this width. */
@media (max-width: 940px) {
  table { font-size: 11px; }
  th, td { padding: 6px 3px; }
}
td.pos { color: var(--aqua); font-weight: 600; }
td.neg { color: var(--red); font-weight: 600; }
td.pick { font-weight: 600; }

.thumbs { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.thumb { background: var(--panel); border: 1px solid var(--grid); border-radius: var(--radius); padding: 10px; cursor: pointer; }
.thumb:hover { border-color: var(--blue); }
.thumb img { width: 100%; display: block; border-radius: 6px; }
.thumb span { display: block; font-size: 12px; color: var(--ink2); margin-top: 8px; }

.modal { position: fixed; inset: 0; background: rgba(11,11,11,.62); display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 20; }
.modal-box { background: var(--panel); border-radius: var(--radius); padding: 18px; max-width: min(1100px, 96vw); max-height: 92vh; overflow: auto; position: relative; }
.modal-box img { max-width: 100%; max-height: 74vh; display: block; margin: 0 auto; }
.modal-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; }
.close { position: absolute; top: 8px; right: 10px; border: none; background: none; font-size: 26px; line-height: 1; color: var(--ink3); padding: 2px 8px; }
.ex-table td { text-align: left; }
.ex-ok { color: var(--aqua); font-weight: 600; }
.ex-no { color: var(--ink3); }

.gate { position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; z-index: 30; }
.pin-box { background: var(--panel); border: 1px solid var(--grid); border-radius: var(--radius); padding: 28px; width: min(360px, 92vw); display: flex; flex-direction: column; gap: 10px; }
.pin-box h1 { font-size: 18px; margin: 0 0 8px; }
.pin-box input { letter-spacing: .5em; text-align: center; font-size: 20px; }
.pin-box button { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }
