:root{
  --bg:#f6f7f9;
  --surface:#ffffff;
  --surface-2:#fbfbfc;
  --text:#111827;
  --muted:#6b7280;
  --line:rgba(17,24,39,.10);
  --line-2:rgba(17,24,39,.14);
  --radius:16px;
  --radius-sm:12px;
  --max:1080px;
  --font-mono:'JetBrains Mono', ui-monospace, monospace;
}

*{box-sizing:border-box}
html{height:100%}
body{
  margin:0;
  font-family:ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background:var(--bg);
  color:var(--text);
  line-height:1.5;
  min-height:100%;
  display:flex;
  flex-direction:column;
}

main{
  flex:1;
}

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

.container{
  width:100%;
  max-width:var(--max);
  margin:0 auto;
  padding:0 20px;
}

.header{
  position:sticky;
  top:0;
  z-index:100;
  background:rgba(255,255,255,0.85);
  backdrop-filter:saturate(180%) blur(20px);
  -webkit-backdrop-filter:saturate(180%) blur(20px);
  border-bottom:1px solid rgba(0,0,0,0.05);
  box-shadow: 0 1px 6px rgba(0,0,0,0.03);
  transition: background 0.3s, border-color 0.3s, box-shadow 0.3s, backdrop-filter 0.3s;
}
/* Transparent header for landing page */
.header--transparent{
  background:transparent;
  backdrop-filter:none;
  -webkit-backdrop-filter:none;
  border-bottom:1px solid transparent;
  box-shadow: none;
}
.header--transparent.header--scrolled{
  background:rgba(255,255,255,0.5);
  backdrop-filter:saturate(180%) blur(20px);
  -webkit-backdrop-filter:saturate(180%) blur(20px);
  border-bottom:1px solid rgba(0,0,0,0.05);
  box-shadow: 0 1px 6px rgba(0,0,0,0.03);
}
.header__inner{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  height:60px;
}

.brand{
  display:flex;
  align-items:center;
  gap:12px;
}
.brand__logo{
  height:32px;
  width:auto;
  display:block;
}
.brand__name{
  font-family:var(--font-mono);
  font-weight:500;
  font-size:15px;
  letter-spacing:-.2px;
  color:var(--text);
}
.brand--small{
  gap:10px;
}
.brand--small .brand__logo{
  height:24px;
}
.brand--small .brand__name{
  font-size:14px;
}

.nav{
  display:none;
  gap:18px;
  align-items:center;
}
.nav__link{
  color:var(--muted);
  font-size:14px;
}
.nav__link:hover{color:var(--text)}

.cta{
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--line-2);
  background:transparent;
  font-size:14px;
}
.cta:hover{background:rgba(17,24,39,.03)}

/* Header actions */
.header__actions{
  display:flex;
  align-items:center;
  gap:12px;
}
.header__user{
  font-size:13px;
  color:var(--muted);
  font-family:var(--font-mono);
}
.cta--logout{
  padding:8px 12px;
  border-radius:8px;
  border:1px solid rgba(239,68,68,0.2);
  background:rgba(239,68,68,0.05);
  color:#ef4444;
  font-size:13px;
  transition:all 0.2s;
}
.cta--logout:hover{
  background:rgba(239,68,68,0.1);
  border-color:rgba(239,68,68,0.3);
}

.hero{
  padding:48px 0 18px;
}
.hero__inner{
  display:grid;
  grid-template-columns:1fr;
  gap:18px;
  align-items:start;
}

.kicker{
  margin:0 0 10px;
  color:var(--muted);
  font-size:13px;
  letter-spacing:.3px;
  text-transform:uppercase;
}
.hero__title{
  margin:0 0 12px;
  font-size:34px;
  line-height:1.1;
  letter-spacing:-.5px;
}
.hero__subtitle{
  margin:0 0 18px;
  color:var(--muted);
  max-width:56ch;
}

.hero__actions{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  margin:0 0 22px;
}

.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:10px 14px;
  border-radius:12px;
  border:1px solid var(--line-2);
  font-weight:600;
  font-size:14px;
  white-space:nowrap;
}
.btn--primary{
  background:#111827;
  color:#ffffff;
  border-color:transparent;
}
.btn--primary:hover{background:#0b1220}
.btn--ghost{
  background:transparent;
  color:var(--text);
}
.btn--ghost:hover{background:rgba(17,24,39,.03)}

.hero__panel{
  border-radius:var(--radius);
}

.card{
  border:1px solid var(--line);
  border-radius:var(--radius);
  background:var(--surface);
  overflow:hidden;
}
.card__body{padding:14px}
.row{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap:12px;
  padding:10px 0;
}
.row--big .value{font-size:18px; font-weight:700}
.label{color:var(--muted); font-size:13px}
.value{font-weight:600}
.divider{height:1px; background:var(--line); margin:8px 0}
.note{margin:10px 0 0; color:var(--muted); font-size:12px}

.section{padding:44px 0}
.section--alt{background:transparent}
.section__title{
  margin:0 0 10px;
  font-size:22px;
  letter-spacing:-.2px;
}
.section__lead{
  margin:0 0 18px;
  color:var(--muted);
  max-width:78ch;
}

.grid3,
.grid2{
  display:grid;
  grid-template-columns:1fr;
  gap:12px;
}
.tile{
  border:1px solid var(--line);
  border-radius:var(--radius);
  background:var(--surface);
  padding:16px;
}
.tile__title{margin:0 0 6px; font-size:15px}
.tile__text{margin:0; color:var(--muted)}

.contact__row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
  border:1px solid var(--line);
  border-radius:var(--radius);
  background:var(--surface);
  padding:16px;
}
.contact__label{color:var(--muted); font-size:12px}
.contact__value{font-weight:600}

.footer{
  border-top:1px solid var(--line);
  background:rgba(255,255,255,0.72);
  backdrop-filter:saturate(180%) blur(20px);
  -webkit-backdrop-filter:saturate(180%) blur(20px);
}
.footer__inner{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  height:60px;
}
.footer__copy{
  margin:0;
  color:var(--muted);
  font-size:13px;
}
.footer__left{
  display:flex;
  flex-direction:column;
  gap:12px;
}
.footer__note{margin:0; color:var(--muted); font-size:13px}
.footer__right{display:flex; gap:14px; flex-wrap:wrap; align-items:center}
.footer__link{
  color:var(--muted);
  font-size:14px;
  padding:8px 12px;
  border-radius:8px;
  transition: all 0.2s;
}
.footer__link:hover{
  color:var(--text);
  background:rgba(17,24,39,.04);
}

/* Demo page styles */
.cta--active{
  background:var(--text);
  color:var(--surface);
  border-color:var(--text);
}
.cta--active:hover{
  background:#374151;
}

.alert{
  padding:16px 20px;
  border-radius:var(--radius-sm);
  margin-bottom:24px;
}
.alert--success{
  background:#ecfdf5;
  border:1px solid #10b981;
  color:#065f46;
}
.alert--error{
  background:#fef2f2;
  border:1px solid #ef4444;
  color:#991b1b;
}

.db-info{
  background:var(--surface-2);
  padding:16px 20px;
  border-radius:var(--radius-sm);
  border:1px solid var(--line);
  margin-bottom:32px;
}
.db-info p{margin:4px 0}

.subsection__title{
  font-size:20px;
  margin:0 0 16px;
}

.table-wrapper{
  overflow-x:auto;
  margin-bottom:32px;
}

.data-table{
  width:100%;
  border-collapse:collapse;
  background:var(--surface);
  border-radius:var(--radius-sm);
  overflow:hidden;
  border:1px solid var(--line);
}
.data-table th,
.data-table td{
  padding:12px 16px;
  text-align:left;
  border-bottom:1px solid var(--line);
}
.data-table th{
  background:var(--surface-2);
  font-weight:600;
  font-size:13px;
  text-transform:uppercase;
  letter-spacing:.5px;
  color:var(--muted);
}
.data-table td{
  font-size:14px;
}
.data-table tr:last-child td{
  border-bottom:none;
}
.data-table tr:hover td{
  background:var(--surface-2);
}
.data-table code{
  font-family:var(--font-mono);
  font-size:13px;
  background:rgba(17,24,39,.06);
  padding:2px 6px;
  border-radius:4px;
}
.data-table .empty{
  text-align:center;
  color:var(--muted);
  padding:32px;
}

.demo-actions{
  margin-top:24px;
}

@media (min-width: 860px){
  .nav{display:flex}
  .hero{padding:64px 0 22px}
  .hero__inner{grid-template-columns: 1.2fr .8fr; gap:22px}
  .hero__title{font-size:44px}
  .grid3{grid-template-columns:repeat(3, 1fr)}
  .grid2{grid-template-columns:repeat(2, 1fr)}
}

/* ============================================
   WIZARD STYLES
   ============================================ */

.wizard-progress {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 40px;
  padding: 20px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.wizard-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  opacity: 0.4;
  transition: all 0.3s ease;
}

.wizard-step.active {
  opacity: 1;
}

.wizard-step.completed {
  opacity: 0.7;
}

.wizard-step__number {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--line);
  border-radius: 50%;
  font-weight: 700;
  font-size: 14px;
}

.wizard-step.active .wizard-step__number {
  background: var(--text);
  color: var(--surface);
}

.wizard-step.completed .wizard-step__number {
  background: #10b981;
  color: white;
}

.wizard-step__label {
  font-size: 14px;
  font-weight: 600;
  display: none;
}

@media (min-width: 640px) {
  .wizard-step__label {
    display: block;
  }
}

.wizard-panel {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.wizard-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

/* ============================================
   STEP 1: USER SELECTION
   ============================================ */

.selection-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 700px) {
  .selection-cards {
    grid-template-columns: repeat(3, 1fr);
  }
  .selection-card--search {
    grid-column: span 2;
  }
}

.selection-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  width: 100%;
  font-family: inherit;
}

.selection-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

.selection-card:active {
  transform: scale(0.98);
}

.selection-card--search {
  cursor: default;
}

.selection-card--search:hover {
  border-color: var(--line);
  box-shadow: none;
}

.selection-card--search:active {
  transform: none;
}

.selection-card__icon-wrap {
  position: relative;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  flex-shrink: 0;
  transition: all 0.2s;
}

.selection-card__icon {
  width: 22px;
  height: 22px;
  transition: opacity 0.2s;
}

.selection-card__spinner {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 2px solid var(--line);
  border-top-color: currentColor;
  border-radius: 50%;
  opacity: 0;
  animation: spin 0.8s linear infinite;
}

.selection-card.is-loading .selection-card__icon {
  opacity: 0;
}

.selection-card.is-loading .selection-card__spinner {
  opacity: 1;
}

.selection-card.is-loading {
  pointer-events: none;
  opacity: 0.7;
}

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

.selection-card__content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.selection-card__label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.selection-card__desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

/* Selection card variants */
.selection-card--random .selection-card__icon-wrap {
  background: linear-gradient(135deg, #ede9fe 0%, #ddd6fe 100%);
  color: #7c3aed;
}
.selection-card--random:hover {
  border-color: #8b5cf6;
}

.selection-card--search .selection-card__icon-wrap {
  background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
  color: #4f46e5;
}
.selection-card--search:focus-within {
  border-color: #4f46e5;
}

.search-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.search-inline__input {
  width: 100%;
  max-width: 180px;
  height: 44px;
  padding: 0 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 16px; /* 16px prevents zoom on iOS */
  font-family: var(--font-mono);
  transition: max-width 0.2s;
}

@media (min-width: 700px) {
  .search-inline__input {
    max-width: 340px;
  }
}

.search-inline__input:focus {
  outline: none;
  border-color: #4f46e5;
}

.search-inline__input::placeholder {
  color: var(--muted);
  opacity: 0.5;
}

.search-inline__btn {
  width: 44px;
  height: 44px;
  padding: 0;
  background: var(--line);
  color: var(--text);
  border: none;
  border-radius: 8px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.search-inline__btn:hover {
  background: var(--text);
  color: #fff;
}

/* Search Expanded (Step 1) */
.selection-card--search {
  cursor: pointer;
  flex-direction: column;
  align-items: stretch;
  transition: all 0.3s ease;
}

.selection-card--search.is-expanded {
  cursor: default;
}

.selection-card--search .selection-card__icon-wrap,
.selection-card--search .selection-card__content {
  cursor: pointer;
}

.selection-card--search.is-expanded .selection-card__icon-wrap,
.selection-card--search.is-expanded .selection-card__content {
  cursor: default;
}

.selection-card--search > .selection-card__icon-wrap,
.selection-card--search > .selection-card__content {
  display: inline-flex;
}

.search-expanded {
  display: none;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.selection-card--search.is-expanded .search-expanded {
  display: flex;
}

.search-expanded__form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.search-expanded__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.search-expanded__row {
  display: flex;
  gap: 8px;
}

.search-expanded__input {
  flex: 1;
  height: 44px;
  padding: 0 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 15px;
  font-family: var(--font-mono);
  color: var(--text);
  transition: all 0.2s;
}

.search-expanded__input:focus {
  outline: none;
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.search-expanded__input::placeholder {
  color: var(--muted);
  opacity: 0.5;
}

.search-expanded__btn {
  width: 44px;
  height: 44px;
  padding: 0;
  background: var(--line);
  color: var(--text);
  border: none;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.search-expanded__btn:hover {
  background: #4f46e5;
  color: #fff;
}

.search-expanded__btn.is-loading {
  pointer-events: none;
  opacity: 0.6;
}

/* Search Dropdown (Step 2 topbar) */
.search-dropdown {
  position: relative;
}

.search-dropdown__toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid transparent;
  border-radius: 20px;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.search-dropdown__toggle:hover {
  background: rgba(255, 255, 255, 0.12);
}

.search-dropdown.is-open .search-dropdown__toggle {
  background: rgba(79, 70, 229, 0.2);
  border-color: rgba(79, 70, 229, 0.4);
}

.search-dropdown__menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 260px;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  z-index: 100;
  animation: dropdownSlide 0.2s ease;
}

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

.search-dropdown.is-open .search-dropdown__menu {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.search-dropdown__form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.search-dropdown__label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.search-dropdown__row {
  display: flex;
  gap: 6px;
}

.search-dropdown__input {
  flex: 1;
  height: 38px;
  padding: 0 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  font-family: var(--font-mono);
  color: var(--text);
  transition: all 0.2s;
}

.search-dropdown__input:focus {
  outline: none;
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.search-dropdown__input::placeholder {
  color: var(--muted);
  opacity: 0.5;
}

.search-dropdown__btn {
  width: 38px;
  height: 38px;
  padding: 0;
  background: var(--line);
  color: var(--text);
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.search-dropdown__btn:hover {
  background: #4f46e5;
  color: #fff;
}

.search-dropdown__btn.is-loading {
  pointer-events: none;
  opacity: 0.6;
}

/* Search inline in topbar (Step 2) */
.search-inline--topbar {
  margin-left: 0;
  position: relative;
}

.search-inline--topbar .search-inline__input {
  height: 34px;
  width: 34px;
  max-width: 34px;
  font-size: 13px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid transparent;
  border-radius: 20px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-inline--topbar .search-inline__input:hover {
  background: rgba(255, 255, 255, 0.1);
}

.search-inline--topbar .search-inline__input:focus,
.search-inline--topbar .search-inline__input:not(:placeholder-shown) {
  width: 160px;
  max-width: 160px;
  padding: 0 32px 0 12px;
  cursor: text;
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(79, 70, 229, 0.5);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.search-inline--topbar .search-inline__input::placeholder {
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.search-inline--topbar .search-inline__input:focus::placeholder {
  opacity: 0.6;
}

.search-inline--topbar .search-inline__btn {
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  font-size: 12px;
  background: transparent;
  border-radius: 50%;
  opacity: 0.6;
  transition: all 0.2s ease;
  pointer-events: none;
}

.search-inline--topbar .search-inline__input:focus ~ .search-inline__btn,
.search-inline--topbar .search-inline__input:not(:placeholder-shown) ~ .search-inline__btn {
  pointer-events: auto;
  opacity: 0.8;
}

.search-inline--topbar .search-inline__btn:hover {
  background: rgba(79, 70, 229, 0.2);
  opacity: 1;
  color: var(--text);
}

@media (min-width: 700px) {
  .search-inline--topbar .search-inline__input:focus,
  .search-inline--topbar .search-inline__input:not(:placeholder-shown) {
    width: 180px;
    max-width: 180px;
  }
}

/* Cluster Selection */
.cluster-selection {
  margin-top: 32px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

.cluster-selection__title {
  margin: 0 0 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.cluster-selection__method {
  font-weight: 400;
  color: var(--muted);
  opacity: 0.7;
  text-transform: none;
}

.cluster-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.cluster-cards:last-child {
  margin-bottom: 0;
}

@media (min-width: 700px) {
  .cluster-cards--row-3 {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .cluster-cards--row-2 {
    grid-template-columns: repeat(2, 1fr);
    max-width: 66.666%;
    margin-left: auto;
    margin-right: auto;
  }
}

.cluster-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  width: 100%;
  font-family: inherit;
}

.cluster-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

.cluster-card:active {
  transform: scale(0.98);
}

.cluster-card__icon-wrap {
  position: relative;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  flex-shrink: 0;
  transition: all 0.2s;
}

.cluster-card__icon {
  width: 22px;
  height: 22px;
  transition: opacity 0.2s;
}

.cluster-card__spinner {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 2px solid var(--line);
  border-top-color: currentColor;
  border-radius: 50%;
  opacity: 0;
  animation: spin 0.8s linear infinite;
}

.cluster-card.is-loading .cluster-card__icon {
  opacity: 0;
}

.cluster-card.is-loading .cluster-card__spinner {
  opacity: 1;
}

.cluster-card.is-loading {
  pointer-events: none;
  opacity: 0.7;
}

.cluster-card__content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.cluster-card__label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.cluster-card__desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

/* Cluster card number */
.cluster-card__number {
  font-size: 24px;
  font-weight: 700;
  font-family: var(--font-mono);
}

/* Cluster card variants */
.cluster-card--0 .cluster-card__icon-wrap {
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  color: #1d4ed8;
}
.cluster-card--0:hover {
  border-color: #3b82f6;
}

.cluster-card--1 .cluster-card__icon-wrap {
  background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
  color: #047857;
}
.cluster-card--1:hover {
  border-color: #10b981;
}

.cluster-card--2 .cluster-card__icon-wrap {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  color: #b45309;
}
.cluster-card--2:hover {
  border-color: #f59e0b;
}

.cluster-card--3 .cluster-card__icon-wrap {
  background: linear-gradient(135deg, #fce7f3 0%, #fbcfe8 100%);
  color: #be185d;
}
.cluster-card--3:hover {
  border-color: #ec4899;
}

.cluster-card--4 .cluster-card__icon-wrap {
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
  color: #b91c1c;
}
.cluster-card--4:hover {
  border-color: #ef4444;
}

/* Search Input */
.search-input {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.search-input__field {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid var(--line);
  border-radius: 12px;
  font-size: 15px;
  font-family: var(--font-mono);
  transition: border-color 0.2s;
}

.search-input__field:focus {
  outline: none;
  border-color: var(--text);
}

.search-input__field::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

.search-input__btn {
  padding: 12px 20px;
  background: var(--text);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 90px;
  justify-content: center;
}

.search-input__btn:hover {
  background: #374151;
}

.search-input__btn-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.search-input__btn.is-loading .search-input__btn-text {
  display: none;
}

.search-input__btn.is-loading .search-input__btn-spinner {
  display: block;
}

.search-input__btn.is-loading {
  pointer-events: none;
  opacity: 0.8;
}

/* Result Card */
.result-card {
  margin-top: 24px;
  padding: 24px;
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
  border: 2px solid #10b981;
  border-radius: var(--radius);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.result-card__badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #10b981;
  color: white;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 16px;
}

.result-card__content {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
}

.result-card__avatar {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border-radius: 16px;
  font-size: 32px;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.15);
}

.result-card__info {
  flex: 1;
}

.result-card__row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 8px;
}

.result-card__row:last-child {
  margin-bottom: 0;
}

.result-card__label {
  font-size: 12px;
  color: #065f46;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.result-card__value {
  font-size: 18px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text);
}

.result-card__btn {
  width: 100%;
  padding: 16px 24px;
  background: #10b981;
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.2s;
}

.result-card__btn:hover {
  background: #059669;
}

.result-card__btn-arrow {
  transition: transform 0.2s;
}

.result-card__btn:hover .result-card__btn-arrow {
  transform: translateX(4px);
}

/* Alert styles update */
.alert {
  padding: 16px 20px;
  border-radius: var(--radius-sm);
  margin-top: 16px;
}

.alert--error {
  background: #fef2f2;
  border: 2px solid #fecaca;
  color: #991b1b;
  display: flex;
  align-items: center;
  gap: 10px;
}

.alert--error::before {
  content: '⚠️';
}

/* Legacy tile styles - keep for other uses */
.tile--action {
  cursor: pointer;
  transition: all 0.2s ease;
}

.tile--action:hover {
  border-color: var(--text);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.tile__icon {
  font-size: 32px;
  margin-bottom: 12px;
}

/* Input */
.input-group {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font-mono);
}

.input:focus {
  outline: none;
  border-color: var(--text);
}

/* User Card */
.user-card {
  margin-top: 24px;
  background: var(--surface);
  border: 2px solid #10b981;
  border-radius: var(--radius);
  overflow: hidden;
}

.user-card__header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  background: rgba(16, 185, 129, 0.1);
  border-bottom: 1px solid rgba(16, 185, 129, 0.2);
}

.user-card__icon {
  font-size: 20px;
}

.user-card__title {
  font-weight: 600;
  color: #065f46;
}

.user-card__body {
  padding: 16px 20px;
}

.user-card__row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
}

.user-card__label {
  color: var(--muted);
}

.user-card__value {
  font-family: var(--font-mono);
  font-weight: 600;
}

.btn--full {
  width: 100%;
  margin-top: 16px;
}

/* Analysis Card */
.analysis-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}

.analysis-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  gap: 12px;
}

.analysis-card__title {
  margin: 0;
  font-size: 16px;
}

.analysis-card__body {
  padding: 20px;
}

/* Data Stats Banner */
.data-stats-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  margin-bottom: 16px;
  background: linear-gradient(135deg, #f0f9ff 0%, #e8f4fd 100%);
  border: 1px solid #bae6fd;
  border-radius: 10px;
  font-size: 13px;
  color: #0369a1;
}

.data-stats-banner__info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.data-stats-banner__icon {
  font-size: 16px;
}

.data-stats-banner__warning {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 6px;
  color: #92400e;
  font-weight: 500;
}

/* Demo Mode Banner */
.demo-mode-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 20px;
  margin-bottom: 24px;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 1px solid #f59e0b;
  border-radius: 12px;
  font-size: 14px;
  color: #92400e;
}

.demo-mode-banner__icon {
  font-size: 18px;
}

.demo-mode-banner__text strong {
  color: #78350f;
}

/* Date Range Selector */
.date-range-selector {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.date-range-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.date-input {
  display: flex;
  align-items: center;
  gap: 6px;
}

.date-input__label {
  font-size: 13px;
  color: var(--muted);
}

.date-input input[type="date"] {
  padding: 6px 10px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.2s;
}

.date-input input[type="date"]:hover {
  border-color: var(--text);
}

.date-input input[type="date"]:focus {
  outline: none;
  border-color: var(--text);
}

.date-range-separator {
  color: var(--muted);
  font-size: 14px;
}

.btn--sm {
  padding: 6px 14px;
  font-size: 13px;
}

/* Period Selector (deprecated) */
.period-selector {
  display: flex;
  gap: 6px;
}

.period-btn {
  padding: 6px 12px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: transparent;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.period-btn:hover {
  background: var(--surface-2);
}

.period-btn.active {
  background: var(--text);
  color: var(--surface);
  border-color: var(--text);
}

/* Chart Container */
.chart-container {
  height: 400px;
  position: relative;
}

.chart-container--small {
  height: 180px;
}

/* Stats Row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.stats-row--compact {
  grid-template-columns: repeat(2, 1fr);
}

.stat {
  text-align: center;
}

.stat__value {
  font-size: 24px;
  font-weight: 700;
  font-family: var(--font-mono);
}

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

/* Events List */
.events-list {
  max-height: 180px;
  overflow-y: auto;
}

.event {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 8px;
}

.event--disconnection {
  background: rgba(239, 68, 68, 0.1);
}

.event--reconnection {
  background: rgba(16, 185, 129, 0.1);
}

.event__icon {
  font-size: 14px;
}

.event__date {
  font-size: 13px;
  color: var(--muted);
}

.event__amount {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
}

.events-empty {
  text-align: center;
  padding: 40px;
  color: var(--muted);
}

.loading {
  text-align: center;
  padding: 40px;
  color: var(--muted);
}

/* Score Display */
.score-display {
  display: flex;
  align-items: center;
  gap: 32px;
  flex-wrap: wrap;
}

.score-circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 6px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: border-color 0.3s;
}

.score-value {
  font-size: 36px;
  font-weight: 700;
  font-family: var(--font-mono);
}

.score-max {
  font-size: 14px;
  color: var(--muted);
}

.score-info {
  flex: 1;
}

.score-category {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 12px;
}

.score-factors {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.factor {
  padding: 6px 12px;
  background: var(--surface-2);
  border-radius: 8px;
  font-size: 13px;
  color: var(--muted);
}

/* Offer Card */
.offer-card {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: var(--radius);
  padding: 40px;
  color: white;
  text-align: center;
  max-width: 500px;
  margin: 0 auto;
}

.offer-card__icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.offer-card__title {
  margin: 0 0 12px;
  font-size: 28px;
}

.offer-card__description {
  margin: 0 0 20px;
  opacity: 0.9;
  font-size: 16px;
}

.offer-card__condition {
  padding: 12px 20px;
  background: rgba(255,255,255,0.15);
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 14px;
}

.offer-card__condition-label {
  opacity: 0.7;
}

.offer-card__score {
  margin-bottom: 24px;
  font-size: 14px;
  opacity: 0.8;
}

.offer-card .btn--primary {
  background: white;
  color: #667eea;
  border: none;
}

.offer-card .btn--primary:hover {
  background: rgba(255,255,255,0.9);
}

.btn--lg {
  padding: 14px 28px;
  font-size: 16px;
}

/* Timeline */
.analysis-card--timeline {
  margin-top: 20px;
}

.timeline-legend {
  display: flex;
  gap: 16px;
  font-size: 12px;
}

.timeline-legend__item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.timeline-legend__item::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.timeline-legend__item--off::before {
  background: #ef4444;
}

.timeline-legend__item--on::before {
  background: #10b981;
}

.timeline {
  position: relative;
  padding: 20px 0;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--line);
}

.timeline-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
  font-size: 15px;
}

.timeline-empty__icon {
  font-size: 48px;
  margin-bottom: 12px;
  display: block;
}

.timeline-item {
  position: relative;
  padding-left: 32px;
  padding-bottom: 24px;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-item__dot {
  position: absolute;
  left: 0;
  top: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 3px solid var(--surface);
  box-shadow: 0 0 0 2px var(--line);
}

.timeline-item--off .timeline-item__dot {
  background: #ef4444;
  box-shadow: 0 0 0 2px #fecaca;
}

.timeline-item--on .timeline-item__dot {
  background: #10b981;
  box-shadow: 0 0 0 2px #a7f3d0;
}

.timeline-item__content {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  border: 1px solid var(--line);
}

.timeline-item--off .timeline-item__content {
  border-left: 3px solid #ef4444;
}

.timeline-item--on .timeline-item__content {
  border-left: 3px solid #10b981;
}

.timeline-item__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}

.timeline-item__title {
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.timeline-item__date {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.timeline-item__details {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 13px;
}

.timeline-item__detail {
  display: flex;
  align-items: center;
  gap: 4px;
}

.timeline-item__detail-label {
  color: var(--muted);
}

.timeline-item__detail-value {
  font-weight: 600;
  font-family: var(--font-mono);
}

.timeline-item__duration {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
  padding: 4px 10px;
  background: rgba(239, 68, 68, 0.1);
  border-radius: 6px;
  font-size: 12px;
  color: #dc2626;
}

.timeline-item__duration-icon {
  font-size: 14px;
}

.timeline-item--clickable {
  cursor: pointer;
}

.timeline-item--clickable .timeline-item__content {
  transition: transform 0.2s, box-shadow 0.2s;
}

.timeline-item--clickable:hover .timeline-item__content {
  transform: translateX(4px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.timeline-item__hint {
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
  opacity: 0.7;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.is-open {
  display: flex;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.modal__container {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 1000px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
}

.modal__title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.modal__close {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--surface-2);
  border-radius: 8px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: background 0.2s;
}

.modal__close:hover {
  background: var(--line);
  color: var(--text);
}

.modal__body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

/* Modal Content Sections */
.modal-section {
  margin-bottom: 24px;
}

.modal-section:last-child {
  margin-bottom: 0;
}

.modal-section__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.modal-stat {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 16px;
  border: 1px solid var(--line);
}

.modal-stat--highlight {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.1) 0%, rgba(239, 68, 68, 0.05) 100%);
  border-color: rgba(239, 68, 68, 0.2);
}

.modal-stat--success {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(16, 185, 129, 0.05) 100%);
  border-color: rgba(16, 185, 129, 0.2);
}

.modal-stat__label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.modal-stat__value {
  font-size: 18px;
  font-weight: 700;
  font-family: var(--font-mono);
}

.modal-stat--highlight .modal-stat__value {
  color: #dc2626;
}

.modal-stat--success .modal-stat__value {
  color: #059669;
}

/* Payments List in Modal */
.modal-payments {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-payment {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface-2);
  border-radius: 8px;
  border: 1px solid var(--line);
}

.modal-payment--critical {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(16, 185, 129, 0.05) 100%);
  border: 2px solid #10b981;
}

.modal-payment__icon {
  font-size: 20px;
}

.modal-payment__info {
  flex: 1;
}

.modal-payment__date {
  font-size: 13px;
  color: var(--muted);
}

.modal-payment__label {
  font-size: 11px;
  color: #059669;
  font-weight: 600;
  margin-top: 2px;
}

.modal-payment__amount {
  font-weight: 700;
  font-family: var(--font-mono);
  font-size: 15px;
}

.modal-payment--critical .modal-payment__amount {
  color: #059669;
}

.modal-payments-empty {
  padding: 20px;
  text-align: center;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 8px;
}

/* Chart in Modal */
.modal-chart {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 16px;
  border: 1px solid var(--line);
}

.modal-chart__container {
  height: 200px;
  position: relative;
}

.modal-chart__legend {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 12px;
  font-size: 12px;
}

.modal-chart__legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.modal-chart__legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.modal-chart__legend-dot--before {
  background: #5DADE2;
}

.modal-chart__legend-dot--after {
  background: #10b981;
}

.modal-chart__legend-dot--off {
  background: #ef4444;
}

/* Comparison Badge */
.comparison-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
}

.comparison-badge--down {
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
}

.comparison-badge--up {
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
}

.comparison-badge--same {
  background: var(--surface-2);
  color: var(--muted);
}

/* Responsive */
@media (max-width: 640px) {
  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .score-display {
    flex-direction: column;
    text-align: center;
  }
  
  .offer-card {
    padding: 24px;
  }
  
  .offer-card__title {
    font-size: 22px;
  }
}

/* ============================================
   ANALYSIS TOPBAR
   ============================================ */

.analysis-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  margin-bottom: 24px;
}

.analysis-topbar__nav {
  display: flex;
  gap: 4px;
}

.analysis-topbar__btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  opacity: 0.5;
}

.analysis-topbar__btn:hover {
  background: var(--bg);
  opacity: 0.8;
}

.analysis-topbar__btn--active {
  background: var(--text);
  opacity: 1;
}

.analysis-topbar__btn--active:hover {
  background: var(--text);
  opacity: 1;
}

.analysis-topbar__step {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--line);
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
}

.analysis-topbar__btn--active .analysis-topbar__step {
  background: var(--surface);
  color: var(--text);
}

.analysis-topbar__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.analysis-topbar__btn--active .analysis-topbar__label {
  color: var(--surface);
}

.analysis-topbar__actions {
  display: flex;
  gap: 8px;
}

.analysis-topbar__random {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: transparent;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text);
}

.analysis-topbar__random:hover {
  background: var(--bg);
  border-color: var(--text);
}

.analysis-topbar__random:active {
  transform: scale(0.97);
}

.analysis-header {
  margin-bottom: 24px;
}

.analysis-header .section__title {
  margin-bottom: 12px;
}

.analysis-header .section__lead {
  margin: 0;
}

.analysis-header__user {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.analysis-header__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: rgba(79, 70, 229, 0.08);
  border: 1px solid rgba(79, 70, 229, 0.15);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.analysis-header__item:hover {
  background: rgba(79, 70, 229, 0.15);
  border-color: rgba(79, 70, 229, 0.3);
}

.analysis-header__item:active {
  transform: scale(0.98);
}

.analysis-header__item.copied {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.3);
}

.analysis-header__label {
  font-size: 13px;
  color: var(--muted);
}

.analysis-header__value {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text);
}

.analysis-header__copy {
  font-size: 14px;
  opacity: 0.4;
  transition: opacity 0.2s;
}

.analysis-header__item:hover .analysis-header__copy {
  opacity: 0.8;
}

@media (max-width: 600px) {
  .analysis-topbar {
    flex-direction: column;
    gap: 12px;
  }
  
  .analysis-topbar__label {
    display: none;
  }
  
  .analysis-topbar__random {
    width: 100%;
    justify-content: center;
  }
}

/* ============================================
   Consumption Modeling Section
   ============================================ */

.analysis-card--modeling {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border: 1px solid rgba(99, 102, 241, 0.15);
}

.analysis-card--modeling .analysis-card__header {
  border-bottom: 1px solid rgba(99, 102, 241, 0.1);
}

.analysis-card__badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  background: rgba(99, 102, 241, 0.1);
  color: #6366f1;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.modeling-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 40px 20px;
  color: var(--muted);
  font-size: 14px;
}

.modeling-empty__icon {
  font-size: 32px;
  opacity: 0.5;
}

/* Summary Stats Grid */
.modeling-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.modeling-stat {
  background: white;
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
  border: 1px solid var(--line);
}

.modeling-stat--primary {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  border: none;
}

.modeling-stat--primary .modeling-stat__value,
.modeling-stat--primary .modeling-stat__label {
  color: white;
}

.modeling-stat__value {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.modeling-stat__label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

/* Period Info */
.modeling-period {
  background: white;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 24px;
  border: 1px solid var(--line);
}

.modeling-period strong {
  color: var(--text);
}

/* Sections */
.modeling-section {
  margin-bottom: 24px;
}

.modeling-section:last-child {
  margin-bottom: 0;
}

.modeling-section__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 16px 0;
}

/* Seasons Grid */
.modeling-seasons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.modeling-season {
  background: white;
  border-radius: var(--radius-sm);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  transition: all 0.2s ease;
}

.modeling-season:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.modeling-season__icon {
  font-size: 24px;
}

.modeling-season__name {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.modeling-season__value {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.modeling-season--winter {
  border-color: rgba(59, 130, 246, 0.3);
  background: linear-gradient(to bottom, rgba(59, 130, 246, 0.05), white);
}

.modeling-season--summer {
  border-color: rgba(249, 115, 22, 0.3);
  background: linear-gradient(to bottom, rgba(249, 115, 22, 0.05), white);
}

/* Monthly Chart */
.modeling-chart {
  background: white;
  border-radius: var(--radius-sm);
  padding: 20px;
  border: 1px solid var(--line);
  margin-bottom: 16px;
}

.modeling-chart__bars {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  height: 120px;
  gap: 4px;
}

.modeling-bar {
  flex: 1;
  background: linear-gradient(to top, #e2e8f0, #cbd5e1);
  border-radius: 4px 4px 0 0;
  min-height: 5%;
  position: relative;
  transition: all 0.3s ease;
  cursor: default;
}

.modeling-bar:hover {
  transform: scaleY(1.05);
  background: linear-gradient(to top, #cbd5e1, #94a3b8);
}

.modeling-bar--winter {
  background: linear-gradient(to top, #93c5fd, #60a5fa);
}

.modeling-bar--winter:hover {
  background: linear-gradient(to top, #60a5fa, #3b82f6);
}

.modeling-bar--summer {
  background: linear-gradient(to top, #fed7aa, #fdba74);
}

.modeling-bar--summer:hover {
  background: linear-gradient(to top, #fdba74, #f97316);
}

.modeling-bar__label {
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  color: var(--muted);
  white-space: nowrap;
}

/* Insight Box */
.modeling-insight {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px;
  color: #92400e;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.modeling-insight strong {
  color: #78350f;
}

/* Yearly Stats */
.modeling-years {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modeling-year {
  background: white;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--line);
  transition: all 0.2s ease;
}

.modeling-year:hover {
  border-color: var(--line-2);
  background: var(--surface-2);
}

.modeling-year__header {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.modeling-year__name {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.modeling-year__consumption {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: #6366f1;
}

.modeling-year__details {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--muted);
}

/* Responsive */
@media (max-width: 768px) {
  .modeling-summary {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .modeling-seasons {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .modeling-year {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  
  .modeling-year__details {
    flex-wrap: wrap;
  }
}

@media (max-width: 480px) {
  .modeling-chart__bars {
    height: 80px;
  }
  
  .modeling-bar__label {
    display: none;
  }
}

/* ============================================
   ML Forecast Section
   ============================================ */

.analysis-card--forecast {
  background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
  border: 1px solid rgba(139, 92, 246, 0.2);
}

.analysis-card--forecast .analysis-card__header {
  border-bottom: 1px solid rgba(139, 92, 246, 0.15);
}

.analysis-card__badge--ml {
  background: linear-gradient(135deg, #8b5cf6 0%, #a855f7 100%);
  color: white;
}

/* Forecast Controls */
.forecast-controls {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.btn--train {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 600;
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.btn--train:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}

.btn--train:active {
  transform: translateY(0);
}

.btn--train.is-loading {
  pointer-events: none;
}

.btn--train.is-loading .btn__icon,
.btn--train.is-loading .btn__text {
  opacity: 0;
}

.btn--train .btn__spinner {
  display: none;
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.btn--train.is-loading .btn__spinner {
  display: block;
}

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

/* Forecast Status */
.forecast-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: white;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--muted);
  border: 1px solid var(--line);
}

.forecast-status--trained {
  background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
  border-color: rgba(16, 185, 129, 0.3);
  color: #047857;
}

.forecast-status--training {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-color: rgba(245, 158, 11, 0.3);
  color: #92400e;
}

.forecast-status--error {
  background: linear-gradient(135deg, #fef2f2 0%, #fecaca 100%);
  border-color: rgba(239, 68, 68, 0.3);
  color: #b91c1c;
}

/* Model Metrics */
.model-metrics {
  margin-bottom: 24px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}

.metric-card {
  background: white;
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
  border: 1px solid var(--line);
}

.metric-card--primary {
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
  border: none;
  color: white;
}

.metric-card--primary .metric-card__label,
.metric-card--primary .metric-card__hint,
.metric-card--primary .metric-card__quality {
  color: rgba(255,255,255,0.85);
}

.metric-card__value {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
}

.metric-card__label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.metric-card__hint {
  font-size: 10px;
  color: var(--muted);
  opacity: 0.7;
}

.metric-card__quality {
  font-size: 11px;
  font-weight: 600;
  margin-top: 4px;
}

.metrics-info {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  padding: 8px;
  background: rgba(139, 92, 246, 0.05);
  border-radius: var(--radius-sm);
}

/* Feature Importance */
.feature-importance {
  margin-top: 24px;
  padding: 20px;
  background: white;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}

.fi-title {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 16px 0;
  color: var(--text);
}

.fi-bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.fi-bar {
  display: grid;
  grid-template-columns: 140px 1fr 50px;
  align-items: center;
  gap: 12px;
}

.fi-bar__label {
  font-size: 12px;
  color: var(--muted);
  text-align: right;
}

.fi-bar__track {
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
}

.fi-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, #8b5cf6 0%, #a855f7 100%);
  border-radius: 4px;
  transition: width 0.5s ease;
}

.fi-bar__value {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}

/* Forecast Chart */
#forecastChartContainer {
  margin: 24px 0;
  padding: 20px;
  background: white;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}

#forecastChartContainer .chart-container {
  height: 280px;
}

/* Forecast Summary */
.forecast-summary {
  margin-top: 24px;
}

.forecast-summary__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.forecast-summary__item {
  background: white;
  border-radius: var(--radius-sm);
  padding: 20px;
  text-align: center;
  border: 1px solid var(--line);
}

.forecast-summary__item--primary {
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
  border: none;
}

.forecast-summary__item--primary .forecast-summary__value,
.forecast-summary__item--primary .forecast-summary__label {
  color: white;
}

.forecast-summary__item--bill {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-color: rgba(245, 158, 11, 0.3);
}

.forecast-summary__item--bill .forecast-summary__value {
  color: #92400e;
}

.forecast-summary__value {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.forecast-summary__label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

.forecast-summary__period {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  padding: 12px;
  background: rgba(139, 92, 246, 0.05);
  border-radius: var(--radius-sm);
}

/* Diagnostics Section */
.diagnostics-section {
  margin-bottom: 20px;
}

.diagnostics-section__title {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 12px 0;
  color: var(--text);
}

.metrics-grid--compact {
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.metric-card--small {
  padding: 12px 8px;
}

.metric-card--small .metric-card__value {
  font-size: 18px;
}

.metric-card--small .metric-card__label {
  font-size: 11px;
}

/* Diagnostics Divider */
.diagnostics-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 32px 0 24px 0;
  padding: 16px 20px;
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.diagnostics-divider__icon {
  font-size: 20px;
}

.diagnostics-divider__text {
  font-size: 14px;
  font-weight: 600;
  color: #1e40af;
}

/* Forecast Comparison */
.forecast-comparison {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.forecast-comparison__item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.forecast-comparison__label {
  color: var(--muted);
}

.forecast-comparison__value {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text);
}

.forecast-comparison__item--diff.positive .forecast-comparison__value {
  color: #ef4444;
}

.forecast-comparison__item--diff.negative .forecast-comparison__value {
  color: #10b981;
}

/* Diagnostics Charts Row */
.diagnostics-charts-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin: 16px 0;
}

/* Chart Container Variants */
.chart-container--forecast {
  margin: 20px 0;
  padding: 16px;
  background: white;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  height: 280px;
}

.chart-container--horizontal {
  margin: 20px 0;
  padding: 16px;
  background: white;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  height: 300px;
}

.chart-container--comparison {
  margin: 16px 0;
  padding: 16px;
  background: white;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  height: 260px;
}

.chart-container--half {
  padding: 16px;
  background: white;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  height: 240px;
}

.chart-container--histogram {
  margin: 16px 0;
  padding: 16px;
  background: white;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  height: 220px;
}

/* Residuals Stats */
.residuals-stats {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 12px;
  padding: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  background: var(--bg);
  border-radius: 6px;
}

.residuals-stats span {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Responsive */
@media (max-width: 768px) {
  .forecast-controls {
    flex-direction: column;
    align-items: stretch;
  }
  
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .metrics-grid--compact {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .forecast-summary__grid {
    grid-template-columns: 1fr;
  }
  
  .fi-bar {
    grid-template-columns: 100px 1fr 40px;
  }
  
  .diagnostics-charts-row {
    grid-template-columns: 1fr;
  }
  
  .forecast-comparison {
    flex-direction: column;
    gap: 8px;
    align-items: center;
  }
}
