:root {
  --bg: #f7f4ee;
  --surface: #ffffff;
  --surface-2: #f1ece1;
  --border: #e2d9c6;
  --border-strong: #cdbf9f;
  --text: #241f14;
  --text-muted: #6b6250;
  --text-faint: #96896c;
  --accent: #b5730f;
  --accent-strong: #8a5608;
  --accent-soft: #f3e3c4;
  --ok: #2f7a4f;
  --ok-soft: #e1f0e5;
  --danger: #b3432f;
  --danger-soft: #f5e2dd;
  --info: #2f5f9e;
  --info-soft: #e2ebf6;
  --shadow: 0 1px 2px rgba(40, 30, 10, 0.06), 0 8px 24px -12px rgba(40, 30, 10, 0.14);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171310;
    --surface: #201a14;
    --surface-2: #29221a;
    --border: #3a3123;
    --border-strong: #4d4130;
    --text: #f3ecdd;
    --text-muted: #bdae8f;
    --text-faint: #8c7f65;
    --accent: #e0a53f;
    --accent-strong: #f0bc61;
    --accent-soft: #3a2c14;
    --ok: #6fc490;
    --ok-soft: #1c3226;
    --danger: #e08674;
    --danger-soft: #3a241f;
    --info: #7fa9dd;
    --info-soft: #1c2b3f;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 28px -12px rgba(0, 0, 0, 0.55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #171310; --surface: #201a14; --surface-2: #29221a; --border: #3a3123;
  --border-strong: #4d4130; --text: #f3ecdd; --text-muted: #bdae8f; --text-faint: #8c7f65;
  --accent: #e0a53f; --accent-strong: #f0bc61; --accent-soft: #3a2c14;
  --ok: #6fc490; --ok-soft: #1c3226; --danger: #e08674; --danger-soft: #3a241f;
  --info: #7fa9dd; --info-soft: #1c2b3f;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 28px -12px rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans KR", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
a { color: var(--accent-strong); }

.page { max-width: 920px; margin: 0 auto; padding: 40px 24px 64px; display: flex; flex-direction: column; gap: 20px; }

header.top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; }
.eyebrow { font-family: "IBM Plex Mono", monospace; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); font-weight: 500; margin-bottom: 8px; }
h1 { font-family: "Gothic A1", sans-serif; font-weight: 800; font-size: clamp(22px, 3.2vw, 30px); margin: 0 0 6px; letter-spacing: -.01em; }
.titleblock p { margin: 0; color: var(--text-muted); font-size: 14px; }

.admin-area { display: flex; align-items: center; gap: 10px; }
.admin-status { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-muted); }
.admin-btn { padding: 9px 15px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-size: 13px; font-weight: 600; font-family: inherit; cursor: pointer; }
.admin-btn:hover { background: var(--surface-2); }
.admin-btn.ghost { border-color: transparent; color: var(--text-muted); }

nav.tabs { display: flex; gap: 6px; flex-wrap: wrap; border-bottom: 1px solid var(--border); padding-bottom: 0; }
nav.tabs button {
  font-family: inherit; font-size: 13.5px; font-weight: 700; padding: 10px 16px; border: none; background: none;
  color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
nav.tabs button.active { color: var(--accent-strong); border-bottom-color: var(--accent); }
nav.tabs button:hover { color: var(--text); }

section.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); padding: 24px; }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 18px; }
.card-head h2 { font-family: "Gothic A1", sans-serif; font-weight: 700; font-size: 16.5px; margin: 0; }
.card-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--border); background: var(--surface-2); border-radius: 8px;
  padding: 10px 11px; font-size: 13.5px; color: var(--text); font-family: "Noto Sans KR", sans-serif;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.dropzone {
  display: block;
  border: 1.5px dashed var(--border-strong); border-radius: 12px; padding: 20px; text-align: center;
  background: var(--surface-2); cursor: pointer; font-size: 13px; color: var(--text-muted);
}
.dropzone:hover { border-color: var(--accent); color: var(--text); }
.dropzone input[type="file"] { display: none; }
.file-chip-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.file-chip {
  display: flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 10px 4px 4px; font-size: 11.5px;
}
.file-chip img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; }
.file-chip button { border: none; background: none; color: var(--text-faint); cursor: pointer; font-size: 13px; padding: 0 2px; }

.submit-row { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 16px; }
.form-msg { font-size: 12.5px; color: var(--text-muted); }
.form-msg.error { color: var(--danger); }
.form-msg.ok { color: var(--ok); }

.btn-primary, .btn-ghost, .btn-danger {
  padding: 10px 18px; border-radius: 9px; font-size: 13px; font-weight: 700; font-family: inherit; cursor: pointer; border: 1px solid transparent;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-primary:disabled { opacity: .5; cursor: default; }
.btn-ghost { background: transparent; border-color: var(--border-strong); color: var(--text-muted); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.muted { background: var(--surface-2); color: var(--text-muted); }

table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data-table th, table.data-table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
table.data-table th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint); font-weight: 700; }
table.data-table tr:last-child td { border-bottom: none; }
table.data-table input { width: 100%; border: 1px solid var(--border); background: var(--surface-2); border-radius: 6px; padding: 6px 8px; font-size: 12.5px; font-family: "IBM Plex Mono", monospace; color: var(--text); }
.mono { font-family: "IBM Plex Mono", monospace; }
.row-actions { display: flex; gap: 6px; }
.row-actions button { border: 1px solid var(--border-strong); background: var(--surface); border-radius: 6px; padding: 4px 8px; font-size: 11.5px; cursor: pointer; color: var(--text-muted); }
.row-actions button:hover { color: var(--text); }

.section-title { font-size: 13px; font-weight: 700; margin: 22px 0 10px; color: var(--text); }
.section-title:first-child { margin-top: 0; }

.result-hero { text-align: center; padding: 12px 0 4px; }
.result-hero .ico { font-size: 34px; }
.result-hero h3 { margin: 8px 0 4px; font-size: 18px; }
.result-hero p { margin: 0; color: var(--text-muted); font-size: 13px; }
.expiry-note { font-size: 12px; color: var(--text-faint); margin-top: 6px; }

.history-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.history-row + .history-row { margin-top: 8px; }
.history-row .h-main { font-size: 13px; font-weight: 700; }
.history-row .h-sub { font-size: 12px; color: var(--text-muted); flex: 1; min-width: 160px; }
.history-row a.h-link { margin-left: auto; font-size: 12px; font-weight: 700; }

.modal { position: fixed; inset: 0; background: rgba(20, 15, 5, .45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal-box { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 22px; width: 100%; max-width: 340px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; }
.modal-box h3 { margin: 0 0 4px; font-family: "Gothic A1", sans-serif; font-size: 16px; }

.hint { font-size: 11.5px; color: var(--text-faint); margin-top: 10px; line-height: 1.6; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  .page { padding: 24px 16px 48px; gap: 16px; }
  section.card { padding: 18px; border-radius: 14px; }
  .field-grid { grid-template-columns: 1fr; }
  .field input, .field select, .field textarea { padding: 11px 12px; font-size: 16px; }
  table.data-table { display: block; overflow-x: auto; white-space: nowrap; }
}
