:root {
  --gold: #B8962E;
  --gold-light: #D4AE4A;
  --gold-pale: #F5EDD0;
  --gold-border: rgba(184, 150, 46, 0.35);

  --blue: #1A2B4A;
  --blue-mid: #2B4270;
  --blue-deep: #111C31;

  --white: #FFFFFF;
  --off-white: #F9F8F6;
  --page: #F2F0EB;

  --text-main: #1A2B4A;
  --text-muted: #6B7A99;
  --text-light: #B0BBCC;

  --success: #1A7A52;
  --error: #B83232;
  --warn: #9A7010;

  --radius-xl: 24px;
  --radius-lg: 20px;
  --radius-md: 12px;
  --radius-sm: 8px;

  --shadow-main:
    0 2px 0 0 var(--gold-border),
    0 12px 50px rgba(26, 43, 74, 0.10),
    0 2px 8px rgba(26, 43, 74, 0.06);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  min-height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Arial, sans-serif;
  background: var(--page);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
}

/* =========================
   CARD BASE
========================= */
.card {
  position: relative;
  width: 100%;
  max-width: 540px;
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(184, 150, 46, 0.22);
  box-shadow: var(--shadow-main);
  padding: 44px 40px 40px;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--gold) 0%, var(--gold-light) 50%, var(--gold) 100%);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

/* =========================
   BRAND
========================= */
.brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge,
.brand-badge,
.modal-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 13px;
  border-radius: 999px;
  background: var(--blue);
  border: 1px solid var(--gold-border);
  color: var(--gold-light);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.badge-dot {
  width: 5px;
  height: 5px;
  background: var(--gold-light);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

/* =========================
   TYPOGRAPHY
========================= */
h1 {
  font-size: 30px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.1;
  margin-bottom: 8px;
  letter-spacing: -0.6px;
}

h2 {
  font-size: 24px;
  line-height: 1.15;
}

.subtitle,
.muted,
.modal-text {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.65;
}

.subtitle {
  margin-bottom: 28px;
}

.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(184, 150, 46, 0.3), transparent);
  margin-bottom: 28px;
}

/* =========================
   FORM GENERAL
========================= */
label {
  display: block;
  font-size: 11px;
  font-weight: 800;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.input-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

input[type="text"],
input[type="password"],
input[type="date"],
.modal-input {
  width: 100%;
  padding: 13px 15px;
  border-radius: var(--radius-md);
  border: 1.5px solid #E0DDD6;
  background: var(--off-white);
  color: var(--text-main);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  letter-spacing: 0.02em;
}

input[type="text"]::placeholder,
input[type="password"]::placeholder,
input[type="date"]::placeholder,
.modal-input::placeholder {
  color: var(--text-light);
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="date"]:focus,
.modal-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(184, 150, 46, 0.12);
  background: #fff;
}

/* =========================
   BUTTONS
========================= */
.btn,
.admin-actions button,
.mini-btn,
.admin-link-btn {
  border: 1px solid var(--blue);
  background: var(--blue);
  color: var(--gold-light);
  font-weight: 700;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, background 0.2s, border-color 0.2s, color 0.2s;
  letter-spacing: 0.04em;
  text-decoration: none;
}

.btn {
  padding: 13px 20px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.btn:hover,
.admin-actions button:hover,
.mini-btn:hover,
.admin-link-btn:hover {
  background: var(--blue-mid);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(26, 43, 74, 0.18);
}

.btn:active,
.admin-actions button:active,
.mini-btn:active,
.admin-link-btn:active {
  transform: scale(0.98);
}

.admin-link-btn {
  padding: 10px 14px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.mini-btn {
  padding: 10px 14px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
}

.mini-btn.danger {
  border-color: rgba(184, 50, 50, 0.25);
  background: #fff;
  color: var(--error);
}

.mini-btn.danger:hover {
  background: #fff3f3;
  box-shadow: 0 6px 20px rgba(184, 50, 50, 0.12);
}

.secondary {
  background: #fff !important;
  color: var(--blue) !important;
  border: 1px solid rgba(26, 43, 74, 0.16) !important;
}

.secondary:hover {
  background: #f7f8fb !important;
}

/* =========================
   STATUS
========================= */
.status-msg {
  margin-top: 13px;
  font-size: 13px;
  min-height: 20px;
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.25s;
}

.status-msg.visible {
  opacity: 1;
}

.status-msg.success { color: var(--success); }
.status-msg.error   { color: var(--error); }
.status-msg.info    { color: var(--warn); }

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-msg.success .status-dot { background: var(--success); }
.status-msg.error .status-dot   { background: var(--error); }
.status-msg.info .status-dot    { background: var(--gold); animation: pulse 1.2s infinite; }

/* =========================
   RESULT PANEL
========================= */
.result-panel {
  margin-top: 22px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(184, 150, 46, 0.28);
  background: var(--off-white);
  overflow: hidden;
  transform: translateY(10px);
  opacity: 0;
  display: none;
  transition: transform 0.35s cubic-bezier(0.23, 1, 0.32, 1), opacity 0.35s ease;
}

.result-panel.visible {
  display: block;
  transform: translateY(0);
  opacity: 1;
}

.result-header {
  background: var(--blue);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.result-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: rgba(184, 150, 46, 0.18);
  border: 1px solid rgba(184, 150, 46, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold-light);
  flex-shrink: 0;
}

.result-label-top,
.result-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: rgba(212, 174, 74, 0.75);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.result-name {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.result-body {
  padding: 18px;
}

.meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.meta-item {
  background: #fff;
  border-radius: var(--radius-sm);
  border: 1px solid #EAE8E0;
  padding: 10px 12px;
}

.meta-key {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-light);
  margin-bottom: 3px;
}

.meta-val {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  word-break: break-word;
}

.state-valid {
  color: var(--success);
}

.download-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px;
  border-radius: var(--radius-sm);
  background: var(--gold);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: transform 0.15s, box-shadow 0.15s, background 0.2s;
  border: none;
}

.download-btn:hover {
  background: var(--gold-light);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(184, 150, 46, 0.3);
}

/* =========================
   FOOTER
========================= */
.footer-note {
  margin-top: 28px;
  text-align: center;
  font-size: 11px;
  color: var(--text-light);
  letter-spacing: 0.06em;
}

/* =========================
   MODAL ADMIN
========================= */
.modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: none;
}

.modal.visible {
  display: block;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(9, 16, 29, 0.58);
  backdrop-filter: blur(4px);
}

.modal-dialog {
  position: relative;
  z-index: 2;
  width: min(92vw, 460px);
  margin: 8vh auto 0;
  background: #fff;
  border-radius: var(--radius-xl);
  border: 1px solid rgba(184, 150, 46, 0.22);
  box-shadow:
    0 18px 60px rgba(17, 28, 49, 0.28),
    0 2px 10px rgba(17, 28, 49, 0.08);
  padding: 28px 24px 24px;
  animation: modalIn 0.22s ease;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover {
  background: #f6f6f6;
  color: var(--text-main);
}

.modal-head {
  padding-right: 30px;
  margin-bottom: 18px;
}

.modal-head h2 {
  margin-top: 12px;
  margin-bottom: 8px;
  color: var(--text-main);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.4px;
}

.modal-body {
  display: grid;
  gap: 12px;
}

.modal-status {
  margin-top: 0;
}

.modal-submit {
  width: 100%;
  justify-content: center;
}

/* =========================
   ADMIN PAGE
========================= */
.admin-body {
  display: block;
  min-height: 100vh;
  padding: 28px 16px;
  background:
    radial-gradient(circle at top left, rgba(212,174,74,0.09), transparent 28%),
    linear-gradient(180deg, #f4f1ea 0%, #f0eee8 100%);
}

.wrap {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
}

.admin-wrap {
  display: block;
}

.admin-card {
  max-width: 100%;
  padding: 30px;
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.admin-topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.brand-block {
  margin-bottom: 18px;
}

.brand-block h1 {
  margin-top: 12px;
  margin-bottom: 8px;
}

.admin-warning {
  background: linear-gradient(180deg, #fffaf0 0%, #fff5db 100%);
  border: 1px solid rgba(184, 150, 46, 0.28);
  color: #6d5514;
  border-radius: 14px;
  padding: 14px 16px;
  line-height: 1.6;
  font-size: 14px;
  margin-bottom: 24px;
}

.admin-warning code {
  background: rgba(255,255,255,0.7);
  padding: 2px 6px;
  border-radius: 8px;
  font-family: Consolas, monospace;
  color: var(--blue);
}

.admin-form {
  display: block;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.field {
  min-width: 0;
}

.field input {
  width: 100%;
}

.admin-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 20px;
}

.admin-actions button {
  padding: 13px 16px;
  border-radius: 12px;
  min-height: 48px;
}

.status {
  margin-top: 18px;
  min-height: 22px;
  font-size: 14px;
  font-weight: 700;
}

.status.success {
  color: var(--success);
}

.status.error {
  color: var(--error);
}

.status.info {
  color: var(--warn);
}

.admin-output {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.output-box {
  background: #fbfaf7;
  border: 1px solid rgba(184, 150, 46, 0.18);
  border-radius: 16px;
  padding: 18px;
  min-width: 0;
}

.output-box h2 {
  font-size: 26px;
  font-weight: 800;
  color: var(--blue);
  letter-spacing: -0.5px;
  word-break: break-word;
}

.output-box code {
  display: inline-block;
  margin-top: 4px;
  background: #fff;
  border: 1px solid #ece7dc;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--blue);
  font-family: Consolas, monospace;
  word-break: break-all;
}

.output-box-full {
  grid-column: 1 / -1;
}

#jsonPreview {
  margin-top: 6px;
  background: #111827;
  color: #e5edf9;
  border-radius: 14px;
  padding: 16px;
  overflow: auto;
  font-size: 13px;
  line-height: 1.6;
  font-family: Consolas, Monaco, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.hidden {
  display: none !important;
}

/* =========================
   ANIMATIONS
========================= */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* =========================
   RESPONSIVE
========================= */
@media (max-width: 900px) {
  .admin-card {
    padding: 24px;
  }

  .grid,
  .admin-output {
    grid-template-columns: 1fr;
  }

  .output-box-full {
    grid-column: auto;
  }
}

@media (max-width: 480px) {
  body {
    padding: 28px 14px;
  }

  .card {
    padding: 32px 20px 28px;
  }

  .top-actions {
    align-items: stretch;
  }

  .admin-link-btn {
    width: 100%;
    justify-content: center;
  }

  .input-group {
    flex-direction: column;
  }

  .btn {
    width: 100%;
    justify-content: center;
  }

  .meta-grid {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 24px;
  }

  .admin-card {
    padding: 20px;
  }

  .admin-actions {
    flex-direction: column;
  }

  .admin-actions button,
  .mini-btn {
    width: 100%;
    justify-content: center;
  }

  .modal-dialog {
    width: calc(100vw - 20px);
    margin-top: 5vh;
    padding: 24px 18px 18px;
  }

  .modal-head h2 {
    font-size: 21px;
  }
}