/**
 * RuCoin — light corporate blue design system.
 * Clear typography, comfortable spacing, subtle borders · smooth motion.
 */

:root {
  /* —— Base palette (cool slate) —— */
  --color-base-0: #ffffff;
  --color-base-50: #f8fafc;
  --color-base-100: #f1f5f9;
  --color-base-200: #e2e8f0;
  --color-base-300: #cbd5e1;
  --color-base-400: #94a3b8;
  --color-base-500: #64748b;
  --color-base-600: #475569;
  --color-base-700: #334155;
  --color-base-800: #1e293b;
  --color-base-900: #0f172a;
  --color-base-950: #020617;

  /* —— Primary: Corporate blue —— */
  --color-primary-50: #eff6ff;
  --color-primary-100: #dbeafe;
  --color-primary-200: #bfdbfe;
  --color-primary-300: #93c5fd;
  --color-primary-400: #60a5fa;
  --color-primary-500: #3b82f6;
  --color-primary-600: #2563eb;
  --color-primary-700: #1d4ed8;
  --color-primary-800: #1e40af;
  --color-primary-900: #1e3a8a;
  --color-primary-950: #172554;

  --color-primary-rgb: 37, 99, 235;

  /* —— Accent —— */
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --color-accent-dark: #1e40af;
  --text-accent: #1d4ed8;

  /* —— Semantic —— */
  --color-success: #059669;
  --color-warning: #d97706;
  --color-error: #dc2626;
  --color-info: #2563eb;

  /* —— Charts —— */
  --chart-1: #2563eb;
  --chart-2: #7c3aed;
  --chart-3: #0d9488;
  --chart-4: #dc2626;
  --chart-5: #64748b;
  --chart-6: #f59e0b;

  /* —— Surfaces —— */
  --bg-page: #f1f5f9;
  --bg-card: #ffffff;
  --bg-input: #ffffff;
  --bg-header: #ffffff;
  /* Sidebar: solid surface distinct from main scroll area (base-50) */
  --bg-sidebar: var(--color-base-0);
  --bg-table-header: #f8fafc;
  --bg-table-row-hover: #f8fafc;

  /* —— Borders (used sparingly — prefer shadows) —— */
  --border-width: 1px;
  --border-default: #e2e8f0;
  --border-subtle: #f1f5f9;

  /* —— Shadows —— */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 2px 8px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 8px 20px rgba(15, 23, 42, 0.08);
  --shadow-xl: 0 16px 32px rgba(15, 23, 42, 0.1);
  --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-card-hover: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-plate: 0 2px 8px rgba(15, 23, 42, 0.06);
  --shadow-control: inset 0 0 0 1px var(--border-default);
  --shadow-control-hover: inset 0 0 0 1px var(--color-base-300);
  --shadow-control-focus: inset 0 0 0 1px var(--color-primary-400), 0 0 0 3px rgba(37, 99, 235, 0.1);
  --shadow-button: 0 1px 2px rgba(37, 99, 235, 0.15);
  --shadow-button-hover: 0 2px 6px rgba(37, 99, 235, 0.2);
  --shadow-focus-error: 0 0 0 3px rgba(220, 38, 38, 0.12);
  --focus-ring: #3b82f6;

  /* —— Typography —— */
  --font-sans: "Inter", "Manrope", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-display: "Inter", "Sora", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-size-base: 0.9375rem;
  --text-size-sm: 0.875rem;
  --text-size-xs: 0.8125rem;
  --text-size-lg: 1rem;
  --text-display: clamp(2rem, 1.6rem + 2vw, 3.5rem);
  --text-page-title: clamp(1.25rem, 1rem + 0.8vw, 1.75rem);
  --text-section: clamp(1rem, 0.9rem + 0.4vw, 1.25rem);
  --text-label: 0.8125rem;
  --text-caption: 0.75rem;
  --text-body-lg: 1rem;
  --leading-base: 1.5;
  --leading-snug: 1.2;
  --leading-tight: 1.3;
  --leading-relaxed: 1.65;
  --prose-max-width: 66ch;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;
  --table-cell-py: 0.875rem;
  --table-cell-px: 1rem;

  /* —— Uniform control height —— */
  --control-h: 40px;
  --control-h-sm: 38px;
  --control-h-lg: 44px;

  /* —— Layout —— */
  --space-touch: 32px;
  --sidebar-width: 15rem;
  --sidebar-collapsed: 3.25rem;
  --header-height: 3.5rem;
  --content-max: 1600px;
  --page-gutter: 1.25rem;
  /* Admin shell: breathable vertical rhythm */
  --admin-stack-gap: 1.75rem;
  --admin-inner-gap: 1rem;
  --admin-main-pad-x: 1.25rem;
  --admin-main-pad-y: 1.25rem;

  /* —— Radius —— */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 12px;
  --radius-2xl: 14px;
  --radius-button: 8px;
  --radius-input: 8px;
  --radius-card: 10px;

  /* —— Motion —— */
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-emphasis: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --transition-base: 120ms var(--ease-out);
  --transition-fast: 80ms var(--ease-out);
  --transition-smooth: 150ms var(--ease-out);
  --transition-colors: color var(--transition-base), background-color var(--transition-base), border-color var(--transition-base), box-shadow var(--transition-base), transform var(--transition-fast);

  /* —— Scrollbar —— */
  --scrollbar-thumb: #cbd5e1;
  --scrollbar-thumb-hover: #94a3b8;
  --scrollbar-thumb-subtle: #e2e8f0;
}

/* ——— Global resets, layout, typography ——— */

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  min-width: 320px;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-page);
  color: var(--text-secondary);
  font-size: var(--text-size-base);
  line-height: var(--leading-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  display: flex;
  flex-direction: column;
}

button, input, select, textarea { font: inherit; }
code, kbd, samp, pre, .font-mono { font-family: var(--font-mono) !important; }

a:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
button:focus-visible:not(.btn) { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

[x-cloak] { display: none !important; }
.dropdown-floating { z-index: 3000 !important; }
.pace .pace-progress { background: var(--color-primary-600) !important; }

@media (min-width: 640px) {
  :root {
    --admin-main-pad-x: 1.5rem;
    --admin-main-pad-y: 1.5rem;
  }
}
@media (min-width: 1024px) {
  :root {
    --admin-main-pad-x: 1.75rem;
    --admin-main-pad-y: 1.75rem;
  }
}

/* Main content inset (admin + portal shell) */
.shell-main-inset {
  padding: var(--admin-main-pad-y) var(--admin-main-pad-x);
  box-sizing: border-box;
}

/* Vertical stack between page sections */
.admin-stack {
  display: flex;
  flex-direction: column;
  gap: var(--admin-stack-gap);
}

/* Admin main column: full width of shell (no content cap) */
.ide-main {
  max-width: none;
  width: 100%;
  min-width: 0;
}

/* Clear separation between major blocks (dashboard / list pages) */
.admin-stack.admin-stack-separated {
  gap: 0;
}
.admin-stack-separated > * {
  width: 100%;
}
.admin-stack-separated > *:not(:last-child) {
  padding-bottom: var(--admin-stack-gap);
  margin-bottom: var(--admin-stack-gap);
  border-bottom: 1px solid var(--border-default);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  color: var(--text-primary);
}

.text-white h1, .text-white h2, .text-white h3,
.text-white h4, .text-white h5, .text-white h6 { color: inherit; }

h1 { font-size: var(--text-display); font-weight: 700; line-height: var(--leading-snug); letter-spacing: -0.03em; }
h2 { font-size: var(--text-page-title); font-weight: 600; line-height: var(--leading-snug); letter-spacing: -0.02em; }
h3 { font-size: var(--text-section); font-weight: 600; line-height: var(--leading-tight); letter-spacing: -0.015em; }
h4 { font-size: var(--text-body-lg); font-weight: var(--weight-semibold); line-height: var(--leading-snug); }
h5 { font-size: var(--text-size-base); font-weight: var(--weight-medium); line-height: var(--leading-base); }
h6 { font-size: var(--text-label); font-weight: var(--weight-medium); line-height: var(--leading-snug); }

a[href]:hover:not(.btn):not(.shell-nav-link):not(.qa-link):not(.stat-card):not(.ux-back-link):not(.card):not(.nav-link-mobile) { color: var(--text-accent); }

.skip-link {
  position: absolute;
  top: -100%;
  left: 0.5rem;
  z-index: 9999;
  padding: 0.5rem 0.75rem;
  background: var(--color-primary-600);
  color: white;
  border-radius: var(--radius-sm);
  font-weight: var(--weight-medium);
  font-size: var(--text-size-sm);
}
.skip-link:focus { top: 0.5rem; }

/* Scrollbar */
html, .overflow-x-auto, .overflow-y-auto, main#main-content {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }

.scrollbar-auto-hide { overflow: auto; }
.scrollbar-auto-hide::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb-subtle); }
.scrollbar-auto-hide:hover::-webkit-scrollbar-thumb,
.scrollbar-auto-hide:focus-within::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb-hover); }

/* ——— Cards & surfaces (shadow-first) ——— */

.glass-card, .shadow-enterprise, .card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-card);
  transition: border-color var(--transition-fast);
}
.glass-card:hover, .shadow-enterprise:hover, .card:hover {
  border-color: var(--color-base-300);
}
a.card:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

.card-surface {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-card);
  transition: border-color var(--transition-fast);
}
.card-surface:hover {
  border-color: var(--color-base-300);
}

.card-surface-muted {
  background: var(--color-base-50);
  border: 1px solid var(--border-subtle);
}

.card-icon-watermark {
  position: absolute;
  right: 0.5rem;
  bottom: 0.5rem;
  font-size: 4rem;
  line-height: 1;
  opacity: 0.06;
  color: var(--color-primary-400);
  pointer-events: none;
}
.card-icon-watermark-lg {
  right: 0.5rem;
  bottom: 0.4rem;
  font-size: 6rem;
  opacity: 0.05;
}

.glass {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
}

.kpi {
  border: 1px solid var(--border-default);
  background: var(--bg-card);
  border-radius: var(--radius-md);
}

.premium-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.premium-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  font-size: var(--text-size-xs);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  background: var(--color-base-50);
  border: 1px solid var(--border-default);
}

.logo-icon-bg {
  background: #2563eb;
  border: none;
}
.logo-icon-bg .logo-r {
  color: #fff;
  flex-shrink: 0;
}

/* ——— Shell: header, sidebar, nav ——— */

.shell-topbar {
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-default);
  box-shadow: none;
  color: var(--text-primary);
}

.shell-sidebar {
  background-color: var(--bg-sidebar);
  background-image: none;
  border-right: 1px solid var(--border-default);
  box-shadow: none;
  color: var(--text-secondary);
  /* Fill full column height (flex + fixed admin shell) */
  align-self: stretch;
  min-height: 100%;
}

.shell-sidebar.ide-sidebar {
  min-height: 100%;
}

@media (min-width: 1024px) {
  .shell-sidebar.ide-sidebar {
    height: 100%;
    max-height: 100%;
  }
}

.shell-sidebar__brand {
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-sidebar);
}

.shell-sidebar__nav {
  flex: 1 1 auto;
  min-height: 0;
  background: var(--bg-sidebar);
}

.shell-sidebar__footer {
  border-top: 1px solid var(--border-default);
  background: var(--bg-sidebar);
}

.shell-sidebar-group:not(:last-child) {
  margin-bottom: 1.25rem;
}

.shell-sidebar-group:last-child {
  margin-bottom: 0;
}

.shell-icon-button {
  min-width: 36px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  background: transparent;
  border: none;
  transition: all var(--transition-base);
}
.shell-icon-button:hover {
  color: var(--text-primary);
  background: var(--color-base-100);
  box-shadow: var(--shadow-xs);
}
.shell-icon-button:active {
  background: var(--color-base-200);
  transform: scale(0.96);
}
.shell-icon-button:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.shell-nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 40px;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  border: none;
  font-size: var(--text-size-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  text-decoration: none;
  transition: all var(--transition-base);
}
.shell-nav-link:hover {
  color: var(--text-primary);
  background: var(--color-base-100);
}
.shell-nav-link--active {
  color: var(--color-primary-700);
  background: var(--color-primary-50);
  font-weight: var(--weight-semibold);
}
.shell-nav-link:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 1px; }

.shell-group-label {
  font-size: var(--text-caption);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  line-height: var(--leading-tight);
}

.shell-user-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  width: 100%;
  max-width: 100%;
  padding: 0.5rem 0.625rem;
  border-radius: var(--radius-md);
  background: var(--color-base-50);
  border: 1px solid var(--border-default);
  transition: all var(--transition-base);
  box-sizing: border-box;
}
.shell-user-pill:hover {
  background: var(--color-base-100);
  border-color: var(--color-base-300);
}

.shell-topbar .material-icons,
.shell-sidebar .material-icons {
  color: inherit;
}

.shell-footer {
  background: var(--color-base-50);
  border-top: 1px solid var(--border-default);
  color: var(--text-muted);
}
.shell-footer a { color: var(--text-secondary); }
.shell-footer a:hover { color: var(--color-primary-600); }

/* ——— Buttons (uniform height, shadow-based) ——— */

@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes message-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.btn {
  height: var(--control-h);
  min-height: var(--control-h);
  padding: 0 1.125rem;
  font-size: var(--text-size-sm);
  font-weight: var(--weight-semibold);
  letter-spacing: 0;
  border-radius: var(--radius-button);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  cursor: pointer;
  font-family: var(--font-sans);
  border: none;
  text-decoration: none;
  white-space: nowrap;
  transition: all var(--transition-base);
}
.btn:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}
.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-sm {
  height: var(--control-h-sm);
  min-height: var(--control-h-sm);
  padding: 0 0.875rem;
  font-size: var(--text-size-sm);
  gap: 0.375rem;
}

.btn-lg {
  height: var(--control-h-lg);
  min-height: var(--control-h-lg);
  padding: 0 1.5rem;
  font-size: var(--text-size-base);
  border-radius: var(--radius-lg);
}

.btn-primary {
  background: var(--color-primary-600);
  color: #fff !important;
  box-shadow: var(--shadow-button);
}
.btn-primary:hover,
a.btn-primary:hover {
  background: var(--color-primary-700) !important;
  box-shadow: var(--shadow-button-hover);
  color: #fff !important;
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-secondary);
  box-shadow: var(--shadow-control);
}
.btn-secondary:hover,
a.btn-secondary:hover {
  background: var(--color-base-100) !important;
  box-shadow: var(--shadow-control-hover);
  color: var(--text-primary) !important;
}

.btn-outline {
  background: transparent;
  color: var(--color-primary-600);
  box-shadow: inset 0 0 0 1.5px var(--color-primary-200);
}
.btn-outline:hover,
a.btn-outline:hover {
  background: var(--color-primary-50) !important;
  box-shadow: inset 0 0 0 1.5px var(--color-primary-400);
  color: var(--color-primary-700) !important;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  box-shadow: none;
}
.btn-ghost:hover,
a.btn-ghost:hover {
  background: var(--color-base-100) !important;
  color: var(--text-primary) !important;
}

.btn.loading {
  position: relative;
  pointer-events: none;
  opacity: 0.8;
}
.btn.loading > *:not(.btn-spinner) { opacity: 0; }
.btn-spinner { display: none; }
.btn.loading .btn-spinner {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-right-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.btn-primary.loading .btn-spinner { border-top-color: #fff; border-right-color: #fff; }
.btn-secondary.loading .btn-spinner { border-top-color: var(--text-secondary); border-right-color: var(--text-secondary); }
.btn.loading-simple {
  position: relative;
  color: transparent !important;
  pointer-events: none;
  opacity: 0.8;
}
.btn.loading-simple::after {
  content: "";
  position: absolute;
  width: 1rem;
  height: 1rem;
  top: 50%;
  left: 50%;
  margin-left: -0.5rem;
  margin-top: -0.5rem;
  border: 2px solid transparent;
  border-top-color: #fff;
  border-right-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.btn-secondary.loading-simple::after { border-top-color: var(--text-secondary); border-right-color: var(--text-secondary); }

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

a.btn:hover {
  text-decoration: none;
}
a.bg-primary-600:hover,
a.bg-primary-700:hover,
.btn-header-cta:hover,
.btn-header-cta-mobile:hover {
  color: #fff !important;
}

/* ——— Form controls (uniform height, shadow-based, generous inner padding) ——— */

.form-input,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="date"],
input[type="datetime-local"],
input[type="time"],
select,
textarea {
  height: var(--control-h);
  min-height: var(--control-h);
  padding: 0.5rem 0.875rem;
  font-size: var(--text-size-base);
  border: none;
  border-radius: var(--radius-input);
  box-shadow: var(--shadow-control);
  transition: all var(--transition-base);
  background: var(--bg-input);
  color: var(--text-primary);
  width: 100%;
  font-family: var(--font-sans);
  box-sizing: border-box;
  line-height: 1.4;
}
input.w-auto, select.w-auto, textarea.w-auto,
.list-filters-form input, .list-filters-form select {
  width: auto;
}

/* ——— Admin list filter bars (users, etc.): keep selects readable; chevron must not overlap label ——— */
.list-filters-form {
  display: block;
  width: 100%;
  max-width: 100%;
}
.list-filters-form > .inline-flex,
.list-filters-form > .flex {
  width: 100%;
  max-width: 100%;
}
.list-filters-form select {
  min-width: 11.75rem;
  max-width: min(100%, 20rem);
  padding-right: 2.875rem !important;
  padding-left: 0.75rem;
  background-position: right 0.65rem center;
  background-size: 1.125rem 1.125rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M5 8l5 5 5-5' stroke='%23334155' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.list-filters-form select[name="tenant"] {
  min-width: 13.5rem;
  max-width: min(100%, 24rem);
}
.list-filters-form select[name="sort"] {
  min-width: 12.5rem;
}
.list-filters-form input[type="text"],
.list-filters-form input[type="search"] {
  min-width: 10rem;
  max-width: 18rem;
}
.list-filters-form input[type="date"] {
  min-width: 10.75rem;
}

.form-input:hover,
input:hover:not(:disabled):not(:focus):not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):not([type="color"]),
select:hover:not(:disabled):not(:focus),
textarea:hover:not(:disabled):not(:focus) {
  box-shadow: var(--shadow-control-hover);
}

.form-input:focus,
input:focus:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
select:focus,
textarea:focus {
  outline: none;
  box-shadow: var(--shadow-control-focus);
}

select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 2.625rem;
  color: var(--text-primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M5 8l5 5 5-5' stroke='%23334155' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.65rem center;
  background-size: 1.125rem 1.125rem;
}
select::-ms-expand { display: none; }
select option { color: var(--text-primary); background: var(--color-base-0); padding: 0.5rem; }

textarea {
  height: auto;
  min-height: 6rem;
  resize: vertical;
  line-height: var(--leading-base);
}

input[type="file"]:focus {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.form-input::placeholder,
input::placeholder,
textarea::placeholder {
  color: var(--color-base-400);
}

input:disabled,
select:disabled,
textarea:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--color-base-50);
}

.form-input.is-error,
input.is-error,
select.is-error,
textarea.is-error {
  box-shadow: 0 0 0 2px #ef4444, var(--shadow-control);
}
.form-input.is-error:focus,
input.is-error:focus,
select.is-error:focus,
textarea.is-error:focus {
  box-shadow: var(--shadow-focus-error), var(--shadow-control);
}

.field-error {
  font-size: var(--text-caption);
  color: var(--color-error);
  margin-top: 0.375rem;
  font-weight: var(--weight-medium);
}

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

.form-label {
  display: block;
  font-size: var(--text-size-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  margin-bottom: 0.375rem;
  line-height: var(--leading-tight);
}
.form-label .required { color: var(--color-error); }

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

.form-group .form-input,
.form-group input,
.form-group select,
.form-group textarea {
  margin-bottom: 0;
}

input[type="checkbox"],
input[type="radio"] {
  min-height: auto;
  height: auto;
  width: 1rem;
  height: 1rem;
  padding: 0;
  border-radius: 4px;
  accent-color: var(--color-primary-600);
  cursor: pointer;
  vertical-align: middle;
  box-shadow: none;
}
input[type="radio"] { border-radius: 50%; }

.form-input.mfa-input {
  font-size: 1.5rem;
  letter-spacing: 0.35rem;
  text-align: center;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ——— Tables ——— */

.table {
  width: 100%;
  font-size: var(--text-size-sm);
  border-collapse: separate;
  border-spacing: 0;
  font-family: var(--font-sans);
}

.table th {
  padding: 0.75rem var(--table-cell-px);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  background: var(--bg-table-header);
  text-align: left;
  font-size: var(--text-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 2px solid var(--color-base-100);
}

.table td {
  padding: var(--table-cell-py) var(--table-cell-px);
  color: var(--text-secondary);
  vertical-align: middle;
  border-bottom: 1px solid var(--color-base-100);
}

.table th.cell-nowrap,
.table td.cell-nowrap {
  white-space: nowrap;
}

.table tbody tr {
  transition: background var(--transition-fast);
}
.table tbody tr:hover { background: var(--bg-table-row-hover); }
.table tbody tr:focus-within { background: var(--color-primary-50); }

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}
.empty-state .material-icons {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  opacity: 0.5;
  color: var(--color-base-500);
}
.empty-state h3 { font-size: var(--text-section); font-weight: var(--weight-semibold); color: var(--text-primary); margin: 0 0 0.5rem; }
.empty-state p { max-width: 36rem; margin-left: auto; margin-right: auto; color: var(--text-secondary); }

/* ——— Alerts ——— */

.alert-success, .alert-error, .alert-danger, .alert-warning, .alert-info, .alert-default {
  border-radius: var(--radius-lg);
  padding: 0.875rem 1rem;
  font-size: var(--text-size-sm);
  font-weight: var(--weight-medium);
  line-height: var(--leading-relaxed);
  border-left: 3px solid transparent;
}

.alert-success { background: #f0fdf4; color: #14532d; border-left-color: var(--color-success); }
.alert-error, .alert-danger { background: #fef2f2; color: #7f1d1d; border-left-color: var(--color-error); }
.alert-warning { background: #fffbeb; color: #78350f; border-left-color: var(--color-warning); }
.alert-info { background: var(--color-primary-50); color: var(--color-primary-900); border-left-color: var(--color-primary-500); }
.alert-default { background: var(--color-base-50); color: var(--text-secondary); border-left-color: var(--color-base-400); }

/* ——— Badges ——— */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: var(--text-caption);
  font-weight: var(--weight-medium);
  border: 1px solid var(--border-default);
  background: var(--color-base-50);
}

.spinner {
  border: 2px solid var(--color-primary-100);
  border-top-color: var(--color-primary-600);
  border-right-color: var(--color-primary-500);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.htmx-indicator { opacity: 0; transition: opacity 200ms var(--ease-out); }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

.message-icon-pulse .material-icons { animation: message-pulse 1.5s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .message-icon-pulse .material-icons { animation: none; } }

/* ——— Section elements ——— */

.section-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  font-family: var(--font-sans);
  font-size: var(--text-caption);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-primary-700);
  background: var(--color-primary-50);
  border: 1px solid var(--color-primary-100);
}
.section-kicker::before {
  content: "";
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 9999px;
  background: var(--color-primary-500);
}

.hero-stat-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}
.hero-stat {
  padding: 0.75rem;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-default);
}
.hero-stat strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: var(--weight-bold);
  color: var(--text-primary);
}
.hero-stat span {
  display: block;
  margin-top: 0.25rem;
  font-size: var(--text-caption);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

@media (max-width: 767px) {
  .hero-stat-strip { grid-template-columns: 1fr; }
}

.auth-showcase-panel {
  background: linear-gradient(155deg, #1e3a8a 0%, #2563eb 50%, #3b82f6 100%);
  color: rgba(255, 255, 255, 0.95);
}

.auth-form-surface {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius-lg);
}

.material-icons {
  font-family: "Material Icons";
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ——— App splash ——— */
.app-splash-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(241, 245, 249, 0.95);
}
.app-splash-card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-lg);
}

/* ——— Mobile nav ——— */
.nav-link-mobile {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem;
  border-radius: var(--radius-md);
  font-size: var(--text-size-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  background: transparent;
  border: none;
  transition: all var(--transition-base);
}
.nav-link-mobile:hover {
  background: var(--color-primary-50);
  color: var(--color-primary-700);
}
.nav-link-mobile:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 1px; }

.landing-icon-accent {
  color: var(--color-primary-600);
  font-size: 1.125rem;
}

.btn-header-cta-mobile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  width: 100%;
  height: var(--control-h);
  padding: 0 1rem;
  border-radius: var(--radius-button);
  font-size: var(--text-size-sm);
  font-weight: var(--weight-semibold);
  color: white;
  background: var(--color-primary-600);
  border: none;
  box-shadow: var(--shadow-button);
  transition: all var(--transition-base);
}
.btn-header-cta-mobile:hover {
  background: var(--color-primary-700);
  box-shadow: var(--shadow-button-hover);
}

.dev-code {
  background: #0f172a;
  border: 1px solid var(--color-base-700);
  color: #e2e8f0;
  font-family: var(--font-mono);
  border-radius: var(--radius-md);
}
.dev-code code {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
}

.dev-chip {
  background: var(--color-primary-50);
  color: var(--color-primary-700);
  border: 1px solid var(--color-primary-100);
}

/* ——— Footer ——— */
.landing-footer {
  background: #0f172a;
  color: rgba(255, 255, 255, 0.9);
}
.landing-footer .landing-footer__lead {
  font-size: 0.9375rem;
  line-height: var(--leading-relaxed);
  color: rgba(226, 232, 240, 0.8);
  max-width: 42ch;
}
.landing-footer .landing-footer__col-title {
  font-size: var(--text-caption);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-primary-300);
  margin-bottom: 1rem;
}
.landing-footer nav a,
.landing-footer nav button {
  font-size: var(--text-size-sm);
  line-height: var(--leading-base);
  color: rgba(226, 232, 240, 0.7);
  text-decoration: none;
  transition: color var(--transition-base);
}
.landing-footer nav a:hover,
.landing-footer nav button:hover { color: #fff; }
.landing-footer nav a:focus-visible,
.landing-footer nav button:focus-visible {
  outline: 2px solid var(--color-primary-300);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
.landing-footer .landing-footer__trust-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  border-radius: 9999px;
  font-size: var(--text-size-sm);
  font-weight: var(--weight-medium);
  color: rgba(255, 255, 255, 0.9);
  background: rgba(37, 99, 235, 0.15);
  border: none;
  box-shadow: 0 0 0 1px rgba(96, 165, 250, 0.2);
}
.landing-footer .landing-footer__trust-badge .material-icons {
  font-size: 0.9375rem;
  color: var(--color-primary-300);
}
.landing-footer .landing-footer__meta {
  font-size: var(--text-size-sm);
  color: rgba(226, 232, 240, 0.45);
}

.testimonials-strip { scrollbar-width: none; -ms-overflow-style: none; }
.testimonials-strip::-webkit-scrollbar { display: none; }

.nav-scrolled {
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}

/* ——— Analytics dashboard components ——— */

.analytics-grid {
  display: grid;
  gap: 1.25rem;
}
.analytics-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.analytics-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.analytics-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1023px) {
  .analytics-grid-3, .analytics-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 639px) {
  .analytics-grid-2, .analytics-grid-3, .analytics-grid-4 { grid-template-columns: 1fr; }
}

.date-range-tabs {
  display: inline-flex;
  align-items: center;
  gap: 0;
  border-radius: var(--radius-md);
  background: var(--color-base-100);
  padding: 3px;
  border: 1px solid var(--border-default);
}
.date-range-tab {
  padding: 0.375rem 0.875rem;
  font-size: var(--text-size-sm);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  border-radius: calc(var(--radius-md) - 2px);
  cursor: pointer;
  border: none;
  background: transparent;
  transition: all var(--transition-base);
  white-space: nowrap;
}
.date-range-tab:hover {
  color: var(--text-primary);
}
.date-range-tab.active,
.date-range-tab[aria-selected="true"] {
  background: var(--bg-card);
  color: var(--color-primary-700);
  font-weight: var(--weight-semibold);
  box-shadow: var(--shadow-sm);
}

.trend-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: var(--text-caption);
  font-weight: var(--weight-semibold);
  line-height: 1;
}
.trend-indicator .material-icons {
  font-size: 0.875rem;
}
.trend-up { color: var(--color-success); }
.trend-down { color: var(--color-error); }
.trend-flat { color: var(--text-muted); }

.stat-card-enhanced {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-card);
  padding: 1.125rem 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
  transition: all var(--transition-fast);
  text-decoration: none;
  color: inherit;
  position: relative;
  overflow: hidden;
}
.stat-card-enhanced:hover {
  border-color: var(--color-base-300);
  box-shadow: var(--shadow-card-hover);
}
.stat-card-enhanced .stat-icon {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-card-enhanced .stat-icon .material-icons { font-size: 1.375rem; }
.stat-card-enhanced .stat-text {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
  flex: 1;
}
.stat-card-enhanced .stat-label {
  font-size: var(--text-size-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  line-height: 1.2;
  margin: 0;
  letter-spacing: 0.02em;
}
.stat-card-enhanced .stat-value {
  font-size: 1.5rem;
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  margin: 0;
}
.stat-card-enhanced .stat-trend {
  margin-top: 0.25rem;
}

.chart-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-card);
  overflow: hidden;
}
.chart-panel-header {
  padding: 0.875rem 1.125rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-table-header);
}
.chart-panel-title {
  font-size: var(--text-size-base);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.chart-panel-title .material-icons { font-size: 1.25rem; }
.chart-panel-body {
  padding: 1.25rem;
}

.chart-container {
  position: relative;
  width: 100%;
}
.chart-container canvas {
  width: 100% !important;
}

.revenue-card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-card);
  padding: 1.25rem;
}
.revenue-card-value {
  font-size: 1.75rem;
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.revenue-card-label {
  font-size: var(--text-size-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
}

/* ——— UX helpers ——— */
.ux-back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: var(--text-size-sm);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius-sm);
  padding: 0.375rem 0.5rem;
  margin: -0.375rem -0.5rem;
  transition: all var(--transition-base);
}
.ux-back-link:hover { color: var(--text-primary); background: var(--color-base-100); }
.ux-back-link:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* ——— IDE theme overrides ——— */
body.ide-theme .ide-sidebar { background: var(--bg-sidebar) !important; }
body.ide-theme .ide-header { background: var(--bg-header) !important; }
body.ide-theme .ide-main code, body.ide-theme .ide-main .font-mono { font-family: var(--font-mono) !important; color: var(--color-primary-600); }
body.ide-theme .ide-main pre { background: var(--color-base-50) !important; border: none; box-shadow: var(--shadow-sm); border-radius: var(--radius-md); color: var(--text-secondary); }

@media (prefers-reduced-motion: reduce) {
  .card-surface:hover,
  .btn-header-cta-mobile:hover,
  .btn-primary:hover,
  .btn-secondary:hover,
  .btn-outline:hover,
  .card:hover,
  .shadow-enterprise:hover {
    transform: none;
  }
  .btn.loading .btn-spinner,
  .btn.loading-simple::after {
    animation: none;
  }
}

/* Splash/loading overlay */
.app-splash-overlay {
  position: fixed;
  inset: 0;
  z-index: 220;
  background: rgba(15, 23, 42, 0.3);
  backdrop-filter: blur(6px);
}
.app-splash-card {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.9), rgba(30, 64, 175, 0.9));
  border: 1px solid rgba(191, 219, 254, 0.4);
  box-shadow: 0 16px 40px -20px rgba(2, 6, 23, 0.7);
}
.spinner {
  display: inline-block;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: rgba(255, 255, 255, 1);
  border-radius: 9999px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
