:root {
  --bg: #0a1019;
  --bg-accent: rgba(102, 166, 255, 0.16);
  --bg-accent-2: rgba(34, 211, 238, 0.12);
  --panel: rgba(15, 24, 36, 0.88);
  --panel-2: rgba(21, 33, 49, 0.94);
  --panel-3: rgba(29, 43, 63, 0.95);
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #f3f7fb;
  --muted: #94a7bd;
  --accent: #8dd1ff;
  --accent-strong: #ffffff;
  --shadow: 0 24px 60px rgba(2, 8, 20, 0.34);
  --success: #7fe7a5;
  --danger: #ff8f8f;
  --warning: #ffd37f;
}

:root[data-theme="light"] {
  --bg: #eef4fb;
  --bg-accent: rgba(76, 125, 255, 0.14);
  --bg-accent-2: rgba(19, 167, 197, 0.1);
  --panel: rgba(255, 255, 255, 0.9);
  --panel-2: rgba(248, 251, 255, 0.95);
  --panel-3: rgba(236, 243, 251, 0.98);
  --line: rgba(17, 32, 49, 0.08);
  --line-strong: rgba(17, 32, 49, 0.14);
  --text: #112031;
  --muted: #5d6c7f;
  --accent: #1e6dff;
  --accent-strong: #0f172a;
  --shadow: 0 20px 44px rgba(71, 96, 128, 0.12);
  --success: #159b5c;
  --danger: #c84545;
  --warning: #b46f00;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, var(--bg-accent), transparent 26%),
    radial-gradient(circle at top right, var(--bg-accent-2), transparent 22%),
    linear-gradient(180deg, var(--bg), color-mix(in srgb, var(--bg) 92%, #ffffff 8%));
  color: var(--text);
  font: 14px/1.5 Manrope, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  transition: background 220ms ease, color 220ms ease;
}

button,
input,
select {
  font: inherit;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

.hidden {
  display: none !important;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 28px 18px;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 90%, transparent);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand strong,
.brand span,
.subtle,
.muted {
  display: block;
}

.brand span,
.subtle,
.muted {
  color: var(--muted);
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-link {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  color: var(--text);
  text-align: left;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: background-color 180ms ease, border-color 180ms ease, transform 180ms ease, color 180ms ease;
}

.nav-link:hover,
.nav-link.is-active {
  background: var(--panel-3);
  border-color: var(--line);
  transform: translateX(2px);
}

.main-content {
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.topbar h1,
.card h2,
.modal-header h3,
.drawer-header h3 {
  margin: 0;
}

.topbar .subtle {
  margin-top: 6px;
}

.panel-section {
  margin-bottom: 22px;
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
  animation: tabFade 220ms ease;
}

@keyframes tabFade {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card,
.modal-dialog,
.drawer-panel,
.toast,
.banner {
  background: color-mix(in srgb, var(--panel) 96%, transparent);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  transition: background-color 220ms ease, border-color 220ms ease, box-shadow 220ms ease, color 220ms ease;
}

.card {
  padding: 20px;
  border-radius: 22px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.card-header.with-controls {
  align-items: flex-start;
}

.receiver-card {
  position: relative;
  overflow: hidden;
}

.receiver-card::before {
  content: "";
  position: absolute;
  inset: -30% auto auto -5%;
  width: 240px;
  height: 240px;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 26%, transparent), transparent 72%);
  pointer-events: none;
}

.receiver-value-wrap {
  position: relative;
  padding: 20px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--panel-2);
}

.receiver-label,
.detail-label,
.meta-chip-label,
.gift-card-kicker {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.receiver-value {
  margin-top: 6px;
  font-size: 30px;
  font-weight: 800;
}

.card-note {
  margin-top: 14px;
  color: var(--muted);
}

.controls-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.controls-row-wide {
  justify-content: flex-end;
}

.input,
.select,
.primary-button,
.ghost-button,
.danger-button,
.tiny-button,
.icon-button,
.theme-toggle,
.filter-pill {
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  transition: transform 180ms ease, border-color 180ms ease, background-color 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

.input,
.select {
  min-height: 42px;
  min-width: 0;
  padding: 0 12px;
  background: var(--panel-2);
  color: var(--text);
}

.input::placeholder {
  color: color-mix(in srgb, var(--muted) 80%, transparent);
}

.primary-button,
.ghost-button,
.danger-button {
  min-height: 42px;
  padding: 0 14px;
  cursor: pointer;
}

.primary-button {
  background: color-mix(in srgb, var(--accent-strong) 90%, var(--accent) 10%);
  color: #07101a;
  border-color: transparent;
  font-weight: 800;
}

:root[data-theme="light"] .primary-button {
  color: #ffffff;
  background: linear-gradient(135deg, #1e6dff, #3f93ff);
}

.ghost-button,
.tiny-button,
.icon-button,
.filter-pill {
  background: var(--panel-2);
  color: var(--text);
}

.danger-button {
  background: rgba(255, 102, 102, 0.12);
  color: var(--danger);
  border-color: rgba(255, 102, 102, 0.22);
  font-weight: 700;
}

.tiny-button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
  cursor: pointer;
}

.icon-button {
  width: 38px;
  height: 38px;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.primary-button:hover,
.ghost-button:hover,
.danger-button:hover,
.tiny-button:hover,
.icon-button:hover,
.theme-toggle:hover,
.filter-pill:hover {
  transform: translateY(-1px);
}

.theme-toggle {
  position: relative;
  width: 78px;
  height: 46px;
  padding: 0;
  background: color-mix(in srgb, var(--panel-3) 94%, transparent);
  color: var(--text);
  cursor: pointer;
  overflow: hidden;
}

.theme-toggle-track {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  width: 100%;
  height: 100%;
  padding: 4px;
}

.theme-toggle-thumb {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 88%, #ffffff 12%), color-mix(in srgb, var(--panel) 72%, #ffffff 28%));
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.18);
  transition: transform 220ms ease, background 220ms ease;
}

.theme-toggle-icon {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: var(--muted);
  transition: color 220ms ease, transform 220ms ease, opacity 220ms ease;
}

.theme-toggle-icon svg {
  width: 18px;
  height: 18px;
}

:root[data-theme="dark"] .theme-toggle-icon-moon,
:root[data-theme="light"] .theme-toggle-icon-sun {
  color: var(--accent-strong);
}

:root[data-theme="light"] .theme-toggle-thumb {
  transform: translateX(34px);
}

:root[data-theme="light"] .theme-toggle-icon-sun,
:root[data-theme="dark"] .theme-toggle-icon-moon {
  transform: scale(0.9);
  opacity: 0.75;
}

.table-wrap,
.mini-table-wrap {
  overflow: auto;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--panel-2);
}

.table-wrap table,
.mini-table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  transition: border-color 220ms ease, background-color 220ms ease;
}

th {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  background: color-mix(in srgb, var(--panel-3) 90%, transparent);
}

tr:last-child td {
  border-bottom: 0;
}

.clickable-row {
  cursor: pointer;
}

.clickable-row:hover td {
  background: color-mix(in srgb, var(--accent) 10%, var(--panel-2) 90%);
}

.token-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.token-cell code {
  overflow-wrap: anywhere;
  white-space: normal;
}

.token-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--panel-3);
  font-size: 12px;
  font-weight: 800;
}

.badge-portals { color: #5ed0ff; }
.badge-mrkt { color: #f0b36d; }
.badge-tonnel { color: #b88cff; }
.badge-other { color: #bfc6d2; }

.badge-transferred { color: #85e2a6; }
.badge-viewed { color: #89b8ff; }
.badge-undefined { color: #c4cbd5; }
.badge-login { color: #f1d071; }

.filter-pills {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.filter-pill {
  min-height: 38px;
  padding: 0 14px;
  cursor: pointer;
}

.filter-pill.is-active {
  background: color-mix(in srgb, var(--accent) 18%, var(--panel-2) 82%);
  border-color: color-mix(in srgb, var(--accent) 42%, transparent);
  color: var(--accent-strong);
}

.logs-feed {
  display: grid;
  gap: 16px;
}

.log-card {
  border-radius: 22px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  padding: 18px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
  transition: transform 180ms ease, border-color 180ms ease, background-color 220ms ease;
}

.clickable-card {
  cursor: pointer;
}

.clickable-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 34%, var(--line));
}

.log-card-top,
.log-card-heading,
.gift-card-title,
.gift-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.log-card-heading strong {
  font-size: 15px;
}

.log-card-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 14px 0;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
}

.meta-chip-value {
  font-weight: 700;
}

.log-ref-block,
.detail-card {
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  padding: 14px;
}

.detail-value {
  margin-top: 8px;
  font-weight: 700;
}

.code-wrap {
  overflow-wrap: anywhere;
}

.gift-card {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 16px;
  padding: 14px;
  border-radius: 24px;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at top left, color-mix(in srgb, var(--accent) 22%, transparent), transparent 40%),
    linear-gradient(135deg, color-mix(in srgb, var(--panel-3) 92%, transparent), color-mix(in srgb, var(--panel) 94%, transparent));
}

.gift-card-compact {
  margin-top: 16px;
}

.gift-card-visual {
  min-height: 160px;
  border-radius: 20px;
  overflow: hidden;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.2), transparent 35%),
    linear-gradient(160deg, rgba(143, 204, 255, 0.18), rgba(132, 112, 255, 0.08));
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
}

.gift-card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gift-card-fallback {
  font-size: 18px;
  font-weight: 800;
}

.gift-card-body {
  display: grid;
  gap: 12px;
}

.gift-card-title {
  align-items: flex-start;
  font-size: 22px;
  font-weight: 800;
}

.gift-card-number {
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

.gift-card-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.gift-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--panel-2) 86%, transparent);
  border: 1px solid var(--line);
}

.gift-chip-label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.gift-chip-value {
  font-weight: 700;
}

.gift-card-footer {
  color: var(--muted);
  font-weight: 700;
}

.gift-card-loading {
  align-items: stretch;
}

.skeleton-card {
  display: grid;
  gap: 10px;
}

.skeleton,
.skeleton-box {
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.04));
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite linear;
}

.skeleton-line {
  height: 14px;
}

.skeleton-line.short {
  width: 42%;
}

.skeleton-box {
  border-radius: 20px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.banner {
  margin-bottom: 18px;
  padding: 14px 16px;
  border-radius: 16px;
  color: var(--danger);
}

.modal,
.drawer {
  position: fixed;
  inset: 0;
  z-index: 1000;
}

.modal-backdrop,
.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
}

.modal-dialog {
  position: relative;
  max-width: 520px;
  margin: 8vh auto 0;
  border-radius: 24px;
  padding: 20px;
}

.modal-sm {
  max-width: 460px;
}

.modal-header,
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.confirm-text {
  color: var(--text);
}

.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(760px, 94vw);
  height: 100vh;
  padding: 20px;
  overflow: auto;
  border-left: 1px solid var(--line);
}

.drawer-content,
.detail-block {
  display: grid;
  gap: 18px;
}

.drawer-state,
.empty-state,
.table-state {
  padding: 18px;
  color: var(--muted);
}

.drawer-state.error,
.table-state.error,
.empty-state.compact {
  color: var(--danger);
}

.detail-grid {
  display: grid;
  gap: 12px;
}

.detail-grid.two-up {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.toast-host {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1100;
  display: grid;
  gap: 10px;
}

.toast {
  min-width: 280px;
  max-width: 420px;
  border-radius: 16px;
  padding: 14px 16px;
}

.toast-success {
  color: var(--success);
}

.toast-error {
  color: var(--danger);
}

.fade-out {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .gift-card {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .main-content {
    padding: 18px;
  }

  .topbar,
  .card-header.with-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .detail-grid.two-up {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .controls-row,
  .controls-row-wide,
  .modal-actions,
  .filter-pills {
    flex-direction: column;
  }

  .token-cell,
  .log-card-top,
  .gift-card-title,
  .gift-card-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .toast-host {
    left: 14px;
    right: 14px;
  }

  .toast {
    min-width: 0;
    width: 100%;
  }
}
