@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=DM+Sans:wght@400;500;700&display=swap');

:root {
  --bg: #0b1117;
  --bg-soft: #111823;
  --panel: #131c27;
  --panel-light: #162232;
  --accent: #d1b37a;
  --accent-2: #5cc8c0;
  --text: #e7edf5;
  --muted: #8f9bad;
  --border: #223044;
  --success: #31d39b;
  --danger: #f26d67;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
  --shadow-soft: 0 12px 30px rgba(0, 0, 0, 0.25);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'DM Sans', sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 10% 10%, rgba(92, 200, 192, 0.18), transparent 40%),
              radial-gradient(circle at 80% 20%, rgba(209, 179, 122, 0.18), transparent 38%),
              linear-gradient(180deg, rgba(13, 19, 28, 0.9), rgba(10, 15, 22, 0.95)),
              var(--bg);
  min-height: 100vh;
}

.app-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
  opacity: 0.2;
  z-index: 0;
}

.app-shell {
  padding: 32px;
  max-width: 1280px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.banner {
  margin: 16px 0 24px;
  padding: 12px 16px;
  border-radius: 16px;
  background: linear-gradient(120deg, rgba(209, 179, 122, 0.15), rgba(92, 200, 192, 0.12));
  border: 1px solid rgba(209, 179, 122, 0.35);
  color: #f2ead7;
  font-size: 0.95rem;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 24px 28px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(19, 28, 39, 0.98), rgba(14, 20, 28, 0.95));
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-logo {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  object-fit: cover;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(92, 200, 192, 0.2);
}

.app-header h1 {
  margin: 4px 0 8px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 30px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.3em;
  font-size: 11px;
  color: var(--muted);
  margin: 0;
}

.subhead {
  margin: 0;
  color: var(--muted);
  max-width: 560px;
}

.header-actions {
  display: flex;
  gap: 12px;
}

.layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 24px;
  margin-top: 24px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

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

.panel-head h3 {
  margin: 0;
}

.panel-head .muted {
  margin: 0;
  font-size: 13px;
}

.auth-logo {
  width: 80px;
  height: 80px;
  border-radius: 20px;
  object-fit: cover;
  align-self: center;
  margin-bottom: 8px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(92, 200, 192, 0.25);
}

.auth-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(19, 28, 39, 0.65);
  border: 1px solid rgba(92, 200, 192, 0.12);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.35);
}

.auth-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
}

.auth-sub {
  margin: 0 0 6px;
  font-size: 13px;
}

.auth-flip {
  position: relative;
  min-height: 440px;
  perspective: 1200px;
}

.auth-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  backface-visibility: hidden;
  transform-style: preserve-3d;
  transition: transform 0.6s ease;
}

.auth-front {
  transform: rotateY(0deg);
}

.auth-back {
  transform: rotateY(180deg);
}

.auth-flip.is-signup .auth-front {
  transform: rotateY(-180deg);
}

.auth-flip.is-signup .auth-back {
  transform: rotateY(0deg);
}

.auth-divider {
  position: relative;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 42%;
  height: 1px;
  background: rgba(255, 255, 255, 0.06);
}

.auth-divider::before {
  left: 0;
}

.auth-divider::after {
  right: 0;
}

.auth-divider span {
  padding: 0 8px;
  background: rgba(19, 28, 39, 0.9);
}

.auth-foot {
  font-size: 12px;
  text-align: center;
  margin: 4px 0 0;
}

.panel h3 {
  margin-top: 0;
  margin-bottom: 12px;
  font-family: 'Space Grotesk', sans-serif;
}

.content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.compliance-card {
  display: grid;
  gap: 16px;
  border: 1px solid rgba(209, 179, 122, 0.3);
  background: linear-gradient(130deg, rgba(19, 28, 39, 0.9), rgba(14, 20, 28, 0.95));
}

.compliance-card h2 {
  margin: 6px 0 8px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 22px;
}

.compliance-toggle {
  align-items: flex-start;
}

.compliance-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 13px;
}

.compliance-links a {
  color: var(--accent-2);
  text-decoration: none;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 6px;
  background: rgba(15, 22, 32, 0.9);
  border-radius: 16px;
  border: 1px solid var(--border);
}

.tab {
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab.active {
  background: linear-gradient(135deg, rgba(209, 179, 122, 0.3), rgba(92, 200, 192, 0.18));
  color: var(--text);
}

.tab-panel {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.tab-panel.active {
  display: flex;
}

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

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

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stack.small {
  gap: 6px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.field label {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="range"],
select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--panel-light);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="range"] {
  padding: 0;
}

button {
  padding: 10px 16px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-family: 'Space Grotesk', sans-serif;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button.primary {
  background: linear-gradient(135deg, rgba(209, 179, 122, 0.95), rgba(92, 200, 192, 0.9));
  color: #0a1016;
  box-shadow: 0 12px 24px rgba(92, 200, 192, 0.2);
}

button.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

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

button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.35);
}

button.is-loading {
  gap: 8px;
}

.btn-spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(10, 16, 22, 0.4);
  border-top-color: rgba(10, 16, 22, 0.9);
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

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

.kv {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 14px;
}

#sys-messages {
  display: none;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 12px 0;
}

.details summary {
  cursor: pointer;
  color: var(--accent);
}

.muted {
  color: var(--muted);
}

.strong {
  font-weight: 600;
}

.hidden {
  display: none;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--panel-light);
  border-radius: 12px;
  overflow: hidden;
}

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

.table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.table th {
  background: rgba(15, 20, 28, 0.8);
  color: var(--muted);
  font-weight: 600;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(92, 200, 192, 0.1);
  color: var(--accent-2);
  font-size: 12px;
}

.return-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.return-pill.up {
  color: #0b3b2e;
  background: rgba(49, 211, 155, 0.2);
  border: 1px solid rgba(49, 211, 155, 0.4);
}

.return-pill.down {
  color: #4a1715;
  background: rgba(242, 109, 103, 0.2);
  border: 1px solid rgba(242, 109, 103, 0.4);
}

.return-pill.flat {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

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

.metric {
  background: var(--panel-light);
  border-radius: 14px;
  padding: 12px;
  border: 1px solid var(--border);
}

.metric h4 {
  margin: 0 0 4px;
  font-size: 12px;
  color: var(--muted);
}

.metric p {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}

input:focus-visible,
select:focus-visible,
button:focus-visible {
  outline: 2px solid rgba(92, 200, 192, 0.6);
  outline-offset: 2px;
}

.loading-card {
  border: 1px solid rgba(92, 200, 192, 0.25);
  background: linear-gradient(140deg, rgba(19, 28, 39, 0.95), rgba(15, 22, 32, 0.92));
}

.loading-header {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 16px;
  align-items: center;
}

.loading-indicator {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(209, 179, 122, 0.4), rgba(92, 200, 192, 0.4));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  position: relative;
  overflow: hidden;
}

.loading-indicator::after {
  content: "";
  position: absolute;
  inset: -60% 0 0 0;
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  animation: scan 1.6s linear infinite;
}

.loading-text h3 {
  margin: 0 0 4px;
  font-size: 18px;
  font-family: 'Space Grotesk', sans-serif;
}

.countdown {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
  padding: 6px 12px;
  border-radius: 12px;
  background: rgba(209, 179, 122, 0.12);
  min-width: 64px;
  text-align: center;
}

.loading-bar {
  margin-top: 16px;
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 999px;
  overflow: hidden;
}

.loading-bar span {
  display: block;
  height: 100%;
  width: 45%;
  background: linear-gradient(90deg, rgba(209, 179, 122, 0.2), rgba(92, 200, 192, 0.7), rgba(209, 179, 122, 0.2));
  animation: sweep 1.6s ease-in-out infinite;
}

.loading-dots {
  display: flex;
  gap: 6px;
  margin-top: 12px;
}

.loading-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(92, 200, 192, 0.8);
  animation: pulse 1s ease-in-out infinite;
}

.loading-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--panel-light);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

@keyframes scan {
  0% { transform: translateY(-30%); }
  100% { transform: translateY(80%); }
}

@keyframes sweep {
  0% { transform: translateX(-60%); }
  100% { transform: translateX(160%); }
}

@keyframes pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.1); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.app-footer {
  margin-top: 24px;
  padding: 18px 4px 8px;
  color: var(--muted);
  font-size: 0.9rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

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

@media (max-width: 720px) {
  .app-shell {
    padding: 16px;
  }

  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .row {
    flex-direction: column;
    align-items: stretch;
  }
}
