:root {
  --bg: #0b0f14;
  --bg-2: #0f141b;
  --card: #151b23;
  --text: #e6edf3;
  --muted: #a9b4c0;
  --brand: #f1b21a;
  --brand-2: #f6c648;
  --brand-3: #f9d475;
  --accent: #2ba58f;
  --danger: #d14b4b;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --radius: 14px;
  --radius-sm: 10px;
  --container: 1180px;
  --muted: var(--muted);
  --color-text-subtle: rgba(169, 180, 192, 0.6);
  --color-text-invert: #ffffff;
  --color-text-dark: #0f172a;
  --color-text-strong: #111827;
  --color-border: rgba(255, 255, 255, 0.08);
  --color-border-strong: rgba(255, 255, 255, 0.12);
  --color-highlight: rgba(241, 178, 26, 0.08);
  --color-panel-shadow: rgba(0, 0, 0, 0.25);
  --color-panel-shadow-deep: rgba(0, 0, 0, 0.35);
  --color-surface-alt: rgba(21, 27, 35, 0.7);
  --space-2xs: 0.25rem;
  --space-xs: 0.5rem;
  --space-sm: 0.75rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.25rem;
  --font-size-xl: 1.5rem;
  --font-size-2xl: 2rem;
  --panel-radius: var(--radius);
  --table-radius: var(--radius-sm);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Roboto",
    Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  line-height: 1.45;
}

a {
  color: var(--brand);
}

.app-layout {
  display: flex;
  min-height: 100vh;
}

.app-sidebar {
  width: 264px;
  background-color: var(--card);
  color: var(--color-text-invert);
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 16px var(--color-panel-shadow-deep);
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--color-border);
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 2.5rem 1.75rem 1.75rem;
  gap: 2rem;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(0deg, var(--brand-3), var(--accent));
  color: var(--color-text-invert);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 1px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.brand-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0;
}

.brand-subtitle {
  font-size: 0.85rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.78);
}

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

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

.sidebar-section + .sidebar-section {
  margin-top: 1.4rem;
}

.sidebar-section-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.52);
  padding: 0 1rem;
}

.sidebar-section-links {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar-link-block {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.sidebar-link {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.88);
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s ease, transform 0.2s ease, color 0.2s ease;
}

.sidebar-link:hover,
.sidebar-link:focus {
  background: rgba(148, 197, 255, 0.28);
  color: var(--color-text-invert);
  transform: translateX(4px);
}

.sidebar-link.is-active {
  background: rgba(148, 197, 255, 0.4);
  color: var(--color-text-invert);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.sidebar-sublinks {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding-left: 1.75rem;
}

.sidebar-sublink {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: rgba(255, 255, 255, 0.74);
  font-weight: 500;
  font-size: 0.9rem;
  text-decoration: none;
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.sidebar-sublink:hover,
.sidebar-sublink:focus {
  background: rgba(148, 197, 255, 0.18);
  color: var(--color-text-invert);
  transform: translateX(3px);
}

.sidebar-sublink.is-active {
  background: rgba(148, 197, 255, 0.28);
  color: var(--color-text-invert);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.app-main {
  background-color: var(--bg);
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 100vh;
}

.app-content {
  flex: 1;
  width: min(1120px, 92%);
  margin: 0 auto;
  padding: 2.5rem 0 2rem;
}

.container {
  width: min(960px, 92%);
  margin: 0 auto;
}

.app-content.container {
  width: min(1120px, 92%);
}

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

.dashboard-subtitle {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.dashboard-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

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

.page-subtitle {
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.95rem;
}

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

.settings-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  border: 1px solid var(--color-border);
}

.settings-card h2 {
  margin: 0;
  font-size: 1.2rem;
}

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

.settings-card-note {
  font-size: 0.85rem;
  color: var(--color-text-subtle);
}

.color-form-grid {
  max-width: none;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.color-form-field {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: var(--space-sm);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.08);
  gap: var(--space-sm);
}

.color-form-field.is-env-override {
  background: rgba(191, 248, 56, 0.12);
  border-color: var(--accent);
}

.color-field-header {
  display: flex;
  justify-content: space-between;
  gap: var(--space-sm);
  font-weight: 600;
  color: var(--text);
  font-family: "Fira Code", "Consolas", "Courier New", monospace;
  font-size: 0.85rem;
}

.color-field-default {
  color: var(--muted);
  font-weight: 500;
}

.color-field-helper {
  font-size: 0.8rem;
  color: var(--color-text-subtle);
}

.color-env-flag {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.color-input-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.color-value-input {
  font-family: "Fira Code", "Consolas", "Courier New", monospace;
}

.color-value-input[disabled] {
  background-color: rgba(148, 197, 255, 0.16);
  cursor: not-allowed;
}

.color-preview {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--color-border-strong);
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.05);
}

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

.env-overrides-table th,
.env-overrides-table td {
  padding: 0.65rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.env-overrides-table code {
  font-family: "Fira Code", "Consolas", "Courier New", monospace;
  font-size: 0.85rem;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  padding: 0.55rem 1.2rem;
  border-radius: 999px;
  font-weight: 600;
  text-decoration: none;
  background: var(--brand);
  color: var(--color-text-invert);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.button-link:hover,
.button-link:focus {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px var(--color-panel-shadow);
}

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

.metric-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.2rem 1.4rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  border: 1px solid var(--color-border);
}

.metric-label {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

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

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

.chart-card {
  min-height: 320px;
  position: relative;
}

.chart-card canvas {
  width: 100%;
  height: 100%;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.panel-header h3 {
  margin: 0;
}

.chart-subtitle {
  margin: 0.25rem 0 0;
  color: var(--color-text-subtle);
  font-size: 0.9rem;
}

.dashboard-panel {
  margin-bottom: 2rem;
}

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

.metric-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.metric-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.striped-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.striped-list li {
  padding: 0.85rem 1rem;
  border-radius: 10px;
  background: var(--color-surface-alt);
  box-shadow: inset 0 0 0 1px rgba(226, 232, 240, 0.6);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.striped-list li + li {
  margin-top: 0.75rem;
}

.list-title {
  font-weight: 600;
  color: var(--color-text-dark);
}

.list-detail {
  color: var(--muted);
  font-size: 0.95rem;
}

.btn.is-loading {
  opacity: 0.75;
  pointer-events: none;
}

.btn.is-loading::after {
  content: "";
  width: 0.85rem;
  height: 0.85rem;
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-top-color: rgba(255, 255, 255, 1);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
  margin-left: 0.6rem;
}

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

.panel {
  background-color: var(--card);
  border-radius: var(--panel-radius);
  padding: var(--space-xl);
  box-shadow: 0 2px 8px var(--color-panel-shadow);
  margin-bottom: var(--space-2xl);
}

.panel h2,
.panel h3 {
  font-weight: 700;
  color: var(--text);
  margin: 0 0 var(--space-sm);
}

.panel h2 {
  font-size: var(--font-size-xl);
}

.panel h3 {
  font-size: var(--font-size-lg);
}

.form-grid {
  display: grid;
  gap: var(--space-md);
  max-width: 480px;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  font-weight: 600;
  color: var(--text);
}

.form-grid input,
.form-grid textarea,
.form-grid select {
  padding: 0.6rem var(--space-sm);
  border: 1px solid var(--color-border-strong);
  border-radius: 8px;
  font-size: var(--font-size-base);
}

.form-grid input:focus,
.form-grid textarea:focus,
.form-grid select:focus {
  outline: 2px solid var(--brand-2);
  outline-offset: 1px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  background-color: var(--color-border);
  color: var(--color-text-dark);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover,
.btn:focus {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px var(--color-panel-shadow);
}

.btn.primary {
  background-color: var(--brand-2);
  color: var(--color-text-invert);
}

.btn.primary:hover,
.btn.primary:focus {
  background-color: var(--brand-3);
}

.result-output {
  background-color: var(--color-text-dark);
  color: var(--color-surface-alt);
  padding: 1rem;
  border-radius: 8px;
  font-family: "Fira Code", "Consolas", "Courier New", monospace;
  overflow-x: auto;
  margin-top: 1.5rem;
}

.monospace-input {
  width: 100%;
  font-family: "Fira Code", "Consolas", "Courier New", monospace;
  min-height: 120px;
}

.button-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.table-container {
  margin-top: 1.5rem;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  border-radius: 12px;
  overflow: hidden;
  background-color: var(--color-surface-alt);
}

thead {
  background-color: var(--brand);
  color: var(--color-text-invert);
}

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

tbody tr:nth-child(even) {
  background-color: var(--color-highlight);
}

.empty-state {
  margin-top: 1.5rem;
  color: var(--muted);
  font-style: italic;
}

.hidden {
  display: none;
}

.feedback {
  margin-top: 1rem;
  font-weight: 600;
}

.feedback.success {
  color: var(--accent);
}

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

.site-footer {
  background-color: var(--brand);
  color: var(--color-text-invert);
  margin-top: 3rem;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem 0;
  font-size: 0.9rem;
}

.sidebar-toggle {
  display: none;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, var(--brand-2), var(--brand));
  color: var(--color-text-dark);
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.sidebar-toggle:hover,
.sidebar-toggle:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.sidebar-toggle:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.65);
  outline-offset: 3px;
}

.sidebar-toggle-icon {
  position: relative;
  display: inline-block;
  width: 18px;
  height: 2px;
  background-color: currentColor;
}

.sidebar-toggle-icon::before,
.sidebar-toggle-icon::after {
  content: "";
  position: absolute;
  left: 0;
  width: 18px;
  height: 2px;
  background-color: currentColor;
}

.sidebar-toggle-icon::before {
  top: -6px;
}

.sidebar-toggle-icon::after {
  top: 6px;
}

.sidebar-toggle-label {
  font-size: 0.95rem;
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 11, 17, 0.6);
  z-index: 800;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

@media (max-width: 1024px) {
  .app-sidebar {
    width: 240px;
  }
}

@media (max-width: 900px) {
  .app-layout {
    flex-direction: column;
  }

  .app-sidebar {
    position: relative;
    width: 100%;
    height: auto;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.14);
  }

  .sidebar-inner {
    padding: 1.5rem 1.25rem;
  }

  .sidebar-brand {
    justify-content: center;
  }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
  }

  .sidebar-link {
    flex: 1 1 140px;
    justify-content: center;
  }

  .app-content {
    width: min(100%, 94%);
    padding-top: 2rem;
  }

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

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

  .sidebar-toggle {
    display: inline-flex;
    margin: 1rem auto 1.5rem;
  }

  body.sidebar-collapsed .app-sidebar {
    display: none;
  }

  body.sidebar-open {
    overflow: hidden;
  }

  body.sidebar-open .app-sidebar {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    width: min(320px, 82vw);
    height: 100vh;
    overflow-y: auto;
    z-index: 900;
    box-shadow: 0 12px 30px rgba(8, 14, 25, 0.4);
  }

  body.sidebar-open .sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  body.sidebar-open .app-main {
    position: relative;
    z-index: 950;
  }
}
