:root {
  --font-sans: "Aptos", "Segoe UI Variable", "DIN Alternate", sans-serif;
  --color-bg: #0e1419;
  --color-bg-elevated: rgba(18, 28, 35, 0.86);
  --color-surface: rgba(23, 36, 45, 0.84);
  --color-surface-soft: rgba(255, 255, 255, 0.08);
  --color-text: #f8f4ec;
  --color-text-soft: #c6cdd2;
  --color-border: rgba(255, 255, 255, 0.08);
  --color-accent: #c62828;
  --color-accent-soft: rgba(198, 40, 40, 0.18);
  --color-warning: #f9a825;
  --color-success: #2e7d32;
  --background-stripe-color: rgba(255, 255, 255, 0.012);
  --shadow-panel: 0 24px 60px rgba(0, 0, 0, 0.28);
  color-scheme: dark;
}

:root[data-theme=light] {
  --color-bg: #f1e8dc;
  --color-bg-elevated: rgba(255, 252, 247, 0.96);
  --color-surface: rgba(255, 255, 255, 0.94);
  --color-surface-soft: rgba(23, 33, 42, 0.1);
  --color-text: #111922;
  --color-text-soft: #394754;
  --color-border: rgba(23, 33, 42, 0.14);
  --color-accent-soft: rgba(198, 40, 40, 0.16);
  --background-stripe-color: rgba(23, 33, 42, 0.06);
  color-scheme: light;
  --shadow-panel: 0 18px 48px rgba(38, 34, 29, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: radial-gradient(circle at top left, rgba(198, 40, 40, 0.24), transparent 30%), radial-gradient(circle at top right, rgba(249, 168, 37, 0.18), transparent 28%), linear-gradient(160deg, var(--color-bg) 0%, #111820 48%, var(--color-bg) 100%);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  color: var(--color-text);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: linear-gradient(rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01)), repeating-linear-gradient(135deg, transparent 0, transparent 22px, var(--background-stripe-color) 22px, var(--background-stripe-color) 24px);
  pointer-events: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.button-link {
  border: 0;
  border-radius: 16px;
  padding: 0.9rem 1.2rem;
  cursor: pointer;
  text-decoration: none;
  transition: transform 160ms ease, opacity 160ms ease, background 160ms ease;
}

button:hover,
.button-link:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: 14px;
  padding: 0.9rem 1rem;
  color: var(--color-text);
  background: var(--color-surface-soft);
}

select {
  color-scheme: dark;
}

select option {
  color: var(--color-text);
  background: #1b252d;
}

:root[data-theme=light] select {
  color-scheme: light;
}

:root[data-theme=light] select option {
  color: var(--color-text);
  background: #fffaf4;
}

textarea {
  resize: vertical;
}

label {
  display: grid;
  gap: 0.45rem;
  color: var(--color-text-soft);
  font-size: 0.95rem;
}

h1,
h2,
h3,
p {
  margin: 0;
}

#root {
  min-height: 100vh;
}

.centered-shell,
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
}

.redirect-shell {
  padding: 1.5rem;
}

.hero-panel,
.sidebar,
.content,
.panel,
.stat-card {
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.hero-panel,
.sidebar,
.panel,
.stat-card {
  border: 1px solid var(--color-border);
  background: var(--color-bg-elevated);
  box-shadow: var(--shadow-panel);
}

.hero-panel {
  max-width: 760px;
  padding: 3rem;
  border-radius: 32px;
  display: grid;
  gap: 1.4rem;
}

.hero-panel h1 {
  font-size: clamp(2.4rem, 5vw, 4.8rem);
  line-height: 0.95;
  max-width: 11ch;
}

.hero-panel p,
.sidebar-copy {
  color: var(--color-text-soft);
  max-width: 52ch;
}

.hero-actions,
.sidebar-actions,
.tracker-actions,
.panel-actions,
.editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(280px, 320px) 1fr;
  gap: 1.2rem;
  min-height: 100vh;
  padding: 1.2rem;
  align-items: start;
}

.sidebar {
  border-radius: 28px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1.5rem;
  position: sticky;
  top: 1.2rem;
  min-height: calc(100vh - 2.4rem);
}

.content-shell {
  display: flex;
  justify-content: center;
  min-width: 0;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: var(--color-warning);
}

.sidebar h1 {
  margin-top: 0.75rem;
  font-size: clamp(1.7rem, 2.4vw, 2.8rem);
  line-height: 0.95;
  word-break: keep-all;
}

.nav {
  display: grid;
  gap: 0.55rem;
}

.nav-item {
  text-align: left;
  color: var(--color-text);
  background: transparent;
  border: 1px solid transparent;
}

.nav-item.active {
  background: linear-gradient(135deg, var(--color-accent), #ff7043);
}

.sidebar-footer {
  display: grid;
  gap: 0.8rem;
}

.sidebar-footer span {
  display: block;
  color: var(--color-text-soft);
}

.content {
  width: min(100%, 1120px);
  border-radius: 28px;
  padding: 1.5rem;
  display: grid;
  align-content: start;
  gap: 1rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--color-border);
}

:root[data-theme=light] .content {
  background: rgba(255, 255, 255, 0.44);
}

.mobile-menu-button,
.sidebar-backdrop {
  display: none;
}

.topbar,
.panel-header,
.history-row,
.legend-item {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
}

.history-row > div:first-child {
  min-width: 0;
  display: grid;
  gap: 0.25rem;
}

.history-row > div:last-child {
  min-width: 0;
  display: grid;
  gap: 0.25rem;
  justify-items: end;
  text-align: right;
}

.history-row > div:first-child span,
.history-row > div:first-child strong {
  overflow-wrap: anywhere;
}

.topbar h2 {
  margin-top: 0.35rem;
  font-size: clamp(1.6rem, 2vw, 2.5rem);
}

.status-pill {
  border-radius: 999px;
  padding: 0.55rem 0.95rem;
  background: var(--color-surface-soft);
  color: var(--color-text);
}

.status-pill.tiny {
  font-size: 0.78rem;
}

.message {
  border-radius: 18px;
  padding: 0.9rem 1rem;
}

.message.error {
  background: rgba(198, 40, 40, 0.16);
  color: #ffcdc8;
}

.message.success {
  background: rgba(46, 125, 50, 0.16);
  color: #cdebd0;
}

:root[data-theme=light] .message.error {
  background: rgba(198, 40, 40, 0.12);
  color: #7d1f1f;
}

:root[data-theme=light] .message.success {
  background: rgba(46, 125, 50, 0.12);
  color: #1f5c26;
}

.panel,
.stat-card {
  border-radius: 24px;
  padding: 1.2rem;
}

.tracker-panel {
  background: linear-gradient(145deg, rgba(198, 40, 40, 0.16), rgba(255, 255, 255, 0.02)), var(--color-bg-elevated);
}

.running-badge {
  color: var(--color-text-soft);
}

:root[data-theme=light] .tracker-panel {
  background: linear-gradient(145deg, rgba(198, 40, 40, 0.12), rgba(255, 255, 255, 0.52)), var(--color-bg-elevated);
}

.tracker-grid,
.form-grid,
.stats-grid,
.charts-grid,
.admin-grid {
  display: grid;
  gap: 1rem;
}

.range-grid {
  grid-template-columns: repeat(2, minmax(0, 220px));
}

.token-form {
  align-items: end;
  margin-bottom: 0.75rem;
}

.token-preview code {
  display: block;
  margin-top: 0.55rem;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.18);
  color: inherit;
  overflow-wrap: anywhere;
}

:root[data-theme=light] .token-preview code {
  background: rgba(23, 33, 42, 0.08);
}

.tracker-grid,
.form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.full-width {
  grid-column: 1/-1;
}

.stats-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stat-card {
  display: grid;
  gap: 0.35rem;
}

.stat-label {
  color: var(--color-text-soft);
}

.stat-value {
  font-size: clamp(1.4rem, 2vw, 2.2rem);
}

.charts-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.bars {
  display: grid;
  gap: 1rem;
}

.bar-row {
  display: grid;
  gap: 0.45rem;
}

.bar-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: var(--color-text-soft);
}

.bar-track {
  height: 12px;
  border-radius: 999px;
  background: var(--color-surface-soft);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
}

.donut-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 1rem;
  align-items: center;
}

.donut {
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.donut-inner {
  width: 62%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--color-bg-elevated);
  display: grid;
  place-items: center;
  text-align: center;
}

.legend {
  display: grid;
  gap: 0.75rem;
}

.legend-item {
  align-items: center;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 999px;
}

.table-like,
.history-card {
  display: grid;
  gap: 0.9rem;
}

.history-card {
  padding: 1rem;
  border-radius: 20px;
  background: var(--color-surface-soft);
}

.breakdown-card {
  gap: 1rem;
}

.compact-bars {
  gap: 0.7rem;
}

.history-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  color: var(--color-text-soft);
  font-size: 0.9rem;
}

.compact .history-row {
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--color-border);
}

.compact .history-row:last-child {
  border-bottom: 0;
}

.settings-row > div:last-child,
.settings-row > div:first-child {
  justify-items: start;
  text-align: left;
}

.editor {
  display: grid;
  gap: 1rem;
  margin-top: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
}

.manual-entry-form {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.admin-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

.toggle input {
  width: auto;
}

.primary,
.button-link.primary {
  background: linear-gradient(135deg, var(--color-accent), #ff7043);
  color: #fff7f2;
}

.danger {
  background: rgba(198, 40, 40, 0.18);
  color: #ffd6d2;
}

.ghost {
  background: var(--color-surface-soft);
  color: var(--color-text);
}

:root[data-theme=light] .danger {
  background: rgba(198, 40, 40, 0.14);
  color: #8d2323;
}

:root[data-theme=light] .ghost,
:root[data-theme=light] .theme-toggle,
:root[data-theme=light] .status-pill {
  background: rgba(23, 33, 42, 0.08);
  color: var(--color-text);
}

:root[data-theme=light] .nav-item {
  color: #1c2630;
}

:root[data-theme=light] .history-card,
:root[data-theme=light] .bar-track {
  background: rgba(23, 33, 42, 0.08);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
}

.pagination-pill {
  min-width: 8.5rem;
  justify-self: center;
  text-align: center;
}

.history-pagination {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
}

.history-pagination > :first-child {
  justify-self: start;
}

.history-pagination > :last-child {
  justify-self: end;
}

.token-list {
  margin-top: 0.35rem;
}

.function-list-item {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
}

.function-list-item > div {
  min-width: 0;
  display: grid;
  gap: 0.25rem;
}

.function-color-dot {
  width: 0.8rem;
  height: 0.8rem;
  margin-top: 0.25rem;
  border-radius: 999px;
  flex: 0 0 auto;
  box-shadow: 0 0 0 1px var(--color-border);
}

.color-input {
  min-height: 3.2rem;
  padding: 0.35rem;
}

.theme-toggle {
  min-width: 3rem;
  padding: 0.8rem 0.95rem;
  background: var(--color-surface-soft);
  color: var(--color-text);
  font-size: 1.15rem;
  line-height: 1;
}

.empty {
  color: var(--color-text-soft);
}

@media (max-width: 1080px) {
  .charts-grid,
  .admin-grid,
  .stats-grid,
  .donut-layout {
    grid-template-columns: 1fr;
  }
  .app-shell {
    grid-template-columns: 1fr;
    padding: 0.8rem;
  }
  .sidebar,
  .content,
  .hero-panel {
    border-radius: 22px;
    padding: 1.2rem;
  }
  .mobile-menu-button {
    display: inline-flex;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 40;
    width: 3.2rem;
    height: 3.2rem;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: var(--color-bg-elevated);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-panel);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 20;
    border: 0;
    padding: 0;
    background: rgba(7, 10, 14, 0.42);
  }
  .sidebar {
    position: fixed;
    top: 0.8rem;
    left: 0.8rem;
    bottom: 0.8rem;
    width: min(84vw, 320px);
    min-height: auto;
    z-index: 30;
    transform: translateX(calc(-100% - 1.2rem));
    transition: transform 180ms ease;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  .content-shell {
    width: 100%;
    padding-top: 3.8rem;
  }
}
@media (max-width: 720px) {
  .tracker-grid,
  .form-grid,
  .range-grid {
    grid-template-columns: 1fr;
  }
  .topbar {
    align-items: start;
    flex-direction: column;
  }
  .history-row,
  .panel-header {
    flex-direction: column;
  }
  .history-row > div:last-child {
    width: 100%;
    justify-items: start;
    text-align: left;
  }
  .history-row > div:last-child .ghost,
  .history-row > div:last-child .danger,
  .history-row > div:last-child .primary {
    width: fit-content;
  }
  .history-meta {
    flex-direction: column;
    gap: 0.35rem;
  }
  .row-actions {
    width: 100%;
    justify-content: flex-start;
  }
}