:root {
  --bg: #f6f7fb;
  --bg-soft: #eef1f7;
  --surface: #ffffff;
  --surface-strong: #11161f;
  --surface-tint: #fafbff;
  --text: #1f2530;
  --text-soft: #6b7280;
  --text-faint: #97a0af;
  --line: #e7eaf1;
  --line-strong: #d9dfeb;
  --accent: #e60000;
  --accent-strong: #ff4d4d;
  --accent-soft: rgba(230, 0, 0, 0.1);
  --success: #14866d;
  --warning: #b7791f;
  --danger: #c24141;
  --shadow-soft: 0 18px 40px rgba(20, 27, 45, 0.08);
  --shadow-card: 0 10px 24px rgba(20, 27, 45, 0.06);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --left-rail: 244px;
}

[data-theme="dark"] {
  --bg: #0c1018;
  --bg-soft: #121824;
  --surface: #111722;
  --surface-strong: #e9eef7;
  --surface-tint: #171e2c;
  --text: #edf2fb;
  --text-soft: #a2aabc;
  --text-faint: #748095;
  --line: #1e2635;
  --line-strong: #283246;
  --accent-soft: rgba(255, 77, 77, 0.18);
  --shadow-soft: 0 20px 46px rgba(0, 0, 0, 0.35);
  --shadow-card: 0 12px 28px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(230, 0, 0, 0.08), transparent 25%),
    linear-gradient(180deg, var(--bg-soft), var(--bg));
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

.brand__link {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
}

.brand__mark {
  display: inline-block;
  width: 30px;
  height: 30px;
  object-fit: contain;
}

.brand__text-light {
  font-weight: 300;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  border-radius: 14px;
  padding: 12px 18px;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

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

.button--primary {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  box-shadow: 0 12px 24px rgba(230, 0, 0, 0.18);
}

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

.button--small {
  padding: 10px 14px;
  border-radius: 12px;
}

.button--block {
  width: 100%;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-card);
}

.auth-shell {
  min-height: 100vh;
  padding: 28px;
}

.auth-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 0 auto 28px;
  max-width: 1240px;
}

.auth-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(360px, 420px);
  gap: 24px;
  max-width: 1240px;
  margin: 0 auto;
}

.auth-showcase,
.auth-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.auth-showcase {
  position: relative;
  overflow: hidden;
  padding: 44px;
  background:
    linear-gradient(135deg, rgba(17, 22, 31, 0.92), rgba(230, 0, 0, 0.8)),
    linear-gradient(180deg, #0d121b, #1e2635);
  color: #fff;
}

.auth-showcase::after {
  content: "";
  position: absolute;
  inset: auto -120px -120px auto;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.78rem;
  font-weight: 700;
}

.auth-showcase .eyebrow {
  color: rgba(255, 255, 255, 0.7);
}

.auth-title {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 1.02;
}

.auth-copy {
  max-width: 540px;
  margin: 18px 0 26px;
  color: rgba(255, 255, 255, 0.82);
  line-height: 1.7;
}

.showcase-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 34px;
}

.showcase-stat {
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
}

.showcase-stat strong,
.showcase-stat span {
  display: block;
}

.showcase-stat strong {
  font-size: 1.35rem;
}

.showcase-stat span {
  margin-top: 8px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.92rem;
}

.auth-card {
  padding: 34px 30px;
}

.auth-card h2 {
  margin: 0 0 8px;
}

.auth-card p {
  margin: 0 0 22px;
  color: var(--text-soft);
  line-height: 1.65;
}

.auth-form {
  display: grid;
  gap: 16px;
}

.auth-field {
  display: grid;
  gap: 8px;
}

.auth-field span {
  font-size: 0.94rem;
  color: var(--text-soft);
}

.auth-field input,
.auth-field select {
  width: 100%;
  min-height: 52px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-tint);
  color: var(--text);
}

.auth-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.auth-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-soft);
  font-size: 0.92rem;
}

.auth-link {
  color: var(--accent);
  font-size: 0.92rem;
}

.auth-footnote {
  margin-top: 18px;
  color: var(--text-faint);
  font-size: 0.9rem;
  line-height: 1.6;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--left-rail) minmax(0, 1fr);
  min-height: 100vh;
}

.left-rail {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px 22px 28px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(18px);
}

[data-theme="dark"] .left-rail {
  background: rgba(17, 23, 34, 0.9);
}

.rail-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.rail-overview {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, var(--surface), var(--surface-tint));
  box-shadow: var(--shadow-card);
}

.rail-overview strong,
.rail-overview span {
  display: block;
}

.rail-overview strong {
  font-size: 1.6rem;
  margin-top: 6px;
}

.rail-overview span {
  color: var(--text-soft);
  font-size: 0.92rem;
}

.rail-nav {
  display: grid;
  gap: 8px;
  margin-top: 24px;
}

.rail-nav__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  color: var(--text-soft);
}

.rail-nav__item:hover,
.rail-nav__item--active {
  background: var(--accent-soft);
  color: var(--text);
}

.rail-nav__icon {
  width: 22px;
  text-align: center;
}

.rail-section {
  margin-top: 22px;
}

.rail-section__title {
  margin: 0 0 12px;
  color: var(--text-faint);
  font-size: 0.82rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.theme-toggle {
  width: 42px;
  height: 24px;
  border: 0;
  border-radius: 999px;
  padding: 0;
  cursor: pointer;
  background: var(--line-strong);
  position: relative;
}

.theme-toggle::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 160ms ease;
}

.theme-toggle[aria-pressed="true"] {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
}

.theme-toggle[aria-pressed="true"]::after {
  transform: translateX(18px);
}

.rail-footer {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 24px;
  color: var(--text-soft);
  font-size: 0.92rem;
  line-height: 1.6;
}

.main-stage {
  min-width: 0;
  padding: 22px 24px 36px;
}

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

.page-title {
  margin: 6px 0 0;
  font-size: 2rem;
}

.page-copy {
  margin: 8px 0 0;
  color: var(--text-soft);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-soft);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}

.content-grid {
  display: grid;
  gap: 22px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.summary-card,
.panel,
.table-shell {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.summary-card {
  padding: 22px;
}

.summary-card__label {
  display: block;
  color: var(--text-soft);
  font-size: 0.92rem;
}

.summary-card__value {
  display: block;
  margin-top: 12px;
  font-size: 2rem;
  font-weight: 700;
}

.stars-icon {
  color: #e6a200;
  margin-right: 0.35em;
  font-weight: 400;
}

.summary-card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  color: var(--text-soft);
  font-size: 0.9rem;
}

.trend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 600;
}

.trend--up {
  color: var(--success);
  background: rgba(20, 134, 109, 0.12);
}

.trend--warn {
  color: var(--warning);
  background: rgba(183, 121, 31, 0.12);
}

.panel {
  padding: 22px;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-header h2,
.panel-header h3 {
  margin: 4px 0 0;
}

.panel-header p {
  margin: 8px 0 0;
  color: var(--text-soft);
}

.panel-note {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-left: 2px solid rgba(230, 0, 0, 0.35);
  background: rgba(230, 0, 0, 0.04);
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.5;
}

.panel-note code {
  font-size: 11px;
  background: rgba(0, 0, 0, 0.2);
  padding: 1px 5px;
  border-radius: 3px;
}

.panel-note em {
  font-style: normal;
  font-weight: 600;
  color: var(--text);
}

.chart-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 18px;
}

.chart {
  padding: 18px 18px 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-tint);
}

.chart svg {
  width: 100%;
  height: auto;
  display: block;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 14px;
  color: var(--text-soft);
  font-size: 0.9rem;
}

.chart-legend span::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 8px;
  border-radius: 50%;
  vertical-align: middle;
}

.legend-issued::before {
  background: #ff5d5d;
}

.legend-spent::before {
  background: #222a38;
}

[data-theme="dark"] .legend-spent::before {
  background: #9aa3b5;
}

.mini-metrics {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.mini-metric {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.mini-metric span {
  color: var(--text-soft);
}

.mini-metric strong {
  font-size: 1.12rem;
}

.activity-grid {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 18px;
}

.list {
  display: grid;
  gap: 14px;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.list-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.list-item strong {
  display: block;
}

.list-item span {
  color: var(--text-soft);
  font-size: 0.92rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}

.badge--credit {
  color: var(--success);
  background: rgba(20, 134, 109, 0.12);
}

.badge--debit {
  color: var(--danger);
  background: rgba(194, 65, 65, 0.12);
}

.badge--pending {
  color: var(--warning);
  background: rgba(183, 121, 31, 0.12);
}

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

.filter,
.search-field {
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-tint);
  color: var(--text);
}

.search-field {
  min-width: 260px;
}

.table-shell {
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead {
  background: var(--surface-tint);
}

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

th {
  color: var(--text-soft);
  font-size: 0.84rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

tbody tr:hover {
  background: rgba(230, 0, 0, 0.03);
}

.amount--positive {
  color: var(--success);
  font-weight: 700;
}

.amount--negative {
  color: var(--danger);
  font-weight: 700;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px;
  color: var(--text-soft);
}

.pagination__actions {
  display: flex;
  gap: 10px;
}

.empty-note {
  padding: 18px;
  border-radius: 16px;
  border: 1px dashed var(--line-strong);
  color: var(--text-soft);
  background: var(--surface-tint);
}

.simulator-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.simulator-help-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.simulator-card {
  display: grid;
  gap: 16px;
}

.simulator-field {
  display: grid;
  gap: 8px;
}

.simulator-field span {
  color: var(--text-soft);
  font-size: 0.92rem;
}

.simulator-textarea {
  width: 100%;
  min-height: 132px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-tint);
  color: var(--text);
  resize: vertical;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  line-height: 1.55;
}

.simulator-textarea--mono {
  min-height: 110px;
}

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

.simulator-response {
  min-height: 160px;
  margin: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-tint);
  color: var(--text);
  overflow: auto;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

/* MSS logo above the horizontal menu — mobile / fold only. */
.topbar-brand {
  display: none;
  align-items: center;
  margin-bottom: 14px;
}

/* Distinct horizontal page menu — hidden on desktop, shown on
   mobile / fold in place of the left-rail sidebar nav. */
.topbar-nav {
  display: none;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 18px;
  padding-bottom: 4px;
}

.topbar-nav__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-soft);
  white-space: nowrap;
}

.topbar-nav__item:hover,
.topbar-nav__item--active {
  background: var(--accent-soft);
  color: var(--text);
  border-color: transparent;
}

.topbar-nav__icon {
  text-align: center;
}

@media (max-width: 1180px) {
  .summary-grid,
  .chart-grid,
  .activity-grid,
  .auth-layout,
  .showcase-grid,
  .simulator-grid,
  .simulator-help-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  /* On mobile / fold the sidebar is hidden; the distinct horizontal
     menu bar (.topbar-nav) takes over. */
  .left-rail {
    display: none;
  }

  .topbar-brand {
    display: flex;
  }

  .topbar-nav {
    display: flex;
  }

  .summary-grid,
  .chart-grid,
  .activity-grid,
  .auth-layout,
  .showcase-grid,
  .simulator-grid,
  .simulator-help-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .auth-shell,
  .main-stage {
    padding: 18px;
  }

  .auth-showcase,
  .auth-card,
  .panel,
  .summary-card {
    padding: 18px;
  }

  .topbar,
  .auth-topbar,
  .panel-header,
  .auth-row,
  .pagination {
    flex-direction: column;
    align-items: flex-start;
  }

  .filters {
    width: 100%;
  }

  .search-field,
  .filter {
    width: 100%;
  }

  th,
  td {
    padding: 14px 12px;
    font-size: 0.92rem;
  }
}
