:root {
  --bg: #f5f5f2; --panel: #fff; --ink: #1d1d1b; --muted: #73736e; --line: #deded9; --soft: #f0f0ec;
  --accent: #2f6fb7; --sale: #e8910f; --bad: #b3261e; --ok: #2e7d32; --head: #1d1d1b;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.4 system-ui, "Segoe UI", sans-serif; color: var(--ink); background: var(--bg); }
section { margin: 16px 24px; }
button, select, input[type=search] { font: inherit; padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--ink); }
button { cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.linkbtn, .tile a, td a { font-size: 12px; color: var(--accent); background: none; border: 0; padding: 0; text-decoration: underline; cursor: pointer; }

header { background: var(--head); color: #fff; padding: 12px 24px; }
h1 { margin: 0; display: flex; align-items: baseline; gap: 14px; font-size: 18px; font-weight: 400; }
.mark { font-size: 22px; font-weight: 800; letter-spacing: .06em; }
.mark span { font-weight: 300; letter-spacing: 0; opacity: .8; }
.title { padding-left: 14px; border-left: 1px solid rgba(255,255,255,.3); letter-spacing: .02em; }
#testdate { margin-left: auto; font-size: 13px; font-weight: 700; background: var(--sale); color: #fff; padding: 2px 10px; border-radius: 999px; }

#drop { background: var(--panel); border: 2px dashed var(--line); border-radius: 10px; padding: 14px 18px; }
#drop.over { border-color: var(--accent); background: #eef4fb; }
.drop-main { margin: 0 0 10px; font-size: 16px; }
#slots { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 8px; }
#slots li { border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
#slots li b { display: block; font-size: 13px; }
#slots li span { color: var(--muted); font-size: 13px; }
#slots li.ok { border-color: var(--ok); }
#slots li.ok span { color: var(--ok); }
#slots li button { padding: 2px 8px; font-size: 13px; }
.saved-note { margin: 8px 0 0; }
#messages { list-style: none; margin: 8px 0 0; padding: 0; }
#messages li { padding: 5px 10px; border-radius: 6px; margin-top: 4px; font-size: 13px; }
#messages li.err { background: #fdecea; color: var(--bad); }
#messages li.info { background: var(--soft); color: var(--muted); }

#attention { background: #fdecea; border: 1px solid #e6b3ae; border-radius: 10px; padding: 10px 16px; }
#attention h2 { margin: 0; font-size: 15px; color: var(--bad); }
#attention p { margin: 2px 0 6px; font-size: 13px; }
#attention ul { margin: 0; padding-left: 18px; font-size: 14px; columns: 2 320px; }
#attention .linkbtn { color: var(--bad); font-size: 13px; margin-top: 4px; }

#toolbar { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 8px 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
#search { flex: 1 1 220px; }
#count { margin-left: auto; color: var(--muted); font-size: 14px; }
.seg { display: inline-flex; }
.seg button { border-radius: 0; margin-left: -1px; }
.seg button:first-child { border-radius: 6px 0 0 6px; margin-left: 0; }
.seg button:last-child { border-radius: 0 6px 6px 0; }
.seg button.on { background: var(--ink); border-color: var(--ink); color: #fff; }
#more { position: relative; }
#more summary { list-style: none; cursor: pointer; padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.more-body { position: absolute; z-index: 20; top: 110%; left: 0; max-width: calc(100vw - 48px); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px; display: grid; gap: 8px; min-width: 260px; box-shadow: 0 6px 20px rgba(0,0,0,.12); }
.more-body label { display: grid; grid-template-columns: 60px 1fr; align-items: center; gap: 8px; }

#result { background: #e8f3e9; border: 1px solid var(--ok); border-radius: 10px; padding: 10px 16px; margin: 8px 0; }
#result a { font-weight: 600; margin-right: 16px; }

.group-head { display: flex; align-items: center; gap: 10px; margin: 18px 0 8px; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.group-head h2 { margin: 0; font-size: 16px; }
.group-head span { color: var(--muted); font-size: 13px; }
.group-head button { padding: 1px 8px; font-size: 13px; }

/* card view */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.tile { display: block; background: var(--panel); border: 2px solid var(--line); border-radius: 8px; padding: 6px; cursor: pointer; }
.tile.sel { border-color: var(--accent); }
.tile.problem { cursor: default; opacity: .7; }
.thumb { width: 86%; margin: 2px auto 0; aspect-ratio: 361 / 217; background: var(--soft); border-radius: 4px; display: grid; place-items: center; color: var(--muted); font-size: 12px; text-align: center; padding: 6px; overflow: hidden; }
.thumb.has { padding: 0; background: #fff; }
.thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.t-head { display: flex; align-items: center; gap: 6px; margin: 6px 2px 2px; }
.t-head input, td input { width: 16px; height: 16px; margin: 0; flex: none; }
.cat { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-name { margin: 0 2px; font-size: 14px; font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.5em; }
.facts { display: grid; grid-template-columns: 1fr 1fr; margin: 6px 0 0; border-top: 1px solid var(--line); }
.facts div { padding: 4px 6px; border-bottom: 1px solid var(--line); min-width: 0; }
.facts div:nth-child(odd) { border-right: 1px solid var(--line); }
.facts dt { font-size: 9px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); line-height: 1.2; }
.facts dd { margin: 0; font-size: 16px; font-weight: 600; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-foot { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 5px 2px 0; min-height: 18px; }
.chip { font-size: 10px; font-weight: 700; letter-spacing: .03em; padding: 1px 7px; border-radius: 999px; background: #e9e9e6; white-space: nowrap; margin-left: auto; }
.chip.sale { background: var(--sale); color: #fff; }
.chip.bad { background: var(--bad); color: #fff; }
.chip.wait { background: #e3ecf7; color: var(--accent); }

/* list view */
.tablewrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 5px 8px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 700; background: var(--soft); }
tr.super th { font-size: 11px; color: var(--ink); }
td.wrap { white-space: normal; min-width: 200px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.split { border-left: 2px solid var(--ink); }
tbody tr:nth-child(even) td { background: #fafaf8; }
tr.sel td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
tr.problem td { color: var(--muted); }
tr.grp td { background: var(--soft) !important; font-weight: 700; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; }
tr.grp button { padding: 0 8px; font-size: 12px; margin-left: 6px; text-transform: none; font-weight: 400; }
.st { font-weight: 700; }
.st.ok { color: var(--ok); } .st.bad { color: var(--bad); } .st.sale { color: var(--sale); } .st.wait { color: var(--accent); }
