/* Dashboard home (tab-dashboard). Layout: welcome → setup (until done) →
   4 KPI cards → usage chart + plan → activity + quick actions. */

#tab-dashboard { max-width: var(--content-max); }
.dash { display: flex; flex-direction: column; gap: 18px; }
.dash-card { padding: 20px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.dash-card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dash-card-head h2 { margin: 0; font-size: var(--fs-card); font-weight: 650; letter-spacing: -.01em; color: var(--text-primary); }
.dash-card-head .dash-head-end { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.dash-link { color: var(--brand-ink); font-size: 13px; font-weight: 600; text-decoration: none; background: none; border: 0; padding: 0; cursor: pointer; font-family: inherit; display: inline-flex; align-items: center; gap: 4px; }
.dash-link:hover { text-decoration: underline; }
.dash-muted { color: var(--text-secondary); font-size: 13px; }
.dash-error { color: var(--error-ink); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.dash-empty { color: var(--text-secondary); font-size: 13px; padding: 18px 4px; text-align: center; }

/* Welcome */
.dash-hero {
  position: relative; overflow: hidden; padding: 24px 26px; border-radius: var(--radius-panel);
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  background:
    radial-gradient(600px 220px at 85% 0%, rgba(0, 168, 149, .22), transparent 70%),
    radial-gradient(500px 220px at 100% 100%, rgba(56, 189, 248, .14), transparent 70%),
    var(--glass-bg);
}
.dash-hero h1 { margin: 0; font-size: var(--fs-page); font-weight: 700; letter-spacing: -.025em; line-height: 1.15; color: var(--text-primary); }
.dash-hero p { margin: 6px 0 0; font-size: 14px; color: var(--text-secondary); }
.dash-hero-main { flex: 1 1 320px; min-width: 0; }
.dash-hero-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.dash-date {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; border-radius: 12px;
  background: var(--surface-primary); border: 1px solid var(--border); font-size: 13px; font-weight: 600; color: var(--text-primary);
}

/* Setup */
.dash-setup-bar { height: 8px; border-radius: 4px; background: var(--surface-hover); overflow: hidden; }
.dash-setup-bar span { display: block; height: 100%; background: var(--brand-primary); border-radius: 4px; transition: width var(--transition-slow); }
.dash-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(140px, 100%), 1fr)); gap: 10px; }
.dash-step {
  display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 14px;
  background: var(--surface-secondary); border: 1px solid var(--border); min-width: 0;
  font-family: inherit; color: var(--text-primary); text-align: left; font-size: 13px; font-weight: 600;
}
button.dash-step { cursor: pointer; }
button.dash-step:hover { border-color: var(--brand-primary); }
.dash-step-dot { width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; border: 1.5px solid var(--border-strong); color: transparent; }
.dash-step.done { color: var(--text-secondary); }
.dash-step.done .dash-step-dot { background: var(--brand-primary); border-color: var(--brand-primary); color: #fff; }
.dash-step small { display: block; font-weight: 500; color: var(--text-secondary); }

/* KPI cards */
.dash-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.dash-kpi {
  padding: 18px; display: flex; flex-direction: column; gap: 10px; min-width: 0; text-align: left;
  font-family: inherit; color: var(--text-primary); cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.dash-kpi:hover { transform: translateY(-2px); border-color: var(--brand-ring); }
.dash-kpi-top { display: flex; align-items: center; gap: 10px; }
.dash-kpi-ico { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; }
.dash-kpi-ico.teal { background: var(--brand-soft); color: var(--brand-ink); }
.dash-kpi-ico.blue { background: var(--blue-soft); color: var(--blue-ink); }
.dash-kpi-ico.indigo { background: var(--indigo-soft); color: var(--indigo-ink); }
.dash-kpi-ico.amber { background: var(--warning-soft); color: var(--warning-ink); }
.dash-kpi-change { margin-left: auto; font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 2px; }
.dash-kpi-change.up { color: var(--success-ink); }
.dash-kpi-change.down { color: var(--error-ink); }
.dash-kpi-value { font-size: 28px; font-weight: 700; letter-spacing: -.03em; line-height: 1.05; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.dash-kpi-value small { font-size: 14px; font-weight: 500; color: var(--text-secondary); letter-spacing: 0; }
.dash-kpi-label { font-size: 13px; color: var(--text-secondary); font-weight: 500; }
.dash-kpi-foot { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-secondary); }
.dash-kpi-foot strong { color: var(--text-primary); font-weight: 600; }
.dash-progress { flex: 1; height: 7px; border-radius: 4px; background: var(--surface-hover); overflow: hidden; }
.dash-progress span { display: block; height: 100%; border-radius: 4px; background: var(--brand-primary); transition: width var(--transition-slow); }
.dash-progress span.blue { background: var(--brand-blue); }
.dash-progress span.warn { background: var(--warning); }
.dash-progress span.full { background: var(--error); }
.dash-spark { width: 100%; height: 40px; display: block; }
.dash-spark path.line { fill: none; stroke: var(--brand-primary); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.dash-spark path.area { fill: var(--brand-soft); stroke: none; }

/* Main grid */
.dash-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; align-items: start; }
.dash-span-8 { grid-column: span 8; }
.dash-span-4 { grid-column: span 4; }
.dash-span-6 { grid-column: span 6; }
.dash-span-12 { grid-column: span 12; }
.dash-chart-wrap { position: relative; height: 280px; }
.dash-legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-secondary); }
.dash-legend span { display: inline-flex; align-items: center; gap: 6px; }
.dash-legend i { width: 10px; height: 10px; border-radius: 50%; background: var(--brand-primary); display: inline-block; }
.dash-select {
  height: 36px; padding: 0 30px 0 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-primary); color: var(--text-primary); font-family: inherit; font-size: 13px; font-weight: 600;
}

/* Plan card */
.dash-plan-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dash-plan-name { font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.dash-plan-price { font-size: 13px; color: var(--text-secondary); }
.dash-ring { position: relative; width: 112px; height: 112px; margin: 4px auto; }
.dash-ring svg { width: 112px; height: 112px; transform: rotate(-90deg); }
.dash-ring circle { fill: none; stroke-width: 10; }
.dash-ring .track { stroke: var(--surface-hover); }
.dash-ring .fill { stroke: var(--brand-primary); stroke-linecap: round; transition: stroke-dashoffset var(--transition-slow); }
.dash-ring-label { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.dash-ring-label strong { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.dash-ring-label span { font-size: 11px; color: var(--text-secondary); }
.dash-allow { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.dash-allow div { display: flex; justify-content: space-between; gap: 10px; }
.dash-allow span:first-child { color: var(--text-secondary); }
.dash-allow span:last-child { font-weight: 600; }
.dash-notice { font-size: 13px; padding: 10px 12px; border-radius: 12px; background: var(--warning-soft); color: var(--text-primary); }
.dash-notice.error { background: var(--error-soft); }

/* Activity */
.dash-timeline { display: flex; flex-direction: column; }
.dash-event { display: flex; align-items: flex-start; gap: 12px; padding: 10px 2px; border-top: 1px solid var(--border); text-align: left; background: none; border-left: 0; border-right: 0; border-bottom: 0; font-family: inherit; color: var(--text-primary); cursor: pointer; width: 100%; border-radius: 0; }
.dash-event:first-child { border-top: 0; }
.dash-event:hover .dash-event-title { color: var(--brand-ink); }
.dash-event-ico { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; }
.dash-event-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.dash-event-title { font-size: 14px; font-weight: 600; }
.dash-event-detail { font-size: 12.5px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-event-time { font-size: 12px; color: var(--text-tertiary); white-space: nowrap; }

/* Quick actions */
.dash-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.dash-action {
  display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 12px; border-radius: 14px;
  background: var(--surface-secondary); border: 1px solid var(--border); color: var(--text-primary);
  font-family: inherit; font-size: 14px; font-weight: 600; text-align: left; cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.dash-action:hover { border-color: var(--brand-primary); background: var(--surface-hover); }
.dash-action.primary { background: var(--brand-primary); border-color: transparent; color: #fff; }
.dash-action.primary:hover { background: var(--brand-primary-hover); }
.dash-action-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-primary); color: var(--brand-ink); flex-shrink: 0; }
.dash-action.primary .dash-action-ico { background: rgba(255, 255, 255, .18); color: #fff; }

/* Skeleton heights */
.dash-skel-line { height: 14px; margin: 6px 0; }
.dash-skel-big { height: 30px; width: 60%; }

/* Responsive */
@media (max-width: 1279px) {
  .dash-span-8, .dash-span-4 { grid-column: span 12; }
  .dash-kpis { gap: 12px; }
}
@media (max-width: 1023px) {
  .dash-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-span-6 { grid-column: span 12; }
}
@media (max-width: 767px) {
  .dash { gap: 14px; }
  .dash-hero { padding: 20px; }
  .dash-hero h1 { font-size: 26px; }
  .dash-kpis { gap: 12px; }
  .dash-kpi { padding: 14px; }
  .dash-kpi-value { font-size: 24px; }
  .dash-chart-wrap { height: 220px; }
  .dash-card { padding: 16px; }
}
@media (max-width: 380px) {
  .dash-kpis { grid-template-columns: minmax(0, 1fr); }
  .dash-actions { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) { .dash-kpi:hover { transform: none; } }

/* Hero illustration (decorative, wide screens only): rising teal bars + trend arrow */
@media (min-width: 1024px) {
  .dash-hero::after {
    content: ''; position: absolute; right: 230px; bottom: 0; width: 220px; height: 120px; pointer-events: none; opacity: .9;
    background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 220 120'><defs><linearGradient id='g' x1='0' y1='0' x2='0' y2='1'><stop offset='0' stop-color='%2300C2AC'/><stop offset='1' stop-color='%2300A895' stop-opacity='.15'/></linearGradient></defs><g fill='url(%23g)'><rect x='70' y='78' width='18' height='42' rx='4'/><rect x='96' y='62' width='18' height='58' rx='4'/><rect x='122' y='44' width='18' height='76' rx='4'/><rect x='148' y='28' width='18' height='92' rx='4'/><rect x='174' y='14' width='18' height='106' rx='4'/></g><path d='M10 104 C50 96 70 70 100 66 S150 40 196 8' fill='none' stroke='%2300A895' stroke-width='4' stroke-linecap='round' opacity='.8'/><path d='M184 6 L200 4 L196 20' fill='none' stroke='%2300A895' stroke-width='4' stroke-linecap='round' stroke-linejoin='round' opacity='.8'/></svg>") no-repeat right bottom / contain;
  }
  .dash-hero > * { position: relative; z-index: 1; }
}

/* Conversation-limit banner */
.dash-limit { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px 18px; border-radius: var(--radius-card); border: 1px solid transparent; }
.dash-limit.full { background: var(--error-soft); border-color: color-mix(in srgb, var(--error) 30%, transparent); }
.dash-limit.warn { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 30%, transparent); }
.dash-limit-icon { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; background: var(--surface-primary); }
.dash-limit.full .dash-limit-icon { color: var(--error-ink); }
.dash-limit.warn .dash-limit-icon { color: var(--warning-ink); }
.dash-limit-text { flex: 1 1 280px; min-width: 0; }
.dash-limit-text strong { display: block; font-size: 15px; font-weight: 650; color: var(--text-primary); }
.dash-limit-text p { margin: 3px 0 0; font-size: 13.5px; color: var(--text-secondary); line-height: 1.45; }
.dash-limit-actions { display: flex; gap: 8px; align-items: center; }
.dash-limit-note { font-size: 13px; color: var(--text-secondary); }
.dash-ring.warn .fill { stroke: var(--warning); }
.dash-ring.full .fill { stroke: var(--error); }
.dash-ring-caption { text-align: center; font-size: 12.5px; color: var(--text-secondary); margin-top: -12px; }
@media (max-width: 767px) { .dash-limit-actions { width: 100%; } .dash-limit-actions .btn { flex: 1; min-height: 40px; } }
