/** Defines the opaque, responsive operator interface for redemption-code administration. */

:root {
  color: #241b1f;
  background: #f6f3f4;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Noto Sans SC", sans-serif;
  font-synthesis: none;
  --ink: #241b1f;
  --muted: #71656a;
  --surface: #ffffff;
  --surface-soft: #f1edef;
  --border: #ded6d9;
  --accent: #a82f58;
  --accent-strong: #8e2047;
  --accent-soft: #f9e8ee;
  --success: #24734b;
  --danger: #b4232f;
  --warning: #95640e;
  --shadow: 0 14px 36px rgba(57, 28, 38, 0.08);
}

* { box-sizing: border-box; }

body {
  min-width: 280px;
  min-height: 100vh;
  margin: 0;
  background: #f6f3f4;
}

button, input, select { font: inherit; }

button { cursor: pointer; }

button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid rgba(168, 47, 88, 0.24);
  outline-offset: 2px;
}

.shell { min-height: 100vh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 10px max(20px, env(safe-area-inset-left)) 10px max(20px, env(safe-area-inset-right));
  border-bottom: 1px solid var(--border);
  background: rgba(246, 243, 244, 0.96);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 11px;
  background: var(--ink);
  color: #fff;
  font-size: 15px;
  font-weight: 750;
  letter-spacing: -0.04em;
}
.brand h1 { margin: 0; font-size: 16px; line-height: 1.3; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }

.page {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 28px 24px 48px;
}

.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.page-heading h2 { margin: 0; font-size: clamp(22px, 3vw, 30px); letter-spacing: -0.03em; }
.page-heading p { max-width: 620px; margin: 6px 0 0; color: var(--muted); font-size: 14px; line-height: 1.55; }

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 15px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 650;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}
.button:hover { border-color: #bcaeb3; background: #fbf9fa; }
.button-primary { border-color: var(--accent); background: var(--accent); color: #fff; }
.button-primary:hover { border-color: var(--accent-strong); background: var(--accent-strong); }
.button-danger { border-color: #edc6ca; color: var(--danger); }
.button-quiet { min-height: 40px; padding: 0 12px; background: transparent; }
.button:disabled { cursor: not-allowed; opacity: 0.5; }

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 12px;
  margin-bottom: 16px;
}

.field { display: grid; gap: 7px; }
.field label { color: #4a3f43; font-size: 13px; font-weight: 650; }
.field input, .field select {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
}
.field small { color: var(--muted); font-size: 12px; line-height: 1.45; }

.search { position: relative; }
.search input { padding-left: 42px; }
.search::before { content: "⌕"; position: absolute; left: 14px; bottom: 10px; color: var(--muted); font-size: 22px; line-height: 1; }

.content-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.panel { overflow: hidden; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 17px; border-bottom: 1px solid var(--border); }
.panel-heading h3 { margin: 0; font-size: 15px; }
.count { color: var(--muted); font-size: 12px; }

.code-table { width: 100%; border-collapse: collapse; }
.code-table th, .code-table td { padding: 13px 14px; border-bottom: 1px solid #eee8ea; text-align: left; vertical-align: middle; }
.code-table th { color: var(--muted); background: #fbf9fa; font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.code-table td { font-size: 13px; }
.code-table tbody tr { cursor: pointer; }
.code-table tbody tr:hover, .code-table tbody tr.is-selected { background: var(--accent-soft); }
.code-table tbody tr:last-child td { border-bottom: 0; }

.code-cards { display: none; }
.code-card { width: 100%; padding: 15px; border: 0; border-bottom: 1px solid #eee8ea; background: var(--surface); color: inherit; text-align: left; }
.code-card:last-child { border-bottom: 0; }
.code-card.is-selected { background: var(--accent-soft); }
.card-top, .card-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-meta { margin-top: 9px; color: var(--muted); font-size: 12px; }

.code-label { font-weight: 700; }
.code-suffix { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.badge { display: inline-flex; min-height: 24px; align-items: center; padding: 2px 8px; border-radius: 999px; background: #e8f4ed; color: var(--success); font-size: 11px; font-weight: 700; }
.badge-off { background: #f3e8ea; color: var(--danger); }
.badge-warn { background: #fff3d8; color: var(--warning); }

.detail { position: sticky; top: 80px; }
.detail-body { padding: 17px; }
.detail-empty, .state { display: grid; min-height: 240px; place-items: center; padding: 30px; color: var(--muted); text-align: center; }
.detail-grid { display: grid; gap: 14px; }
.detail-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 16px; }
.detail-note { margin: 12px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }

.activations { margin-top: 20px; border-top: 1px solid var(--border); padding-top: 17px; }
.activations h4 { margin: 0 0 10px; font-size: 13px; }
.activation { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 12px 0; border-bottom: 1px solid #eee8ea; }
.activation:last-child { border-bottom: 0; }
.activation strong { display: block; overflow: hidden; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; text-overflow: ellipsis; }
.activation span { color: var(--muted); font-size: 11px; }

.auth-wrap { display: grid; min-height: 100vh; place-items: center; padding: 24px; }
.auth-card { width: min(440px, 100%); padding: 28px; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); }
.auth-card .brand-mark { margin-bottom: 20px; }
.auth-card h1 { margin: 0; font-size: 24px; letter-spacing: -0.03em; }
.auth-card p { margin: 8px 0 22px; color: var(--muted); font-size: 14px; line-height: 1.55; }
.auth-card form { display: grid; gap: 16px; }
.auth-card .button { width: 100%; }

.modal { width: min(560px, calc(100% - 32px)); padding: 0; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); color: var(--ink); box-shadow: 0 24px 80px rgba(45, 24, 31, 0.25); }
.modal::backdrop { background: rgba(28, 19, 22, 0.55); }
.modal-header { padding: 19px 20px 0; }
.modal-header h3 { margin: 0; font-size: 18px; }
.modal-header p { margin: 6px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.modal-body { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 19px 20px; }
.modal-body .field-wide { grid-column: 1 / -1; }
.modal-footer { display: flex; justify-content: flex-end; gap: 9px; padding: 14px 20px max(20px, env(safe-area-inset-bottom)); border-top: 1px solid var(--border); }

.fresh-codes { max-height: 260px; overflow: auto; margin: 12px 0; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: #f8f6f7; }
.fresh-code { display: block; padding: 7px 4px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; user-select: all; }

.notice { margin-bottom: 14px; padding: 11px 13px; border: 1px solid #d9cfd2; border-radius: 10px; background: var(--surface); color: #4a3f43; font-size: 13px; }
.notice-success { border-color: #b9ddc8; background: #edf8f1; color: var(--success); }
.notice-error { border-color: #edc6ca; background: #fff0f1; color: var(--danger); }
.error-text { margin: 0; color: var(--danger); font-size: 12px; }
.spinner { width: 24px; height: 24px; border: 3px solid #eadde2; border-top-color: var(--accent); border-radius: 50%; animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .content-grid { grid-template-columns: 1fr; }
  .detail { position: static; }
}

@media (max-width: 640px) {
  .topbar { min-height: 58px; padding: 8px 14px; }
  .brand p { display: none; }
  .page { padding: 20px 12px 36px; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .toolbar { grid-template-columns: 1fr; }
  .code-table { display: none; }
  .code-cards { display: block; }
  .modal-body { grid-template-columns: 1fr; }
  .modal-body .field-wide { grid-column: auto; }
  .modal-footer { display: grid; grid-template-columns: 1fr 1fr; }
}

@media (max-width: 350px) {
  .brand h1 { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar .button { width: 44px; padding: 0; font-size: 0; }
  .topbar .button::before { content: "↪"; font-size: 18px; }
  .detail-actions { grid-template-columns: 1fr; }
}

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