:root {
  --bg: #0f0a1a;
  --bg-card: #1a1228;
  --bg-hover: #241a36;
  --border: rgba(180, 140, 255, 0.15);
  --text: #e8e0f5;
  --text-muted: #9b8fb8;
  --accent: #c4a4ff;
  --gold: #f0c674;
  --green: #7dcea0;
  --red: #e87878;
  --warn: #f0a060;
  --radius: 14px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(120, 80, 200, 0.15), transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(80, 40, 120, 0.12), transparent 50%);
  pointer-events: none;
  z-index: 0;
}

.layout {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.sidebar {
  width: 260px;
  background: rgba(20, 12, 35, 0.95);
  border-right: 1px solid var(--border);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
}

.brand-icon { font-size: 1.75rem; }
.brand-icon.large { font-size: 3rem; display: block; text-align: center; margin-bottom: 0.5rem; }

.brand strong { display: block; font-size: 1rem; }
.brand small, .brand-center p { color: var(--text-muted); font-size: 0.85rem; }

.sidebar nav { display: flex; flex-direction: column; gap: 0.35rem; }

.sidebar a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  transition: 0.15s;
  font-size: 0.95rem;
}

.sidebar nav a:hover,
.sidebar nav a.active {
  background: var(--bg-hover);
  color: var(--text);
}

.sidebar nav a.active {
  border-left: 3px solid var(--accent);
}

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.export-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 0.25rem 0.85rem;
}

.sidebar-footer a { font-size: 0.85rem; padding: 0.45rem 0.85rem; }
.sidebar-footer .logout { color: var(--red); margin-top: 0.5rem; }

.content {
  flex: 1;
  padding: 2rem;
  max-width: 1200px;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 2rem;
}

.page-header h1 { font-size: 1.75rem; font-weight: 600; }
.subtitle { color: var(--text-muted); margin-top: 0.25rem; }

.back-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  display: inline-block;
  margin-bottom: 0.5rem;
}

.back-link:hover { color: var(--accent); }

.tabs, .filters, .search-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.tab {
  padding: 0.45rem 1rem;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
}

.tab.active, .tab:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--accent);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.metric-card.accent { border-color: rgba(196, 164, 255, 0.35); }
.metric-card.gold { border-color: rgba(240, 198, 116, 0.35); }
.metric-card.warn { border-color: rgba(240, 160, 96, 0.35); }

.metric-label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.metric-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
}

.metric-card.gold .metric-value { color: var(--gold); }

.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
  box-shadow: var(--shadow);
}

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

th, td {
  padding: 0.85rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tr:hover td { background: var(--bg-hover); }

.empty {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem !important;
}

.truncate {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: rgba(196, 164, 255, 0.15);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
}

.badge.large { font-size: 1.25rem; padding: 0.25rem 0.75rem; }

.status-paid { background: rgba(125, 206, 160, 0.15); color: var(--green); }
.status-pending { background: rgba(240, 160, 96, 0.15); color: var(--warn); }
.status-failed, .status-canceled { background: rgba(232, 120, 120, 0.15); color: var(--red); }

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

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

code {
  background: rgba(255, 255, 255, 0.06);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.85em;
}

.pagination {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: center;
  margin-top: 1.5rem;
  color: var(--text-muted);
}

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

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.detail-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.detail-card h3 {
  margin-bottom: 1rem;
  font-size: 1rem;
  color: var(--accent);
}

.detail-card dl { display: grid; grid-template-columns: auto 1fr; gap: 0.5rem 1rem; }
.detail-card dt { color: var(--text-muted); }
.detail-card dd { margin: 0; }

.section-block { margin-bottom: 2rem; }
.section-block h2 { font-size: 1.1rem; margin-bottom: 1rem; }

.mini-list { list-style: none; }
.mini-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.mini-list small { display: block; color: var(--text-muted); margin-top: 0.15rem; }

.interpretation-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  white-space: pre-wrap;
  line-height: 1.7;
  max-height: 600px;
  overflow: auto;
}

.text-green { color: var(--green); }
.text-red { color: var(--red); }

select, input[type="search"], input[type="password"] {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.55rem 0.85rem;
  border-radius: 10px;
  font-size: 0.9rem;
}

select:focus, input:focus {
  outline: none;
  border-color: var(--accent);
}

.btn {
  display: inline-block;
  padding: 0.55rem 1.1rem;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, #7c5cbf, #a855f7);
  color: white;
}

.btn-primary:hover { filter: brightness(1.08); }
.btn-danger {
  background: linear-gradient(135deg, #b91c1c, #dc2626);
  color: white;
}
.btn-danger:hover { filter: brightness(1.08); }
.btn-block { width: 100%; margin-top: 0.5rem; }

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
}

.brand-center { text-align: center; margin-bottom: 1.5rem; }
.brand-center h1 { font-size: 1.5rem; margin-bottom: 0.25rem; }

.login-card label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.login-card input { width: 100%; margin-bottom: 0.5rem; }

.alert {
  padding: 0.85rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.alert-error {
  background: rgba(232, 120, 120, 0.12);
  border: 1px solid rgba(232, 120, 120, 0.3);
  color: var(--red);
}

.alert-warn {
  background: rgba(240, 160, 96, 0.12);
  border: 1px solid rgba(240, 160, 96, 0.3);
  color: var(--warn);
}

.alert-success {
  background: rgba(125, 206, 160, 0.12);
  border: 1px solid rgba(125, 206, 160, 0.3);
  color: var(--green);
}

.admin-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.admin-form label {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.admin-form input[type="number"],
.admin-form select {
  width: 100%;
  max-width: 280px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text) !important;
  cursor: pointer;
}

.checkbox-label input { width: auto; }

.form-hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.5;
}

.form-hint.small { font-size: 0.8rem; }

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.inline-form { display: inline; }

.btn-small {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
}

.btn-small:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.danger-zone h2 {
  color: #f87171;
}

.danger-card {
  border-color: rgba(248, 113, 113, 0.35);
  background: rgba(127, 29, 29, 0.12);
}

@media (max-width: 768px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
  }
  .content { padding: 1rem; }
  .metrics { grid-template-columns: 1fr 1fr; }
}
