:root {
  --bg: #0b0b0d;
  --card: #131317;
  --muted: #a0a0ad;
  --text: #f3f3f6;
  --accent: #b7ff5a;
  --purple: #a78bfa;
  --cyan: #67e8f9;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

.app { max-width: 920px; margin: 0 auto; padding: 60px 14px 40px; }
.tariff-bar { position: sticky; top: 0; z-index: 20; height: 28px; border-radius: 8px; margin: 6px 0 10px; overflow: hidden; border: 1px solid #2a2a32; }
.tariff-bar.hidden { display: none; }
.tariff-bar .marquee { white-space: nowrap; animation: marquee 14s linear infinite; padding: 4px 10px; font-size: 13px; font-weight: 600; }
.tariff-green { background: rgba(183,255,90,0.15); color: #dfffb6; }
.tariff-yellow { background: rgba(255,232,137,0.18); color: #fff1b3; }
.tariff-red { background: rgba(255,99,132,0.15); color: #ffc1cc; }
@keyframes marquee { 0% { transform: translateX(0); } 100% { transform: translateX(-50%); } }
.tariff-actions { display: flex; justify-content: center; margin: 6px 0 8px; }
.btn.accent { background: linear-gradient(135deg, #b7ff5a, #7cffd6); color: #0a0a0a; font-weight: 800; }
.header { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px; }
.header .brand { font-weight: 700; font-size: 20px; color: #d6d6dc; }
.header .ai { color: var(--accent); }
/* AI-colored span to reuse accent */
.ai-colored { color: var(--accent); font-weight: 800; }
.header .title { margin-top: 6px; font-size: 24px; font-weight: 700; letter-spacing: -0.2px; grid-column: 1 / -1; }
.header .hello { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 42vw; }
.header .userbar { display: flex; align-items: center; gap: 8px; min-width: 0; }
.header .avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg,#3b3b44,#23232a); border: 1px solid #2a2a32; background-size: cover; background-position: center; }
.crm-slot { display: flex; justify-content: center; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; vertical-align: middle; margin-left: 6px; }
.dot.red { background: #ff9064; box-shadow: 0 0 0 2px rgba(255,100,100,0.15) inset; }
.dot.green { background: #b7ff5a; box-shadow: 0 0 0 2px rgba(183,255,90,0.15) inset; }
.dot.yellow { background: #ffe284; box-shadow: 0 0 0 2px rgba(255,226,132,0.18) inset; }
.debug-wrap { margin-top: 6px; display: flex; gap: 1px; flex-wrap: nowrap; align-items: center; }

.chips { display: grid; gap: 8px; margin-top: 16px; grid-template-columns: repeat(6, 1fr); }
.chip { padding: 6px 12px; border-radius: 999px; background: #1a1a1f; color: #dcdce3; cursor: pointer; border: 1px solid #23232a; width: 100%; text-align: center; }
.chip.active { background: #c6ff7a; color: #131317; font-weight: 700; }
.chip.current { border-color: rgba(183,255,90,0.5); }

/* === Months: exactly 2 rows (6 columns) on all screens === */
@media (max-width: 720px) {
  .chips { grid-template-columns: repeat(6, 1fr); }
}
@media (max-width: 420px) {
  .chips { grid-template-columns: repeat(6, 1fr); }
}

.range { margin-top: 8px; display: grid; gap: 8px; grid-template-columns: repeat(4, 1fr); align-items: center; }
.range-label { color: var(--muted); text-align: center; grid-column: 4; }
.btn { padding: 6px 9px; border-radius: 10px; border: 1px solid #24242c; background: #15151a; color: #e6e6ef; cursor: pointer; }
.btn.ghost { background: transparent; }
.btn.cyan { background: linear-gradient(135deg, #67e8f9, #38bdf8); color: #0a0a0a; font-weight: 800; border-color: transparent; }
.day-quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; grid-column: 1 / span 3; }
.day-chip { padding: 6px 12px; border: 1px solid #23232a; background: #1a1a1f; color: #dcdce3; border-radius: 999px; cursor: pointer; width: 100%; text-align: center; }
.day-chip.active { background: #c6ff7a; color: #131317; font-weight: 700; }

.kpi { margin-top: 10px; }
.kpi-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
.kpi-item { position: relative; background: transparent; border: 0; border-radius: 18px; padding: 0; display: grid; place-items: center; gap: 6px; overflow: visible; }
.kpi-item .neon { margin: 0 auto; }
.kpi-item .kpi-label { color: var(--muted); font-weight: 700; letter-spacing: 1px; font-size: 12px; }
/* Пояснення під KPI */
.kpi-note { color: #a8a8b8; font-size: 12px; text-align: center; margin-top: 6px; }
/* Неоновий круг */
.neon { position: relative; width: 96px; height: 96px; border-radius: 50%; isolation: isolate; }
.neon .core { position: absolute; inset: 0; border-radius: 50%; overflow: hidden; background: radial-gradient(64% 64% at 50% 45%, var(--c-soft, #1bff9a33) 0%, #071019 68%, transparent 76%); box-shadow: 0 0 60px var(--c-outer, #1cff9b88), 0 0 120px var(--c-outer2, #1cff9b44); filter: saturate(1.3); }
.neon canvas { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; display: block; }
.neon .rim { position: absolute; inset: 0; border-radius: 50%; pointer-events: none; box-shadow: inset 0 0 0 2px var(--c-edge, #20ff9d), inset 0 0 24px var(--c-edge, #20ff9d), 0 0 36px var(--c-outer, #1cff9b88); mix-blend-mode: screen; }
.neon .glare { position: absolute; inset: 0; border-radius: 50%; pointer-events: none; background: radial-gradient(80% 55% at 35% 20%, rgba(255,255,255,.25), rgba(255,255,255,0) 58%); mix-blend-mode: screen; }
.neon .center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; font-weight: 900; font-size: 22px; color: #ffffff; text-shadow: 0 0 10px var(--c-edge, #20ff9d), 0 0 24px var(--c-outer, #1cff9b88); pointer-events: none; letter-spacing: .2px; }
/* Колірні стани */
.kpi-item.green .neon { --c-soft:#1bff9a33; --c-edge:#20ff9d; --c-outer:#1cff9b88; --c-outer2:#1cff9b44; }
.kpi-item.yellow .neon { --c-soft:#fff04a33; --c-edge:#ffe54a; --c-outer:#ffe54a88; --c-outer2:#ffe54a44; }
.kpi-item.red .neon { --c-soft:#ff4d6a33; --c-edge:#ff824d; --c-outer:#ff4d6a88; --c-outer2:#ff4d6a44; }

.cards { margin-top: 14px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 720px) { .cards { grid-template-columns: repeat(3, 1fr); } }
.card.span-2 { grid-column: 1 / -1; }
@media (min-width: 720px) { .card.span-2 { grid-column: span 3; } }

.card {
  background: radial-gradient(1200px 240px at 80% 100%, rgba(183,255,90,0.06), transparent 50%) , var(--card);
  border: 1px solid #24242c;
  border-radius: 18px;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px 14px;
  align-items: center;
}
.card .icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: linear-gradient(135deg, #b7ff5a, #9cff32); color: #0a0a0a; font-weight: 800; }
.card .label { color: var(--muted); grid-column: 2; }
.card .value {
  font-size: 24px;
  font-weight: 800;
  /* Дозволяємо перенесення під іконку за рахунок висячого відступу */
  grid-column: 1 / -1;
  padding-left: calc(40px + 14px);
  text-indent: calc(-1 * (40px + 14px));
  letter-spacing: 0.3px;
}

.goal { margin-top: 12px; background: var(--card); border: 1px solid #24242c; border-radius: 18px; padding: 14px; }
.goal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.pill { background: #1a1a20; color: #dcdce3; padding: 6px 10px; border-radius: 999px; border: 1px solid #2a2a32; font-size: 12px; }
.goal-caption { color: var(--muted); margin-bottom: 10px; }
.editable { cursor: pointer; color: #e9ffe0; }
.editable:hover { text-decoration: underline; }
.goal-actions { margin: 6px 0 8px; }
.pay-subscription { display: flex; justify-content: center; margin: 8px 0; }
.btn.tiny { padding: 4px 8px; font-size: 12px; }
.progress { background: #1a1a22; height: 10px; border-radius: 999px; overflow: hidden; border: 1px solid #24242c; }
.bar { height: 100%; background: linear-gradient(90deg, #b7ff5a, #7cffd6); width: 0%; }
.progress.small { height: 8px; }
.today-goal { margin-top: 10px; }
.today-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.today-caption { margin-top: 6px; }

.chart { margin-top: 12px; background: var(--card); border: 1px solid #24242c; border-radius: 18px; padding: 14px; }
.sources { margin-top: 16px; background: var(--card); border: 1px solid #24242c; border-radius: 18px; padding: 14px; }
.sources-head { font-weight: 700; margin-bottom: 8px; }
.sources-list { display: grid; gap: 8px; }
.source-item { display: grid; grid-template-columns: 1fr auto; gap: 6px; padding: 10px; border: 1px solid #2a2a32; border-radius: 12px; background: #111115; }
.source-item .meta { color: #cfcfe3; }
.source-item .sum { font-weight: 800; }
.source-item .bar-wrap { grid-column: 1 / -1; height: 6px; background: #16161b; border-radius: 999px; overflow: hidden; border: 1px solid #24242c; }
.source-item .bar-inner { height: 100%; background: linear-gradient(90deg, #b7ff5a, #7cffd6); width: 0%; }
.legend { display: flex; gap: 18px; margin-bottom: 6px; color: #cfcfe3; }
.legend-item { display: flex; align-items: center; gap: 8px; }
.swatch { width: 16px; height: 8px; border-radius: 6px; display: inline-block; }
.swatch.purple { background: var(--purple); }
.swatch.cyan { background: var(--cyan); }

.footer { margin-top: 18px; display: grid; place-items: center; justify-items: center; text-align: center; gap: 6px; color: var(--muted); }
.muted { color: var(--muted); }

canvas { width: 100%; height: 320px; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: grid; place-items: center; }
.modal.hidden { display: none; }
.modal-card { width: min(720px, 92vw); background: var(--card); border: 1px solid #2a2a32; border-radius: 14px; padding: 12px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.pre { white-space: pre-wrap; color: #eaeaf5; background: #0e0e12; padding: 10px; border-radius: 10px; border: 1px solid #2a2a32; max-height: 60vh; overflow: auto; }

/* Blocked overlay */
.blocked { position: fixed; inset: 0; background: #0b0b0d; display: grid; place-items: center; z-index: 10000; }
.blocked.hidden { display: none; }
.blocked-card { width: min(720px, 92vw); background: var(--card); border: 1px solid #2a2a32; border-radius: 14px; padding: 16px; display: grid; gap: 12px; text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,0.5); }
.blocked-card .title { font-size: 18px; font-weight: 800; }
.blocked-card .desc { color: var(--muted); }
.blocked-card .actions { display: flex; justify-content: center; }

/* Pay modal */
.pay-body { display: grid; gap: 10px; }
.pay-note { color: #cfcfe3; }
.price-row { display: flex; align-items: baseline; gap: 10px; }
.price-row .old { color: #aaa; text-decoration: line-through; }
.price-row .new { color: #eaffb6; font-size: 20px; font-weight: 800; }
.pay-status { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.pay-actions { display: flex; justify-content: center; }
.pay-debug { margin-top: 6px; }
.pre.small { max-height: 160px; font-size: 12px; }

/* Payments */
.payments { margin-top: 12px; background: var(--card); border: 1px solid #24242c; border-radius: 18px; padding: 12px; }
.payments-title { font-weight: 700; margin-bottom: 8px; color: #e6e6ef; }
.payments-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 720px) { .payments-grid { grid-template-columns: repeat(3, 1fr); } }
.pay-card { background: var(--card); border: 1px solid #24242c; border-radius: 14px; padding: 12px 14px; display: grid; gap: 6px; }
.pay-card .label { color: var(--muted); }
.pay-card .value { font-size: 22px; font-weight: 800; }
.pay-card.paid { box-shadow: inset 0 0 0 1px rgba(183,255,90,0.15); }
.pay-card.partial { box-shadow: inset 0 0 0 1px rgba(103,232,249,0.15); }
.pay-card.unpaid { box-shadow: inset 0 0 0 1px rgba(255,99,132,0.12); }

/* Recent orders */
.recent { margin-top: 16px; background: var(--card); border: 1px solid #24242c; border-radius: 18px; padding: 14px; }
.recent-head { font-weight: 700; margin-bottom: 8px; }
.recent-list { display: grid; gap: 8px; }
.recent-item { display: grid; grid-template-columns: 1fr auto; gap: 4px; padding: 10px; border: 1px solid #2a2a32; border-radius: 12px; background: #111115; }
.recent-item .meta { color: #cfcfe3; }
.recent-item .sum { font-weight: 800; }
.recent-item .muted { color: var(--muted); }
.recent-item .client { grid-column: 1 / -1; color: #a6a6b8; font-size: 12px; }

/* Funnel */
.funnel { margin-top: 16px; background: var(--card); border: 1px solid #24242c; border-radius: 18px; padding: 14px; }
.funnel-head { font-weight: 700; margin-bottom: 8px; }
.funnel-list { display: grid; gap: 8px; }
.funnel-item { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 8px 10px; border: 1px solid #2a2a32; border-radius: 12px; background: #101015; }
.funnel-item .meta { color: #d6d6e5; font-weight: 700; }
.funnel-item .count { font-weight: 900; }
.funnel-item .bar-wrap { grid-column: 1 / -1; height: 8px; background: #14141a; border-radius: 999px; overflow: hidden; border: 1px solid #24242c; }
.funnel-item .bar-inner { height: 100%; width: 0%; background: linear-gradient(90deg, #67e8f9, #a78bfa); }
.funnel-item.s1 .bar-inner { background: linear-gradient(90deg, #b7ff5a, #7cffd6); }
.funnel-item.s2 .bar-inner { background: linear-gradient(90deg, #ffd166, #ff7b54); }
.funnel-item.s3 .bar-inner { background: linear-gradient(90deg, #67e8f9, #a78bfa); }
.funnel-item.s4 .bar-inner { background: linear-gradient(90deg, #ff6ac1, #ffa6b9); }
.funnel-item.s5 .bar-inner { background: linear-gradient(90deg, #a3ffae, #eaffb6); }

/* AI */
.ai-fab { position: fixed; right: 16px; bottom: 16px; width: 66px; height: 66px; border-radius: 50%; box-shadow: 0 10px 30px rgba(0,0,0,0.35); display: grid; place-items: center; cursor: pointer; }
.ai-fab .neon { width: 66px; height: 66px; }
.neon-cyan { --c-soft:#67e8f933; --c-edge:#67e8f9; --c-outer:#67e8f988; --c-outer2:#67e8f944; }
/* AI unread badge */
.ai-fab .badge { position: absolute; top: -2px; right: -2px; width: 14px; height: 14px; border-radius: 50%; background: #ff6b6b; box-shadow: 0 0 0 2px #0b0b0d; }
.hidden { display: none; }
.modal .actions { display: flex; align-items: center; gap: 8px; }
.input { padding: 8px 10px; border-radius: 10px; border: 1px solid #2a2a32; background: #0f0f14; color: #eaeaf5; }
.ai-msg { border: 1px solid #2a2a32; border-radius: 10px; padding: 10px; background: #0f0f14; margin-bottom: 8px; font-size: 14px; line-height: 1.45; }
.ai-msg .meta { color: #a6a6b8; font-size: 12px; margin-bottom: 6px; display: flex; justify-content: space-between; }

/* CRM modal */
.crm-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 8px 0 12px; }
.crm-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 14px; border: 1px solid #2a2a32; border-radius: 12px; background: #0e0e14; cursor: pointer; }
.crm-item:hover { background: #12121a; }
.crm-item .name { font-size: 16px; color: #d1d5db; font-weight: 700; }
.crm-item.connected { border-color: rgba(183,255,90,0.6); box-shadow: inset 0 0 0 1px rgba(183,255,90,0.15); }
.crm-item.connected .name::after { content: '✓'; color: #c8ff7d; font-weight: 900; margin-left: 6px; }
.crm-setup { border-top: 1px solid #2a2a32; padding-top: 12px; }
.crm-setup-head { display: flex; gap: 8px; align-items: baseline; margin-bottom: 8px; }
.crm-setup .field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.crm-setup input { padding: 10px 12px; border-radius: 10px; border: 1px solid #2a2a32; background: #0e0e14; color: #fff; }
.crm-setup .small { font-size: 12px; }

