/* ═══════════════════════════════════════════════════════════════════════════
   PayGateway – Design System
   Professional admin UI with clean typography and compact information density
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --bg-deep: #e9ecf1;
  --panel: #ffffff;
  --panel-strong: #f8f9fc;
  --ink: #1a1d26;
  --ink-secondary: #374151;
  --muted: #6b7280;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --accent-strong: #3730a3;
  --success: #059669;
  --success-bg: #ecfdf5;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --radius: 8px;
  --radius-lg: 12px;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "SF Mono", "Cascadia Code", "Fira Code", Menlo, Monaco, "Courier New", monospace;
}

/* ─── Reset ────────────────────────────────────────────────────────────────── */

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

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  position: relative;
}

/* ─── Public page shell (index.html) ──────────────────────────────────────── */

.page-shell {
  padding: 40px 20px 60px;
  background:
    radial-gradient(circle at top left, rgba(79, 70, 229, 0.06), transparent 40%),
    linear-gradient(160deg, var(--bg) 0%, #eef0f5 50%, var(--bg-deep) 100%);
}

.ambient {
  position: fixed;
  inset: auto;
  width: 28rem;
  height: 28rem;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.18;
  pointer-events: none;
}

.ambient-left {
  top: -8rem;
  left: -8rem;
  background: radial-gradient(circle, rgba(79, 70, 229, 0.5), transparent 65%);
}

.ambient-right {
  right: -8rem;
  bottom: -10rem;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.35), transparent 65%);
}

/* ─── Layout grid ─────────────────────────────────────────────────────────── */

.layout {
  position: relative;
  z-index: 1;
  width: min(1140px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 16px;
}

.two-column {
  grid-template-columns: 1.05fr 0.95fr;
  align-items: start;
}

.console-layout {
  grid-template-columns: 1fr;
}

/* ─── Panel ────────────────────────────────────────────────────────────────── */

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 20px;
}

.hero-panel {
  min-height: 100%;
}

.wide-panel {
  grid-column: 1 / -1;
}

/* ─── Typography ──────────────────────────────────────────────────────────── */

.eyebrow {
  margin: 0 0 6px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
}

h1,
h2 {
  margin: 0;
  font-family: var(--font-sans);
  font-weight: 700;
  line-height: 1.2;
  color: var(--ink);
}

h1 {
  font-size: 1.75rem;
}

h2 {
  font-size: 1.15rem;
}

.lead {
  font-size: 0.92rem;
  margin-top: 12px;
  line-height: 1.7;
  color: var(--muted);
}

.section-note {
  font-size: 0.82rem;
  color: var(--muted);
}

.message {
  font-size: 0.82rem;
  min-height: 20px;
  margin: 8px 0 0;
}

.message.error {
  color: var(--danger);
}

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

.info-list {
  padding-left: 18px;
  line-height: 1.8;
  font-size: 0.88rem;
  color: var(--muted);
}

.hidden {
  display: none !important;
}

/* ─── Forms ────────────────────────────────────────────────────────────────── */

label {
  display: grid;
  gap: 6px;
}

label span {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-secondary);
  letter-spacing: 0.01em;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--ink);
  font-size: 0.88rem;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

input::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

.stack-form {
  display: grid;
  gap: 14px;
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  align-items: end;
}

.filter-actions {
  align-self: end;
  justify-content: flex-start;
}

/* ─── Buttons ──────────────────────────────────────────────────────────────── */

button {
  border: 0;
  border-radius: var(--radius);
  padding: 8px 18px;
  background: var(--accent);
  color: #fff;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms ease, opacity 150ms ease, box-shadow 150ms ease;
  box-shadow: var(--shadow-xs);
}

button:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: var(--shadow);
}

button:active:not(:disabled) {
  transform: translateY(0.5px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

button.secondary {
  background: var(--panel);
  color: var(--ink-secondary);
  border: 1px solid var(--border);
  box-shadow: none;
}

button.secondary:hover:not(:disabled) {
  background: var(--panel-strong);
  border-color: var(--border-strong);
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  padding: 8px 18px;
  font-size: 0.84rem;
  font-weight: 600;
  text-decoration: none;
}

.button-link.secondary-link {
  background: var(--panel);
  color: var(--ink-secondary);
  border: 1px solid var(--border);
}

.button-link.secondary-link:hover {
  background: var(--panel-strong);
  text-decoration: none;
}

.button-row,
.toolbar-row,
.compact-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* ─── Section layout ──────────────────────────────────────────────────────── */

.order-header,
.section-head,
.console-topbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.inline-select {
  display: flex;
  gap: 8px;
  align-items: center;
}

.inline-select span {
  font-size: 0.82rem;
  white-space: nowrap;
}

.inline-select select {
  width: auto;
  min-width: 100px;
}

/* ─── Status badges ───────────────────────────────────────────────────────── */

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.status-badge.neutral {
  background: #f3f4f6;
  color: var(--muted);
}

.status-badge.pending {
  background: var(--warning-bg);
  color: var(--warning);
}

.status-badge.paid {
  background: var(--success-bg);
  color: var(--success);
}

.status-badge.expired {
  background: var(--danger-bg);
  color: var(--danger);
}

/* ─── Summary cards ───────────────────────────────────────────────────────── */

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.summary-card,
.qr-card,
.detail-card,
.trend-row {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.summary-card,
.qr-card,
.detail-card,
.trend-row {
  padding: 16px;
}

.summary-card h3,
.summary-card p {
  margin: 0;
}

.summary-card h3 {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.summary-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.5rem;
  font-weight: 700;
  font-family: var(--font-sans);
  color: var(--ink);
  letter-spacing: -0.02em;
}

.summary-card .sub-value {
  margin-top: 4px;
  font-size: 0.76rem;
  color: var(--muted);
}

/* ─── Trend chart ─────────────────────────────────────────────────────────── */

.trend-list {
  display: grid;
  gap: 8px;
}

.trend-row {
  display: grid;
  grid-template-columns: 90px 1fr 80px 80px;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
}

.trend-meta {
  display: grid;
  gap: 2px;
}

.trend-meta strong {
  font-size: 0.82rem;
}

.trend-meta span {
  font-size: 0.72rem;
  color: var(--muted);
}

.trend-bar-track {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: #f3f4f6;
  overflow: hidden;
}

.trend-bar-track-secondary {
  margin-top: 4px;
}

.trend-bar-svg {
  display: block;
  width: 100%;
  height: 100%;
}

.trend-bar {
  height: 10px;
}

.trend-bar.created {
  fill: #9ca3af;
}

.trend-bar.paid {
  fill: var(--accent);
}

.trend-row strong {
  font-size: 0.84rem;
}

.trend-row .section-note {
  font-size: 0.68rem;
}

/* ─── Tables ──────────────────────────────────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
  margin: 0 -4px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

th,
td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  color: var(--ink-secondary);
}

th {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: var(--panel-strong);
  position: sticky;
  top: 0;
}

th:first-child {
  border-radius: var(--radius) 0 0 0;
}

th:last-child {
  border-radius: 0 var(--radius) 0 0;
}

tbody tr:hover {
  background: rgba(79, 70, 229, 0.03);
}

tbody tr:last-child td {
  border-bottom: none;
}

.table-link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  font-size: 0.82rem;
}

.table-link:hover {
  text-decoration: underline;
}

.action-link {
  white-space: nowrap;
  font-size: 0.78rem;
  padding: 4px 10px;
}

.code-copy-cell {
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}

.table-empty-cell {
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--muted);
}

.activation-status-card {
  margin-bottom: 1rem;
}

/* ─── Activation detail page layout ──────────────────────────────────────── */

.act-detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
  grid-template-rows: auto auto;
  gap: 16px;
  align-items: start;
}

.act-info-panel {
  grid-column: 1;
  grid-row: 1 / 3;
}

.act-bind-panel {
  grid-column: 2;
  grid-row: 1;
}

.act-edit-panel {
  grid-column: 2;
  grid-row: 2;
}

.act-detail-list {
  margin-top: 16px;
}

.act-detail-list dt {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.act-detail-list dd {
  margin: 0;
  font-size: 0.92rem;
  color: var(--ink);
  word-break: break-all;
}

.act-detail-list .code-value {
  font-family: var(--font-mono);
  font-size: 1rem;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.act-bind-empty {
  padding: 12px 0;
  font-size: 0.84rem;
  color: var(--muted);
}

.act-bind-grid {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.act-bind-item {
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.act-bind-item dt {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.act-bind-item dd {
  margin: 4px 0 0;
  font-size: 0.9rem;
  color: var(--ink);
  word-break: break-all;
}

.table-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  white-space: nowrap;
}

@media (max-width: 860px) {
  .act-detail-layout {
    grid-template-columns: 1fr;
  }

  .act-info-panel,
  .act-bind-panel,
  .act-edit-panel {
    grid-column: auto;
    grid-row: auto;
  }
}

.inline-link {
  margin-top: 12px;
  color: var(--accent);
  font-size: 0.84rem;
}

.inline-link:hover,
.button-link:hover {
  text-decoration: underline;
}

/* ─── Order detail page ───────────────────────────────────────────────────── */

.order-grid {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 14px;
  margin-top: 16px;
}

.qr-card {
  display: grid;
  place-items: center;
  min-height: 280px;
}

.qr-placeholder {
  text-align: center;
  line-height: 1.7;
  color: var(--muted);
  font-size: 0.84rem;
}

.qr-image {
  width: 100%;
  max-width: 240px;
  background: #fff;
  padding: 8px;
  border-radius: var(--radius);
}

.detail-list {
  display: grid;
  gap: 14px;
  margin: 0;
}

.detail-list div {
  display: grid;
  gap: 4px;
}

.detail-list dt {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.detail-list dd {
  margin: 0;
  font-size: 0.92rem;
  color: var(--ink);
}

.order-detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.6fr);
  gap: 16px;
  align-items: start;
}

.order-hero-panel,
.timeline-panel {
  grid-column: 1;
}

.qr-panel,
.metadata-panel {
  grid-column: 2;
}

.order-detail-summary-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 16px;
}

.detail-qr-card {
  min-height: 260px;
}

.timeline-list {
  display: grid;
  gap: 8px;
}

.timeline-item {
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
}

.timeline-item strong {
  font-size: 0.82rem;
}

.timeline-item strong,
.metadata-list dd,
.order-detail-topbar h1 {
  word-break: break-word;
}

.timeline-item p {
  margin: 4px 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.timeline-item.paid {
  border-color: rgba(5, 150, 105, 0.2);
  background: var(--success-bg);
}

.timeline-item.expired {
  border-color: rgba(220, 38, 38, 0.15);
  background: var(--danger-bg);
}

.metadata-list {
  gap: 14px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Admin Shell – Sidebar + Content
   ═══════════════════════════════════════════════════════════════════════════ */

.admin-shell {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}

.admin-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 220px;
  display: flex;
  flex-direction: column;
  background: #111827;
  color: #d1d5db;
  z-index: 100;
  overflow-y: auto;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 20px 18px 16px;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.02em;
}

.sidebar-version {
  font-size: 0.65rem;
  font-weight: 500;
  opacity: 0.4;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 8px 10px;
}

.sidebar-footer {
  padding: 8px 10px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: #9ca3af;
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 500;
  transition: background 120ms ease, color 120ms ease;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #e5e7eb;
}

.sidebar-link.active {
  background: rgba(79, 70, 229, 0.2);
  color: #fff;
  font-weight: 600;
}

.sidebar-link svg {
  flex-shrink: 0;
  opacity: 0.55;
  width: 16px;
  height: 16px;
}

.sidebar-link.active svg,
.sidebar-link:hover svg {
  opacity: 0.85;
}

/* Admin content area */

.admin-content {
  flex: 1;
  margin-left: 220px;
  padding: 20px 24px 40px;
  display: grid;
  gap: 14px;
  align-content: start;
  max-width: 100%;
  overflow-x: hidden;
}

.admin-page {
  display: none;
}

.admin-page.active {
  display: contents;
}

/* Admin topbar / page header */

.admin-shell .console-topbar {
  align-items: center;
  padding: 16px 20px;
}

.admin-shell h1 {
  font-size: 1.35rem;
  letter-spacing: -0.01em;
}

.admin-shell h2 {
  font-size: 1rem;
}

.admin-shell .eyebrow {
  margin-bottom: 2px;
  font-size: 0.68rem;
}

.admin-shell .panel {
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

.admin-shell .summary-card {
  box-shadow: var(--shadow-xs);
  padding: 14px 16px;
}

.admin-shell .summary-card strong {
  font-size: 1.35rem;
  margin-top: 6px;
}

.admin-shell .filters-grid {
  gap: 10px;
}

.admin-shell input,
.admin-shell select {
  padding: 7px 10px;
  font-size: 0.82rem;
}

.admin-shell button {
  padding: 7px 14px;
  font-size: 0.8rem;
}

.admin-shell .action-link {
  padding: 3px 8px;
  font-size: 0.74rem;
}

/* Mobile header */

.admin-mobile-header {
  display: none;
}

.sidebar-toggle-btn {
  background: none;
  box-shadow: none;
  padding: 4px;
  border-radius: var(--radius);
  color: var(--ink);
  line-height: 0;
}

.sidebar-toggle-btn:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.05);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 1100px) {
  .filters-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .two-column,
  .order-grid,
  .trend-row {
    grid-template-columns: 1fr;
  }

  .order-detail-layout,
  .order-detail-summary-grid {
    grid-template-columns: 1fr;
  }

  .order-hero-panel,
  .timeline-panel,
  .qr-panel,
  .metadata-panel {
    grid-column: auto;
  }

  .filters-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .order-header,
  .section-head,
  .console-topbar {
    flex-direction: column;
    gap: 8px;
  }
}

@media (max-width: 860px) {
  .admin-sidebar {
    position: fixed;
    transform: translateX(-100%);
    transition: transform 200ms ease;
    box-shadow: none;
  }

  .admin-sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
  }

  .admin-content {
    margin-left: 0;
    padding: 68px 14px 32px;
  }

  .admin-mobile-header {
    display: flex;
    align-items: center;
    gap: 10px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 50px;
    padding: 0 14px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    z-index: 90;
    font-size: 0.88rem;
  }
}

@media (max-width: 640px) {
  .page-shell {
    padding: 20px 12px 32px;
  }

  .panel {
    padding: 16px;
    border-radius: var(--radius);
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .admin-shell .panel {
    padding: 14px 16px;
  }
}

/* ─── Dialog modal ────────────────────────────────────────────────────────── */

dialog {
  border: 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 24px 28px 20px;
  min-width: 320px;
  max-width: 460px;
  width: 92%;
  background: var(--panel);
  color: var(--ink);
}

dialog::backdrop {
  background: rgba(15, 15, 30, 0.5);
}

dialog h3 {
  margin: 0 0 6px;
  font-size: 1.05rem;
  font-weight: 700;
}

.dialog-code-label {
  font-family: ui-monospace, SFMono-Regular, monospace;
  background: var(--panel-strong);
  border-radius: 4px;
  padding: 3px 8px;
  margin: 0 0 18px;
  font-size: 0.82rem;
  color: var(--ink-secondary);
  display: inline-block;
}

dialog .message {
  margin-top: 8px;
  min-height: 1.4em;
}

/* ─── Status tabs ─────────────────────────────────────────────────────────── */

.status-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 0 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.status-tab {
  padding: 5px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.status-tab:hover {
  background: var(--panel-strong);
  color: var(--text);
}

.status-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ─── Pagination ──────────────────────────────────────────────────────────── */

.pagination-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 14px 0 4px;
}

.pagination-info {
  font-size: 0.85rem;
  color: var(--muted);
  min-width: 160px;
  text-align: center;
}
