:root {
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", Arial, sans-serif;
  font-synthesis: none;
  color: #203b44;
  background: #f6f8f6;
  font-size: 14px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  --ink: #203b44;
  --muted: #667782;
  --border: #d8e4e6;
  --border-strong: #bfd4d8;
  --surface: #fff;
  --surface-soft: #f4f8f8;
  --green: #237d76;
  --green-hover: #196b65;
  --green-light: #e6f4f1;
  --navy: #244854;
  --navy-soft: #356876;
  --gold: #f2c66d;
  --red: #bf5252;
  --amber: #936523;
  --control-shadow: 0 1px 2px rgba(23, 56, 64, .07);
  --panel-shadow: 0 8px 24px rgba(23, 56, 64, .045);
}

* { box-sizing: border-box; }
html { overflow-y: scroll; scrollbar-gutter: stable; }
body { margin: 0; min-width: 0; }
button, input, select, textarea { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .52; }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 28px; font-weight: 750; line-height: 1.2; letter-spacing: -.025em; }
h2 { font-size: 18px; font-weight: 750; line-height: 1.4; }
h3 { font-size: 15px; font-weight: 700; }
[hidden] { display: none !important; }

button:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid rgba(79, 154, 179, .36);
  outline-offset: 2px;
}

input:focus,
select:focus,
textarea:focus {
  outline: 0;
  border-color: #4f9ab3;
  box-shadow: 0 0 0 3px rgba(79, 154, 179, .18);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.muted { color: var(--muted); font-size: 13px; }
.eyebrow { color: var(--green); font-size: 12px; font-weight: 750; letter-spacing: .08em; }
.full-width { width: 100%; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 750;
  line-height: 1.3;
  white-space: nowrap;
  box-shadow: var(--control-shadow);
  transition: background-color .16s, border-color .16s, box-shadow .16s;
}

.button.primary { background: var(--green); color: #fff; }
.button.primary:hover:not(:disabled) { background: var(--green-hover); box-shadow: 0 3px 8px rgba(25, 107, 101, .18); }
.button.secondary { background: #fff; border-color: var(--border-strong); color: var(--green); }
.button.secondary:hover:not(:disabled) { background: var(--surface-soft); border-color: #8eb9bc; }
.button.compact { min-height: 34px; padding: 0 10px; border-radius: 7px; font-size: 13px; }

.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 5px 4px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
  white-space: nowrap;
}

.text-button:hover:not(:disabled) { color: var(--green); }
label { display: block; margin-bottom: 7px; color: var(--ink); font-size: 13px; font-weight: 700; }
input, select, textarea {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.4;
}
input::placeholder, textarea::placeholder { color: #82929b; }
.field-help { margin-top: 7px; color: var(--muted); font-size: 12px; line-height: 1.65; }
.form-error { margin-top: 8px; color: var(--red); font-size: 13px; overflow-wrap: anywhere; }

.boot-screen { display: grid; min-height: 100vh; place-items: center; color: var(--muted); }
.login-screen {
  display: grid;
  min-height: 100svh;
  padding: 40px 24px;
  place-items: center;
  background: radial-gradient(circle at 13% 10%, rgba(242, 198, 109, .3), transparent 24%),
    radial-gradient(circle at 88% 88%, rgba(103, 177, 158, .19), transparent 28%),
    linear-gradient(145deg, #163b47 0%, #245963 58%, #1d4a56 100%);
}
.login-card {
  width: min(100%, 460px);
  padding: 34px;
  border: 1px solid rgba(255, 255, 255, .56);
  border-radius: 22px;
  background: rgba(249, 251, 250, .98);
  box-shadow: 0 26px 75px rgba(6, 30, 37, .3);
}
.brand-mark {
  display: inline-grid;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 12px;
  background: var(--gold);
  color: var(--navy);
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: .03em;
}
.login-card .brand-mark { margin-bottom: 23px; }
.login-card .eyebrow { margin-bottom: 7px; }
.login-card h1 { font-size: 28px; }
.login-description { margin: 12px 0 24px; line-height: 1.8; }
.login-card form label:not(:first-child) { margin-top: 16px; }
.login-card form .button { margin-top: 20px; }
.login-note { margin-top: 24px; color: #70858a; font-size: 12px; line-height: 1.7; overflow-wrap: anywhere; }

.app-shell { display: grid; min-height: 100vh; grid-template-columns: 224px minmax(0, 1fr); }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 5;
  display: flex;
  width: 224px;
  padding: 28px 18px;
  flex-direction: column;
  overflow-y: auto;
  background: var(--navy);
  color: #fff;
  scrollbar-color: #5b8790 transparent;
  scrollbar-width: thin;
}
.brand {
  display: flex;
  min-width: 0;
  padding: 0 8px 28px;
  align-items: center;
  gap: 12px;
  color: #fff;
  text-decoration: none;
}
.brand > span:last-child { min-width: 0; }
.brand strong { display: block; font-size: 20px; font-weight: 750; letter-spacing: .04em; white-space: nowrap; }
.brand .brand-description { display: block; margin-top: 4px; color: #a9c0c8; font-size: 13px; line-height: 1.3; }
.brand-mark.small { width: 38px; height: 38px; border-radius: 10px; font-size: 10px; }
.sidebar .tabs { display: grid; margin: 0; padding: 0; gap: 2px; flex: 0 0 auto; }
.sidebar .tab {
  display: flex;
  width: 100%;
  min-height: 40px;
  padding: 9px 12px;
  align-items: center;
  gap: 13px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #c6d7db;
  text-align: left;
  font-size: 14px;
  font-weight: 500;
}
.sidebar .tab .nav-number { color: #82a4ad; font-size: 12px; font-weight: 500; }
.sidebar .tab .nav-label { font-size: 14px; line-height: 1.4; }
.sidebar .tab:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sidebar .tab.active { background: var(--navy-soft); color: #fff; font-weight: 700; }
.sidebar .tab.active .nav-number { color: var(--gold); }
.sidebar-footer { margin-top: auto; padding: 20px 8px 0; border-top: 1px solid #3a6874; flex: 0 0 auto; }
.status-pill {
  display: inline-flex;
  max-width: 100%;
  padding: 5px 9px;
  align-items: center;
  gap: 7px;
  border-radius: 6px;
  background: var(--green-light);
  color: #267867;
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap;
}
.status-pill::before { width: 6px; height: 6px; flex: 0 0 auto; border-radius: 50%; background: currentColor; content: ""; }
.status-pill.neutral { background: #eef2f3; color: #667782; }
.status-pill.warning { background: #fff3e6; color: #916325; }
.sidebar .status-pill { padding: 0; background: transparent; color: #d9e7e9; }
.sidebar .status-pill::before { background: #56c3a6; box-shadow: 0 0 0 3px #315e69; }
.sidebar .status-pill.neutral { color: #acc2c8; }
.sidebar .status-pill.neutral::before { background: #acc2c8; }
.sidebar .status-pill.warning { color: #f2c66d; }
.sidebar .status-pill.warning::before { background: #f2c66d; }
.sidebar-description { margin-top: 10px; color: #a9c0c8; font-size: 12px; line-height: 1.65; }
.sidebar-logout.text-button {
  width: 100%;
  min-height: 36px;
  margin-top: 16px;
  padding: 8px 12px;
  border: 1px solid #527985;
  border-radius: 8px;
  color: #d9e7e9;
  font-size: 13px;
}
.sidebar-logout.text-button:hover:not(:disabled) { border-color: #8bb0b9; background: #315e69; color: #fff; }

.app-main { grid-column: 2; min-width: 0; padding: 18px 34px 0; }
.workspace-topbar {
  display: flex;
  min-height: 56px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--border);
}
.workspace-topbar .eyebrow { margin-bottom: 5px; }
.workspace-topbar h1 { font-size: 22px; line-height: 1.1; }
.workspace-description { max-width: 420px; color: var(--muted); font-size: 13px; line-height: 1.6; text-align: right; }
.library-totals { display: grid; margin-bottom: 18px; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.library-totals > div {
  display: flex;
  min-width: 0;
  min-height: 76px;
  padding: 13px 18px;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--border);
  border-top: 3px solid #5f9fc1;
  border-radius: 10px;
  background: #edf6fb;
}
.library-totals > div:nth-child(2) { border-top-color: #56aa8f; background: #edf8f3; }
.library-totals > div:nth-child(3) { border-top-color: #e9a34f; background: #fff3e6; }
.library-totals strong { display: block; font-size: 30px; font-weight: 750; line-height: 1; letter-spacing: -.03em; }
.library-totals span { color: var(--muted); font-size: 13px; }
.panel { min-width: 0; }
.surface { min-width: 0; border: 1px solid var(--border); border-radius: 12px; background: #fff; box-shadow: var(--panel-shadow); }
.notice {
  display: flex;
  margin-bottom: 16px;
  padding: 13px 16px;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid #c8e2db;
  border-radius: 8px;
  background: var(--green-light);
  color: #296b60;
  font-size: 13px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}
.notice strong { font-size: 13px; font-weight: 750; }
.notice p { margin-top: 2px; font-size: 12px; }
.notice.warning { border-color: #ead9bc; background: #fff7eb; color: #815d29; }
.notice.error { border-color: #ebc9c6; background: #fff1ef; color: #a64a43; }
.service-status { align-items: center; justify-content: space-between; }
.service-status > div { min-width: 0; }
.service-status > button { flex-shrink: 0; }
.upload-recovery { margin: 0 22px 16px; padding: 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-soft); overflow-wrap: anywhere; }
.recovery-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 12px; }
.recovery-warning { margin: 0 22px 16px; }
.metadata-conflict { display: block; margin-top: 16px; }
.metadata-conflict .current-metadata { white-space: pre-wrap; margin: 10px 0; padding: 8px 0; border-top: 1px solid #ead9bc; }
.metadata-conflict > div { max-height: 220px; overflow-y: auto; }
.metadata-conflict .button { white-space: normal; }
.notice-icon { display: grid; width: 19px; height: 19px; margin-top: 2px; flex: 0 0 auto; place-items: center; border: 1px solid currentColor; border-radius: 50%; font-size: 12px; line-height: 1; }

.upload-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 18px; align-items: start; }
.upload-input-card { padding: 22px; }
.section-heading { display: flex; margin-bottom: 20px; align-items: flex-start; justify-content: space-between; gap: 12px; }
.section-heading .muted { margin-top: 5px; font-size: 12px; line-height: 1.65; }
.step-label { margin-top: 4px; color: #7b919a; font-size: 12px; white-space: nowrap; }
.drop-zone {
  display: flex;
  min-height: 168px;
  margin-top: 18px;
  padding: 20px 12px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px dashed #9ec2c3;
  border-radius: 8px;
  background: var(--surface-soft);
  text-align: center;
  cursor: pointer;
  transition: border-color .16s, background-color .16s;
}
.drop-zone:hover, .drop-zone.dragging { border-color: var(--green); background: var(--green-light); }
.upload-symbol { margin-bottom: 12px; color: #55958e; line-height: 1; }
.drop-zone strong { color: #355b61; font-size: 14px; font-weight: 700; }
.drop-zone > span { margin-top: 5px; color: var(--muted); font-size: 12px; }
.file-buttons { display: flex; margin-top: 12px; gap: 10px; }
.file-buttons .button { min-width: 0; padding-inline: 10px; flex: 1; font-size: 13px; }
.supported-formats { margin-top: 11px; text-align: center; }
.flow-note { display: flex; margin-top: 20px; padding-top: 18px; align-items: flex-start; gap: 10px; border-top: 1px solid var(--border); }
.flow-note > span { color: var(--green); font-size: 22px; line-height: 1.2; }
.flow-note strong { color: #46656c; font-size: 13px; font-weight: 700; }
.flow-note p { margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.queue-card { display: flex; min-height: 564px; flex-direction: column; overflow: hidden; }
.queue-card > .section-heading { margin-bottom: 0; padding: 20px 22px 16px; border-bottom: 1px solid var(--border); background: var(--surface-soft); }
.count-badge { display: inline-block; margin-left: 7px; padding: 2px 7px; border: 1px solid #cfe1e0; border-radius: 5px; background: #fff; color: var(--green); font-size: 12px; font-weight: 700; vertical-align: middle; }
.empty-state { display: flex; min-height: 280px; padding: 48px 22px; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.empty-state p { max-width: 360px; margin-top: 8px; color: var(--muted); font-size: 12px; line-height: 1.8; }
.empty-state h3 { color: #59727b; font-size: 14px; font-weight: 700; }
.empty-state .button { margin-top: 18px; }
.empty-icon { display: grid; width: 58px; height: 58px; margin-bottom: 17px; place-items: center; border: 1px solid #dbe8e7; border-radius: 12px; background: var(--surface-soft); color: #82a7ac; font-size: 28px; line-height: 1; }
.queue-empty { min-height: 360px; flex: 1; }
.queue-footer { display: flex; min-height: 76px; padding: 16px 22px; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--border); }
.queue-footer .field-help { margin: 0; }
.queue-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.queue-actions .button { font-size: 13px; }
.queue-list { min-height: 360px; max-height: 534px; margin: 0; padding: 10px 22px; overflow-y: auto; list-style: none; flex: 1; }
.queue-item { display: flex; padding: 14px 0; align-items: center; gap: 12px; border-bottom: 1px solid #e6eeee; }
.queue-item:last-child { border-bottom: 0; }
.queue-thumb { display: grid; width: 48px; height: 58px; flex: 0 0 auto; place-items: center; overflow: hidden; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-soft); color: #80989e; font-size: 12px; }
.queue-thumb img { width: 100%; height: 100%; object-fit: cover; }
.queue-detail { min-width: 0; flex: 1; }
.queue-name { overflow: hidden; color: #35535c; font-size: 13px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.queue-path { margin-top: 2px; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.queue-state-line { display: flex; margin-top: 6px; align-items: center; justify-content: space-between; gap: 8px; }
.queue-state { color: var(--muted); font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.queue-state.error { color: var(--red); }
.queue-state.success { color: var(--green); }
.queue-size { color: #758992; font-size: 12px; white-space: nowrap; }
.queue-progress { height: 4px; margin-top: 6px; overflow: hidden; border-radius: 3px; background: #e8f0f0; }
.queue-progress > span { display: block; width: 0; height: 100%; background: #63a99e; transition: width .2s; }
.queue-item.failed .queue-progress > span, .queue-item.index_failed .queue-progress > span { background: #c78f82; }
.queue-item.indexing .queue-progress > span { animation: pulse 1.6s ease infinite; }
.queue-row-actions { display: flex; align-items: flex-end; flex: 0 0 auto; flex-direction: column; gap: 2px; }
.queue-row-actions button { color: var(--green); font-size: 12px; }
.queue-remove { padding: 2px 4px; color: #82979c !important; font-size: 20px !important; }

.search-form-card { padding: 22px; }
.search-form { display: flex; align-items: center; gap: 26px; }
.search-reference { width: 200px; min-width: 0; flex: 0 0 auto; }
.reference-button { width: 200px; height: 148px; padding: 0; overflow: hidden; border: 1px dashed #9ec2c3; border-radius: 8px; background: var(--surface-soft); color: #5c858c; }
.reference-button:hover { border-color: var(--green); background: var(--green-light); }
.reference-button > span { display: flex; height: 100%; flex-direction: column; align-items: center; justify-content: center; font-size: 13px; }
.reference-plus { margin-bottom: 10px; color: #6b999d; font-size: 28px; line-height: 1; }
.reference-button > img { width: 100%; height: 100%; background: var(--surface-soft); object-fit: contain; }
.search-reference > .field-help { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-fields { min-width: 0; max-width: 620px; flex: 1; }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) 140px; gap: 16px; }
.form-grid > div { min-width: 0; }
.search-fields .button { margin-top: 18px; }
.search-fields > .field-help { margin-top: 10px; }
.result-heading { display: flex; margin: 22px 0 14px; align-items: center; justify-content: space-between; gap: 16px; }
.result-heading h2 { font-size: 18px; }
.result-heading .muted { margin-top: 4px; font-size: 12px; }
.result-heading > .field-help { margin: 0; }
.image-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.image-card { min-width: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 12px; background: #fff; box-shadow: var(--panel-shadow); transition: box-shadow .16s, border-color .16s; }
.image-card:hover { border-color: #a9c9cc; box-shadow: 0 8px 24px rgba(23, 56, 64, .09); }
.image-card-link { position: relative; display: block; overflow: hidden; aspect-ratio: 1.15; background: #f0f4f3; }
.image-card-link img { display: block; width: 100%; height: 100%; object-fit: contain; transition: transform .2s; }
.image-card-link:hover img { transform: scale(1.02); }
.image-fallback { display: flex; width: 100%; height: 100%; align-items: center; justify-content: center; background: var(--surface-soft); color: #7b9299; font-size: 12px; }
.image-card-body { padding: 13px 14px; }
.image-card-name { overflow: hidden; color: #35535c; font-size: 13px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.image-card-path { margin-top: 4px; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.image-card-meta { display: flex; margin-top: 12px; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12px; }
.collection-tag { display: inline-block; max-width: 65%; padding: 2px 6px; overflow: hidden; border: 1px solid #d5e4e2; border-radius: 4px; background: #f4f8f7; color: #526e71; font-size: 12px; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
.image-card-status { color: var(--green); font-size: 12px; white-space: nowrap; }
.image-card-status.failed { color: #946b38; }
.image-card-error { margin-top: 8px; color: #a65a50; font-size: 12px; overflow-wrap: anywhere; }
.image-card-action { display: flex; margin-top: 8px; align-items: center; justify-content: space-between; gap: 8px; }
.image-card-action .text-button { padding: 0; color: var(--green); font-size: 12px; }
.similarity-badge { position: absolute; right: 9px; bottom: 9px; padding: 4px 8px; border: 1px solid #d3e5df; border-radius: 5px; background: rgba(255, 255, 255, .95); color: #2b7267; box-shadow: var(--control-shadow); font-size: 12px; }
.gallery-toolbar { display: flex; padding: 16px 18px; align-items: center; justify-content: space-between; gap: 18px; }
.gallery-filters { display: flex; min-width: 0; max-width: 900px; align-items: center; gap: 12px; flex: 1; }
.gallery-filters .gallery-query { min-width: 120px; flex: 1; }
.gallery-filters > div:not(.gallery-query) { width: 180px; min-width: 0; }
.gallery-toolbar > .text-button { padding-inline: 4px; }
.gallery-toolbar > .text-button > span { font-size: 22px; }
.pagination { display: flex; margin-top: 24px; align-items: center; justify-content: center; gap: 18px; }
.pagination .field-help { margin: 0; }
.app-footer { display: flex; margin-top: 18px; padding: 22px 0 24px; justify-content: space-between; gap: 20px; border-top: 1px solid var(--border); color: #758a91; font-size: 12px; line-height: 1.6; }
.app-footer > span { min-width: 0; overflow-wrap: anywhere; }
.app-footer > span > span { padding-inline: 6px; }

.upload-metadata { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.upload-metadata summary { color: var(--green); font-size: 13px; font-weight: 700; cursor: pointer; }
.metadata-fields { min-width: 0; margin-top: 16px; }
.metadata-fields label:not(:first-child) { margin-top: 14px; }
.metadata-fields textarea { min-height: 72px; resize: vertical; }
.search-mode-tabs { display: grid; margin-bottom: 20px; padding: 4px; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-soft); }
.search-mode { min-width: 0; min-height: 42px; padding: 8px 10px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--muted); font-size: 14px; font-weight: 700; line-height: 1.4; }
.search-mode:hover { color: var(--green); background: #edf5f3; }
.search-mode.active { border-color: #bdd8d4; background: #fff; color: var(--green); box-shadow: var(--control-shadow); }
.search-scope { max-width: 800px; margin-bottom: 20px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.lookup-form { min-width: 0; }
.lookup-row { display: flex; align-items: center; gap: 12px; }
.lookup-row input { min-width: 0; flex: 1; }
.lookup-row .button { flex: 0 0 auto; }
.code-recognition-layout { display: flex; min-width: 0; align-items: center; gap: 26px; }
.code-reference { display: flex; width: 200px; min-width: 0; flex: 0 0 auto; flex-direction: column; gap: 8px; }
.code-reference > .field-help { margin-top: 0; overflow-wrap: anywhere; }
.code-recognition-info { min-width: 0; max-width: 620px; flex: 1; }
.code-recognition-info .button { margin-top: 16px; }
.code-confirm-form { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.code-candidates { min-width: 0; margin: 18px 0 0; padding: 12px; border: 1px solid var(--border); border-radius: 8px; }
.code-candidates legend { padding: 0 5px; color: var(--muted); font-size: 12px; }
.candidate-list { display: flex; min-width: 0; flex-wrap: wrap; gap: 8px; }
.candidate-label { display: inline-flex; max-width: 100%; margin: 0; padding: 7px 10px; align-items: center; gap: 7px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-soft); cursor: pointer; }
.candidate-label span { min-width: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.candidate-label:has(input:checked) { border-color: #70ada4; background: var(--green-light); color: var(--green); }
.candidate-label input { width: 16px; height: 16px; min-height: 16px; margin: 0; padding: 0; flex: 0 0 auto; accent-color: var(--green); }
.reference-options { display: flex; margin-top: 9px; flex-direction: column; align-items: flex-start; gap: 5px; }
.reference-options .field-help { margin-top: 0; overflow-wrap: anywhere; }
.image-product-codes { display: -webkit-box; margin-top: 7px; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; color: var(--green); font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.image-product-codes.muted { color: #82929b; }
.image-card-controls { display: flex; margin-top: 10px; padding-top: 8px; align-items: center; justify-content: space-between; gap: 8px; border-top: 1px solid #e6eeee; }
.image-card-controls > .text-button { margin-left: auto; padding: 3px 0; color: var(--green); font-size: 12px; }
.image-card.selected { border-color: #70ada4; box-shadow: 0 0 0 1px #70ada4; }
.checkbox-label { display: inline-flex; min-width: 0; margin: 0; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 400; cursor: pointer; }
.checkbox-label input { width: 16px; height: 16px; min-height: 16px; margin: 0; padding: 0; flex: 0 0 auto; accent-color: var(--green); }
.gallery-selection { display: flex; margin-top: 12px; padding: 10px 0; align-items: center; flex-wrap: wrap; gap: 10px 16px; border-bottom: 1px solid var(--border); }
.gallery-selection > .checkbox-label { white-space: nowrap; }
.gallery-selection > .field-help { margin: 0; flex: 1; }
.selection-actions { display: flex; min-width: 0; align-items: center; flex-wrap: wrap; gap: 10px; }
.metadata-dialog { width: min(560px, calc(100% - 32px)); max-height: calc(100dvh - 40px); margin: auto; padding: 24px; overflow-y: auto; border: 1px solid var(--border-strong); border-radius: 12px; background: #fff; color: var(--ink); box-shadow: 0 24px 80px rgba(15, 42, 52, .22); }
.metadata-dialog::backdrop { background: rgba(20, 43, 53, .48); }
.dialog-heading { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-heading h2 { min-width: 0; }
.dialog-heading > .text-button { width: 34px; flex: 0 0 auto; font-size: 22px; }
.metadata-dialog > form > .field-help { overflow-wrap: anywhere; }
.dialog-actions { display: flex; margin-top: 22px; justify-content: flex-end; flex-wrap: wrap; gap: 10px; }
.batch-notice { margin-top: 14px; padding: 12px; border: 1px solid #ead9bc; border-radius: 8px; background: #fff7eb; color: #815d29; font-size: 12px; line-height: 1.7; }

@media (max-width: 800px) {
  .code-recognition-layout { gap: 20px; }
  .code-reference { width: 170px; }
}

@media (max-width: 680px) {
  .search-mode-tabs { gap: 4px; padding: 3px; }
  .search-mode { min-height: 48px; padding: 7px 4px; font-size: 12px; overflow-wrap: anywhere; }
  .lookup-row { align-items: stretch; flex-direction: column; gap: 10px; }
  .lookup-row .button { width: 100%; }
  .code-recognition-layout { align-items: stretch; flex-direction: column; gap: 16px; }
  .code-reference { width: 100%; }
  .code-reference .reference-button { width: 100%; height: 160px; }
  .code-reference .button { align-self: flex-start; }
  .code-recognition-info .button { width: 100%; }
  .search-reference { flex-wrap: wrap; }
  .reference-options { min-width: 0; flex: 1 1 100%; }
  .search-scope { margin-bottom: 18px; padding-bottom: 18px; }
  .selection-actions { margin-left: auto; }
  .gallery-selection > .field-help { flex-basis: 50%; }
  .gallery-selection .button { font-size: 12px; }
  .metadata-dialog { padding: 18px; }
}

@keyframes pulse { 50% { opacity: .5; } }

@media (max-width: 1200px) {
  .upload-layout { grid-template-columns: 300px minmax(0, 1fr); gap: 16px; }
  .upload-input-card { padding: 18px; }
  .queue-card > .section-heading { padding: 18px 18px 14px; }
  .queue-list { padding-inline: 18px; }
  .queue-footer { padding: 14px 18px; flex-wrap: wrap; }
  .queue-footer .field-help { flex: 1 0 100%; }
  .queue-actions { margin-left: auto; }
  .section-heading { gap: 8px; }
  .step-label { display: none; }
}

@media (max-width: 1100px) {
  .image-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .gallery-filters > div:not(.gallery-query) { width: 145px; }
}

@media (max-width: 1000px) {
  .app-shell { display: block; }
  .sidebar {
    position: static;
    display: grid;
    width: 100%;
    padding: 16px 22px 12px;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px 20px;
  }
  .brand { padding: 0; }
  .brand strong { font-size: 18px; }
  .brand .brand-description { margin-top: 3px; font-size: 12px; }
  .sidebar .tabs { grid-column: 1 / -1; grid-row: 2; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .sidebar .tab { justify-content: center; }
  .sidebar-footer { display: flex; margin: 0; padding: 0; align-items: center; gap: 18px; border: 0; grid-column: 2; grid-row: 1; }
  .sidebar-description { display: none; }
  .sidebar-logout.text-button { width: auto; min-height: 34px; margin: 0; padding: 6px 12px; }
  .app-main { padding: 22px 22px 0; }
  .workspace-topbar { margin-bottom: 14px; }
  .upload-layout { grid-template-columns: 320px minmax(0, 1fr); }
  .queue-footer .field-help { flex: initial; }
}

@media (max-width: 800px) {
  .upload-layout { grid-template-columns: minmax(0, 1fr); }
  .upload-input-card { padding: 22px; }
  .drop-zone { min-height: 150px; }
  .queue-card { min-height: 400px; }
  .queue-empty { min-height: 260px; }
  .queue-list { min-height: 260px; max-height: 460px; }
  .queue-card > .section-heading { padding: 18px 22px 14px; }
  .queue-list { padding-inline: 22px; }
  .queue-footer { padding: 16px 22px; }
  .workspace-topbar { align-items: flex-start; }
  .workspace-description { max-width: 45%; }
  .search-form { gap: 20px; }
  .search-reference, .reference-button { width: 170px; }
  .form-grid { grid-template-columns: minmax(0, 1fr) 100px; gap: 12px; }
}

@media (max-width: 680px) {
  .sidebar { padding: 14px 16px 12px; gap: 13px 12px; }
  .brand { gap: 9px; }
  .brand strong { font-size: 17px; }
  .brand .brand-description { font-size: 12px; }
  .sidebar-footer { gap: 12px; }
  .sidebar .status-pill { font-size: 12px; }
  .sidebar-logout.text-button { padding-inline: 9px; font-size: 12px; }
  .sidebar .tab { gap: 8px; padding-inline: 8px; }
  .sidebar .tab .nav-label { font-size: 13px; }
  .app-main { padding: 18px 16px 0; }
  .workspace-topbar { min-height: 0; padding-bottom: 12px; flex-direction: column; gap: 8px; }
  .workspace-topbar h1 { font-size: 23px; }
  .workspace-description { max-width: none; text-align: left; font-size: 12px; }
  .library-totals { margin-bottom: 16px; gap: 8px; }
  .library-totals > div { min-height: 80px; padding: 12px 10px; flex-direction: column; align-items: flex-start; gap: 5px; }
  .library-totals strong { font-size: 26px; }
  .library-totals span { font-size: 12px; }
  .upload-layout { gap: 16px; }
  .upload-input-card { padding: 18px; }
  .section-heading { margin-bottom: 18px; }
  .section-heading h2 { font-size: 18px; }
  .file-buttons { gap: 8px; }
  .flow-note { margin-top: 18px; padding-top: 16px; }
  .queue-card > .section-heading { padding: 17px 18px 14px; }
  .queue-list { min-height: 240px; padding: 8px 18px; }
  .queue-item { gap: 10px; }
  .queue-thumb { width: 42px; height: 52px; }
  .queue-footer { padding: 14px 18px; }
  .queue-footer .field-help { flex: 1 0 100%; }
  .queue-actions { max-width: 100%; flex-wrap: wrap; }
  .queue-actions .button { min-height: 40px; }
  .queue-state-line { align-items: flex-start; flex-wrap: wrap; gap: 2px 8px; }
  .search-form-card { padding: 18px; }
  .search-form { flex-direction: column; align-items: stretch; gap: 16px; }
  .search-reference { display: flex; width: 100%; align-items: center; gap: 14px; }
  .reference-button { width: 125px; height: 110px; flex: 0 0 auto; }
  .search-reference > .field-help { white-space: normal; overflow-wrap: anywhere; }
  .search-fields { width: 100%; }
  .search-fields .button { width: 100%; margin-top: 16px; }
  .form-grid { grid-template-columns: minmax(0, 1fr) 90px; gap: 12px; }
  .result-heading { margin-top: 20px; align-items: flex-start; gap: 12px; }
  .result-heading > .field-help { display: none; }
  .image-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .image-card { border-radius: 10px; }
  .image-card-body { padding: 10px; }
  .image-card-name { font-size: 12px; }
  .image-card-meta { margin-top: 9px; flex-wrap: wrap; gap: 6px; }
  .collection-tag { max-width: 100%; }
  .similarity-badge { right: 7px; bottom: 7px; padding: 3px 6px; }
  .gallery-toolbar { padding: 14px; align-items: flex-start; gap: 10px; }
  .gallery-filters { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
  .gallery-filters .gallery-query { min-width: 0; grid-column: 1 / -1; }
  .gallery-filters > div:not(.gallery-query) { width: auto; }
  .gallery-filters .button { padding-inline: 12px; }
  .gallery-toolbar > .text-button { min-height: 40px; font-size: 12px; }
  .pagination { gap: 12px; }
  .pagination .button { min-height: 40px; }
  .app-footer { margin-top: 18px; padding-top: 18px; flex-direction: column; gap: 5px; }
  .notice { padding: 12px; gap: 9px; }
  .login-screen { padding: 28px 18px; }
  .login-card { padding: 28px; }
}

@media (max-width: 420px) {
  .sidebar { grid-template-columns: minmax(0, 1fr); }
  .brand { grid-row: 1; }
  .sidebar-footer { grid-column: 1; grid-row: 2; justify-content: space-between; }
  .sidebar .tabs { grid-row: 3; gap: 5px; }
  .sidebar .tab { gap: 6px; padding-inline: 6px; }
  .sidebar .tab .nav-number { font-size: 12px; }
  .image-grid { gap: 10px; }
  .image-card-body { padding: 9px; }
  .gallery-toolbar { padding: 12px; flex-wrap: wrap; }
  .gallery-filters { flex: 1 0 100%; }
  .gallery-toolbar > .text-button { margin-left: auto; }
  .queue-card > .section-heading { padding-inline: 16px; }
  .queue-list { padding-inline: 16px; }
  .queue-footer { padding-inline: 16px; }
  .queue-row-actions .text-button { padding-inline: 2px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}

/* Group management shares the existing library controls and colors. */
.upload-group-field { margin-top: 16px; }
.group-picker { display: flex; min-width: 0; align-items: center; gap: 8px; }
.group-picker select { min-width: 0; flex: 1; }
.group-picker .button { flex: 0 0 auto; }
.image-card-group { margin-top: 5px; overflow: hidden; color: #54797c; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.groups-toolbar { display: flex; padding: 20px 22px; align-items: center; justify-content: space-between; gap: 18px; }
.group-toolbar-actions { display: flex; flex: 0 0 auto; align-items: center; gap: 10px; }
.group-filter { max-width: 320px; margin-top: 18px; }
#groups-summary { margin: 14px 0; }
#groups-permission { margin-top: 14px; }
.group-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.group-card { padding: 20px; }
.group-card-heading { display: flex; min-width: 0; align-items: flex-start; justify-content: space-between; gap: 12px; }
.group-card-heading h3 { min-width: 0; overflow-wrap: anywhere; font-size: 16px; }
.group-status { padding: 4px 7px; flex: 0 0 auto; border-radius: 5px; background: #eef2f3; color: #667782; font-size: 11px; line-height: 1.4; }
.group-status.active, .group-status.completed { background: var(--green-light); color: var(--green); }
.group-status.pending { background: #fff3e6; color: #936523; }
.group-stats { display: flex; margin-top: 18px; align-items: baseline; gap: 14px; color: var(--muted); font-size: 13px; }
.group-stats strong { color: var(--ink); font-size: 20px; font-weight: 750; }
.group-card-actions { display: flex; margin-top: 18px; padding-top: 14px; align-items: center; flex-wrap: wrap; gap: 12px; border-top: 1px solid var(--border); }
.group-card-actions .danger-text { margin-left: auto; }
.danger-text { color: var(--red); }
.image-card-controls > .danger-text { color: var(--red); }
.image-deletion-tasks { margin-top: 24px; }
.image-delete-names { margin-top: 10px; overflow-wrap: anywhere; }
.danger-text:hover:not(:disabled) { color: #a43c3c; }
.button.danger { background: #b84f4f; color: #fff; }
.button.danger:hover:not(:disabled) { background: #a43c3c; }
.group-progress { display: block; width: 100%; height: 10px; margin-top: 16px; accent-color: var(--green); }
.group-job-status { min-height: 40px; }
.group-background-note { margin-top: 18px; }
#folder-use-existing { margin-top: 10px; }
.search-scope.form-grid { max-width: 100%; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 110px; }
@media (max-width: 1100px) {
  .gallery-filters { flex-wrap: wrap; }
  .gallery-filters .gallery-query { flex-basis: 100%; }
  .gallery-filters > div:not(.gallery-query) { flex: 1; }
}
@media (max-width: 1000px) {
  .sidebar .tabs { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .groups-toolbar { padding: 18px; flex-direction: column; align-items: stretch; gap: 14px; }
  .group-toolbar-actions { flex-wrap: wrap; justify-content: flex-end; }
  .group-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .group-card { padding: 16px; }
  .group-card-heading { flex-wrap: wrap; gap: 8px; }
  .group-card-heading h3 { flex-basis: 100%; }
  .search-scope.form-grid { grid-template-columns: minmax(0, 1fr) 90px; }
  .search-scope.form-grid > div:first-child { grid-column: 1 / -1; }
  .gallery-filters > div:not(.gallery-query) { width: auto; }
  .gallery-filters > div:has(#gallery-group) { grid-column: 1 / -1; grid-row: 3; }
  .sidebar .tab { gap: 4px; padding-inline: 4px; }
  .sidebar .tab .nav-number { display: none; }
  .sidebar .tab .nav-label { font-size: 12px; }
  .group-background-note { font-size: 11px; }
}
@media (max-width: 420px) {
  .sidebar .tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dialog-actions .button.danger { width: 100%; min-height: 44px; white-space: normal; }
}
