* { box-sizing: border-box; }

:root {
  --primary: #e8799d;
  --primary-hover: #d95f8c;
  --primary-soft: #fdeef4;
  --primary-ring: rgba(232, 121, 157, .25);
  --text: #3d2b33;
  --text-secondary: #8a6b76;
  --text-muted: #a58b94;
  --surface: #fffdfe;
  --surface-subtle: #fff5f8;
  --surface-hover: #fdeaf1;
  --border: #f3d9e2;
  --border-strong: #e8c3d1;
  --danger: #c9363e;
  --danger-soft: #fff0f1;
  --success: #237a4b;
  --success-soft: #eaf7ef;
  --warning: #9a5a08;
  --shadow-sm: 0 1px 2px rgba(61, 43, 51, .05), 0 5px 16px rgba(61, 43, 51, .04);
  --shadow-md: 0 12px 32px rgba(61, 43, 51, .11);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--surface-subtle);
  font-synthesis: none;
}

html { min-width: 320px; background: var(--surface-subtle); }
body { min-width: 320px; min-height: 100vh; min-height: 100dvh; margin: 0; color: var(--text); background: var(--surface-subtle); line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, select { max-width: 100%; font: inherit; }
button { cursor: pointer; }
button, a.btn, label.btn { transition: color .18s ease, background-color .18s ease, border-color .18s ease, box-shadow .18s ease, transform .18s ease; }
button:active, a.btn:active, label.btn:active { transform: translateY(1px); }
button:disabled { opacity: .46; cursor: not-allowed; transform: none; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--primary-ring); outline-offset: 2px; }

.main-container { width: min(1180px, 100%); margin: 0 auto; padding: 0 24px 56px; }
.page-header { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 20px; margin: 0 -24px 28px; padding: max(17px, env(safe-area-inset-top)) 24px 16px; border-bottom: 1px solid rgba(201, 212, 216, .76); background: rgba(244, 247, 248, .9); backdrop-filter: saturate(150%) blur(18px); -webkit-backdrop-filter: saturate(150%) blur(18px); }
.page-header > div { min-width: 0; }
.eyebrow { display: block; color: var(--primary); font-size: 11px; font-weight: 750; letter-spacing: .08em; }
h1 { margin: 3px 0 0; font-size: clamp(27px, 4vw, 35px); line-height: 1.15; letter-spacing: 0; }
.page-header p { margin: 4px 0 0; color: var(--text-secondary); font-size: 13px; }

.quick-search, .panel-toolbar, .admin-panel, .access-card { border: 1px solid rgba(220, 228, 231, .9); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow-sm); }
.quick-search { margin-bottom: 16px; padding: 20px; border-top: 3px solid var(--primary); }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 15px; }
.section-heading strong { color: var(--text); font-size: 17px; line-height: 1.35; }
.section-heading span { color: var(--text-muted); font-size: 12px; line-height: 1.55; text-align: right; }
.toolbar-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; min-width: 0; }
label { color: #364349; font-size: 13px; font-weight: 650; }
input, select { min-width: 0; min-height: 44px; border: 1px solid var(--border-strong); border-radius: 7px; padding: 9px 12px; color: var(--text); background: var(--surface); outline: none; transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease; }
input::placeholder { color: #96a1a6; }
input:hover, select:hover { border-color: #aebcc1; }
input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
input[type="file"] { padding: 7px; color: var(--text-secondary); }
input[type="file"]::file-selector-button { min-height: 30px; margin-right: 10px; border: 0; border-radius: 5px; padding: 5px 11px; color: var(--primary); background: var(--primary-soft); font-weight: 650; cursor: pointer; }
.quick-search input { flex: 1; min-width: 180px; }
.quick-search-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
.filter-field { display: flex; min-width: 0; align-items: center; gap: 8px; }
.filter-field label { flex: none; }
.quick-search-field input { width: 100%; }
.catalog-filter-row { display: grid; grid-template-columns: minmax(190px, 1fr) minmax(190px, 1fr) auto; }
.catalog-filter-row .filter-field { cursor: default; }
.select-control { position: relative; display: block; min-width: 0; flex: 1; }
.select-control::after { content: ""; position: absolute; top: 50%; right: 14px; width: 7px; height: 7px; border-right: 2px solid var(--text-muted); border-bottom: 2px solid var(--text-muted); pointer-events: none; transform: translateY(-65%) rotate(45deg); }
.select-control select { width: 100%; padding-right: 38px; appearance: none; -webkit-appearance: none; }
.filter-actions { display: flex; min-width: 0; gap: 10px; }
.btn { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 7px; padding: 10px 17px; font-size: 14px; font-weight: 700; line-height: 1.2; text-decoration: none; white-space: nowrap; }
.btn-search { color: #fff; background: var(--primary); box-shadow: 0 3px 10px rgba(232, 121, 157, .18); }
.btn-search:hover:not(:disabled) { background: var(--primary-hover); box-shadow: 0 5px 14px rgba(232, 121, 157, .24); }
.btn-outline { color: var(--primary); border-color: var(--border-strong); background: var(--surface); }
.btn-outline:hover:not(:disabled) { border-color: #9fb6bb; background: var(--primary-soft); }
.btn-danger { color: var(--danger); border-color: #efc3c6; background: var(--danger-soft); }
.btn-danger:hover:not(:disabled) { color: #a92931; border-color: #dfa2a6; background: #ffe4e6; }

/* Visitor catalog */
.browser-layout { display: block; min-height: 0; }
.access-panel { display: grid; min-height: min(540px, calc(100vh - 150px)); min-height: min(540px, calc(100dvh - 150px)); place-items: center; padding: 24px 0 72px; }
.access-card { width: min(420px, 100%); padding: 28px; border-top: 3px solid var(--primary); box-shadow: var(--shadow-md); }
.access-card h2 { margin: 0 0 20px; font-size: 22px; line-height: 1.3; }
.access-card label, .access-card input { display: block; width: 100%; }
.access-card input { margin-top: 7px; }
.access-card .btn { width: 100%; margin-top: 18px; }
.access-card .error { margin-bottom: 0; text-align: center; }
.left-panel { min-width: 0; }
.panel-toolbar { margin-bottom: 16px; padding: 15px 18px; }
.panel-toolbar .toolbar-row > label { margin-right: -3px; }
.image-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; min-height: 390px; align-content: start; }
.image-grid.compact { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.image-media { position: relative; aspect-ratio: 1; overflow: hidden; background: #edf1f2; }
.image-media::before { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, #edf1f2 20%, #f7f9f9 40%, #edf1f2 60%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
.image-media.is-loaded::before { display: none; }
.card-img { opacity: 0; transition: opacity .3s ease, transform .28s ease; }
.image-media.is-loaded .card-img { opacity: 1; }
.card-mark { position: absolute; top: 7px; left: 7px; z-index: 2; width: 44px; height: 44px; border: 0; color: #d08a00; background: rgba(255,255,255,.9); border-radius: 50%; font-size: 23px; cursor: pointer; }
.image-card.is-marked { border-color: #d6a437; }
.skeleton-card { aspect-ratio: 1.08; border-radius: 8px; background: linear-gradient(100deg,#edf1f2 20%,#f7f9f9 40%,#edf1f2 60%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.marks-panel { margin: 0 0 16px; padding: 13px 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-subtle); }
.marks-heading { display:flex; align-items:center; justify-content:space-between; gap:10px; }.marks-list { display:flex; flex-wrap:wrap; gap:7px; margin-top:10px; }.mark-chip { min-height:36px; padding:5px 10px; border:1px solid var(--border-strong); border-radius:18px; color:var(--primary); background:#fff; cursor:pointer; }
.empty-state, .placeholder { grid-column: 1 / -1; margin: 0; border: 1px dashed var(--border-strong); border-radius: 8px; padding: 76px 14px; color: var(--text-muted); background: rgba(255, 255, 255, .55); font-size: 14px; text-align: center; }
.image-card { position: relative; min-width: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow-sm); cursor: pointer; transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease; }
.image-card:hover { z-index: 1; border-color: #b9c8cc; box-shadow: 0 12px 26px rgba(24, 33, 38, .12); transform: translateY(-3px); }
.image-card.selected { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-ring), 0 12px 26px rgba(24, 33, 38, .12); }
.image-card.selected::after { content: "✓"; position: absolute; top: 9px; right: 9px; display: grid; width: 26px; height: 26px; place-items: center; border: 2px solid #fff; border-radius: 50%; color: #fff; background: var(--primary); box-shadow: 0 2px 7px rgba(24, 33, 38, .22); font-size: 14px; font-weight: 800; }
.card-img { display: block; width: 100%; aspect-ratio: 1; object-fit: contain; background: #f1f4f5; transition: transform .28s ease; }
.image-card:hover .card-img { transform: scale(1.025); }
.card-label { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; overflow: hidden; padding: 8px 9px 9px; border-top: 1px solid #f3d9e2; color: #3d2b33; background: var(--surface); font-size: 13px; font-weight: 650; line-height: 1.25; text-align: center; }
.card-label .card-code { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-label .card-cat { max-width: 100%; overflow: hidden; color: #c9a8b5; font-size: 11px; font-weight: 400; text-overflow: ellipsis; white-space: nowrap; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 22px 0 4px; }
.pagination > #page { min-width: 175px; color: var(--text-secondary); font-size: 13px; text-align: center; }
.btn-page { color: var(--primary); border-color: var(--border-strong); background: var(--surface); }
.btn-page:hover:not(:disabled) { border-color: #9fb6bb; background: var(--primary-soft); }
.quick-page { display: inline-flex; align-items: center; gap: 5px; margin-left: 2px; padding-left: 12px; border-left: 1px solid var(--border); color: var(--text-secondary); font-size: 13px; white-space: nowrap; }
.quick-page input { width: 52px; min-height: 44px; padding: 8px 5px; border: 1px solid var(--border-strong); border-radius: 9px; color: var(--text); background: var(--surface); text-align: center; }
.quick-page-total { min-width: auto !important; color: var(--text-secondary) !important; font-size: 13px !important; text-align: left !important; }
.btn-quick-page { min-height: 44px; padding: 8px 16px; color: #fff; border-color: var(--primary); border-radius: 999px; background: var(--primary); box-shadow: 0 4px 10px rgba(232, 121, 157, .2); }
.btn-quick-page:hover:not(:disabled) { border-color: var(--primary-hover); background: var(--primary-hover); }
.quick-page input:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }

/* Dialogs and preview */
dialog { width: min(480px, calc(100% - 28px)); border: 1px solid var(--border); border-radius: 8px; padding: 25px; color: var(--text); background: var(--surface); box-shadow: 0 24px 64px rgba(15, 25, 30, .25); }
dialog::backdrop { background: rgba(16, 25, 29, .5); backdrop-filter: blur(3px); }
dialog h2 { margin: 0 0 16px; font-size: 21px; }
dialog label { display: block; margin: 13px 0; }
dialog input, dialog select { display: block; width: 100%; margin-top: 6px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }
.update-reminder { width: min(440px, calc(100% - 24px)); max-height: calc(100dvh - 24px); overflow-x: hidden; overflow-y: auto; overflow-wrap: anywhere; border-color: #f1a9c4; padding: 28px; background: #fff7fa; }
.update-reminder h2 { color: #8f2852; text-align: center; }
.update-reminder-close { position: absolute; top: 8px; right: 8px; width: 44px; height: 44px; border: 0; color: #7b3a55; background: transparent; font-size: 28px; line-height: 1; cursor: pointer; }
.update-reminder-close:focus-visible { outline: 3px solid #df6b99; outline-offset: 1px; }
.update-reminder-mark { width: 48px; height: 48px; margin: 0 auto 12px; border-radius: 50%; color: #ffffff; background: #d94f86; font-size: 30px; font-weight: 800; line-height: 48px; text-align: center; }
.update-reminder-versions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 18px 0; }
.update-reminder-versions div { min-width: 0; border: 1px solid #f2bfd2; border-radius: 6px; padding: 10px; background: #ffffff; }
.update-reminder-versions dt { color: #855d6d; font-size: 12px; }
.update-reminder-versions dd { margin: 4px 0 0; color: #59233a; font-weight: 750; overflow-wrap: anywhere; }
.update-reminder-notes { max-height: 30vh; overflow-y: auto; white-space: pre-wrap; }
.update-reminder-busy { min-height: 1.5em; margin: 10px 0 0; color: #9b315c; font-weight: 700; }
.error { min-height: 1.5em; color: var(--danger); font-size: 13px; }
.modal-overlay { position: fixed; inset: 0; z-index: 9998; display: flex; width: 100%; height: 100vh; height: 100dvh; align-items: center; justify-content: center; padding: 24px; background: rgba(16, 25, 29, .58); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.modal-box { position: relative; display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr); width: min(960px, 100%); max-height: min(82vh, 760px); max-height: min(82dvh, 760px); overflow: hidden; border: 1px solid rgba(255, 255, 255, .32); border-radius: 8px; background: var(--surface); box-shadow: 0 28px 80px rgba(5, 13, 16, .34); }
.modal-close { position: absolute; top: 12px; right: 12px; z-index: 2; width: 44px; height: 44px; border: 1px solid rgba(201, 212, 216, .8); border-radius: 50%; color: var(--text); background: rgba(255, 255, 255, .9); box-shadow: 0 3px 12px rgba(24, 33, 38, .14); font-size: 17px; }
.modal-close:hover { color: var(--primary); background: #fff; }
.modal-img { width: 100%; height: 100%; min-height: 420px; max-height: min(82vh, 760px); max-height: min(82dvh, 760px); object-fit: contain; background: #eef2f3; cursor: zoom-in; }
.preview-stage { position:relative; min-width:0; min-height:420px; overflow:hidden; background:#eef2f3; }.preview-stage .modal-img { display:block; min-height:100%; transition:transform .12s ease; }.preview-arrow { position:absolute; top:50%; z-index:2; width:48px; height:48px; border:1px solid rgba(255,255,255,.65); border-radius:50%; color:#fff; background:rgba(16,25,29,.55); font-size:34px; transform:translateY(-50%); cursor:pointer; }.preview-prev{left:12px}.preview-next{right:12px}.preview-count{margin-bottom:10px;color:var(--primary);font-weight:700}.mark-button{width:100%;margin-bottom:12px}
.modal-detail { min-width: 0; overflow-y: auto; padding: 64px 22px 24px; border-left: 1px solid var(--border); font-size: 14px; line-height: 1.6; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.modal-detail table { width: 100%; border-collapse: collapse; }
.modal-detail tr:not(:last-child) { border-bottom: 1px solid #edf1f2; }
.modal-detail td { padding: 9px 4px; vertical-align: top; overflow-wrap: anywhere; }
.modal-detail .label { width: 72px; color: var(--text-muted); font-weight: 650; white-space: nowrap; }
.modal-detail .section { padding-top: 18px; color: var(--primary); font-weight: 750; border-top: 0; }
.lightbox { position: fixed; inset: 0; z-index: 9999; display: flex; width: 100%; height: 100vh; height: 100dvh; align-items: center; justify-content: center; padding: max(16px, env(safe-area-inset-top)) 16px max(48px, env(safe-area-inset-bottom)); cursor: zoom-out; background: rgba(5, 10, 12, .96); }
.lightbox img { max-width: 100%; max-height: 90vh; max-height: 90dvh; object-fit: contain; border-radius: 6px; box-shadow: 0 20px 70px rgba(0, 0, 0, .45); }
.lightbox-hint { position: fixed; right: 0; bottom: calc(16px + env(safe-area-inset-bottom)); left: 0; color: rgba(255, 255, 255, .7); font-size: 13px; text-align: center; pointer-events: none; }

/* Admin */
.admin-container { width: min(1180px, 100%); }
.admin-panel { margin: 0 0 18px; padding: 21px; }
.admin-stats { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:10px; margin-bottom:18px; }.admin-stats div { padding:14px; border:1px solid var(--border); border-radius:8px; background:var(--surface); box-shadow:var(--shadow-sm); }.admin-stats strong,.admin-stats span{display:block}.admin-stats strong{color:var(--primary);font-size:24px}.admin-stats span{margin-top:3px;color:var(--text-muted);font-size:12px}.upload-dropzone{margin:0 0 12px;padding:18px;border:1px dashed var(--border-strong);border-radius:7px;color:var(--text-secondary);background:var(--surface-subtle);text-align:center}.upload-dropzone.is-dragover{border-color:var(--primary);color:var(--primary);background:var(--primary-soft)}
.admin-panel h2 { margin: 0 0 7px; font-size: 22px; line-height: 1.3; }
.admin-panel > p { margin: 0 0 18px; color: var(--text-secondary); font-size: 14px; }
.admin-login { width: min(430px, 100%); margin: 72px auto 0; padding: 28px; border-top: 3px solid var(--primary); box-shadow: var(--shadow-md); }
.admin-login label, .admin-login input { display: block; width: 100%; }
.admin-login input { margin-top: 7px; }
.admin-login .btn { width: 100%; margin-top: 10px; }
.admin-notice { position: fixed; top: max(16px, env(safe-area-inset-top)); left: 50%; z-index: 10000; max-width: min(520px, calc(100% - 28px)); border: 1px solid #a8d6ba; border-radius: 8px; padding: 12px 17px; color: var(--success); background: rgba(234, 247, 239, .97); box-shadow: var(--shadow-md); font-size: 14px; font-weight: 650; line-height: 1.45; transform: translateX(-50%); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.admin-notice.is-error { border-color: #efbec2; color: #a82830; background: rgba(255, 240, 241, .98); }
.admin-notice:empty { display: none; }
.checkbox-label { display: inline-flex; min-height: 44px; align-items: center; gap: 9px; margin-bottom: 10px; white-space: nowrap; cursor: pointer; }
.checkbox-label input { position: relative; width: 44px; height: 26px; min-width: 44px; min-height: 26px; margin: 0; border: 0; border-radius: 999px; padding: 0; appearance: none; -webkit-appearance: none; background: #d9e0e2; box-shadow: none; cursor: pointer; transition: background-color .2s ease; }
.checkbox-label input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(24, 33, 38, .25); transition: transform .2s ease; }
.checkbox-label input:checked { background: var(--primary); }
.checkbox-label input:checked::after { transform: translateX(18px); }
.checkbox-label input:focus-visible { box-shadow: 0 0 0 3px var(--primary-ring); }
#settingsForm { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 18px; }
#settingsForm .checkbox-label, #settingsForm button { grid-column: 1 / -1; justify-self: start; }
#settingsForm label:not(.checkbox-label) { display: block; margin-bottom: 12px; }
#settingsForm label:not(.checkbox-label) input { display: block; width: 100%; margin-top: 6px; }
#settingsForm label:first-of-type + label { grid-column: 1 / -1; }
#settingsForm label small { display: block; margin-top: 5px; color: var(--text-muted); font-weight: 400; }
.admin-filters { margin-bottom: 14px; padding: 12px; border: 1px solid #e5ebed; border-radius: 7px; background: var(--surface-subtle); }
.admin-filters label { display: inline-flex; align-items: center; gap: 7px; }
.admin-filters input { width: 160px; }
.batch-bar { position: sticky; top: 91px; z-index: 10; margin-bottom: 14px; padding: 11px 12px; border: 1px solid #b7d8dc; border-radius: 7px; background: rgba(232, 245, 246, .97); box-shadow: 0 5px 18px rgba(24, 33, 38, .08); backdrop-filter: blur(12px); }
.batch-bar > span { margin-right: 2px; color: #345159; font-size: 13px; }
.batch-bar b { color: var(--primary); font-size: 15px; }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.admin-card { position: relative; min-width: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow-sm); transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease; }
.admin-card:hover { border-color: #b9c8cc; box-shadow: 0 9px 22px rgba(24, 33, 38, .1); transform: translateY(-2px); }
.admin-card img { display: block; width: 100%; aspect-ratio: 1; object-fit: contain; background: #f1f4f5; user-select: none; }
.admin-image-placeholder { display: grid; width: 100%; aspect-ratio: 1; place-items: center; padding: 12px; color: var(--text-muted); background: #f1f4f5; font-size: 13px; text-align: center; }
.item-check { position: absolute; top: 8px; left: 8px; z-index: 2; width: 22px; height: 22px; margin: 0; opacity: 0; accent-color: var(--primary); pointer-events: none; }
.admin-card.selected { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-ring), 0 9px 22px rgba(232, 121, 157, .14); }
.admin-card.selected::after { content: "✓"; position: absolute; top: 9px; right: 9px; z-index: 3; display: grid; width: 26px; height: 26px; place-items: center; border: 2px solid #fff; border-radius: 50%; color: #fff; background: var(--primary); box-shadow: 0 2px 7px rgba(24, 33, 38, .22); font-size: 14px; font-weight: 800; }
.admin-card-info { display: grid; gap: 4px; padding: 11px 12px; font-size: 12px; }
.admin-card-info strong { overflow: hidden; color: #26363d; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.admin-card-info small { overflow: hidden; color: var(--text-muted); text-overflow: ellipsis; white-space: nowrap; }
.admin-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding: 10px 11px 11px; border-top: 1px solid #edf1f2; }
.admin-actions .btn { min-width: 0; min-height: 44px; padding: 8px 5px; font-size: 12px; }
.admin-result { margin-top: 13px; }
.upload-progress { display: flex; align-items: center; gap: 12px; padding: 14px 0 3px; }
.progress-track { flex: 1; height: 9px; overflow: hidden; border-radius: 99px; background: #dfe7e9; }
.progress-bar { width: 0%; height: 100%; border-radius: 99px; background: var(--primary); transition: width .2s ease; }
.upload-progress span { min-width: min(320px, 46vw); color: var(--text-secondary); font-size: 13px; text-align: right; }
.upload-summary { font-weight: 600; }
.local-import-directory { display:flex; align-items:center; gap:10px; margin-bottom:14px; flex-wrap:wrap; }
.local-import-directory code { max-width:100%; padding:7px 9px; border:1px solid var(--border); border-radius:6px; overflow-wrap:anywhere; background:var(--surface-subtle); }
.local-import-directory > span:last-child { color:var(--text-secondary); font-size:13px; }
.local-import-progress { display:flex; align-items:center; gap:12px; margin-top:12px; }
.local-import-progress .progress-track { flex:1; min-width:120px; }
.local-import-progress span { color:var(--text-secondary); font-size:13px; }
.local-import-current { min-height:22px; margin-top:8px; color:var(--text-secondary); font-size:13px; }
@media (max-width: 640px) { .local-import-directory > * { width:100%; } .local-import-progress { align-items:stretch; flex-direction:column; } .local-import-panel .toolbar-row > label,.local-import-panel .toolbar-row > input,.local-import-panel .toolbar-row > button { width:100%; } }
.up-item { padding: 7px 0; border-bottom: 1px solid #edf1f2; font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.up-match { color: var(--success); }
.up-miss { color: var(--warning); }
.up-failed { color: var(--danger); }
.up-uncertain { color: var(--warning); font-weight: 600; }
.works-summary { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 14px; }
.works-summary > div { display: grid; min-width: 0; gap: 3px; }
.works-summary strong { font-size: 17px; }
.works-summary span { color: var(--text-muted); font-size: 12px; }
#worksManagement { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 16px; }
.works-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(138px, auto) minmax(92px, auto) auto; align-items: end; gap: 9px; }
.works-toolbar label { display: grid; min-width: 0; gap: 4px; color: var(--text-secondary); font-size: 11px; }
.works-toolbar input, .works-toolbar select { width: 100%; }
.works-filters { display: flex; min-width: 0; gap: 4px; }
.works-filters .btn { padding-right: 12px; padding-left: 12px; }
.works-filters .is-active { color: #fff; border-color: var(--primary); background: var(--primary); }
.work-list { margin-top: 12px; border-top: 1px solid var(--border); }
.work-row { min-width: 0; border-bottom: 1px solid var(--border); padding: 4px 0; }
.work-row-main { display: grid; grid-template-columns: minmax(0, 1fr) 44px; min-width: 0; align-items: center; gap: 8px; }
.work-info { display: flex; min-width: 0; align-items: baseline; gap: 10px; padding: 5px 2px; }
.work-name { min-width: 0; overflow-wrap: anywhere; font-size: 13px; font-weight: 650; line-height: 1.35; }
.work-count { flex: none; color: var(--text-muted); font-size: 12px; white-space: nowrap; }
.work-menu-button { min-width: 44px; min-height: 44px; border: 0; border-radius: 7px; color: var(--primary); background: transparent; font-size: 22px; line-height: 1; }
.work-menu-button:hover { background: var(--primary-soft); }
.work-actions { display: flex; min-width: 0; align-items: center; flex-wrap: wrap; gap: 7px; padding: 7px 52px 9px 2px; }
.work-actions .btn { min-height: 44px; padding: 8px 13px; font-size: 12px; }
.work-reason { color: var(--text-muted); font-size: 12px; }
.work-empty-state { padding: 34px 12px; }
.works-pagination { padding-top: 14px; }
.product-card { margin-bottom: 10px; padding: 14px; border: 1px solid #e2e9eb; border-radius: 7px; background: #f8fafb; }
.product-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.product-title { display: flex; min-width: 0; flex: 1; align-items: baseline; gap: 9px; }
.product-title strong { flex: none; color: #2b3c43; font-size: 14px; }
.product-title span { overflow: hidden; color: var(--text-muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.product-desc { display: -webkit-box; overflow: hidden; margin-top: 8px; color: var(--text-secondary); font-size: 13px; line-height: 1.55; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.product-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; margin-top: 12px; padding-top: 13px; border-top: 1px solid var(--border); }
.product-field { display: grid; gap: 5px; color: var(--text-secondary); font-size: 12px; }
.product-field input { width: 100%; }
.product-form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 8px; }
.badge { display: inline-flex; min-height: 24px; align-items: center; border-radius: 999px; padding: 3px 9px; color: var(--success); background: #dff2e7; font-size: 11px; font-weight: 700; }
.upload-code { min-height: 44px; padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: 7px; color: var(--text); background: var(--surface); font-size: 14px; }
.upload-code:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px var(--primary-ring); }

@media (min-width: 1025px) {
  .image-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

@media (min-width: 640px) and (max-width: 1024px) {
  .main-container { padding-right: 20px; padding-left: 20px; }
  .page-header { margin-right: -20px; margin-left: -20px; padding-right: 20px; padding-left: 20px; }
  .catalog-filter-row { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; }
  .catalog-filter-row .filter-field { display: grid; grid-template-columns: 52px minmax(0, 1fr); }
  .filter-actions { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filter-actions .btn { width: 100%; }
  .image-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .image-grid.compact { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .admin-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .admin-filters label { display: grid; grid-template-columns: 54px minmax(0, 1fr); flex: 1 1 calc(50% - 10px); }
  .admin-filters label input, .admin-filters label select { width: 100%; }
  .admin-filters > .btn { flex: 1; }
}

@media (min-width: 768px) and (max-width: 1024px) {
  .image-grid, .admin-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 639px) {
  .main-container { padding: 0 14px 40px; }
  .page-header { margin-right: -14px; margin-left: -14px; padding-right: 14px; padding-left: 14px; }
  .page-header p { display: none; }
  .quick-search, .admin-panel { padding: 17px; }
  .section-heading { display: block; }
  .section-heading span { display: block; margin-top: 3px; text-align: left; }
  .quick-search-row { grid-template-columns: minmax(0, 1fr); }
  .catalog-filter-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: stretch; }
  .filter-field { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; width: 100%; }
  .filter-field input, .filter-field select, .select-control, .quick-search-row > .btn, .filter-actions .btn { width: 100%; }
  .quick-search input { min-width: 0; }
  .filter-actions { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr); width: 100%; }
  .admin-panel .toolbar-row > label:not(.checkbox-label) { width: 100%; }
  .admin-panel .toolbar-row > input, .admin-panel .toolbar-row > select, .admin-panel .toolbar-row > .btn { flex: none; width: 100%; }
  input:not([type="checkbox"]), select { font-size: 16px; }
  .image-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .image-grid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pagination { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 18px 0 4px; padding: 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-sm); }
  .pagination > #prev, .pagination > #prevPage, .pagination > #worksPrev { grid-column: 1; grid-row: 1; width: 100%; min-height: 44px; margin: 0; }
  .pagination > #next, .pagination > #nextPage, .pagination > #worksNext { grid-column: 2; grid-row: 1; width: 100%; min-height: 44px; margin: 0; }
  .pagination > #page, .pagination > #pageInfo, .pagination > #worksPageInfo { grid-column: 1 / -1; grid-row: 2; min-width: 0; padding-bottom: 2px; font-size: 13px; font-weight: 650; text-align: center; }
  .pagination > .quick-page { grid-column: 1 / -1; grid-row: 3; display: grid; grid-template-columns: auto 64px auto 1fr; width: 100%; margin: 2px 0 0; padding: 12px 0 0; border-top: 1px solid var(--border); border-left: 0; }
  .quick-page label, .quick-page-total { align-self: center; }
  .quick-page input { width: 64px; }
  .quick-page .btn-quick-page { width: 100%; }
  .admin-stats { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .admin-grid { grid-template-columns: 1fr; gap: 10px; }
  .admin-filters label { display: grid; grid-template-columns: 54px minmax(0, 1fr); }
  .admin-filters label input, .admin-filters label select { width: 100%; }
  .batch-bar { top: 83px; }
  #settingsForm, .product-form { grid-template-columns: 1fr; }
  #settingsForm > *, .product-form-actions { grid-column: 1; }
  .marks-heading { align-items: stretch; flex-direction: column; }
  .marks-heading > div { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .marks-heading .btn { width: 100%; }
  dialog { max-height: calc(100dvh - 28px); overflow-y: auto; padding: 20px; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal-box { display: flex; flex-direction: column; width: 100%; max-height: 96vh; max-height: 96dvh; border-width: 1px 0 0; border-radius: 8px 8px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .modal-box::before { content: ""; align-self: center; flex: none; width: 38px; height: 4px; margin: 9px 0 3px; border-radius: 99px; background: #c3cdd1; }
  .preview-stage { width: 100%; min-height: 0; height: min(52vh, 420px); height: min(52dvh, 420px); flex: 1 1 auto; }
  .modal-img { height: 100%; min-height: 0; max-height: none; }
  .modal-detail { max-height: 39vh; max-height: 39dvh; flex: 0 1 auto; padding: 13px 16px 20px; border-top: 1px solid var(--border); border-left: 0; }
  .modal-close { top: 14px; right: 10px; }
  .preview-arrow { width: 44px; height: 44px; }
}

@media (max-width: 420px) {
  .main-container { padding-right: 10px; padding-left: 10px; }
  .page-header { gap: 8px; margin-right: -10px; margin-bottom: 20px; margin-left: -10px; padding-right: 10px; padding-left: 10px; }
  h1 { font-size: 25px; }
  .page-header .btn { padding-right: 11px; padding-left: 11px; font-size: 13px; }
  .quick-search, .panel-toolbar, .admin-panel, .access-card { padding: 15px; }
  .pagination { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 18px 0 4px; padding: 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-sm); }
  .pagination > #prev, .pagination > #prevPage, .pagination > #worksPrev { grid-column: 1; grid-row: 1; width: 100%; min-height: 44px; }
  .pagination > #next, .pagination > #nextPage, .pagination > #worksNext { grid-column: 2; grid-row: 1; width: 100%; min-height: 44px; }
  .pagination > #page, .pagination > #pageInfo, .pagination > #worksPageInfo { grid-column: 1 / -1; grid-row: 2; min-width: 0; padding-bottom: 2px; font-size: 13px; font-weight: 650; text-align: center; }
  .quick-page { grid-column: 1 / -1; grid-row: 3; display: grid; grid-template-columns: auto 64px auto 1fr; width: 100%; margin-top: 2px; padding: 12px 0 0; border-top: 1px solid var(--border); border-left: 0; }
  .quick-page label, .quick-page-total { align-self: center; }
  .quick-page input { width: 64px; }
  .quick-page .btn-quick-page { width: 100%; }
  .admin-actions .btn { font-size: 13px; }
  .batch-bar > .btn { flex-basis: calc(50% - 5px); }
  .works-summary { align-items: flex-start; }
  .works-summary .btn { flex: none; padding-right: 10px; padding-left: 10px; }
  .works-toolbar { grid-template-columns: minmax(0, 1fr) minmax(82px, auto); }
  .works-search, .works-filters { grid-column: 1 / -1; }
  .works-filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .works-toolbar > .btn { width: 100%; }
  .work-actions { padding-right: 2px; }
  .product-head { align-items: stretch; flex-direction: column; }
  .product-title { width: 100%; }
  .product-head > .btn { width: 100%; }
  .dialog-actions .btn { flex: 1; }
  .update-reminder { padding: 24px 16px 18px; }
  .update-reminder-versions { grid-template-columns: 1fr; }
  .update-reminder .dialog-actions { align-items: stretch; flex-direction: column-reverse; }
  .update-reminder .dialog-actions .btn { width: 100%; min-height: 44px; }
}

@media (hover: none) {
  .image-card:hover, .admin-card:hover { transform: none; }
  .image-card:hover .card-img { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}

/* Global protection: hidden state must win over component display rules. */
[hidden] { display: none !important; }
