@import url('css/tokens.css');

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

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--cr-font-sans);
  background: var(--cr-color-bg);
  color: var(--cr-color-text);
  -webkit-font-smoothing: antialiased;
}

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

a:hover {
  color: var(--cr-color-primary-hover);
}

h1, h2, h3 {
  letter-spacing: -0.02em;
  font-weight: 700;
}

label {
  display: block;
  font-size: var(--cr-text-sm);
  font-weight: 500;
  color: var(--cr-color-text-muted);
  margin-bottom: var(--cr-space-1);
}

/* ?? Auth / marketing shell ?? */
.cr-auth-shell {
  min-height: 100vh;
  min-height: 100dvh;
  height: 100%;
  overflow-y: auto;
  display: grid;
  place-items: center;
  padding: 0;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(37, 99, 235, 0.16), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(13, 148, 136, 0.12), transparent 50%),
    linear-gradient(180deg, #f8fafc 0%, #e8eef6 100%);
}

.cr-auth-shell:has(.cr-auth-split),
.cr-auth-shell:has(.cr-landing-hero) {
  place-items: stretch;
  padding: 0;
  background: #0b1220;
}

.cr-auth-card {
  width: min(100%, 26rem);
  background: var(--cr-color-surface);
  border: 1px solid var(--cr-color-border);
  border-radius: var(--cr-radius-lg);
  box-shadow: var(--cr-shadow-lg);
  padding: var(--cr-space-6);
  animation: cr-fade-up 320ms ease both;
}

.cr-auth-card-elevated {
  width: min(100%, 24rem);
  box-shadow: var(--cr-shadow-lg);
}

.cr-auth-card .cr-field {
  grid-template-rows: auto var(--cr-control-height);
}

.cr-auth-card .cr-field:not(:has(> .cr-hint))::after {
  display: none;
}

.cr-auth-brand {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 var(--cr-space-1);
  color: var(--cr-color-text);
}

.cr-auth-welcome {
  margin: 0 0 var(--cr-space-1);
  font-size: var(--cr-text-xl);
}

.cr-auth-sub {
  margin: 0 0 var(--cr-space-5);
  color: var(--cr-color-text-muted);
  font-size: var(--cr-text-sm);
}

.cr-auth-foot {
  margin: var(--cr-space-4) 0 0;
  font-size: var(--cr-text-xs);
  color: var(--cr-color-text-muted);
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.cr-auth-split {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
}

.cr-auth-panel {
  padding: clamp(1.5rem, 4vw, 3.5rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--cr-space-4);
  background:
    radial-gradient(700px 420px at 20% 10%, rgba(37, 99, 235, 0.45), transparent 55%),
    radial-gradient(600px 380px at 90% 90%, rgba(13, 148, 136, 0.28), transparent 50%),
    #0b1220;
  color: #e2e8f0;
}

.cr-auth-panel-brand {
  display: flex;
  align-items: center;
  gap: var(--cr-space-3);
}

.cr-auth-panel-title {
  margin: 0;
  font-size: clamp(1.75rem, 3.2vw, 2.5rem);
  color: #fff;
  line-height: 1.15;
  max-width: 18ch;
}

.cr-auth-panel-text {
  margin: 0;
  color: #94a3b8;
  font-size: var(--cr-text-md);
  line-height: 1.55;
  max-width: 36rem;
}

.cr-auth-features {
  list-style: none;
  margin: var(--cr-space-2) 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--cr-space-3);
}

.cr-auth-features li {
  display: flex;
  align-items: center;
  gap: var(--cr-space-3);
  color: #cbd5e1;
  font-size: var(--cr-text-sm);
  font-weight: 500;
}

.cr-auth-feature-icon {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--cr-radius-md);
  display: grid;
  place-items: center;
  background: rgba(37, 99, 235, 0.25);
  color: #93c5fd;
  flex-shrink: 0;
}

.cr-auth-form-wrap {
  display: grid;
  place-items: center;
  padding: var(--cr-space-5);
  background:
    radial-gradient(800px 400px at 80% 0%, rgba(37, 99, 235, 0.08), transparent 55%),
    #f1f5f9;
}

.cr-landing {
  width: min(100%, 40rem);
  text-align: left;
  animation: cr-fade-up 320ms ease both;
  padding: var(--cr-space-5);
}

.cr-landing h1 {
  font-size: clamp(2rem, 4vw, 2.75rem);
  margin: 0 0 var(--cr-space-3);
}

.cr-landing p {
  color: var(--cr-color-text-muted);
  font-size: var(--cr-text-lg);
  line-height: 1.55;
  margin: 0 0 var(--cr-space-5);
}

.cr-landing-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--cr-space-3);
}

.cr-landing-hero {
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  display: grid;
  place-items: center;
  padding: var(--cr-space-6);
  background:
    radial-gradient(900px 500px at 15% 20%, rgba(37, 99, 235, 0.4), transparent 55%),
    radial-gradient(700px 420px at 90% 80%, rgba(13, 148, 136, 0.28), transparent 50%),
    #0b1220;
  color: #e2e8f0;
}

.cr-landing-hero-inner {
  width: min(100%, 40rem);
  animation: cr-fade-up 320ms ease both;
}

.cr-landing-brand {
  display: flex;
  align-items: center;
  gap: var(--cr-space-3);
  margin-bottom: var(--cr-space-5);
}

.cr-landing-hero h1 {
  margin: 0 0 var(--cr-space-3);
  color: #fff;
  font-size: clamp(2rem, 4vw, 2.85rem);
  line-height: 1.15;
}

.cr-landing-hero p {
  margin: 0 0 var(--cr-space-5);
  color: #94a3b8;
  font-size: var(--cr-text-lg);
  line-height: 1.55;
}

.cr-landing-pills {
  list-style: none;
  margin: var(--cr-space-6) 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--cr-space-2);
}

.cr-landing-pills li {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.12);
  border: 1px solid rgba(148, 163, 184, 0.18);
  color: #cbd5e1;
  font-size: var(--cr-text-sm);
  font-weight: 500;
}

@media (max-width: 900px) {
  .cr-auth-split {
    grid-template-columns: 1fr;
  }

  .cr-auth-panel {
    padding: var(--cr-space-5);
    min-height: auto;
  }

  .cr-auth-panel-title {
    max-width: none;
  }
}

/* ?? App shell (fixed chrome, content scrolls) ?? */
.cr-shell {
  display: grid;
  grid-template-columns: var(--cr-sidebar-width) 1fr;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--cr-color-bg);
}

.cr-sidebar {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(480px 280px at 0% 0%, rgba(37, 99, 235, 0.35), transparent 60%),
    radial-gradient(400px 240px at 100% 100%, rgba(13, 148, 136, 0.18), transparent 55%),
    #0b1220;
  color: #e2e8f0;
  padding: var(--cr-space-4) var(--cr-space-3);
  border-right: 1px solid rgba(148, 163, 184, 0.12);
}

.cr-sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--cr-space-3);
  padding: var(--cr-space-2) var(--cr-space-2) var(--cr-space-5);
  flex-shrink: 0;
}

.cr-nav-toggle,
.cr-nav-close,
.cr-nav-backdrop {
  display: none;
}

.cr-topbar-left {
  display: flex;
  align-items: center;
  gap: var(--cr-space-2);
  min-width: 0;
}

.cr-brand-mark {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: var(--cr-text-sm);
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #0ea5e9 55%, #0d9488);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
}

.cr-brand-name {
  font-weight: 700;
  font-size: var(--cr-text-lg);
  letter-spacing: -0.02em;
  color: #fff;
}

.cr-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 var(--cr-space-1);
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.35) transparent;
}

.cr-nav-section {
  margin: var(--cr-space-4) 0 var(--cr-space-2);
  padding: 0 var(--cr-space-3);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
}

.cr-nav-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-height: 2.5rem;
  padding: 0 var(--cr-space-3);
  border-radius: var(--cr-radius-md);
  color: #cbd5e1 !important;
  font-size: var(--cr-text-sm);
  font-weight: 500;
  transition: background var(--cr-ease), color var(--cr-ease), transform var(--cr-ease);
}

.cr-nav-link:hover {
  background: rgba(148, 163, 184, 0.12);
  color: #fff !important;
}

.cr-nav-link.active {
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.38), rgba(14, 165, 233, 0.18));
  color: #fff !important;
  box-shadow: inset 3px 0 0 #38bdf8;
}

.cr-sidebar-foot {
  margin-top: auto;
  padding-top: var(--cr-space-4);
  border-top: 1px solid rgba(148, 163, 184, 0.12);
  display: flex;
  flex-direction: column;
  gap: var(--cr-space-3);
  flex-shrink: 0;
}

.cr-user-chip {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 var(--cr-space-2);
  font-size: var(--cr-text-sm);
}

.cr-user-chip strong {
  color: #fff;
  font-weight: 600;
}

.cr-user-chip span {
  color: #94a3b8;
  font-size: var(--cr-text-xs);
}

.cr-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.cr-topbar {
  height: var(--cr-topbar-height);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--cr-space-3);
  padding: 0 var(--cr-space-5);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--cr-color-border);
  z-index: 20;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
}

.cr-topbar-title {
  font-weight: 600;
  color: var(--cr-color-text-muted);
  font-size: var(--cr-text-sm);
  display: flex;
  align-items: center;
  gap: var(--cr-space-2);
}

.cr-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--cr-space-5);
  background:
    radial-gradient(900px 420px at 100% -10%, rgba(37, 99, 235, 0.07), transparent 55%),
    radial-gradient(700px 360px at -5% 30%, rgba(13, 148, 136, 0.06), transparent 50%),
    var(--cr-color-bg);
  animation: cr-fade-up 280ms ease both;
  scrollbar-width: thin;
  scrollbar-color: var(--cr-color-border-strong) transparent;
}

/* ?? Components ?? */
.cr-card {
  background: var(--cr-color-surface);
  border: 1px solid var(--cr-color-border);
  border-radius: var(--cr-radius-lg);
  box-shadow: var(--cr-shadow-sm);
  padding: var(--cr-space-5);
  transition: box-shadow var(--cr-ease-out), transform var(--cr-ease-out), border-color var(--cr-ease);
}

.cr-card:hover {
  box-shadow: var(--cr-shadow-md);
  border-color: var(--cr-color-border-strong);
}

.cr-card-static:hover {
  box-shadow: var(--cr-shadow-sm);
  border-color: var(--cr-color-border);
  transform: none;
}

.cr-bento {
  display: grid;
  gap: var(--cr-space-4);
  grid-template-columns: repeat(12, 1fr);
}

.cr-span-12 { grid-column: span 12; }
.cr-span-8 { grid-column: span 8; }
.cr-span-6 { grid-column: span 6; }
.cr-span-4 { grid-column: span 4; }
.cr-span-3 { grid-column: span 3; }

/* Stat cards */
.cr-stat {
  display: flex;
  align-items: flex-start;
  gap: var(--cr-space-4);
  position: relative;
  overflow: hidden;
}

.cr-stat::after {
  content: "";
  position: absolute;
  inset: auto -20% -40% auto;
  width: 8rem;
  height: 8rem;
  border-radius: 50%;
  opacity: 0.45;
  pointer-events: none;
  background: radial-gradient(circle, currentColor 0%, transparent 70%);
  color: var(--cr-stat-glow, rgba(37, 99, 235, 0.2));
}

.cr-stat-icon {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--cr-radius-md);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: var(--cr-stat-bg, var(--cr-color-primary-subtle));
  color: var(--cr-stat-fg, var(--cr-color-primary));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.cr-stat-body {
  min-width: 0;
  position: relative;
  z-index: 1;
}

.cr-stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: var(--cr-space-1) 0 0;
  line-height: 1.15;
}

.cr-stat-label {
  margin: 0;
  color: var(--cr-color-text-muted);
  font-size: var(--cr-text-sm);
  font-weight: 600;
}

.cr-stat-blue {
  --cr-stat-bg: var(--cr-color-primary-subtle);
  --cr-stat-fg: var(--cr-color-primary);
  --cr-stat-glow: rgba(37, 99, 235, 0.22);
}

.cr-stat-teal {
  --cr-stat-bg: var(--cr-color-accent-subtle);
  --cr-stat-fg: var(--cr-color-accent);
  --cr-stat-glow: rgba(13, 148, 136, 0.22);
}

.cr-stat-green {
  --cr-stat-bg: var(--cr-color-success-subtle);
  --cr-stat-fg: var(--cr-color-success);
  --cr-stat-glow: rgba(5, 150, 105, 0.22);
}

.cr-stat-amber {
  --cr-stat-bg: var(--cr-color-warning-subtle);
  --cr-stat-fg: var(--cr-color-warning);
  --cr-stat-glow: rgba(217, 119, 6, 0.2);
}

.cr-stat-cyan {
  --cr-stat-bg: var(--cr-color-info-subtle);
  --cr-stat-fg: var(--cr-color-info);
  --cr-stat-glow: rgba(8, 145, 178, 0.22);
}

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

.cr-stack {
  display: flex;
  flex-direction: column;
  gap: var(--cr-space-3);
}

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

.cr-btn {
  font-family: var(--cr-font-sans);
  font-weight: 600;
  font-size: var(--cr-text-sm);
  border-radius: var(--cr-radius-md);
  padding: 0 1rem;
  min-height: var(--cr-control-height);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: background var(--cr-ease), border-color var(--cr-ease), opacity var(--cr-ease), color var(--cr-ease), box-shadow var(--cr-ease), transform var(--cr-ease);
  text-decoration: none;
  color: inherit;
  background: var(--cr-color-surface-muted);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}

.cr-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--cr-shadow-sm);
}

.cr-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.cr-btn-primary {
  background: linear-gradient(180deg, #3b82f6 0%, var(--cr-color-primary) 100%);
  color: #fff !important;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.28);
}

.cr-btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #2563eb 0%, var(--cr-color-primary-hover) 100%);
}

.cr-btn-ghost {
  background: transparent;
  border-color: rgba(148, 163, 184, 0.25);
  color: #e2e8f0 !important;
  box-shadow: none;
}

.cr-btn-ghost:hover:not(:disabled) {
  background: rgba(148, 163, 184, 0.12);
  transform: none;
}

.cr-btn-sm {
  padding: 0 0.75rem;
  min-height: 2rem;
  font-size: var(--cr-text-xs);
}

.cr-btn-block {
  width: 100%;
}

.cr-btn:focus-visible,
.cr-input:focus-visible {
  outline: 2px solid var(--cr-color-primary);
  outline-offset: 2px;
}

.cr-input {
  font-family: var(--cr-font-sans);
  border: 1px solid var(--cr-color-border);
  border-radius: var(--cr-radius-md);
  padding: 0 0.75rem;
  height: var(--cr-control-height);
  min-height: var(--cr-control-height);
  max-height: var(--cr-control-height);
  line-height: 1.25;
  background: var(--cr-color-surface);
  width: 100%;
  color: var(--cr-color-text);
  transition: border-color var(--cr-ease), box-shadow var(--cr-ease);
}

select.cr-input {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
  padding-right: 2.25rem;
}

.cr-input:hover {
  border-color: var(--cr-color-border-strong);
}

.cr-input:focus {
  border-color: var(--cr-color-primary);
  box-shadow: var(--cr-shadow-glow);
  outline: none;
}

.cr-table-wrap {
  overflow-x: auto;
}

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

.cr-table th,
.cr-table td {
  text-align: left;
  padding: 0.85rem 0.65rem;
  border-bottom: 1px solid var(--cr-color-border);
  vertical-align: middle;
}

.cr-table th {
  color: var(--cr-color-text-muted);
  font-weight: 600;
  font-size: var(--cr-text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: linear-gradient(180deg, #f8fafc, #f1f5f9);
  position: sticky;
  top: 0;
  z-index: 1;
}

.cr-table tbody tr {
  transition: background var(--cr-ease);
}

.cr-table tbody tr:hover {
  background: rgba(37, 99, 235, 0.035);
}

/* Table / list toolbar */
.cr-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--cr-space-3);
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--cr-space-4);
  padding-bottom: var(--cr-space-3);
  border-bottom: 1px solid var(--cr-color-border);
}

.cr-toolbar-title {
  display: flex;
  align-items: center;
  gap: var(--cr-space-2);
  margin: 0;
  font-size: var(--cr-text-lg);
  font-weight: 700;
}

.cr-toolbar-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--cr-space-2);
  align-items: center;
  flex: 1;
  justify-content: flex-end;
  min-width: 0;
}

.cr-search {
  position: relative;
  min-width: min(100%, 14rem);
  flex: 1 1 12rem;
  max-width: 20rem;
}

.cr-search .cr-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--cr-color-text-muted);
  pointer-events: none;
}

.cr-search .cr-input {
  padding-left: 2.35rem;
}

.cr-filter-select {
  min-width: 9rem;
  flex: 0 1 auto;
}

.cr-filter-count {
  font-size: var(--cr-text-xs);
  font-weight: 600;
  color: var(--cr-color-text-muted);
  white-space: nowrap;
}

@keyframes cr-fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 900px) {
  html, body {
    height: 100%;
    overflow: hidden;
  }

  .cr-shell {
    grid-template-columns: 1fr;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  .cr-nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border: 1px solid var(--cr-color-border);
    border-radius: var(--cr-radius-md);
    background: var(--cr-color-surface);
    color: var(--cr-color-text);
    cursor: pointer;
    flex-shrink: 0;
  }

  .cr-nav-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    margin-left: auto;
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: var(--cr-radius-md);
    background: transparent;
    color: #e2e8f0;
    cursor: pointer;
  }

  .cr-nav-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 35;
    border: 0;
    padding: 0;
    cursor: pointer;
  }

  .cr-nav-backdrop.is-open {
    display: block;
  }

  .cr-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(18.5rem, 88vw);
    z-index: 40;
    height: 100%;
    max-height: none;
    overflow: hidden;
    transform: translateX(-105%);
    transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: none;
  }

  .cr-sidebar.is-open {
    transform: translateX(0);
    box-shadow: var(--cr-shadow-lg);
  }

  .cr-nav {
    flex-direction: column;
    flex-wrap: nowrap;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
  }

  .cr-nav-section {
    width: auto;
    margin: var(--cr-space-4) 0 var(--cr-space-2);
  }

  .cr-nav-link {
    width: 100%;
  }

  .cr-main {
    height: 100%;
    overflow: hidden;
    min-width: 0;
  }

  .cr-topbar {
    position: sticky;
    top: 0;
    padding: 0 var(--cr-space-3);
    gap: var(--cr-space-2);
  }

  .cr-topbar-title-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 42vw;
  }

  .cr-content {
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--cr-space-3);
  }

  .cr-span-8,
  .cr-span-6,
  .cr-span-4,
  .cr-span-3 {
    grid-column: span 12;
  }

  .cr-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .cr-toolbar-filters {
    justify-content: stretch;
  }

  .cr-search,
  .cr-filter-select {
    max-width: none;
    width: 100%;
    flex: 1 1 100%;
  }

  .cr-field-grid {
    grid-template-columns: 1fr;
  }

  .cr-page-head h1 {
    font-size: 1.35rem;
  }

  .cr-stat-value {
    font-size: 1.45rem;
  }

  .cr-hero-balance .cr-stat-value {
    font-size: 1.75rem;
  }

  .cr-bars {
    gap: 0.35rem;
    min-height: 10rem;
  }

  .cr-bar-track {
    height: 7rem;
    max-width: 1.75rem;
  }

  .cr-bar-label,
  .cr-bar-value {
    font-size: 0.58rem;
  }

  .cr-card {
    padding: var(--cr-space-4);
  }

  .cr-person-actions {
    gap: var(--cr-space-1);
  }

  .cr-item-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .cr-item-actions .cr-input {
    max-width: none;
    flex: 1 1 auto;
  }
}

@media (max-width: 480px) {
  .cr-topbar-cta-text {
    display: none;
  }

  .cr-content {
    padding: var(--cr-space-2);
  }

  .cr-bento {
    gap: var(--cr-space-3);
  }
}

#blazor-error-ui {
  background: #fef3c7;
  bottom: 0;
  box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.12);
  display: none;
  left: 0;
  padding: 0.75rem 1.25rem;
  position: fixed;
  width: 100%;
  z-index: 1000;
}

#blazor-error-ui .dismiss {
  cursor: pointer;
  position: absolute;
  right: 0.75rem;
  top: 0.5rem;
}

.validation-message {
  color: var(--cr-color-danger);
  font-size: var(--cr-text-sm);
}

/* ?? Forms ?? */
.cr-page-head {
  margin-bottom: var(--cr-space-4);
}

.cr-page-head h1 {
  margin: 0 0 var(--cr-space-2);
  display: flex;
  align-items: center;
  gap: var(--cr-space-2);
}

.cr-page-head p {
  margin: 0;
  color: var(--cr-color-text-muted);
  max-width: 40rem;
  line-height: 1.5;
}

.cr-field-grid {
  display: grid;
  gap: var(--cr-space-4) var(--cr-space-3);
  grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr));
  align-items: stretch;
}

.cr-field {
  display: grid;
  grid-template-rows: 2.5rem var(--cr-control-height) 2.4rem;
  gap: 0.35rem;
  min-width: 0;
  align-content: start;
}

.cr-field > label {
  margin: 0;
  display: flex;
  align-items: flex-end;
  align-self: stretch;
  gap: 0.35rem;
  color: var(--cr-color-text);
  font-weight: 600;
  font-size: var(--cr-text-sm);
  line-height: 1.25;
  min-height: 0;
  overflow: hidden;
}

.cr-field > label .cr-icon {
  flex-shrink: 0;
  margin-bottom: 1px;
}

.cr-field > .cr-input {
  align-self: stretch;
  width: 100%;
}

.cr-field > .cr-hint {
  margin: 0;
  font-size: var(--cr-text-xs);
  color: var(--cr-color-text-muted);
  font-weight: 400;
  line-height: 1.3;
  align-self: start;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Reserva la fila de hint aunque falte el texto */
.cr-field:not(:has(> .cr-hint))::after {
  content: "";
  display: block;
}

.cr-field-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: var(--cr-space-2);
  align-items: center;
  flex-wrap: wrap;
  padding-top: var(--cr-space-3);
  margin-top: var(--cr-space-1);
  border-top: 1px solid var(--cr-color-border);
}

.cr-steps {
  display: grid;
  gap: var(--cr-space-3);
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.cr-step {
  background: var(--cr-color-surface);
  border: 1px solid var(--cr-color-border);
  border-radius: var(--cr-radius-lg);
  padding: var(--cr-space-4);
  display: flex;
  flex-direction: column;
  gap: var(--cr-space-2);
  transition: border-color var(--cr-ease), box-shadow var(--cr-ease), transform var(--cr-ease-out);
  text-decoration: none;
  color: inherit;
  position: relative;
  overflow: hidden;
  min-height: 10rem;
}

.cr-step::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, #2563eb, #0ea5e9, #0d9488);
  opacity: 0;
  transition: opacity var(--cr-ease);
}

.cr-step:hover {
  border-color: #bfdbfe;
  box-shadow: var(--cr-shadow-md);
  transform: translateY(-2px);
}

.cr-step:hover::before {
  opacity: 1;
}

.cr-step-num {
  position: absolute;
  top: var(--cr-space-3);
  right: var(--cr-space-3);
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 999px;
  background: var(--cr-color-surface-muted);
  color: var(--cr-color-text-muted);
  display: grid;
  place-items: center;
  font-size: var(--cr-text-xs);
  font-weight: 700;
}

.cr-step-icon {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--cr-radius-md);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
  margin-top: 0.15rem;
}

.cr-step-icon-blue {
  background: var(--cr-color-primary-subtle);
  color: var(--cr-color-primary);
}

.cr-step-icon-cyan {
  background: var(--cr-color-info-subtle);
  color: var(--cr-color-info);
}

.cr-step-icon-amber {
  background: var(--cr-color-warning-subtle);
  color: var(--cr-color-warning);
}

.cr-step-icon-teal {
  background: var(--cr-color-accent-subtle);
  color: var(--cr-color-accent);
}

.cr-step-icon-green {
  background: var(--cr-color-success-subtle);
  color: var(--cr-color-success);
}

.cr-step strong {
  font-size: var(--cr-text-md);
  margin: 0;
  padding-right: 1.75rem;
}

.cr-step > span:not(.cr-step-num):not(.cr-step-icon) {
  color: var(--cr-color-text-muted);
  font-size: var(--cr-text-sm);
  line-height: 1.4;
  margin-top: auto;
}

@media (max-width: 1100px) {
  .cr-steps {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .cr-steps {
    grid-template-columns: 1fr;
  }
}

.cr-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: var(--cr-text-xs);
  font-weight: 600;
  background: var(--cr-color-primary-subtle);
  color: var(--cr-color-primary);
}

.cr-badge-muted {
  background: var(--cr-color-surface-muted);
  color: var(--cr-color-text-muted);
}

.cr-badge-danger {
  background: var(--cr-color-danger-subtle);
  color: var(--cr-color-danger);
}

.cr-badge-success {
  background: var(--cr-color-success-subtle);
  color: var(--cr-color-success);
}

.cr-badge-warning {
  background: var(--cr-color-warning-subtle);
  color: var(--cr-color-warning);
}

.cr-btn-danger {
  background: var(--cr-color-danger-subtle);
  color: var(--cr-color-danger) !important;
  border: 1px solid #fecaca;
  box-shadow: none;
}

.cr-btn-danger:hover:not(:disabled) {
  background: #fee2e2;
}

.cr-actions-cell {
  display: flex;
  gap: var(--cr-space-1);
  flex-wrap: wrap;
  align-items: center;
}

.cr-inline-edit {
  background: var(--cr-color-primary-subtle);
  border: 1px solid #bfdbfe;
  border-radius: var(--cr-radius-md);
  padding: var(--cr-space-3);
  margin-top: var(--cr-space-2);
}

/* Collection / list item cards */
.cr-item-card {
  display: flex;
  flex-direction: column;
  gap: var(--cr-space-3);
  margin-bottom: var(--cr-space-3);
}

.cr-item-card:last-child {
  margin-bottom: 0;
}

.cr-item-head {
  display: flex;
  align-items: flex-start;
  gap: var(--cr-space-3);
}

.cr-item-avatar {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--cr-radius-md);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--cr-color-primary-subtle), var(--cr-color-accent-subtle));
  color: var(--cr-color-primary);
  font-weight: 700;
  font-size: var(--cr-text-sm);
}

.cr-item-meta {
  min-width: 0;
  flex: 1;
}

.cr-item-meta strong {
  display: block;
  font-size: var(--cr-text-md);
}

.cr-item-amount {
  font-weight: 700;
  color: var(--cr-color-accent);
  font-size: var(--cr-text-lg);
  white-space: nowrap;
}

.cr-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--cr-space-2);
  align-items: center;
  padding-top: var(--cr-space-3);
  border-top: 1px solid var(--cr-color-border);
}

.cr-item-actions .cr-input {
  max-width: 9rem;
  flex: 0 1 9rem;
}

.cr-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--cr-space-3);
  flex-wrap: wrap;
}

.cr-card-title {
  margin: 0;
  font-size: var(--cr-text-lg);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: var(--cr-space-2);
}

.cr-alert {
  padding: var(--cr-space-3) var(--cr-space-4);
  border-radius: var(--cr-radius-md);
  font-size: var(--cr-text-sm);
  margin: 0;
}

.cr-alert-danger {
  background: var(--cr-color-danger-subtle);
  color: var(--cr-color-danger);
  border: 1px solid #fecaca;
}

.cr-alert-success {
  background: var(--cr-color-success-subtle);
  color: var(--cr-color-success);
  border: 1px solid #a7f3d0;
}

/* ?? Dashboard chart / empty / trial ?? */
.cr-bars {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: var(--cr-space-2);
  align-items: end;
  min-height: 12rem;
  padding-top: var(--cr-space-2);
}

.cr-bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}

.cr-bar-track {
  width: 100%;
  max-width: 2.5rem;
  height: 9rem;
  border-radius: 8px 8px 4px 4px;
  background: var(--cr-color-surface-muted);
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}

.cr-bar-fill {
  width: 100%;
  min-height: 4px;
  border-radius: 8px 8px 4px 4px;
  background: linear-gradient(180deg, #34d399 0%, #059669 100%);
  transition: height 280ms ease;
}

.cr-bar-label {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--cr-color-text-muted);
  text-transform: capitalize;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.cr-bar-value {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--cr-color-success);
}

.cr-empty {
  display: grid;
  place-items: center;
  gap: var(--cr-space-2);
  padding: var(--cr-space-8) var(--cr-space-4);
  color: var(--cr-color-text-muted);
  text-align: center;
}

.cr-empty .cr-icon {
  opacity: 0.35;
  width: 3rem;
  height: 3rem;
}

.cr-empty p {
  margin: 0;
  font-size: var(--cr-text-sm);
  font-weight: 500;
}

.cr-trial-chip {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--cr-space-3);
  border-radius: var(--cr-radius-md);
  background: rgba(37, 99, 235, 0.22);
  border: 1px solid rgba(59, 130, 246, 0.35);
  color: #bfdbfe;
  font-size: var(--cr-text-xs);
  margin-bottom: var(--cr-space-2);
}

.cr-trial-chip strong {
  color: #fff;
  font-size: var(--cr-text-sm);
}

.cr-hero-balance {
  background: linear-gradient(135deg, #ecfdf5 0%, #f0fdfa 55%, #fff 100%);
  border-color: #a7f3d0;
}

.cr-hero-balance .cr-stat-value {
  color: var(--cr-color-success);
  font-size: 2.25rem;
}

.cr-hero-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
  gap: var(--cr-space-3);
  margin-top: var(--cr-space-4);
  padding-top: var(--cr-space-4);
  border-top: 1px solid #a7f3d0;
}

.cr-hero-meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cr-hero-meta-item span {
  font-size: var(--cr-text-xs);
  color: var(--cr-color-text-muted);
  font-weight: 600;
}

.cr-hero-meta-item strong {
  font-size: var(--cr-text-md);
}

.cr-hero-meta-item strong.is-pos { color: var(--cr-color-success); }
.cr-hero-meta-item strong.is-neg { color: var(--cr-color-danger); }
.cr-hero-meta-item strong.is-info { color: var(--cr-color-primary); }

.cr-calc-box {
  margin-top: var(--cr-space-4);
  padding: var(--cr-space-4);
  border-radius: var(--cr-radius-md);
  background: var(--cr-color-primary-subtle);
  border: 1px solid #bfdbfe;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--cr-space-3);
}

.cr-calc-box h3 {
  grid-column: 1 / -1;
  margin: 0;
  font-size: var(--cr-text-sm);
  color: var(--cr-color-primary);
  display: flex;
  align-items: center;
  gap: var(--cr-space-2);
}

.cr-calc-item span {
  display: block;
  font-size: var(--cr-text-xs);
  color: var(--cr-color-text-muted);
  font-weight: 600;
  margin-bottom: 2px;
}

.cr-calc-item strong {
  font-size: var(--cr-text-lg);
}

.cr-calc-item strong.is-accent {
  color: var(--cr-color-success);
}

.cr-person-list {
  display: flex;
  flex-direction: column;
  gap: var(--cr-space-3);
}

.cr-person-card {
  display: flex;
  flex-direction: column;
  gap: var(--cr-space-3);
  padding: var(--cr-space-4);
  border: 1px solid var(--cr-color-border);
  border-radius: var(--cr-radius-lg);
  background: var(--cr-color-surface);
  box-shadow: var(--cr-shadow-sm);
  transition: box-shadow var(--cr-ease), border-color var(--cr-ease);
}

.cr-person-card:hover {
  box-shadow: var(--cr-shadow-md);
  border-color: var(--cr-color-border-strong);
}

.cr-person-top {
  display: flex;
  align-items: flex-start;
  gap: var(--cr-space-3);
}

.cr-person-avatar {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: var(--cr-color-primary-subtle);
  color: var(--cr-color-primary);
  font-weight: 700;
  font-size: var(--cr-text-sm);
}

.cr-person-info {
  min-width: 0;
  flex: 1;
}

.cr-person-info strong {
  display: block;
  font-size: var(--cr-text-md);
}

.cr-person-info .cr-muted {
  font-size: var(--cr-text-sm);
}

.cr-person-contacts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--cr-space-3);
  font-size: var(--cr-text-sm);
  color: var(--cr-color-text-muted);
}

.cr-person-contacts span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.cr-person-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--cr-space-2);
  padding-top: var(--cr-space-3);
  border-top: 1px solid var(--cr-color-border);
}

.cr-btn-success {
  background: linear-gradient(180deg, #10b981 0%, #059669 100%);
  color: #fff !important;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.28);
}

.cr-btn-success:hover:not(:disabled) {
  background: linear-gradient(180deg, #059669 0%, #047857 100%);
}

.cr-btn-outline-danger {
  background: #fff;
  color: var(--cr-color-danger) !important;
  border: 1px solid #fecaca;
  box-shadow: none;
}

@media (max-width: 700px) {
  .cr-calc-box {
    grid-template-columns: 1fr;
  }

  .cr-bars {
    min-height: 10rem;
  }

  .cr-bar-track {
    height: 7rem;
  }
}
