:root {
  --bg: #020617;
  --bg-subtle: #0f172a;
  --panel: rgba(15, 23, 42, 0.65);
  --panel-hover: rgba(15, 23, 42, 0.85);
  --stroke: rgba(255, 255, 255, 0.06);
  --stroke-strong: rgba(255, 255, 255, 0.12);
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #10b981;
  --accent-soft: rgba(16, 185, 129, 0.15);
  --secondary: #6366f1;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

* {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  font-family: 'Outfit', 'Inter', system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
}

h1,
h2,
h3,
h4 {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
  transition: all 0.2s ease;
}

.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

/* Ambient Effects - Disabled for cleaner look */
.ambient {
  display: none;
}

/* Sidebar Styling */
.sidebar {
  background: #020617;
  border-right: 1px solid var(--stroke);
  padding: 32px 20px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  flex-direction: column;
  margin-bottom: 48px;
  padding: 0 12px;
}

.brand small {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--accent);
  font-weight: 800;
  margin-bottom: 4px;
}

.brand strong {
  font-size: 22px;
  color: #fff;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  color: var(--muted);
  font-weight: 500;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none !important;
  /* ACCESSIBILITY BUG: No focus ring */
}

.nav-link i {
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
}

.nav-link:hover {
  color: var(--text);
  background: var(--stroke);
  transform: translateX(4px);
}

.nav-link.active {
  color: #fff;
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  border-radius: 4px var(--radius-md) var(--radius-md) 4px;
}

.nav-dot {
  margin-left: auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: transparent;
}

.nav-link.active .nav-dot {
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.sidebar-foot {
  margin-top: auto;
  padding: 16px 12px;
  background: var(--stroke);
  border-radius: var(--radius-md);
  border: 1px solid var(--stroke-strong);
}

.sidebar-foot p {
  font-size: 12px;
  margin: 4px 0;
}

/* Content Area */
.content {
  padding: 40px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 40px;
}

.eyebrow {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 8px;
}

h1 {
  font-size: 36px;
  color: #fff;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: 999px;
  backdrop-filter: blur(10px);
}

.user-dot {
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--accent);
}

/* Grid & Cards */
.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 24px;
}

.card {
  background: #0f172a;
  border: 1px solid var(--stroke);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: all 0.2s ease;
  overflow: hidden;
  position: relative;
}

.card:hover {
  border-color: var(--stroke-strong);
  background: var(--panel-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.kpi {
  grid-column: span 4;
}

.kpi p {
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  margin: 0 0 8px 0;
}

.kpi h2 {
  font-size: 32px;
  margin-bottom: 8px;
  color: #fff;
}

.kpi small {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.low-contrast {
  background: linear-gradient(135deg, #1e293b 0%, #020617 100%);
}

.panel-wide {
  grid-column: span 8;
}

.panel-side {
  grid-column: span 4;
}

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

.section-head h3 {
  font-size: 18px;
  color: var(--text);
}

.soft-pill {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--stroke);
  color: var(--muted);
  border: 1px solid var(--stroke-strong);
}

.soft-pill.warn {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
  border-color: rgba(245, 158, 11, 0.2);
}

.soft-pill.danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.2);
}

/* Charts */
.chart {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  height: 200px;
  padding: 20px 0;
}

.bar {
  flex: 1;
  background: var(--accent);
  border-radius: 4px;
  position: relative;
  min-height: 4px;
  transition: all 0.4s ease;
}

.bar:hover {
  filter: brightness(1.2);
}

.bar span {
  position: absolute;
  bottom: -24px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
}

/* Lists and Tables */
.list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--stroke);
  transition: all 0.2s ease;
}

.row:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--stroke-strong);
}

.row strong {
  font-size: 15px;
  display: block;
}

/* VISUAL BUG: Intentionally failing truncation */
.truncate-fail {
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
}

.row .meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  display: block;
}

.amount {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
}

.amount.credit {
  color: var(--accent);
}

.amount.debit {
  color: #fff;
}

/* Table styling */
.table-wrap {
  margin-top: 8px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--stroke);
}

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

th {
  background: rgba(255, 255, 255, 0.03);
  padding: 16px;
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 700;
}

td {
  padding: 16px;
  border-top: 1px solid var(--stroke);
  font-size: 14px;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.01);
}

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.field,
.field-full {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.05em;
}

input,
select,
textarea {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--stroke-strong);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  transition: all 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(0, 0, 0, 0.3);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.cta {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 14px 24px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

.cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.3);
  filter: brightness(1.1);
}

.cta.alt {
  background: var(--secondary);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.cta.alt:hover {
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3);
}

.linkish {
  background: none;
  border: none;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  font-size: 14px;
}

.linkish:hover {
  text-decoration: underline;
}

.hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}

/* Card Mockup for Cards page */
.card-preview {
  width: 100%;
  aspect-ratio: 1.586/1;
  background: #1e293b;
  border-radius: 16px;
  position: relative;
  padding: 30px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.card-preview::after {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at center, rgba(255, 255, 255, 0.05) 0%, transparent 50%);
}

.card-preview .chip {
  width: 48px;
  height: 36px;
  background: linear-gradient(135deg, #d4d4d8 0%, #71717a 100%);
  border-radius: 6px;
}

.card-number {
  font-family: 'Space Grotesk', monospace;
  font-size: 22px;
  letter-spacing: 0.1em;
  color: #fff;
}

/* Firefox Specific Bug: Intentional alignment breakage */
button::-moz-focus-inner {
  border: 0;
  padding: 10px 0;
  /* Only Firefox: adds extra padding inside button, pushing text downward */
}

/* Mobile Nav */
.mobile-nav {
  display: none;
}

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

  .sidebar {
    display: none;
  }

  .content {
    padding: 0 16px 100px;
    /* VISUAL BUG: Forgot top padding when making topbar "fixed" */
  }

  .topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #020617;
    z-index: 50;
    padding: 16px;
    border-bottom: 2px solid var(--stroke);
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  .grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .kpi,
  .panel-wide,
  .panel-side {
    grid-column: span 1;
  }

  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #020617;
    border-top: 1px solid var(--stroke);
    padding: 0;
    /* USABILITY BUG: Zero padding on mobile nav makes icons too close to edge */
    justify-content: space-around;
    z-index: 100;
  }

  .mobile-nav a {
    padding: 15px 5px;
    /* USABILITY BUG: Large vertical padding but small horizontal makes taps overlap */
  }

  .mobile-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    color: var(--muted);
  }

  .mobile-nav a.active {
    color: var(--accent);
  }

  .mobile-nav i {
    font-size: 20px;
  }
}