/* ==========================================================================
   Rubyn Design System
   Dark ruby-themed design system matching the Rubyn landing page.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. CSS Custom Properties (Design Tokens)
   -------------------------------------------------------------------------- */

:root {
  /* Core palette — HSL values matching the landing page */
  --background: 330 30% 9%;        /* #1A1016 */
  --foreground: 15 100% 97%;       /* #FFF5F0 */
  --card: 330 25% 12%;             /* #2D1B24 */
  --card-foreground: 15 100% 97%;
  --popover: 330 25% 12%;
  --popover-foreground: 15 100% 97%;
  --primary: 2 67% 49%;            /* #CC342D — Ruby Red */
  --primary-foreground: 15 100% 97%;
  --secondary: 345 70% 36%;        /* #9B1B30 — Deep Burgundy */
  --secondary-foreground: 15 100% 97%;
  --muted: 330 20% 16%;            /* #3D2B34 */
  --muted-foreground: 20 30% 65%;  /* #A89090 */
  --accent: 345 70% 36%;
  --accent-foreground: 15 100% 97%;
  --destructive: 0 84.2% 60.2%;    /* #EF4444 */
  --destructive-foreground: 210 40% 98%;
  --border: 330 15% 20%;
  --input: 330 15% 20%;
  --ring: 2 67% 49%;
  --radius: 0.75rem;

  /* Named colors */
  --ruby: 2 67% 49%;
  --burgundy: 345 70% 36%;
  --cream: 25 53% 91%;             /* #F5E6D3 */

  /* Terminal */
  --terminal-bg: 220 20% 8%;
  --terminal-border: 220 15% 16%;

  /* Sidebar */
  --sidebar-background: 330 25% 10%;
  --sidebar-foreground: 15 100% 97%;
  --sidebar-primary: 2 67% 49%;
  --sidebar-primary-foreground: 15 100% 97%;
  --sidebar-accent: 330 20% 16%;
  --sidebar-accent-foreground: 15 100% 97%;
  --sidebar-border: 330 15% 20%;

  /* Layout */
  --sidebar-width: 260px;
  --header-height: 56px;

  /* Semantic */
  --success: 142 71% 45%;
  --warning: 38 92% 50%;
  --danger: 0 84.2% 60.2%;

  /* Convenience aliases (used by existing landing-page classes) */
  --bg: hsl(var(--background));
  --bg-card: hsl(var(--card));
  --bg-card-hover: hsl(330 25% 14%);
  --text: hsl(var(--foreground));
  --text-muted-color: hsl(var(--muted-foreground));
  --border-color: hsl(var(--border));
  --border-light: hsl(330 15% 25%);
  --primary-color: hsl(var(--primary));
  --primary-hover: hsl(2 67% 42%);
  --secondary-color: hsl(var(--secondary));
  --cream-color: hsl(var(--cream));
  --gradient-ruby: linear-gradient(135deg, hsl(var(--ruby)), hsl(var(--burgundy)));
  --font-body: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
  --transition: all 0.2s ease;
}

/* --------------------------------------------------------------------------
   2. Reset & Base Styles
   -------------------------------------------------------------------------- */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-body);
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.375rem; }
h4 { font-size: 1.125rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.875rem; }

p {
  color: var(--text-muted-color);
  line-height: 1.7;
  margin-bottom: 1rem;
}

p:last-child {
  margin-bottom: 0;
}

a {
  color: var(--primary-color);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  opacity: 0.85;
}

code, pre, kbd, samp {
  font-family: var(--font-mono);
}

code {
  background: hsl(var(--muted));
  color: var(--cream-color);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-size: 0.875em;
}

pre {
  background: hsl(var(--terminal-bg));
  border: 1px solid hsl(var(--terminal-border));
  border-radius: var(--radius);
  padding: 1rem;
  overflow-x: auto;
  font-size: 0.875rem;
  line-height: 1.7;
}

pre code {
  background: none;
  padding: 0;
  border-radius: 0;
}

hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 1.5rem 0;
}

img {
  max-width: 100%;
  height: auto;
}

::selection {
  background: hsl(var(--ruby) / 0.3);
  color: var(--text);
}

/* --------------------------------------------------------------------------
   3. Layout Classes
   -------------------------------------------------------------------------- */

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
}

.container-narrow {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 2rem;
}

.container-wide {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 2rem;
}

.section {
  padding: 5rem 0;
}

.section-sm {
  padding: 3rem 0;
}

/* Sidebar layout -- used by admin and user dashboards */
.sidebar-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar-layout .main-area {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.sidebar-layout .main-content {
  padding: 1.5rem;
  flex: 1;
}

/* Grid utilities */
.grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.grid-features {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.three-col {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
}

/* Flex utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-xs { gap: 0.25rem; }
.gap-sm { gap: 0.5rem; }
.gap-md { gap: 1rem; }
.gap-lg { gap: 1.5rem; }

/* Spacing utilities */
.mb-0 { margin-bottom: 0; }
.mb-sm { margin-bottom: 0.5rem; }
.mb-md { margin-bottom: 1rem; }
.mb-lg { margin-bottom: 1.5rem; }
.mb-xl { margin-bottom: 2rem; }
.mt-sm { margin-top: 0.5rem; }
.mt-md { margin-top: 1rem; }
.mt-lg { margin-top: 1.5rem; }
.p-md { padding: 1rem; }
.p-lg { padding: 1.5rem; }

/* --------------------------------------------------------------------------
   4. Text Utilities
   -------------------------------------------------------------------------- */

.text-gradient-ruby {
  background: var(--gradient-ruby);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent;
}

.text-ruby {
  color: var(--primary-color);
}

.text-muted {
  color: var(--text-muted-color);
}

.text-cream {
  color: var(--cream-color);
}

.text-foreground {
  color: var(--text);
}

.text-success {
  color: hsl(var(--success));
}

.text-warning {
  color: hsl(var(--warning));
}

.text-danger {
  color: hsl(var(--danger));
}

.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-base { font-size: 1rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.text-3xl { font-size: 2rem; }
.text-center { text-align: center; }
.text-right { text-align: right; }

.font-mono {
  font-family: var(--font-mono);
}

.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.font-extrabold { font-weight: 800; }

.uppercase {
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   5. Background Utilities
   -------------------------------------------------------------------------- */

.bg-gradient-ruby {
  background: linear-gradient(135deg, hsl(var(--ruby)), hsl(var(--burgundy)));
}

.bg-gradient-ruby-subtle {
  background: linear-gradient(180deg, hsl(var(--ruby) / 0.08), transparent);
}

.bg-card {
  background: var(--bg-card);
}

.bg-muted {
  background: hsl(var(--muted));
}

.bg-background {
  background: var(--bg);
}

.bg-terminal {
  background: hsl(var(--terminal-bg));
}

/* --------------------------------------------------------------------------
   6. Glow Effect
   -------------------------------------------------------------------------- */

.glow-ruby {
  box-shadow: 0 0 40px hsl(var(--ruby) / 0.2), 0 0 80px hsl(var(--ruby) / 0.1);
}

/* --------------------------------------------------------------------------
   7. Card Component
   -------------------------------------------------------------------------- */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-bottom: 1rem;
  color: hsl(var(--card-foreground));
  transition: var(--transition);
}

.card:hover {
  border-color: var(--border-light);
  background: var(--bg-card-hover);
}

.card-static {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1rem;
  color: hsl(var(--card-foreground));
  overflow-x: auto;
}

/* Card with less padding for table-heavy content */
.card-table {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 0;
  margin-bottom: 1rem;
  color: hsl(var(--card-foreground));
  overflow-x: auto;
}

.card-table .card-title {
  padding: 1rem 1.25rem 0.5rem;
}

.card-table table th:first-child,
.card-table table td:first-child {
  padding-left: 1.25rem;
}

.card-table table th:last-child,
.card-table table td:last-child {
  padding-right: 1.25rem;
}

.card-glow {
  box-shadow: var(--shadow);
}

.card-glow:hover {
  box-shadow: var(--shadow-lg), 0 0 30px hsla(2, 67%, 49%, 0.08);
}

.card-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted-color);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

/* Stat card variant */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  transition: var(--transition);
}

.stat-card:hover {
  border-color: var(--border-light);
}

.stat-card .stat-label {
  font-size: 0.75rem;
  color: var(--text-muted-color);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  margin-top: 0.25rem;
}

.stat-card .stat-sub {
  font-size: 0.75rem;
  color: var(--text-muted-color);
  margin-top: 0.125rem;
}

/* --------------------------------------------------------------------------
   8. Button Components
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.75rem;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  line-height: 1.4;
  white-space: nowrap;
}

.btn:hover {
  text-decoration: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--gradient-ruby);
  color: white;
  box-shadow: 0 2px 12px hsl(var(--ruby) / 0.3);
}

.btn-primary:hover {
  opacity: 0.92;
  box-shadow: 0 4px 20px hsl(var(--ruby) / 0.4);
  transform: translateY(-1px);
  color: white;
}

.btn-secondary {
  background: transparent;
  color: var(--cream-color);
  border: 1.5px solid var(--border-light);
}

.btn-secondary:hover {
  border-color: var(--primary-color);
  color: var(--text);
  background: hsl(330 25% 15% / 0.5);
}

.btn-danger {
  background: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
}

.btn-danger:hover {
  box-shadow: 0 0 20px hsl(var(--destructive) / 0.3);
  color: hsl(var(--destructive-foreground));
}

.btn-success {
  background: hsl(var(--success));
  color: #fff;
}

.btn-warning {
  background: hsl(var(--warning));
  color: #fff;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text);
}

.btn-outline:hover {
  background: hsl(var(--muted));
  color: var(--text);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted-color);
}

.btn-ghost:hover {
  background: hsl(var(--muted));
  color: var(--text);
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8125rem;
  border-radius: 0.5rem;
}

.btn-lg {
  padding: 0.85rem 2.25rem;
  font-size: 1.05rem;
}

.btn-full {
  width: 100%;
}

/* --------------------------------------------------------------------------
   9. Badge Component
   -------------------------------------------------------------------------- */

.badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.badge-ruby {
  background: hsl(var(--ruby) / 0.15);
  color: var(--primary-color);
  border: 1px solid hsl(var(--ruby) / 0.25);
}

.badge-green {
  background: hsl(var(--success) / 0.15);
  color: hsl(var(--success));
}

.badge-red {
  background: hsl(var(--destructive) / 0.15);
  color: hsl(var(--destructive));
}

.badge-yellow {
  background: hsl(var(--warning) / 0.15);
  color: hsl(var(--warning));
}

.badge-blue {
  background: hsl(210 80% 50% / 0.15);
  color: hsl(210 80% 60%);
}

.badge-purple {
  background: hsl(270 60% 50% / 0.15);
  color: hsl(270 60% 65%);
}

.badge-gray {
  background: hsl(var(--muted));
  color: var(--text-muted-color);
}

/* --------------------------------------------------------------------------
   10. Form Styles
   -------------------------------------------------------------------------- */

.form-group {
  margin-bottom: 1.25rem;
}

.label,
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted-color);
  margin-bottom: 0.35rem;
}

.input,
input.form-control,
textarea.form-control,
select.form-control,
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="url"],
.form-group input[type="search"],
.form-group input[type="tel"],
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background: hsl(330 28% 10%);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.95rem;
  line-height: 1.5;
  transition: var(--transition);
  outline: none;
}

.input:focus,
input.form-control:focus,
textarea.form-control:focus,
select.form-control:focus,
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.15);
}

.input::placeholder,
.form-group input::placeholder,
.form-group textarea::placeholder {
  color: hsl(330 15% 35%);
}

textarea.form-control,
.form-group textarea {
  resize: vertical;
  min-height: 120px;
  font-family: var(--font-mono);
}

select.form-control,
.form-group select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none' stroke='%23A89090' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 5l3 3 3-3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
}

/* Checkbox and radio */
.form-check,
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"],
.checkbox-row input[type="checkbox"] {
  accent-color: var(--primary-color);
  width: auto;
}

.checkbox-row label {
  font-size: 0.9rem;
  color: var(--text-muted-color);
  margin-bottom: 0;
}

/* Inline form */
.inline-form {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.inline-form input,
.inline-form select {
  padding: 0.25rem 0.625rem;
  background: hsl(330 28% 10%);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.8125rem;
}

/* Filters bar */
.filters {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  align-items: center;
}

.filters input,
.filters select {
  padding: 0.375rem 0.75rem;
  background: hsl(330 28% 10%);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.8125rem;
}

/* --------------------------------------------------------------------------
   11. Table Component
   -------------------------------------------------------------------------- */

/* Table wrapper for horizontal scroll on overflow */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: -0.25rem;
  padding: 0.25rem;
}

.table,
.card table,
.card-static table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.card table th,
.card-static table th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted-color);
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
}

.table td,
.card table td,
.card-static table td {
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text);
  white-space: nowrap;
}

/* Compact table variant for data-dense views */
.table-compact th {
  padding: 0.375rem 0.5rem;
  font-size: 0.65rem;
}

.table-compact td {
  padding: 0.375rem 0.5rem;
  font-size: 0.75rem;
}

.table tbody tr,
.card table tbody tr,
.card-static table tbody tr {
  transition: background 0.1s ease;
}

.table tbody tr:nth-child(even),
.card table tbody tr:nth-child(even),
.card-static table tbody tr:nth-child(even) {
  background: hsl(var(--muted) / 0.3);
}

.table tbody tr:hover,
.card table tbody tr:hover,
.card-static table tbody tr:hover {
  background: hsl(var(--muted) / 0.6);
}

/* Text size utilities for table cells */
.text-sm { font-size: 0.75rem; }
.text-xs { font-size: 0.65rem; }

/* --------------------------------------------------------------------------
   12. Sidebar Component
   -------------------------------------------------------------------------- */

.sidebar {
  width: var(--sidebar-width);
  background: hsl(var(--sidebar-background));
  color: hsl(var(--sidebar-foreground));
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 100;
  border-right: 1px solid hsl(var(--sidebar-border));
  display: flex;
  flex-direction: column;
}

.sidebar .brand {
  padding: 1rem 1.25rem;
  font-size: 1.125rem;
  font-weight: 700;
  color: hsl(var(--sidebar-foreground));
  border-bottom: 1px solid hsl(var(--sidebar-border));
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sidebar .brand .brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  background: var(--gradient-ruby);
  border-radius: 0.5rem;
  font-weight: 800;
  font-size: 0.875rem;
  color: white;
}

.sidebar .brand .brand-logo {
  width: 2rem;
  height: 2rem;
  border-radius: 0.5rem;
}

.sidebar nav {
  padding: 0.75rem 0;
  flex: 1;
}

.sidebar .nav-section {
  padding: 0.75rem 1.25rem 0.25rem;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: hsl(var(--muted-foreground) / 0.6);
  margin-top: 0.5rem;
  font-weight: 600;
}

.sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1.25rem;
  color: hsl(var(--sidebar-foreground) / 0.7);
  text-decoration: none;
  font-size: 0.875rem;
  transition: background 0.15s ease, color 0.15s ease;
  border-left: 3px solid transparent;
}

.sidebar .nav-link:hover {
  background: hsl(var(--sidebar-accent));
  color: hsl(var(--sidebar-foreground));
  text-decoration: none;
  opacity: 1;
}

.sidebar .nav-link.active {
  background: hsl(var(--ruby) / 0.12);
  color: hsl(var(--sidebar-foreground));
  border-left-color: hsl(var(--sidebar-primary));
}

.sidebar .sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid hsl(var(--sidebar-border));
  margin-top: auto;
}

.sidebar .user-block {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid hsl(var(--sidebar-border));
}

.sidebar .user-block .user-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: hsl(var(--sidebar-foreground));
}

.sidebar .user-block .user-email {
  font-size: 0.75rem;
  color: var(--text-muted-color);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar .credit-balance {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid hsl(var(--sidebar-border));
}

.sidebar .credit-balance .credit-label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted-color);
}

.sidebar .credit-balance .credit-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary-color);
  font-family: var(--font-mono);
}

/* --------------------------------------------------------------------------
   13. Nav / Header Component
   -------------------------------------------------------------------------- */

.nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.nav a {
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  color: var(--text-muted-color);
  text-decoration: none;
  transition: var(--transition);
}

.nav a:hover {
  background: hsl(var(--muted));
  color: var(--text);
  text-decoration: none;
  opacity: 1;
}

.nav a.active {
  background: hsl(var(--ruby) / 0.12);
  color: var(--primary-color);
}

/* Top header bar */
.header-bar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-bar .breadcrumb {
  font-size: 0.875rem;
  color: var(--text-muted-color);
}

.header-bar .breadcrumb a {
  color: var(--text-muted-color);
}

.header-bar .breadcrumb a:hover {
  color: var(--text);
  opacity: 1;
}

.header-bar .breadcrumb .separator {
  margin: 0 0.375rem;
  color: hsl(var(--muted-foreground) / 0.4);
}

.header-bar .user-info {
  font-size: 0.8125rem;
  color: var(--text-muted-color);
}

.header-bar .user-info strong {
  color: var(--text);
}

/* --------------------------------------------------------------------------
   14. Flash Messages (Toast-style with colored left border)
   -------------------------------------------------------------------------- */

.flash-messages {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 420px;
  width: 100%;
  pointer-events: none;
}

.flash {
  padding: 0.875rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  line-height: 1.5;
  border-left: 4px solid;
  background: var(--bg-card);
  color: var(--text);
  box-shadow: var(--shadow);
  pointer-events: auto;
  animation: flash-slide-in 0.3s ease-out;
}

@keyframes flash-slide-in {
  from { opacity: 0; transform: translateX(1rem); }
  to { opacity: 1; transform: translateX(0); }
}

.flash-success,
.flash-notice {
  border-left-color: hsl(var(--success));
}

.flash-warning {
  border-left-color: hsl(var(--warning));
}

.flash-error,
.flash-alert {
  border-left-color: hsl(var(--destructive));
}

/* Inline flash variant (positioned within content) */
.flash-inline {
  position: static;
  max-width: none;
  pointer-events: auto;
}

.flash-inline .flash {
  box-shadow: none;
  animation: none;
}

/* --------------------------------------------------------------------------
   15. Pagination (Pagy)
   -------------------------------------------------------------------------- */

.pagy {
  display: flex;
  gap: 0.25rem;
  margin-top: 1rem;
  justify-content: center;
}

.pagy a, .pagy em {
  padding: 0.375rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 0.375rem;
  font-size: 0.8125rem;
  text-decoration: none;
  color: var(--text);
  transition: background 0.15s ease;
}

.pagy a:hover {
  background: hsl(var(--muted));
  text-decoration: none;
  opacity: 1;
}

.pagy em, .pagy a.current {
  background: var(--gradient-ruby);
  color: white;
  border-color: var(--primary-color);
  font-style: normal;
}

.pagy .disabled {
  color: hsl(var(--muted-foreground) / 0.4);
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   16. Detail Views
   -------------------------------------------------------------------------- */

.detail-row {
  display: flex;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-color);
}

.detail-label {
  width: 180px;
  font-size: 0.8125rem;
  color: var(--text-muted-color);
  font-weight: 500;
  flex-shrink: 0;
}

.detail-value {
  font-size: 0.875rem;
  color: var(--text);
}

/* --------------------------------------------------------------------------
   17. Terminal / Code Blocks
   -------------------------------------------------------------------------- */

.terminal {
  background: hsl(330 30% 7%);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.75rem;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.8;
  overflow-x: auto;
  position: relative;
}

.terminal-dots {
  display: flex;
  gap: 6px;
  margin-bottom: 1rem;
}

.terminal-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.terminal-dots span:nth-child(1) { background: hsl(0 70% 55%); }
.terminal-dots span:nth-child(2) { background: hsl(40 70% 55%); }
.terminal-dots span:nth-child(3) { background: hsl(130 50% 45%); }

.terminal .prompt { color: hsl(330 15% 40%); }
.terminal .accent { color: var(--primary-color); }
.terminal .output { color: var(--text-muted-color); }
.terminal .cmd { color: var(--cream-color); }

.prompt-box {
  background: hsl(var(--terminal-bg));
  color: var(--cream-color);
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--terminal-border));
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 600px;
  overflow-y: auto;
}

.prompt-box--formatted {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  white-space: normal;
}

.prompt-box--formatted p {
  margin: 0 0 0.75rem 0;
}

.prompt-box--formatted p:last-child {
  margin-bottom: 0;
}

.prompt-message {
  border-left: 3px solid hsl(var(--muted));
  margin-bottom: 1rem;
  padding-left: 0;
}

.prompt-message--user {
  border-left-color: hsl(var(--info));
}

.prompt-message--assistant {
  border-left-color: hsl(var(--success));
}

.prompt-message-role {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: hsl(var(--muted-foreground));
  padding: 0.5rem 1rem 0;
}

/* --------------------------------------------------------------------------
   18. Message Bubbles (Conversations)
   -------------------------------------------------------------------------- */

.message-bubble {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  line-height: 1.7;
  white-space: pre-wrap;
}

.message-user {
  background: hsl(var(--ruby) / 0.1);
  border: 1px solid hsl(var(--ruby) / 0.2);
  margin-right: 3rem;
}

.message-assistant {
  background: hsl(var(--muted));
  border: 1px solid var(--border-color);
  margin-left: 3rem;
}

.message-meta {
  font-size: 0.6875rem;
  color: var(--text-muted-color);
  margin-bottom: 0.25rem;
}

/* --------------------------------------------------------------------------
   19. Page Title
   -------------------------------------------------------------------------- */

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  color: var(--text);
}

.page-subtitle {
  font-size: 0.9375rem;
  color: var(--text-muted-color);
  margin-top: -0.75rem;
  margin-bottom: 1.5rem;
}

/* --------------------------------------------------------------------------
   20. Auth Layout
   -------------------------------------------------------------------------- */

.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  box-shadow: var(--shadow-lg);
}

.auth-header {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-header .logo {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.auth-header h1 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  margin-top: 0.75rem;
}

.auth-header p {
  color: var(--text-muted-color);
  font-size: 0.92rem;
  margin-top: 0.35rem;
}

.auth-footer {
  text-align: center;
  margin-top: 1.75rem;
  font-size: 0.9rem;
  color: var(--text-muted-color);
}

.auth-footer a {
  color: var(--primary-color);
  font-weight: 500;
}

.auth-footer a:hover {
  text-decoration: underline;
}

.auth-links {
  text-align: center;
  margin-top: 1rem;
}

.auth-links a {
  color: var(--text-muted-color);
  font-size: 0.85rem;
}

.auth-links a:hover {
  color: var(--text);
}

/* --------------------------------------------------------------------------
   21. Pricing Cards (Landing page)
   -------------------------------------------------------------------------- */

.pricing-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 2.25rem;
  text-align: center;
  transition: var(--transition);
}

.pricing-card.featured {
  border-color: var(--primary-color);
  box-shadow: 0 0 30px hsl(var(--ruby) / 0.12);
  position: relative;
}

.pricing-card .price {
  font-size: 2.5rem;
  font-weight: 800;
  margin: 1rem 0 0.25rem;
}

.pricing-card .period {
  color: var(--text-muted-color);
  font-size: 0.9rem;
}

.pricing-card ul {
  list-style: none;
  text-align: left;
  margin: 1.5rem 0;
}

.pricing-card ul li {
  padding: 0.4rem 0;
  color: var(--text-muted-color);
  font-size: 0.92rem;
}

.pricing-card ul li::before {
  content: "\2713";
  color: var(--primary-color);
  font-weight: 700;
  margin-right: 0.6rem;
}

/* --------------------------------------------------------------------------
   22. Step Numbers (Landing page)
   -------------------------------------------------------------------------- */

.step-number {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--gradient-ruby);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   23. Chart Container
   -------------------------------------------------------------------------- */

.chart-container {
  margin-bottom: 1.5rem;
}

/* --------------------------------------------------------------------------
   24. API Key Display
   -------------------------------------------------------------------------- */

.api-key {
  font-family: var(--font-mono);
  background: hsl(var(--terminal-bg));
  border: 1px solid hsl(var(--terminal-border));
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  color: var(--cream-color);
  user-select: all;
  word-break: break-all;
}

/* --------------------------------------------------------------------------
   25. Empty State
   -------------------------------------------------------------------------- */

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted-color);
}

.empty-state h3 {
  color: var(--text-muted-color);
  margin-bottom: 0.5rem;
}

.empty-state p {
  margin-bottom: 1.5rem;
}

/* --------------------------------------------------------------------------
   26. Misc Utilities
   -------------------------------------------------------------------------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden { display: none; }
.overflow-auto { overflow: auto; }
.rounded { border-radius: var(--radius); }
.border { border: 1px solid var(--border-color); }
.border-b { border-bottom: 1px solid var(--border-color); }
.border-t { border-top: 1px solid var(--border-color); }
.w-full { width: 100%; }

/* --------------------------------------------------------------------------
   27. Responsive Breakpoints
   -------------------------------------------------------------------------- */

@media (max-width: 1024px) {
  .three-col, .grid-3 {
    grid-template-columns: 1fr 1fr;
  }

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

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    width: 260px;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 0 0 40px hsl(var(--background) / 0.8);
  }

  .sidebar-layout .main-area {
    margin-left: 0;
  }

  .two-col, .three-col, .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }

  .grid-stats {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }

  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.375rem; }
  h3 { font-size: 1.125rem; }

  .container, .container-narrow, .container-wide {
    padding: 0 1rem;
  }

  .flash-messages {
    right: 0.5rem;
    left: 0.5rem;
    max-width: none;
  }

  .header-bar {
    padding: 0 1rem;
  }

  .auth-card {
    padding: 1.75rem;
  }
}

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

  .stat-card .stat-value {
    font-size: 1.5rem;
  }

  .detail-row {
    flex-direction: column;
  }

  .detail-label {
    width: auto;
    margin-bottom: 0.125rem;
  }
}
