:root {
  --bg: #0f1724;
  --card: #151f31;
  --muted: #8aa0c2;
  --text: #e8f0ff;
  --accent: #7dd3fc;
  --accent-strong: #60a5fa;
  --danger: #f87171;
  --success: #34d399;
  --border: #22304a;
  --shadow: 0 10px 35px rgba(0, 0, 0, 0.25);
  --radius: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Manrope", "Segoe UI", "Helvetica Neue", sans-serif;
  background: radial-gradient(circle at 20% 20%, rgba(96, 165, 250, 0.08), transparent 30%),
    radial-gradient(circle at 80% 0%, rgba(124, 58, 237, 0.1), transparent 35%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover { color: var(--accent-strong); }

header {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(12px);
  background: rgba(15, 23, 36, 0.85);
  border-bottom: 1px solid var(--border);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.brand .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  box-shadow: 0 0 18px rgba(96, 165, 250, 0.8);
}

.nav-links {
  display: flex;
  gap: 12px;
  align-items: center;
}

.button, button, input[type="submit"], .link-button {
  appearance: none;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #0b1020;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.1s ease, background 0.1s ease;
  box-shadow: 0 8px 20px rgba(96, 165, 250, 0.25);
}

.button:hover,
button:hover,
input[type="submit"]:hover,
.link-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 25px rgba(96, 165, 250, 0.35);
}

.button.secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
  box-shadow: none;
}

.button.danger {
  background: linear-gradient(135deg, #f87171, #fb7185);
  color: #0f172a;
}

.container {
  width: min(1100px, 92vw);
  margin: 32px auto 64px;
}

.page-content {
  flex: 1 0 auto;
}

.hero {
  margin: 24px 0 32px;
}

.hero h1 {
  margin: 0 0 10px;
  font-size: 30px;
}

.hero p {
  margin: 0;
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}

.grid.single-column {
  grid-template-columns: 1fr;
}

.card {
  background: rgba(21, 31, 49, 0.95);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.card h2,
.card h3 {
  margin-top: 0;
  margin-bottom: 10px;
}

.legal-content h1 {
  margin-top: 0;
  margin-bottom: 16px;
}

.legal-content h2 {
  margin-bottom: 10px;
  margin-top: 22px;
}

.legal-content p,
.legal-content ul {
  color: var(--muted);
  line-height: 1.6;
}

.legal-content ul {
  padding-left: 18px;
}

.card p {
  color: var(--muted);
  margin-top: 0;
}

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
  align-items: end;
}

.field.align-end {
  align-self: flex-end;
}

.stats-grid {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  margin-bottom: 18px;
}

.stat-card {
  background: linear-gradient(150deg, rgba(124, 58, 237, 0.12), rgba(96, 165, 250, 0.12));
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid var(--border);
}

.stat-card h2 {
  margin: 8px 0 0;
  font-size: 28px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  border: 1px solid var(--border);
  background: rgba(52, 211, 153, 0.1);
}

.pill-success {
  color: var(--success);
  border-color: rgba(52, 211, 153, 0.35);
}

.charts-grid {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  margin-bottom: 18px;
}

.chart-card .card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chart-body {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bar-row, .timeline-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.01);
}

.bar-title {
  font-weight: 600;
}

.bar {
  display: grid;
  grid-template-columns: auto;
  gap: 4px;
  height: 10px;
  overflow: hidden;
  border-radius: 6px;
  background: #0d1422;
}

.bar-success {
  display: inline-block;
  height: 10px;
  background: linear-gradient(120deg, #22c55e, #34d399);
}

.bar-failed {
  display: inline-block;
  height: 10px;
  background: linear-gradient(120deg, #ef4444, #f87171);
}

.bar-meta {
  color: var(--muted);
  font-size: 13px;
}

.timeline-row {
  gap: 8px;
}

.timeline-bars {
  display: flex;
  gap: 6px;
  align-items: center;
}

.table-card .table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.table-card {
  position: relative;
}

.table-wrapper {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  font-weight: 600;
  color: var(--text);
  background: rgba(255, 255, 255, 0.02);
}

.pager {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.pager-size {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pager-size select {
  width: auto;
  min-width: 80px;
}

.export-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.export-controls .button {
  min-width: 130px;
  font-weight: 700;
}

.toast-stack {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  gap: 8px;
  z-index: 2;
}

.toast {
  background: rgba(21, 31, 49, 0.95);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  min-width: 220px;
  font-weight: 600;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast-success { border-color: rgba(52, 211, 153, 0.5); }
.toast-error { border-color: rgba(248, 113, 113, 0.5); }
.toast-info { border-color: rgba(125, 211, 252, 0.5); }

.toast.is-hidden {
  opacity: 0;
  transform: translateY(-6px);
}

form .field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

label {
  color: var(--muted);
  font-size: 14px;
}

input, select {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #0e1626;
  color: var(--text);
}

input:focus, select:focus {
  outline: 2px solid rgba(96, 165, 250, 0.4);
  border-color: var(--accent-strong);
}

.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 6px;
}

.table thead tr,
.table tbody tr {
  display: table-row;
}

.table th,
.table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  vertical-align: top;
}

.table td.actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
  min-width: 160px;
}

.table td.actions form { margin: 0; }
.table td.actions button { white-space: nowrap; width: 100%; }

.limit-dashboard {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-top: 12px;
}

.limit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.limit-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
  border-radius: var(--radius);
  border: 1px solid rgba(125, 211, 252, 0.12);
  background: rgba(14, 22, 38, 0.94);
  box-shadow: 0 12px 32px rgba(11, 17, 33, 0.45);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.limit-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  background: radial-gradient(circle at top right, rgba(125, 211, 252, 0.18), transparent 55%);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.limit-card:hover {
  border-color: rgba(125, 211, 252, 0.35);
  box-shadow: 0 16px 38px rgba(11, 17, 33, 0.55);
  transform: translateY(-2px);
}

.limit-card:hover::after { opacity: 1; }

.limit-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.limit-card-title {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.limit-card-name {
  font-weight: 600;
  font-size: 15px;
}

.limit-usage {
  color: var(--muted);
  font-size: 13px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.limit-usage .limit-remaining {
  color: var(--accent);
  font-size: 12px;
  background: rgba(125, 211, 252, 0.12);
  padding: 2px 8px;
  border-radius: 999px;
}

.limit-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(96, 165, 250, 0.18);
  border: 1px solid rgba(96, 165, 250, 0.35);
  font-size: 12px;
  color: var(--accent);
  white-space: nowrap;
}

.limit-pill.is-unlimited {
  background: rgba(52, 211, 153, 0.14);
  border-color: rgba(52, 211, 153, 0.35);
  color: var(--success);
}

.limit-input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.limit-input-group input {
  font-size: 15px;
  letter-spacing: 0.4px;
}

.limit-hint {
  font-size: 12px;
  color: var(--muted);
}

.limit-status {
  font-size: 12px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.limit-status[hidden] { display: none !important; }

.limit-status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
}

.limit-status.is-pending { color: var(--accent-strong); }
.limit-status.is-pending::before { background: var(--accent-strong); }

.limit-status.is-success { color: var(--success); }
.limit-status.is-success::before { background: var(--success); }

.limit-status.is-error { color: var(--danger); }
.limit-status.is-error::before { background: var(--danger); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 12px;
  background: rgba(122, 162, 247, 0.18);
  border: 1px solid var(--border);
  color: var(--text);
}

.badge.success {
  background: rgba(52, 211, 153, 0.18);
  border-color: rgba(52, 211, 153, 0.4);
}

.badge.danger {
  background: rgba(248, 113, 113, 0.18);
  border-color: rgba(248, 113, 113, 0.45);
}

.messages {
  display: grid;
  gap: 10px;
  margin: 14px 0 20px;
}

.message {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(21, 31, 49, 0.9);
  color: var(--text);
  box-shadow: var(--shadow);
}

.message.success { border-color: rgba(52, 211, 153, 0.45); }
.message.error { border-color: rgba(248, 113, 113, 0.45); }
.message.info { border-color: rgba(125, 211, 252, 0.45); }

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.token-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.token-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.copy-box {
  background: #0b1220;
  border: 1px dashed var(--border);
  padding: 12px;
  border-radius: var(--radius-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.helper {
  color: var(--muted);
  font-size: 13px;
  margin-top: 8px;
}

.title-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hint {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text);
  font-size: 12px;
  cursor: help;
}

.hint-text {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  min-width: 200px;
  max-width: 320px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: #0b1220;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  color: var(--text);
  z-index: 60;
}

.hint:hover .hint-text,
.hint:focus-within .hint-text {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.action-with-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 16px;
}

.modal-backdrop[hidden] {
  display: none !important;
}

.modal {
  background: #0f1724;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  max-width: 380px;
  width: 100%;
  box-shadow: var(--shadow);
}

.modal h4 {
  margin: 0 0 8px;
}

.modal-text {
  margin: 0 0 14px;
  color: var(--muted);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  margin-bottom: 16px;
  align-items: flex-end;
}
.filters .field {
  flex: 1 1 160px;
  min-width: 150px;
}
.filters .field input {
  min-width: 0;
}
.field.align-end {
  align-self: flex-end;
  flex: 0 0 auto;
}
  border-top: 1px solid var(--border);
}

.footer-links {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.footer-link {
  color: var(--muted);
  border-bottom: 1px solid transparent;
  padding: 2px 0;
  transition: color 0.12s ease, border-color 0.12s ease;
  white-space: nowrap;
}

.footer-link + .footer-link {
  border-left: 1px solid rgba(138, 160, 194, 0.35);
  padding-left: 12px;
  margin-left: 2px;
}

.footer-link:hover {
  color: var(--accent-strong);
  border-color: rgba(96, 165, 250, 0.5);
}

@media (max-width: 700px) {
  .footer {
    justify-content: center;
    text-align: center;
  }

  .footer-links {
    justify-content: center;
  }
}

@media (max-width: 700px) {
  .nav { flex-wrap: wrap; }
  .token-line { flex-direction: column; align-items: flex-start; }
  .actions { width: 100%; }
  .copy-box { flex-direction: column; align-items: flex-start; }
}
