:root {
  color-scheme: light dark;
  --bg: #0b0f1a;
  --card: #121829;
  --text: #e6e9f2;
  --muted: #97a1b8;
  --accent: #6ea8fe;
  --border: #232b3d;
  --error: #ff6b6b;
  --surface: #0f1424;
  --input-bg: #0b0f1a;
}

.theme-light {
  color-scheme: light;
  --bg: #f6f8fc;
  --card: #ffffff;
  --text: #0b1220;
  --muted: #5b667a;
  --accent: #2f6fed;
  --border: #e1e6ef;
  --error: #d64545;
  --surface: #f1f4fa;
  --input-bg: #f7f8fb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

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

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.theme-toggle {
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
}

.theme-toggle:hover {
  box-shadow: 0 6px 14px rgba(14, 24, 38, 0.15);
}

.header.hero {
  padding: 18px 20px;
  border-radius: 20px;
  background: radial-gradient(circle at top right, rgba(110, 168, 254, 0.18), transparent 55%),
    var(--surface);
  border: 1px solid var(--border);
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.7rem;
  color: var(--muted);
  margin: 0 0 8px;
}

.subtitle {
  color: var(--muted);
  margin: 8px 0 0;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 12px 30px rgba(5, 8, 16, 0.35);
}

.login-card {
  max-width: 460px;
  width: min(92vw, 460px);
  padding: 28px;
}

.login-header {
  margin-bottom: 20px;
}


.chart-card {
  padding: 20px 20px 28px;
}

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

.chart-controls {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.chart-controls .field {
  min-width: 200px;
}

.chart-controls .row {
  flex-wrap: nowrap;
}

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

.login-card .form {
  gap: 10px;
}

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

.section h2 {
  margin: 0 0 6px;
  font-size: 1.1rem;
}

.hint {
  color: var(--muted);
  margin: 0 0 12px;
  font-size: 0.9rem;
}

.item {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 12px;
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
  background: var(--surface);
}

.row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

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

.field input,
.field select {
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  padding: 10px 12px;
  font-size: 0.9rem;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% - 2px),
    calc(100% - 13px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 36px;
}

.field select:focus {
  outline: 2px solid rgba(110, 168, 254, 0.7);
  border-color: var(--accent);
}

.field select option {
  background: var(--surface);
  color: var(--text);
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.label {
  font-weight: 600;
}

textarea {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 16px;
  font-family: "Fira Code", "SFMono-Regular", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.9rem;
}

textarea:focus {
  outline: 2px solid rgba(110, 168, 254, 0.7);
  border-color: var(--accent);
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.button {
  background: linear-gradient(135deg, #6ea8fe 0%, #8fd3fe 100%);
  color: #0b0f1a;
  border: none;
  padding: 12px 20px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.button.danger {
  background: transparent;
  border: 1px solid rgba(255, 107, 107, 0.6);
  color: var(--error);
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(110, 168, 254, 0.4);
}

.error {
  border-color: rgba(255, 107, 107, 0.4);
}

.output pre {
  white-space: pre-wrap;
  background: var(--surface);
  border-radius: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  max-height: 320px;
  overflow: auto;
}

.chart-wrap {
  width: 100%;
  overflow-x: auto;
  min-height: 220px;
}

.tables {
  display: grid;
  gap: 16px;
}

.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  overflow-x: auto;
}

.table-card h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

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

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

th.sortable {
  cursor: pointer;
}

th.sortable:hover {
  color: var(--text);
}


.sort-indicator {
  margin-left: 6px;
  font-size: 0.8rem;
  color: var(--muted);
}

.error-text {
  color: var(--error);
  font-weight: 600;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

@media (max-width: 720px) {
  .page {
    padding: 20px 14px 48px;
  }

  .header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .theme-toggle {
    width: 100%;
    text-align: center;
  }

  .header.hero {
    padding: 16px;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

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

  .row {
    flex-direction: column;
  }

  .field {
    flex: 1 1 auto;
  }

  textarea {
    font-size: 0.85rem;
  }

  .actions {
    justify-content: stretch;
  }

  .button {
    width: 100%;
    text-align: center;
  }

  .chart-wrap {
    min-height: 260px;
  }

  .chart-controls {
    width: 100%;
  }

  .chart-controls .field {
    width: 100%;
  }

  .chart-controls .row {
    flex-direction: column;
    width: 100%;
  }
}

.footer {
  color: var(--muted);
  text-align: center;
  font-size: 0.85rem;
}
