/* 功能优先的朴素样式。电脑和平板（触屏）都能用：按钮至少 36px 高。 */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif; color: #222; background: #f4f4f4; }
a { color: #1a5fb4; }
button, .button, select, input, textarea { font: inherit; }
button, .button { min-height: 36px; padding: 4px 12px; border: 1px solid #aaa; border-radius: 4px; background: #fff; color: #222; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
button:hover, .button:hover { background: #eee; }
button:disabled { opacity: .45; cursor: default; }
button.primary, .button.primary { background: #1a5fb4; border-color: #1a5fb4; color: #fff; }
button.primary:hover { background: #164f96; }
button.danger { color: #b00; border-color: #b00; }
button.mini { min-height: 32px; min-width: 32px; padding: 0 6px; justify-content: center; }
input[type=text], input[type=password], input[type=search], select, textarea { min-height: 36px; padding: 4px 8px; border: 1px solid #aaa; border-radius: 4px; background: #fff; max-width: 100%; }
textarea { width: 100%; resize: vertical; }
.muted { color: #777; }
.err { color: #b00; }
.small { font-size: 13px; }
.mono { font-family: Consolas, "SFMono-Regular", monospace; }

/* 顶栏 */
#top { position: sticky; top: 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; padding: 6px 12px; background: #263238; color: #fff; }
#top .brand { font-size: 17px; }
#top nav { display: flex; flex-wrap: wrap; gap: 2px; }
#top nav a { color: #cfd8dc; text-decoration: none; padding: 6px 10px; border-radius: 4px; }
#top nav a.on { background: #fff; color: #263238; }
#top .me { margin-left: auto; }
#top .me button { min-height: 30px; padding: 0 8px; }
main { padding: 12px; max-width: 1800px; margin: 0 auto; }

/* 状态 */
.badge { display: inline-block; padding: 0 6px; border-radius: 3px; font-size: 12px; line-height: 20px; white-space: nowrap; color: #fff; background: #888; }
.badge.s-未填 { background: #9e9e9e; }
.badge.s-已填 { background: #2e7d32; }
.badge.s-需要复核 { background: #e65100; }
.badge.s-不用于训练 { background: #6a1b9a; }
.tag { display: inline-block; padding: 0 5px; border: 1px solid #bbb; border-radius: 3px; font-size: 12px; line-height: 18px; color: #555; background: #fafafa; white-space: nowrap; }
.tag.warn { border-color: #e65100; color: #e65100; }

/* 列表 */
.progress { background: #fff; border: 1px solid #ddd; border-radius: 6px; padding: 8px 12px; margin-bottom: 10px; }
.bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: #e0e0e0; margin: 6px 0; }
.bar span { display: block; height: 100%; }
.counts { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.counts button { min-height: 30px; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.filters input[type=search] { width: 220px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; }
.toolbar .sep { flex: 1; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.card { position: relative; background: #fff; border: 2px solid #ddd; border-radius: 6px; overflow: hidden; cursor: pointer; display: flex; flex-direction: column; }
.card:hover { border-color: #90a4ae; }
.card.sel { border-color: #1a5fb4; box-shadow: 0 0 0 2px #1a5fb4 inset; }
.card .thumb { aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center; padding: 6px; }
.card .thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.card .info { padding: 4px 6px 6px; font-size: 13px; line-height: 1.35; }
.card .id { font-family: Consolas, monospace; font-size: 12px; color: #555; }
.card .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .name.batchname { font-weight: normal; color: #888; }
.card .tags { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 3px; }
.card .check { position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 4px; border: 2px solid #1a5fb4; background: #fff; display: none; align-items: center; justify-content: center; color: #1a5fb4; font-weight: bold; }
.selecting .card .check { display: flex; }
.card.sel .check { background: #1a5fb4; color: #fff; }

/* 浅底 / 深底 */
.bg-light { background: #fff; background-image: linear-gradient(45deg, #f3f3f3 25%, transparent 25%, transparent 75%, #f3f3f3 75%), linear-gradient(45deg, #f3f3f3 25%, transparent 25%, transparent 75%, #f3f3f3 75%); background-size: 16px 16px; background-position: 0 0, 8px 8px; }
.bg-dark { background: #2b2b2b; }

/* 详情 */
.actions { position: sticky; top: 46px; z-index: 10; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px 8px; margin: -12px -12px 12px; background: #eceff1; border-bottom: 1px solid #cfd8dc; }
.actions .title { font-weight: 600; margin-right: 6px; }
.actions .sep { flex: 1; }
.actions .keys { font-size: 12px; color: #666; }
.detail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(380px, 560px); gap: 14px; align-items: start; }
@media (max-width: 1000px) { .detail { grid-template-columns: minmax(0, 1fr); } .actions { top: 0; position: static; } }
.panel { background: #fff; border: 1px solid #ddd; border-radius: 6px; padding: 10px; margin-bottom: 12px; }
.panel h4 { margin: 0 0 6px; font-size: 15px; }
.media { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 560px) { .media { grid-template-columns: minmax(0, 1fr); } }
.fig { margin: 0; }
.fig .imgbox { position: relative; border: 1px solid #ddd; border-radius: 4px; display: flex; align-items: center; justify-content: center; min-height: 160px; padding: 6px; }
.fig .imgbox img { max-width: 100%; max-height: 60vh; object-fit: contain; cursor: zoom-in; }
.fig figcaption { font-size: 13px; color: #555; margin-top: 4px; }
.boxwrap { position: relative; display: inline-block; max-width: 100%; }
.boxwrap img { display: block; max-width: 100%; max-height: 60vh; }
.cropbox { position: absolute; border: 2px solid #f00; box-shadow: 0 0 0 1px #fff; pointer-events: none; }
.seg { display: inline-flex; }
.seg button { border-radius: 0; min-height: 30px; }
.seg button:first-child { border-radius: 4px 0 0 4px; }
.seg button:last-child { border-radius: 0 4px 4px 0; }
.seg button.on { background: #263238; color: #fff; border-color: #263238; }
.thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.thumbs img { height: 80px; border: 1px solid #ccc; border-radius: 3px; cursor: zoom-in; background: #fff; }
.strip-row { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.strip-item { flex: 0 0 96px; text-decoration: none; color: #333; border: 2px solid #ddd; border-radius: 4px; font-size: 12px; text-align: center; background: #fff; }
.strip-item.cur { border-color: #1a5fb4; }
.strip-item .thumb { height: 80px; display: flex; align-items: center; justify-content: center; }
.strip-item img { max-width: 90px; max-height: 76px; }
.kv { display: grid; grid-template-columns: 7em minmax(0, 1fr); gap: 2px 8px; font-size: 14px; }
.kv dt { color: #666; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.sw { display: flex; flex-direction: column; align-items: center; font-size: 12px; width: 70px; }
.sw .chip-color { width: 44px; height: 30px; border: 1px solid #999; border-radius: 3px; }
.sw .hex { font-family: Consolas, monospace; }
.flags { margin: 4px 0 0; padding-left: 18px; color: #b45309; font-size: 13px; }

/* 表单 */
.form fieldset { border: 1px solid #ddd; border-radius: 6px; margin: 0 0 10px; padding: 6px 10px 10px; background: #fff; min-width: 0; }
.form legend { font-weight: 600; padding: 0 4px; }
.field { margin: 8px 0; }
.field-label { display: block; font-weight: 600; margin-bottom: 3px; }
.req { color: #b00; }
.hint { font-size: 12px; color: #777; margin-bottom: 3px; }
.field input[type=text] { width: 100%; }
.field.bad .field-label { color: #b00; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { min-height: 34px; padding: 2px 10px; border-radius: 17px; border: 1px solid #999; background: #fff; }
.chip.on { background: #1a5fb4; border-color: #1a5fb4; color: #fff; }
.chip.on:hover { background: #164f96; }
.chip-add { width: 7em !important; min-height: 34px; border-radius: 17px !important; }
.rows .row { display: flex; gap: 4px; align-items: center; margin-bottom: 4px; }
.rows .row input[type=text] { flex: 1 1 auto; min-width: 0; width: auto; }
.rows .row select { flex: 0 1 auto; width: 8em; min-width: 5em; }
.rows .row-no { width: 1.6em; color: #777; text-align: right; }
.rows .add { min-height: 32px; }
.form-msg { border: 1px solid #b00; background: #fff3f3; color: #900; padding: 6px 10px; border-radius: 4px; margin-bottom: 8px; }
.saved-info { font-size: 13px; color: #555; }
.history { font-size: 13px; }
.history li { margin-bottom: 4px; }
.prefilled { color: #b45309; }

/* 弹窗 */
.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; padding: 12px; }
.overlay.solid { background: #263238; }
.dialog { background: #fff; border-radius: 8px; padding: 14px 16px; width: min(640px, 100%); max-height: 92vh; overflow: auto; }
.dialog h3 { margin: 0 0 8px; }
.dialog-buttons { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.dialog input[type=text], .dialog input[type=password] { width: 100%; }
.dialog table { border-collapse: collapse; width: 100%; font-size: 14px; }
.dialog td, .dialog th { border: 1px solid #ddd; padding: 4px 6px; vertical-align: top; text-align: left; }
.lightbox { position: fixed; inset: 0; z-index: 110; background: rgba(0,0,0,.85); display: flex; flex-direction: column; }
.lightbox .lb-bar { display: flex; gap: 6px; align-items: center; padding: 6px 10px; color: #fff; }
.lightbox .lb-bar .sep { flex: 1; }
.lightbox .lb-body { flex: 1; overflow: auto; display: flex; touch-action: pan-x pan-y pinch-zoom; }
.lightbox .lb-body img { margin: auto; display: block; }
.lightbox .lb-body.fit img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox .lb-body.actual img { max-width: none; max-height: none; }

/* 表格页 */
table.list { border-collapse: collapse; width: 100%; background: #fff; font-size: 14px; }
table.list th, table.list td { border: 1px solid #ddd; padding: 4px 6px; text-align: left; vertical-align: top; }
table.list th { background: #eceff1; position: sticky; top: 46px; }
table.list td.ids { max-width: 360px; }
table.list td.ids a { margin-right: 6px; white-space: nowrap; }
.mergebar { position: sticky; bottom: 0; background: #fffde7; border: 1px solid #e0d080; padding: 8px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0 16px; }
.vocab-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.vocab-list textarea { min-height: 180px; font-size: 14px; }
.used-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }

#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 200; padding: 8px 16px; border-radius: 6px; background: #2e7d32; color: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.3); max-width: 90vw; }
#toast.err { background: #b00020; }
#toast.warn { background: #e65100; }
