/* ============================================================
   BIG VIBES CONSULTING — DESIGN SYSTEM
   Extracted from design language v1.0
   ============================================================ */

/* ---------- CSS VARIABLES / TOKENS ---------- */
:root {
  /* Brand Gradient */
  --gradient-start: #FFCC00;
  --gradient-end: #FF7A00;
  --brand-gradient: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));

  /* Fonts */
  --font-heading: "Book Antiqua", "Palatino Linotype", Palatino, serif;
  --font-body: "Avenir", "Nunito Sans", "Segoe UI", sans-serif;

  /* Sizing Scale (rem) */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 2rem;
  --text-4xl: 2.5rem;
  --text-5xl: 3.5rem;

  /* Spacing Scale */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;
  --space-4xl: 6rem;

  /* Border */
  --border-width: 1px;
  --border-gradient: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
  --radius: 0px; /* ALWAYS 0 — sharp corners */

  /* Shadow */
  --shadow-rest: 3px 3px 4px rgba(60, 60, 60, 0.5);
  --shadow-hover: none;
  --transition-shadow: box-shadow 0.3s ease, transform 0.3s ease;
}

/* ---------- DARK THEME ---------- */
[data-theme="dark"] {
  --bg-primary: #2a2a2a;
  --bg-secondary: #313131;
  --bg-tertiary: #393939;
  --bg-elevated: #414141;
  --text-primary: #f0f0f0;
  --text-secondary: #b0b0b0;
  --text-muted: #808080;
  --border-subtle: #444444;
  --input-bg: #333333;
  --shadow-rest: 3px 3px 4px rgba(0, 0, 0, 0.6);
  --shadow-hover: none;
  --success: #16A34A;
  --error: #DC2626;
  --warning: #E8850A;
  --info: #2563EB;
}

/* ---------- LIGHT THEME ---------- */
[data-theme="light"] {
  --bg-primary: #FAF6F0;
  --bg-secondary: #F3EDE4;
  --bg-tertiary: #EBE4D8;
  --bg-elevated: #FFFFFF;
  --text-primary: #1a1a1a;
  --text-secondary: #555555;
  --text-muted: #888888;
  --border-subtle: #ddd5c8;
  --input-bg: #FFFFFF;
  --shadow-rest: 3px 3px 4px rgba(120, 110, 95, 0.35);
  --shadow-hover: none;
  --success: #16A34A;
  --error: #DC2626;
  --warning: #E8850A;
  --info: #2563EB;
}

/* ---------- RESET & BASE ---------- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  border-radius: 0px !important;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-primary);
  transition: background 0.4s ease, color 0.4s ease;
}

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

/* ---------- GRADIENT BORDER UTILITY ---------- */
.gb {
  border: var(--border-width) solid;
  border-image: var(--border-gradient) 1;
  transition: var(--transition-shadow);
}

.gb:hover {
  box-shadow: var(--shadow-hover);
}

.gb-card {
  position: relative;
  background: var(--bg-secondary);
  border: var(--border-width) solid;
  border-image: var(--border-gradient) 1;
  transition: var(--transition-shadow);
}

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

/* ---------- LAYOUT ---------- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-xl);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-xl);
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--space-xl);
}

.grid-4 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: var(--space-lg);
}

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

.flex-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
}

/* ---------- SECTION DIVIDERS ---------- */
section {
  margin-bottom: var(--space-4xl);
}

.section-label {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
}

.section-title {
  font-family: var(--font-heading);
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-lg);
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.section-desc {
  color: var(--text-secondary);
  max-width: 600px;
  margin-bottom: var(--space-2xl);
}

.divider {
  border: none;
  height: 1px;
  background: var(--border-subtle);
  margin: var(--space-3xl) 0;
}

/* ============================================================
   HEADER / MASTHEAD
   ============================================================ */
.masthead {
  padding: var(--space-4xl) var(--space-xl);
  text-align: center;
  position: relative;
  border-bottom: 2px solid;
  border-image: var(--brand-gradient) 1;
}

.masthead-label {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-lg);
}

.masthead-title {
  font-family: var(--font-heading);
  font-size: var(--text-5xl);
  font-weight: 700;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: var(--space-md);
}

.masthead-sub {
  font-family: var(--font-body);
  font-size: var(--text-lg);
  color: var(--text-secondary);
  max-width: 500px;
  margin: 0 auto var(--space-xl);
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
.type-heading-1 {
  font-family: var(--font-heading);
  font-size: var(--text-5xl);
  font-weight: 700;
  line-height: 1.1;
  color: var(--text-primary);
}

.type-heading-2 {
  font-family: var(--font-heading);
  font-size: var(--text-4xl);
  font-weight: 700;
  line-height: 1.15;
  color: var(--text-primary);
}

.type-heading-3 {
  font-family: var(--font-heading);
  font-size: var(--text-3xl);
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
}

.type-heading-4 {
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
}

.type-heading-5 {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
}

.type-body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--text-primary);
}

.type-body-sm {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--text-secondary);
}

.type-caption {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  line-height: 1.4;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.type-overline {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
}

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

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-xl);
  background: var(--brand-gradient);
  border: none;
  color: #1a1a1a;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: var(--transition-shadow);
  box-shadow: var(--shadow-rest);
  text-decoration: none;
}

.btn-primary:hover {
  box-shadow: var(--shadow-hover);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-xl);
  background: var(--bg-elevated);
  border: 1px solid;
  border-image: var(--brand-gradient) 1;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-shadow);
  box-shadow: var(--shadow-rest);
  text-decoration: none;
}

.btn-secondary:hover {
  box-shadow: var(--shadow-hover);
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  background: none;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  position: relative;
  transition: color 0.3s ease;
  text-decoration: none;
}

.btn-ghost::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: var(--space-lg);
  right: var(--space-lg);
  height: 2px;
  background: var(--brand-gradient);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.4s ease;
}

.btn-ghost:hover::after {
  transform: scaleX(1);
}

.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-xl);
  background: var(--error);
  border: none;
  color: #ffffff;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition-shadow);
  box-shadow: var(--shadow-rest);
  text-decoration: none;
}

.btn-danger:hover {
  box-shadow: var(--shadow-hover);
}

.btn-sm {
  padding: var(--space-xs) var(--space-md);
  font-size: var(--text-xs);
}

.btn-lg {
  padding: var(--space-md) var(--space-2xl);
  font-size: var(--text-lg);
}

.btn-disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
  box-shadow: none !important;
}

/* ============================================================
   FORM ELEMENTS
   ============================================================ */
.form-group {
  margin-bottom: var(--space-lg);
}

.form-label {
  display: block;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

.form-input {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--input-bg);
  border: 1px solid;
  border-image: var(--border-gradient) 1;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--text-base);
  outline: none;
  transition: var(--transition-shadow);
  box-shadow: var(--shadow-rest);
}

.form-input:hover,
.form-input:focus {
  box-shadow: var(--shadow-hover);
}

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

textarea.form-input {
  min-height: 100px;
  resize: vertical;
}

.form-select {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--input-bg);
  border: 1px solid;
  border-image: var(--border-gradient) 1;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--text-base);
  cursor: pointer;
  outline: none;
  transition: var(--transition-shadow);
  box-shadow: var(--shadow-rest);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.form-select:hover,
.form-select:focus {
  box-shadow: var(--shadow-hover);
}

.form-checkbox {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--text-primary);
}

.form-checkbox input[type="checkbox"] {
  appearance: none;
  width: 18px;
  height: 18px;
  border: 1px solid;
  border-image: var(--brand-gradient) 1;
  background: var(--input-bg);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
}

.form-checkbox input[type="checkbox"]:checked {
  background: var(--brand-gradient);
}

.form-checkbox input[type="checkbox"]:checked::after {
  content: '\2713';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #1a1a1a;
  font-size: 12px;
  font-weight: 900;
}

.form-radio {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--text-primary);
}

.form-radio input[type="radio"] {
  appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid var(--text-muted);
  background: var(--input-bg);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
}

.form-radio input[type="radio"]:checked {
  border-color: var(--gradient-start);
}

.form-radio input[type="radio"]:checked::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  right: 3px;
  bottom: 3px;
  background: var(--brand-gradient);
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--bg-secondary);
  border: 1px solid;
  border-image: var(--brand-gradient) 1;
  padding: var(--space-xl);
  transition: var(--transition-shadow);
  box-shadow: var(--shadow-rest);
}

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

.card-title {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.card-body {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.6;
}

.card-subtle {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  padding: var(--space-xl);
  transition: var(--transition-shadow);
  box-shadow: var(--shadow-rest);
}

.card-subtle:hover {
  border-image: var(--brand-gradient) 1;
  box-shadow: var(--shadow-hover);
}

.card-elevated {
  background: var(--bg-elevated);
  border: 1px solid;
  border-image: var(--brand-gradient) 1;
  padding: var(--space-xl);
  box-shadow: var(--shadow-rest);
  transition: var(--transition-shadow);
}

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

/* ============================================================
   BADGES / TAGS
   ============================================================ */
.badge {
  display: inline-block;
  padding: var(--space-xs) var(--space-md);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.badge-gradient {
  background: var(--brand-gradient);
  color: #1a1a1a;
}

.badge-outline {
  background: transparent;
  border: 1px solid;
  border-image: var(--brand-gradient) 1;
  color: var(--text-primary);
}

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

.badge-error {
  background: var(--error);
  color: #fff;
}

.badge-warning {
  background: var(--warning);
  color: #1a1a1a;
}

.badge-info {
  background: var(--info);
  color: #fff;
}

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  padding: var(--space-md) var(--space-lg);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  border-left: 3px solid;
  margin-bottom: var(--space-md);
}

.alert-success {
  background: color-mix(in srgb, var(--success) 10%, var(--bg-secondary));
  border-left-color: var(--success);
  color: var(--text-primary);
}

.alert-error {
  background: color-mix(in srgb, var(--error) 10%, var(--bg-secondary));
  border-left-color: var(--error);
  color: var(--text-primary);
}

.alert-warning {
  background: color-mix(in srgb, var(--warning) 10%, var(--bg-secondary));
  border-left-color: var(--warning);
  color: var(--text-primary);
}

.alert-info {
  background: color-mix(in srgb, var(--info) 10%, var(--bg-secondary));
  border-left-color: var(--info);
  color: var(--text-primary);
}

.alert strong {
  display: block;
  margin-bottom: 2px;
}

/* ============================================================
   TABLE
   ============================================================ */
.table-wrapper {
  border: 1px solid;
  border-image: var(--brand-gradient) 1;
  overflow: hidden;
  box-shadow: var(--shadow-rest);
  transition: var(--transition-shadow);
}

.table-wrapper:hover {
  box-shadow: var(--shadow-hover);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-body);
  font-size: var(--text-sm);
}

thead {
  background: var(--bg-tertiary);
}

th {
  text-align: left;
  padding: var(--space-sm) var(--space-md);
  font-weight: 700;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

td {
  padding: var(--space-sm) var(--space-md);
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: var(--bg-tertiary);
}

/* ============================================================
   NAVIGATION
   ============================================================ */
.nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-xl);
  background: var(--bg-secondary);
  border-bottom: 1px solid;
  border-image: var(--brand-gradient) 1;
}

/* Hamburger toggle for the top nav — hidden on desktop, shown < 768px */
.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: var(--space-xs);
}

.nav-brand {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  font-weight: 700;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: var(--space-lg);
  list-style: none;
}

.nav-link {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-decoration: none;
  position: relative;
  padding-bottom: 4px;
  transition: color 0.3s ease;
}

.nav-link:hover {
  color: var(--text-primary);
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--brand-gradient);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.nav-link:hover::after {
  transform: scaleX(1);
}

.nav-link.active {
  color: var(--text-primary);
  font-weight: 600;
}

.nav-link.active::after {
  transform: scaleX(1);
}

/* ============================================================
   TABS
   ============================================================ */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border-subtle);
  gap: 0;
}

.tab {
  padding: var(--space-sm) var(--space-lg);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: none;
  position: relative;
  transition: color 0.3s ease;
}

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

.tab.active {
  color: var(--text-primary);
  font-weight: 600;
}

.tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--brand-gradient);
}

/* ============================================================
   PROGRESS / METER
   ============================================================ */
.progress-track {
  width: 100%;
  height: 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--brand-gradient);
  transition: width 1s ease;
}

/* ============================================================
   TOOLTIP (CSS only)
   ============================================================ */
.tooltip-wrap {
  position: relative;
  display: inline-block;
}

.tooltip-wrap .tooltip {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-elevated);
  border: 1px solid;
  border-image: var(--brand-gradient) 1;
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--text-primary);
  white-space: nowrap;
  transition: opacity 0.3s ease;
  box-shadow: var(--shadow-rest);
}

.tooltip-wrap:hover .tooltip {
  visibility: visible;
  opacity: 1;
}

/* ============================================================
   CODE BLOCK
   ============================================================ */
.code-block {
  background: var(--bg-tertiary);
  border: 1px solid;
  border-image: var(--brand-gradient) 1;
  padding: var(--space-lg);
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  font-size: var(--text-sm);
  color: var(--text-primary);
  overflow-x: auto;
  line-height: 1.7;
  white-space: pre;
}

code {
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  font-size: 0.9em;
  background: var(--bg-tertiary);
  padding: 2px 6px;
  color: var(--gradient-start);
}

/* ============================================================
   AVATAR
   ============================================================ */
.avatar {
  width: 48px;
  height: 48px;
  background: var(--brand-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: var(--text-lg);
  color: #1a1a1a;
  flex-shrink: 0;
}

.avatar-sm { width: 32px; height: 32px; font-size: var(--text-sm); }
.avatar-lg { width: 64px; height: 64px; font-size: var(--text-2xl); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }
  .grid-4 {
    grid-template-columns: 1fr 1fr;
  }
  .masthead-title {
    font-size: var(--text-3xl);
  }
  .page-title {
    font-size: var(--text-2xl);
  }
  .stat-value {
    font-size: var(--text-2xl);
  }
  .container {
    padding: var(--space-lg);
  }

  /* Top nav (portal/public) collapses to a tap-to-open menu */
  .nav-bar {
    position: relative;
    flex-wrap: wrap;
  }
  .nav-toggle {
    display: inline-flex;
  }
  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: var(--space-sm);
    background: var(--bg-secondary);
    border-bottom: 1px solid;
    border-image: var(--brand-gradient) 1;
    padding: var(--space-md) var(--space-xl);
    z-index: 200;
  }
  .nav-links.open {
    display: flex;
  }

  /* Wide tables scroll horizontally instead of squashing */
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  table {
    min-width: 560px;
  }
}

/* ============================================================
   APP-SPECIFIC STYLES
   ============================================================ */

/* --- Admin Sidebar Layout --- */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* No page-level horizontal scroll on admin pages, at any width */
body:has(.admin-layout) {
  overflow-x: hidden;
  max-width: 100%;
}

.sidebar {
  width: 240px;
  background: var(--bg-secondary);
  border-right: 1px solid;
  border-image: var(--border-gradient) 1;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-brand {
  padding: var(--space-xl);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.sidebar-brand a {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  font-weight: 700;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-decoration: none;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-md) 0;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-xl);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 500;
  transition: color 0.3s ease, background 0.3s ease;
  border-left: 3px solid transparent;
}

.sidebar-link:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.sidebar-link.active {
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border-left-color: var(--gradient-start);
  font-weight: 600;
}

.sidebar-link i {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: var(--space-md) var(--space-xl);
  border-top: 1px solid var(--border-subtle);
}

.admin-main {
  flex: 1;
  min-width: 0; /* allow shrinking below wide content (tables) on mobile */
  margin-left: 240px;
  padding: var(--space-2xl);
  min-height: 100vh;
  container-type: inline-size; /* admin grids respond to available width, not viewport */
  transition: margin-left 0.25s ease;
}

/* Wide tables always scroll inside their card, never the page */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-wrapper table {
  min-width: 560px;
}

/* --- Mobile top bar + drawer overlay (shown < 768px) --- */
.admin-topbar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  align-items: center;
  gap: var(--space-md);
  padding: 0 var(--space-lg);
  background: var(--bg-secondary);
  border-bottom: 1px solid;
  border-image: var(--brand-gradient) 1;
  z-index: 260;
}

.admin-topbar .menu-btn {
  display: inline-flex;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: var(--space-xs);
}

.admin-topbar .topbar-brand {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  font-weight: 700;
  text-decoration: none;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.admin-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 250;
}

/* --- Collapsible sidebar (tablet/desktop) --- */
.sidebar-collapse-btn,
.sidebar-open-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: var(--space-xs);
  line-height: 0;
}

.sidebar-collapse-btn:hover {
  color: var(--text-primary);
}

.sidebar-open-btn {
  position: fixed;
  top: var(--space-md);
  left: var(--space-md);
  z-index: 240;
  background: var(--bg-secondary);
  border: 1px solid;
  border-image: var(--brand-gradient) 1;
  color: var(--text-primary);
  padding: var(--space-xs) var(--space-sm);
  box-shadow: var(--shadow-rest);
}

.sidebar-open-btn:hover {
  box-shadow: var(--shadow-hover);
}

@media (min-width: 769px) {
  .sidebar {
    transition: transform 0.25s ease;
  }
  .sidebar-collapse-btn {
    display: inline-flex;
  }
  html.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
  }
  html.sidebar-collapsed .admin-main {
    margin-left: 0;
    padding-left: calc(var(--space-2xl) + 40px); /* clear the reopen button */
  }
  html.sidebar-collapsed .sidebar-open-btn {
    display: inline-flex;
  }
}

/* --- Page Header --- */
.page-header {
  margin-bottom: var(--space-2xl);
}

.page-title {
  font-family: var(--font-heading);
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

/* --- Stat Cards --- */
.stat-card {
  background: var(--bg-secondary);
  border: 1px solid;
  border-image: var(--brand-gradient) 1;
  padding: var(--space-lg);
  box-shadow: var(--shadow-rest);
  transition: var(--transition-shadow);
}

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

.stat-label {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-xs);
}

.stat-value {
  font-family: var(--font-heading);
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--text-primary);
}

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

/* --- Login Page --- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
}

.login-card {
  background: var(--bg-secondary);
  border: 1px solid;
  border-image: var(--brand-gradient) 1;
  padding: var(--space-2xl);
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-rest);
}

.login-brand {
  font-family: var(--font-heading);
  font-size: var(--text-3xl);
  font-weight: 700;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-align: center;
  margin-bottom: var(--space-xs);
}

.login-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-sm);
  margin-bottom: var(--space-2xl);
}

/* --- Stripe Element Containers --- */
.stripe-element {
  padding: var(--space-sm) var(--space-md);
  background: var(--input-bg);
  border: 1px solid;
  border-image: var(--border-gradient) 1;
  transition: var(--transition-shadow);
  box-shadow: var(--shadow-rest);
  min-height: 42px;
}

.stripe-element:hover,
.stripe-element.StripeElement--focus {
  box-shadow: var(--shadow-hover);
}

.stripe-element.StripeElement--invalid {
  border-image: none;
  border-color: var(--error);
}

/* --- Payment Page --- */
.pay-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
}

.pay-card {
  background: var(--bg-elevated);
  border: 1px solid;
  border-image: var(--brand-gradient) 1;
  padding: var(--space-2xl);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-rest);
}

.pay-brand {
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  font-weight: 700;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-align: center;
  margin-bottom: var(--space-lg);
}

.pay-summary {
  text-align: center;
  padding: var(--space-lg);
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  margin-bottom: var(--space-xl);
}

.pay-amount {
  font-family: var(--font-heading);
  font-size: var(--text-4xl);
  font-weight: 700;
  color: var(--text-primary);
}

.pay-interval {
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.pay-description {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  margin-top: var(--space-xs);
}

.pay-section-title {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-xs);
  border-bottom: 1px solid var(--border-subtle);
}

/* --- Trust Bar --- */
.trust-bar {
  display: flex;
  justify-content: center;
  gap: var(--space-lg);
  padding: var(--space-md) 0;
  margin-top: var(--space-lg);
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.trust-item {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

/* --- Success Overlay --- */
.success-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.success-overlay.active {
  opacity: 1;
  visibility: visible;
}

.success-card {
  background: var(--bg-elevated);
  border: 1px solid;
  border-image: var(--brand-gradient) 1;
  padding: var(--space-2xl);
  text-align: center;
  max-width: 400px;
  width: 90%;
  box-shadow: var(--shadow-rest);
}

.success-icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
}

/* --- Copy Button --- */
.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  cursor: pointer;
  transition: all 0.3s ease;
}

.copy-btn:hover {
  color: var(--text-primary);
  border-image: var(--brand-gradient) 1;
}

.copy-btn.copied {
  color: var(--success);
  border-color: var(--success);
}

/* --- Loading Spinner --- */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-subtle);
  border-top-color: var(--gradient-start);
  animation: spin 0.6s linear infinite;
}

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

.btn-loading {
  position: relative;
  color: transparent !important;
}

.btn-loading::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  top: 50%;
  left: 50%;
  margin: -9px 0 0 -9px;
  border: 2px solid rgba(26, 26, 26, 0.3);
  border-top-color: #1a1a1a;
  animation: spin 0.6s linear infinite;
}

/* --- Error Message Display --- */
.form-error {
  color: var(--error);
  font-size: var(--text-xs);
  margin-top: var(--space-xs);
}

.input-error {
  border-image: none !important;
  border-color: var(--error) !important;
}

/* --- Status Indicators --- */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: var(--space-xs);
}

.status-dot.active { background: var(--success); }
.status-dot.pending { background: var(--brand-gradient); }
.status-dot.expired { background: var(--error); }
.status-dot.cancelled { background: var(--text-muted); }
.status-dot.past_due { background: var(--warning); }

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: var(--space-3xl) var(--space-xl);
  color: var(--text-muted);
}

.empty-state p {
  margin-bottom: var(--space-lg);
}

/* --- Responsive Admin: sidebar becomes a slide-in drawer --- */
@media (max-width: 768px) {
  html, body {
    overflow-x: hidden;
    max-width: 100%;
  }
  .admin-topbar {
    display: flex;
  }
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 3px 0 14px rgba(0, 0, 0, 0.28);
    z-index: 300;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-brand a,
  .sidebar-link span {
    display: inline;
  }
  .admin-main {
    margin-left: 0;
    padding: var(--space-lg);
    padding-top: calc(56px + var(--space-lg));
  }
  .admin-overlay.open {
    display: block;
  }
  .pay-card,
  .login-card {
    padding: var(--space-xl);
  }
  .trust-bar {
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
  }
}

/* --- Utility --- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-error { color: var(--error); }
.text-warning { color: var(--warning); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ============================================================
   ADMIN CONTAINER QUERIES
   Grids inside .admin-main respond to the actual content width
   (sidebar open or collapsed), not the viewport. Portal/public
   pages have no query container, so these never apply there.
   ============================================================ */
@container (max-width: 1100px) {
  .grid-4 {
    grid-template-columns: 1fr 1fr;
  }
}

@container (max-width: 900px) {
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
  .page-title {
    font-size: var(--text-2xl);
  }
  .stat-value {
    font-size: var(--text-2xl);
  }
}

@container (max-width: 520px) {
  .grid-4 {
    grid-template-columns: 1fr;
  }
}
