:root {
  color-scheme: light;
  font-family: Inter, "Microsoft YaHei", system-ui, sans-serif;
  color: #172033;
  background: #f3f5f8;
  --navy: #16263f;
  --blue: #2563eb;
  --line: #d9e0e9;
  --muted: #64748b;
  --green: #087f5b;
  --amber: #a15c00;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; min-height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
button, input, select, textarea { font: inherit; }
button { border: 0; border-radius: 8px; padding: 10px 16px; background: var(--blue); color: white; cursor: pointer; }
button:hover { filter: brightness(.95); }
button:disabled { cursor: not-allowed; opacity: .65; }
button.secondary { background: white; color: #334155; border: 1px solid var(--line); }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; background: white; color: #172033; }
textarea { resize: vertical; }
label { display: grid; gap: 6px; color: #475569; font-size: 13px; }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 18px 28px; background: var(--navy); color: white; }
.topbar h1 { margin: 0; font-size: 22px; }
.topbar p { margin: 5px 0 0; color: #b8c5d8; font-size: 13px; }
.reviewer-session { display: flex; align-items: center; gap: 12px; }
.signed-user { display: grid; text-align: right; }
.signed-user strong { font-size: 14px; }
.signed-user span { color: #b8c5d8; font-size: 12px; margin-top: 3px; }
.topbar-button { background: #243a59; border: 1px solid #46607f; padding: 8px 12px; font-size: 13px; }

.stats { flex: none; display: grid; grid-template-columns: repeat(5, minmax(120px, 1fr)); gap: 12px; padding: 16px 24px; }
.stat { padding: 14px 16px; border: 1px solid var(--line); background: white; border-radius: 10px; }
.stat strong { display: block; font-size: 22px; }
.stat span { color: var(--muted); font-size: 12px; }

.workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: 310px 1fr; gap: 16px; padding: 0 24px 24px; overflow: hidden; }
.filters, .venue-panel, .empty-state { border: 1px solid var(--line); border-radius: 12px; background: white; }
.filters { min-height: 0; padding: 16px; display: flex; flex-direction: column; gap: 10px; overflow: hidden; }
.filters h2 { margin: 0 0 4px; font-size: 17px; }
.venue-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; margin: 4px -8px 0; padding: 0 8px; }
.venue-item { padding: 12px; border: 1px solid transparent; border-bottom-color: #edf1f5; cursor: pointer; }
.venue-item:hover, .venue-item.active { background: #eff6ff; border-color: #bfdbfe; border-radius: 8px; }
.venue-item strong { display: block; font-size: 14px; }
.venue-item small { display: block; margin-top: 5px; color: var(--muted); }

.empty-state { display: grid; place-content: center; text-align: center; color: var(--muted); }
.empty-state h2 { color: #334155; margin-bottom: 4px; }
.venue-panel { min-height: 0; padding: 20px; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.hidden { display: none !important; }
.panel-heading, .section-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.panel-heading h2 { margin: 5px 0 0; font-size: 22px; }
.section-heading { margin-top: 26px; border-top: 1px solid var(--line); padding-top: 18px; }
.section-heading h3 { margin: 0; }
.section-heading p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.section-heading select { width: 190px; }
.badge { display: inline-block; padding: 4px 8px; border-radius: 999px; font-size: 12px; background: #fff4db; color: var(--amber); }
.badge.reviewed { background: #ddf6ec; color: var(--green); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 20px; }
.form-grid .wide { grid-column: 1 / -1; }

.space-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; margin-top: 14px; }
.space-empty { grid-column: 1 / -1; display: grid; gap: 5px; padding: 18px; border: 1px dashed #93c5fd; border-radius: 10px; background: #f8fbff; }
.space-empty strong { font-size: 14px; color: #1e3a5f; }
.space-empty span { color: var(--muted); font-size: 12px; }
.space-card { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.space-card > div { min-width: 0; }
.space-card h4 { margin: 5px 0; font-size: 15px; }
.space-card p { margin: 0; color: #475569; font-size: 12px; }
.space-card small { display: block; margin-top: 8px; color: var(--muted); line-height: 1.45; }
.space-card button { flex: none; padding: 7px 10px; font-size: 12px; }
.space-type { display: inline-block; padding: 3px 7px; border-radius: 999px; background: #e0e7ff; color: #4338ca; font-size: 11px; font-weight: 700; }

.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-top: 16px; }
.image-card { border: 1px solid var(--line); background: white; border-radius: 10px; overflow: hidden; cursor: pointer; }
.image-card:hover { border-color: #93b4ee; box-shadow: 0 5px 18px rgba(33, 61, 103, .1); }
.image-card img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: #e8edf3; }
.image-meta { padding: 10px; }
.image-meta strong { font-size: 13px; }
.image-meta small { display: block; margin-top: 5px; color: var(--muted); }
.image-dimensions { color: #64748b; }
.image-usage-badges { min-height: 0; }
.image-usage-badges span { display: inline-block; margin: 0 5px 7px 0; padding: 4px 7px; border-radius: 999px; background: #dbeafe; color: #1d4ed8; font-size: 11px; font-weight: 700; }
.chip { display: inline-block; margin: 7px 5px 0 0; padding: 3px 6px; border-radius: 5px; background: #edf2f7; color: #475569; font-size: 11px; }
.chip.done { background: #ddf6ec; color: var(--green); }
.chip.pending { background: #fff4db; color: #925400; }
.chip.suggestion { background: #e0e7ff; color: #4338ca; }
.chip.warning { background: #ffedd5; color: #9a3412; }
.chip.rejected { background: #fee2e2; color: #b42318; }

.selection-summary { margin-top: 16px; padding: 14px; border: 1px solid #bfdbfe; border-radius: 10px; background: #f8fbff; }
.selection-schema-warning { color: #92400e; background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.selection-summary-heading { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; margin-bottom: 10px; }
.selection-summary-heading span { color: var(--muted); font-size: 12px; }
.selection-summary-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 9px; }
.selection-card { min-height: 64px; display: flex; align-items: center; gap: 9px; border: 1px solid var(--line); border-radius: 8px; padding: 7px; background: white; cursor: pointer; }
.selection-card:hover { border-color: #93b4ee; }
.selection-card img { width: 72px; height: 52px; object-fit: cover; border-radius: 6px; background: #e8edf3; }
.selection-card div { min-width: 0; }
.selection-card span, .selection-card small { display: block; color: var(--muted); font-size: 11px; }
.selection-card strong { display: block; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.selection-card.empty { display: grid; align-content: center; cursor: default; border-style: dashed; }
.selection-card.empty:hover { border-color: var(--line); }

dialog { width: min(1050px, 94vw); max-height: 94vh; overflow: auto; padding: 0; border: 0; border-radius: 14px; box-shadow: 0 25px 80px rgba(15, 23, 42, .35); }
dialog::backdrop { background: rgba(15, 23, 42, .6); }
.dialog-shell { position: relative; display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(320px, .8fr); }
.dialog-close { position: absolute; right: 12px; top: 10px; z-index: 2; padding: 3px 10px; background: #e2e8f0; color: #334155; font-size: 22px; }
.dialog-image-wrap { min-height: 600px; background: #101827; display: grid; place-items: center; }
.dialog-image-wrap img { max-width: 100%; max-height: 78vh; object-fit: contain; }
.dialog-form { padding: 28px 24px; display: flex; flex-direction: column; gap: 14px; }
.dialog-form h2 { margin: 0 35px 2px 0; }
.image-usage-panel { display: grid; gap: 10px; padding: 13px; border: 1px solid #bfdbfe; border-radius: 10px; background: #f5f9ff; }
.image-usage-panel h3 { margin: 0; font-size: 15px; }
.image-usage-panel p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.usage-status { display: flex; flex-wrap: wrap; gap: 6px; }
.usage-current { padding: 4px 7px; border-radius: 999px; background: #dbeafe; color: #1d4ed8; font-size: 11px; font-weight: 700; }
.usage-empty { color: var(--muted); font-size: 12px; }
.usage-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.usage-actions button, .space-cover-action button { color: #1d4ed8; border-color: #93c5fd; }
.space-cover-action { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 8px; }
.no-space-hint { padding: 9px 11px; border: 1px solid #fde68a; border-radius: 8px; background: #fffbeb; color: #92400e; font-size: 12px; }
.review-divider { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; padding-top: 3px; }
.review-divider span { color: var(--muted); font-size: 11px; }
.image-facts { padding: 9px 11px; border-radius: 8px; background: #f8fafc; color: #475569; font-size: 12px; }
.source-hint { display: grid; gap: 6px; padding: 10px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.source-hint strong { font-size: 12px; }
.source-hint div { display: grid; gap: 4px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px; }
.flag-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.toast { position: fixed; right: 24px; bottom: 24px; padding: 12px 18px; border-radius: 8px; background: #172033; color: white; box-shadow: 0 8px 30px rgba(0,0,0,.2); }

.login-page { background: radial-gradient(circle at top left, #244b7e, #101b2d 60%); display: grid; place-items: center; padding: 24px; }
.login-card { width: min(430px, 100%); background: white; border-radius: 18px; padding: 34px; box-shadow: 0 28px 80px rgba(3, 10, 24, .38); }
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; }
.login-brand h1 { font-size: 22px; margin: 0; }
.login-brand p { color: var(--muted); margin: 5px 0 0; font-size: 13px; }
.login-mark { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 13px; background: var(--blue); color: white; font-weight: 800; font-size: 24px; }
.login-form, .standalone-form { display: grid; gap: 16px; }
.login-form button { margin-top: 4px; padding: 12px; }
.login-help { color: var(--muted); font-size: 12px; margin: 22px 0 0; text-align: center; }
.form-error { color: #b42318; background: #fff1f0; border: 1px solid #ffc9c5; border-radius: 8px; padding: 9px 11px; margin: 0; font-size: 13px; }

.small-dialog { width: min(460px, 92vw); }
.standalone-form { padding: 28px; }
.standalone-form h2 { margin: 0; }
.standalone-form p { margin: -6px 0 0; color: var(--muted); font-size: 13px; }
.standalone-form small, .password-rule { color: var(--muted); font-size: 12px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }
.space-dialog-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.space-dialog-heading p { margin-top: 5px; }
.space-dialog-heading button { flex: none; }
.space-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.admin-dialog { width: min(1120px, 96vw); }
.admin-shell { padding: 24px; }
.admin-heading { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.admin-heading h2 { margin: 0; }
.admin-heading p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.dialog-close-button { background: white; color: #334155; border: 1px solid var(--line); }
.create-user-form { display: grid; grid-template-columns: 1.2fr 1fr .8fr 1.2fr auto; gap: 10px; align-items: end; margin-top: 22px; padding: 16px; background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; }
.password-rule { margin: 8px 2px 18px; }
.user-table-wrap { overflow-x: auto; }
.user-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.user-table th, .user-table td { border-bottom: 1px solid var(--line); padding: 11px 8px; text-align: left; vertical-align: middle; }
.user-table th { color: var(--muted); font-weight: 600; background: #f8fafc; }
.user-table td:first-child { min-width: 210px; }
.user-table td:first-child small { display: block; color: var(--muted); margin-top: 5px; }
.user-table select { min-width: 110px; }
.status-toggle { display: flex; grid-template-columns: none; align-items: center; white-space: nowrap; }
.status-toggle input { width: auto; }
.user-actions { display: flex; gap: 6px; min-width: 180px; }
.user-actions button { padding: 7px 9px; font-size: 12px; }
.read-only .venue-panel input:disabled,
.read-only .venue-panel select:disabled,
.read-only .venue-panel textarea:disabled { opacity: 1; color: #334155; background: #f8fafc; }

@media (max-width: 850px) {
  body { height: auto; min-height: 100vh; overflow: auto; }
  .topbar { align-items: flex-start; gap: 14px; flex-direction: column; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .workspace { min-height: auto; overflow: visible; grid-template-columns: 1fr; }
  .filters { max-height: 420px; }
  .dialog-shell { grid-template-columns: 1fr; }
  .dialog-image-wrap { min-height: 300px; }
  .selection-summary-heading, .review-divider { align-items: flex-start; flex-direction: column; }
  .usage-actions, .space-cover-action, .dialog-actions { grid-template-columns: 1fr; }
  .reviewer-session { width: 100%; flex-wrap: wrap; }
  .signed-user { text-align: left; margin-right: auto; }
  .create-user-form { grid-template-columns: 1fr; }
  .space-form-grid { grid-template-columns: 1fr; }
}
