:root {
  color-scheme: light;
  --black: #050505;
  --ink: #102033;
  --muted: #657386;
  --line: #dfe7ee;
  --soft: #f5f9fc;
  --sky-50: #eef9ff;
  --sky-100: #dff4ff;
  --sky-500: #19a9e5;
  --sky-700: #087bad;
  --danger: #dc2626;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: #fff; color: var(--ink); font-family: "Pretendard Variable", Pretendard, sans-serif; letter-spacing: 0; }
body.is-modal-open { overflow: hidden; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.login-screen { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: #000; }
.code-form { width: min(360px, calc(100vw - 48px)); }
.code-form input { width: 100%; height: 58px; padding: 0 6px; border: 0; border-bottom: 1px solid #616161; border-radius: 0; outline: 0; background: transparent; color: #fff; font-size: 17px; text-align: center; }
.code-form input::placeholder { color: #777; }
.code-form input:focus { border-bottom-color: #fff; }
.code-form input.is-error { border-bottom-color: #ef4444; animation: shake 0.28s ease; }
.login-message { min-height: 20px; margin: 12px 0 0; color: #ef4444; font-size: 13px; text-align: center; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

.admin-app { min-height: 100vh; background: #fff; }
.admin-header { position: sticky; top: 0; z-index: 30; min-height: 72px; padding: 0 24px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.97); display: grid; grid-template-columns: 230px minmax(360px, 1fr) auto; align-items: center; gap: 22px; }
.admin-brand { min-width: 0; color: inherit; text-decoration: none; display: flex; align-items: center; gap: 10px; }
.admin-brand-mark { width: 34px; height: 34px; border-radius: 6px; background: var(--sky-500); color: #fff; display: grid; place-items: center; font-size: 19px; font-weight: 900; }
.admin-brand strong, .admin-brand small { display: block; }
.admin-brand strong { font-size: 14px; }
.admin-brand small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.admin-tabs { height: 72px; display: flex; align-items: stretch; justify-content: center; gap: 4px; }
.admin-tabs { scrollbar-width: none; }
.admin-tabs::-webkit-scrollbar { display: none; }
.admin-tabs button, .admin-tabs a { min-width: 84px; padding: 0 14px; border: 0; border-bottom: 3px solid transparent; background: transparent; color: #5b6879; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-size: 14px; font-weight: 750; }
.admin-tabs button:hover, .admin-tabs a:hover { background: var(--soft); color: var(--ink); }
.admin-tabs button.is-active { border-bottom-color: var(--sky-500); color: var(--sky-700); }
.admin-tabs svg { width: 17px; height: 17px; }
.admin-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.save-state { min-width: 52px; color: #7a8797; font-size: 12px; text-align: right; }
.save-state.is-dirty { color: #d97706; font-weight: 700; }
.icon-action, .primary-action, .secondary-action, .danger-icon { border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.icon-action { width: 38px; height: 38px; border: 1px solid var(--line); background: #fff; color: #4d5c6e; text-decoration: none; }
.icon-action:hover { background: var(--soft); color: var(--ink); }
.icon-action svg, .primary-action svg, .secondary-action svg, .danger-icon svg { width: 17px; height: 17px; }
.primary-action { height: 40px; padding: 0 15px; border: 0; background: var(--sky-500); color: #fff; font-weight: 800; }
.primary-action:hover { background: var(--sky-700); }
.primary-action:disabled { opacity: .55; cursor: wait; }
.secondary-action { height: 38px; padding: 0 13px; border: 1px solid #b9dcec; background: var(--sky-50); color: var(--sky-700); font-size: 13px; font-weight: 750; }
.secondary-action:hover { background: var(--sky-100); }
.danger-icon { width: 38px; height: 38px; border: 1px solid #fecaca; background: #fff; color: var(--danger); }
.danger-icon:hover { background: #fef2f2; }

.admin-content { width: min(1540px, calc(100% - 48px)); margin: 0 auto; padding: 22px 0 48px; }
.summary-strip { min-height: 82px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, 1fr); }
.summary-strip > div { padding: 16px 22px; border-right: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.summary-strip > div:last-child { border-right: 0; }
.summary-strip span { color: var(--muted); font-size: 13px; }
.summary-strip strong { color: var(--ink); font-size: 24px; }
.page-message { min-height: 22px; margin: 10px 0 0; color: var(--sky-700); font-size: 13px; }
.page-message.is-error { color: var(--danger); }

.data-panel { margin-top: 10px; }
.panel-header { min-height: 70px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.panel-header span { color: var(--sky-700); font-size: 11px; font-weight: 850; }
.panel-header h1 { margin: 4px 0 0; font-size: 21px; }
.editor-layout { min-height: 620px; display: grid; grid-template-columns: 390px minmax(0, 1fr); border-bottom: 1px solid var(--line); }
.record-browser { min-width: 0; padding: 16px 16px 16px 0; border-right: 1px solid var(--line); }
.search-box { height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 6px; display: flex; align-items: center; gap: 8px; }
.search-box:focus-within { border-color: var(--sky-500); box-shadow: 0 0 0 3px rgba(25,169,229,.1); }
.search-box svg { width: 17px; height: 17px; color: #8a97a6; }
.search-box input { min-width: 0; width: 100%; height: 38px; border: 0; outline: 0; color: var(--ink); }
.record-list { height: 552px; margin-top: 12px; overflow: auto; border-top: 1px solid var(--line); }
.record-item { width: 100%; min-height: 78px; padding: 10px 8px; border: 0; border-bottom: 1px solid var(--line); background: #fff; color: inherit; display: grid; grid-template-columns: 58px minmax(0, 1fr) auto; align-items: center; gap: 11px; text-align: left; }
.record-item:hover { background: var(--soft); }
.record-item.is-active { background: var(--sky-50); box-shadow: inset 3px 0 var(--sky-500); }
.record-thumb { width: 58px; height: 54px; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; background: var(--soft); display: grid; place-items: center; color: #9aa6b4; }
.record-thumb img { width: 100%; height: 100%; object-fit: cover; }
.record-thumb svg { width: 20px; height: 20px; }
.record-copy { min-width: 0; }
.record-copy strong, .record-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.record-copy strong { font-size: 14px; }
.record-copy span { margin-top: 5px; color: var(--muted); font-size: 12px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #16a34a; }
.status-dot.is-hidden { background: #a8b0ba; }
.status-dot.is-unmasked { background: #f59e0b; box-shadow: 0 0 0 3px #fef3c7; }
.record-empty { padding: 38px 12px; color: var(--muted); font-size: 13px; text-align: center; }

.record-editor { min-width: 0; margin: 0; padding: 20px 0 20px 24px; }
.empty-editor { min-height: 540px; color: #8c98a7; display: grid; place-content: center; justify-items: center; gap: 10px; }
.empty-editor svg { width: 28px; height: 28px; }
.empty-editor strong { font-size: 14px; }
.editor-fields { max-width: 980px; }
.editor-title-row { min-height: 50px; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.editor-title-row h2 { margin: 4px 0 0; font-size: 19px; }
.record-id { color: var(--muted); font-family: Consolas, monospace; font-size: 11px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid label { min-width: 0; display: grid; gap: 7px; }
.form-grid label > span, .image-editor strong { color: #4c5968; font-size: 12px; font-weight: 750; }
.form-wide { grid-column: 1 / -1; }
.form-grid input, .form-grid select, .form-grid textarea { width: 100%; border: 1px solid var(--line); border-radius: 6px; outline: 0; background: #fff; color: var(--ink); }
.form-grid input, .form-grid select { height: 42px; padding: 0 11px; }
.form-grid textarea { min-height: 138px; padding: 11px; resize: vertical; line-height: 1.6; }
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus { border-color: var(--sky-500); box-shadow: 0 0 0 3px rgba(25,169,229,.1); }
.form-grid .review-compliance { min-height: 66px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 6px; display: flex; grid-template-columns: none; align-items: flex-start; gap: 11px; background: #f8fbfd; cursor: pointer; }
.form-grid .review-compliance input { flex: 0 0 auto; width: 18px; height: 18px; margin: 2px 0 0; padding: 0; accent-color: var(--sky-700); box-shadow: none; }
.form-grid .review-compliance > span { display: grid; gap: 4px; }
.review-compliance strong { color: var(--ink); font-size: 13px; }
.review-compliance small { color: var(--muted); font-size: 11px; line-height: 1.55; }
.image-editor { min-height: 150px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); display: grid; grid-template-columns: 220px minmax(0, 1fr); align-items: center; gap: 20px; }
.image-preview { width: 220px; height: 132px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: var(--soft); display: grid; place-items: center; color: #98a4b2; font-size: 12px; }
.image-preview img { width: 100%; height: 100%; object-fit: cover; }
.vehicle-image-preview img { object-fit: contain; }
.image-editor p { max-width: 620px; margin: 7px 0 14px; color: var(--muted); font-family: Consolas, monospace; font-size: 11px; overflow-wrap: anywhere; }
.image-editor-heading { display: flex; align-items: center; gap: 10px; }
.image-editor-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.mask-status { min-height: 24px; padding: 0 8px; border: 1px solid #f5c86f; border-radius: 999px; background: #fffbeb; color: #9a6207; display: inline-flex; align-items: center; font-size: 11px; font-weight: 800; }
.mask-status.is-ready { border-color: #a7dfbd; background: #effcf4; color: #13763a; }
.secondary-action:disabled { opacity: .5; cursor: not-allowed; }
.editor-note { margin: 16px 0 0; padding: 11px 12px; border-left: 3px solid #f59e0b; background: #fffbeb; color: #806114; font-size: 12px; }

.mask-modal { position: fixed; inset: 0; z-index: 90; padding: 24px; background: rgba(3, 15, 25, .72); display: grid; place-items: center; }
.mask-dialog { width: min(1320px, 100%); max-height: calc(100vh - 48px); border-radius: 8px; overflow: hidden; background: #fff; box-shadow: 0 24px 70px rgba(0, 0, 0, .3); display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; }
.mask-dialog-header { min-height: 72px; padding: 14px 18px 14px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.mask-dialog-header span { color: var(--sky-700); font-size: 10px; font-weight: 850; }
.mask-dialog-header h2 { margin: 3px 0 0; font-size: 20px; }
.mask-toolbar { min-height: 52px; padding: 7px 18px 7px 22px; border-bottom: 1px solid var(--line); background: var(--soft); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mask-toolbar > div { display: flex; gap: 7px; }
.mask-counter { color: var(--muted); font-size: 12px; font-weight: 750; }
.mask-stage { min-height: 300px; padding: 18px; overflow: auto; background: #dfe9ef; display: grid; place-items: center; }
.mask-stage canvas { display: block; max-width: 100%; max-height: calc(100vh - 270px); background: #fff; box-shadow: 0 6px 24px rgba(10, 35, 55, .18); cursor: crosshair; touch-action: none; user-select: none; }
.mask-dialog-footer { min-height: 70px; padding: 12px 18px 12px 22px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mask-dialog-footer > div { display: flex; gap: 8px; }

.progress-layer { position: fixed; inset: 0; z-index: 110; background: rgba(4, 15, 26, .38); display: grid; place-items: center; }
.progress-layer > div { width: 240px; min-height: 118px; border-radius: 7px; background: #fff; box-shadow: 0 18px 50px rgba(0,0,0,.2); display: grid; place-content: center; justify-items: center; gap: 12px; }
.progress-layer strong { font-size: 14px; }
.spinner { width: 28px; height: 28px; border: 3px solid #d8edf7; border-top-color: var(--sky-500); border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1180px) {
  .admin-header { grid-template-columns: 180px 1fr; padding: 0 16px; }
  .admin-tabs { order: 3; grid-column: 1 / -1; height: 52px; border-top: 1px solid var(--line); }
  .admin-actions { grid-column: 2; }
  .admin-tabs button, .admin-tabs a { min-width: 0; flex: 1; }
  .admin-content { width: calc(100% - 32px); }
}

@media (max-width: 760px) {
  .admin-header { position: static; min-height: 0; padding: 10px 14px 0; display: flex; flex-wrap: wrap; gap: 10px; }
  .admin-brand { flex: 1; }
  .admin-brand small, .save-state, .admin-actions a.icon-action { display: none; }
  .admin-actions { order: 2; }
  .primary-action { padding: 0 11px; }
  .primary-action span { display: none; }
  .admin-tabs { width: calc(100% + 28px); height: 50px; margin: 0 -14px; order: 3; overflow-x: auto; justify-content: flex-start; }
  .admin-tabs button, .admin-tabs a { min-width: 94px; padding: 0 10px; flex: 0 0 auto; font-size: 12px; }
  .admin-content { width: calc(100% - 24px); padding-top: 14px; }
  .summary-strip { grid-template-columns: repeat(2, 1fr); }
  .summary-strip > div { min-height: 64px; padding: 11px 12px; border-bottom: 1px solid var(--line); }
  .summary-strip > div:nth-child(2n) { border-right: 0; }
  .summary-strip strong { font-size: 20px; }
  .panel-header { min-height: 62px; }
  .panel-header h1 { font-size: 18px; }
  .editor-layout { display: block; }
  .record-browser { padding-right: 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .record-list { height: 260px; }
  .record-editor { padding: 18px 0; }
  .empty-editor { min-height: 230px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-wide { grid-column: auto; }
  .image-editor { grid-template-columns: 1fr; }
  .image-preview { width: 100%; height: auto; aspect-ratio: 16 / 9; }
  .mask-modal { padding: 0; }
  .mask-dialog { width: 100%; height: 100%; max-height: none; border-radius: 0; }
  .mask-dialog-header { min-height: 62px; padding: 10px 12px 10px 16px; }
  .mask-dialog-header h2 { font-size: 17px; }
  .mask-toolbar { padding: 6px 12px 6px 16px; }
  .mask-stage { min-height: 0; padding: 10px; }
  .mask-stage canvas { max-height: calc(100vh - 232px); }
  .mask-dialog-footer { min-height: 68px; padding: 10px 12px; }
  .mask-dialog-footer .primary-action { padding: 0 12px; }
  .mask-dialog-footer .primary-action span { display: inline; }
}
