/* AI аналитик Mircli — веб-чат. Светлая тема, зелёный акцент, по макету. */
:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --border: #e6e8eb;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #16a34a;
  --accent-hover: #15803d;
  --accent-weak: #e8f7ee;
  --user-bubble: #dcf5e3;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }

/* ── общие элементы ─────────────────────────────── */
.btn { font: inherit; cursor: pointer; border-radius: 12px; border: 1px solid var(--border);
  background: var(--panel); padding: 10px 14px; transition: background .15s, border-color .15s; }
.btn:hover { background: #f9fafb; }
.btn--primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--primary:disabled { opacity: .6; cursor: default; }
.btn--ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn--ghost:hover { background: #f1f3f5; }
.btn--sm { padding: 6px 10px; font-size: 13px; }
.icon-btn { border: none; background: transparent; cursor: pointer; font-size: 18px; color: var(--muted);
  width: 40px; height: 40px; border-radius: 50%; }
.icon-btn:hover:not(:disabled) { background: #f1f3f5; }
.icon-btn:disabled { opacity: .45; cursor: default; }

.brand { display: flex; align-items: center; gap: 12px; }
.brand__logo { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
  background: var(--accent-weak); color: var(--accent); font-size: 20px; flex: none; }
.brand__title { font-weight: 700; font-size: 17px; }
.brand__sub { color: var(--muted); font-size: 12.5px; }

/* ── раскладка ──────────────────────────────────── */
.app { display: flex; height: 100vh; overflow: hidden; }

.sidebar { width: 300px; flex: none; background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 16px; gap: 14px; }
.btn--newchat { display: flex; align-items: center; justify-content: center; font-weight: 600;
  border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.history-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  font-weight: 600; margin-top: 2px; }
.chat-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; display: flex;
  flex-direction: column; gap: 4px; }
.chat-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 10px; border-radius: 11px;
  cursor: pointer; position: relative; }
.chat-item:hover { background: #f5f6f8; }
.chat-item.active { background: var(--accent-weak); }
.chat-item__icon { color: var(--muted); flex: none; margin-top: 1px; }
.chat-item.active .chat-item__icon { color: var(--accent); }
.chat-item__body { min-width: 0; flex: 1; }
.chat-item__title { font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.chat-item__time { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.chat-item__del { position: absolute; right: 6px; top: 8px; opacity: 0; border: none; background: transparent;
  cursor: pointer; color: var(--muted); font-size: 15px; padding: 2px 6px; border-radius: 6px; }
.chat-item:hover .chat-item__del { opacity: 1; }
.chat-item__del:hover { background: #fee2e2; color: #dc2626; }

.sidebar-footer { border-top: 1px solid var(--border); padding-top: 12px; display: flex;
  align-items: center; justify-content: space-between; }
.userbox { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 500; }
.userbox__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { height: 58px; border-bottom: 1px solid var(--border); background: var(--panel);
  display: flex; align-items: center; gap: 12px; padding: 0 18px; flex: none; }
.topbar__title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.badge { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; font-size: 12px;
  padding: 3px 9px; border-radius: 999px; font-weight: 600; }
.burger { display: none; }

.conversation { flex: 1; overflow-y: auto; padding: 24px clamp(16px, 6vw, 80px); }

/* приветствие + чипы */
.welcome { max-width: 900px; margin: 8px auto 20px; }
.welcome__head { display: flex; gap: 16px; align-items: flex-start; }
.avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font-size: 22px; }
.avatar--bot { background: var(--accent-weak); }
.welcome__h1 { font-size: 21px; margin: 2px 0 6px; }
.welcome__sub { color: var(--muted); margin: 0; max-width: 640px; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 0 60px; }
.chip { border: 1px solid var(--border); background: var(--panel); border-radius: 999px;
  padding: 9px 15px; font: inherit; font-size: 13.5px; cursor: pointer; color: var(--text);
  transition: background .15s, border-color .15s; }
.chip:hover { background: var(--accent-weak); border-color: #bbf7d0; color: var(--accent-hover); }

/* сообщения */
.messages { max-width: 900px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.msg { display: flex; gap: 12px; max-width: 100%; }
.msg--user { flex-direction: row-reverse; }
.msg__avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-weak);
  display: grid; place-items: center; flex: none; font-size: 17px; }
.msg--user .msg__avatar { display: none; }
.bubble { padding: 12px 15px; border-radius: 14px; max-width: 76%; white-space: normal;
  word-wrap: break-word; box-shadow: var(--shadow); }
.msg--bot .bubble { background: var(--panel); border: 1px solid var(--border); border-top-left-radius: 4px; }
.msg--user .bubble { background: var(--user-bubble); border-top-right-radius: 4px; }
.bubble p { margin: 0 0 8px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul { margin: 6px 0; padding-left: 20px; }
.bubble li { margin: 2px 0; }
.bubble code { background: #f1f5f9; padding: 1px 5px; border-radius: 5px; font-size: 13px; }
.bubble table { border-collapse: collapse; margin: 6px 0; font-size: 13.5px; display: block;
  overflow-x: auto; }
.bubble th, .bubble td { border: 1px solid var(--border); padding: 5px 9px; text-align: left; white-space: nowrap; }
.msg__meta { color: var(--muted); font-size: 11.5px; margin-top: 5px; }
.msg--user .msg__meta { text-align: right; }

/* индикатор набора */
.typing { display: inline-flex; gap: 4px; align-items: center; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: #cbd5e1; animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .3; } 30% { opacity: 1; } }

/* composer */
.composer { border-top: 1px solid var(--border); background: var(--panel); padding: 14px clamp(16px, 6vw, 80px); flex: none; }
.composer__box { max-width: 900px; margin: 0 auto; display: flex; align-items: flex-end; gap: 8px;
  border: 1px solid var(--border); border-radius: 16px; padding: 6px 6px 6px 16px; background: #fff; }
.composer__box:focus-within { border-color: #bbf7d0; box-shadow: 0 0 0 3px var(--accent-weak); }
#input { flex: 1; border: none; outline: none; resize: none; font: inherit; padding: 8px 0;
  max-height: 160px; background: transparent; color: var(--text); }
.send-btn { border: none; background: var(--accent); color: #fff; width: 42px; height: 42px;
  border-radius: 50%; cursor: pointer; font-size: 17px; flex: none; transition: background .15s; }
.send-btn:hover { background: var(--accent-hover); }
.send-btn:disabled { opacity: .5; cursor: default; }
.disclaimer { max-width: 900px; margin: 8px auto 0; color: var(--muted); font-size: 12px; text-align: center; }

/* ── страница входа ─────────────────────────────── */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login-card { background: var(--panel); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: var(--shadow); padding: 28px; width: 100%; max-width: 380px; display: flex;
  flex-direction: column; gap: 14px; }
.brand--login { margin-bottom: 4px; }
.login-h1 { font-size: 20px; margin: 4px 0 2px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; color: var(--muted); }
.field input { font: inherit; color: var(--text); padding: 11px 13px; border: 1px solid var(--border);
  border-radius: 11px; outline: none; }
.field input:focus { border-color: #bbf7d0; box-shadow: 0 0 0 3px var(--accent-weak); }
.login-error { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; border-radius: 10px;
  padding: 9px 12px; font-size: 13.5px; }
.login-note { color: var(--muted); font-size: 12.5px; margin: 2px 0 0; text-align: center; }

/* ── левое вертикальное меню разделов ───────────── */
.nav { display: flex; flex-direction: column; gap: 2px; }
.tab { display: flex; align-items: center; gap: 11px; width: 100%; text-align: left; border: none;
  background: transparent; font: inherit; font-size: 14px; font-weight: 500; color: var(--text);
  padding: 10px 12px; border-radius: 10px; cursor: pointer; transition: background .12s, color .12s; }
.tab:hover { background: #f3f5f7; }
.tab.tab--active { background: var(--accent-weak); color: var(--accent-hover); font-weight: 600; }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.nav__ic { font-size: 17px; width: 22px; text-align: center; flex: none; }
.nav-sep { height: 1px; background: var(--border); margin: 2px 0; }
.side-view { display: flex; flex-direction: column; gap: 14px; flex: 1; min-height: 0; }
.side-view[hidden] { display: none; }   /* класс display:flex иначе перебивает атрибут hidden */

/* ── панель дашбордов (main) ────────────────────── */
.dash-panel { flex: 1; overflow-y: auto; padding: 24px clamp(16px, 6vw, 80px); }
.dash-empty { max-width: 560px; margin: 6vh auto 0; text-align: center; display: flex;
  flex-direction: column; align-items: center; gap: 10px; }
.dash-empty .avatar { width: 56px; height: 56px; font-size: 28px; }
.dash-empty .welcome__sub { text-align: center; }
.dash-empty .btn--primary { margin-top: 8px; }
.dash-result { max-width: 720px; margin: 0 auto; }
.dash-grid { max-width: 980px; margin: 0 auto; display: grid; gap: 16px; align-items: start;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.dcard--building { color: var(--muted); display: flex; align-items: center; gap: 12px; }
.dash-empty2 { color: var(--muted); text-align: center; padding: 44px 20px; grid-column: 1 / -1; }
.dcard { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.dcard__title { font-size: 18px; font-weight: 700; }
.dcard__sub { color: var(--muted); font-size: 13.5px; margin-top: -6px; }
.dcard__open { display: inline-flex; align-items: center; gap: 8px; align-self: flex-start; text-decoration: none; }
.dcard__actions { display: flex; flex-wrap: wrap; gap: 8px; border-top: 1px solid var(--border); padding-top: 14px; }
.dcard__actions .btn { display: inline-flex; align-items: center; gap: 6px; }
.dcard__hist-btn { margin-left: auto; color: var(--muted); }
/* попап истории правок */
.hist-scroll { max-height: 60vh; overflow-y: auto; }
.hist-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.hist-list li { display: flex; gap: 10px; align-items: flex-start; }
.hist-tag { flex: none; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em;
  color: var(--accent-hover); background: var(--accent-weak); border-radius: 6px; padding: 3px 8px; margin-top: 1px; }
.hist-tag--edit { color: #b45309; background: #fff7ed; }
.hist-text { font-size: 14px; line-height: 1.45; }
.hist-note { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border);
  font-size: 12.5px; color: var(--muted); }
.btn--danger:hover { background: #fee2e2; border-color: #fecaca; color: #dc2626; }

/* спиннер сборки */
.dash-building { max-width: 560px; margin: 8vh auto 0; text-align: center; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 14px; }
.spinner { width: 38px; height: 38px; border: 4px solid var(--accent-weak); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── точки роста ────────────────────────────────── */
.side-note { color: var(--muted); font-size: 12.5px; line-height: 1.45; margin: 4px 2px; }
.growth-panel { flex: 1; overflow-y: auto; padding: 24px clamp(16px, 6vw, 80px); }
.growth-head { max-width: 900px; margin: 0 auto 18px; display: flex; gap: 16px; align-items: flex-start;
  justify-content: space-between; flex-wrap: wrap; }
.growth-head .welcome__sub { max-width: 640px; }
.growth-head .btn--primary { flex: none; white-space: nowrap; }
.growth-meta { max-width: 900px; margin: 0 auto 10px; color: var(--muted); font-size: 12.5px; }
.growth-cards { max-width: 900px; margin: 0 auto; display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.gcard { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 8px;
  border-left: 4px solid var(--accent); }
.gcard__top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.gcard__cat { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  color: var(--accent); background: var(--accent-weak); padding: 2px 8px; border-radius: 999px; }
.gcard__impact { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; margin-left: auto; }
.gcard__impact.high { background: #fef3c7; color: #b45309; }
.gcard__impact.mid { background: #eef2f7; color: var(--muted); }
.gcard__title { font-weight: 700; font-size: 15px; }
.gcard__insight { font-size: 13.5px; color: #374151; }
.gcard__action { font-size: 13px; background: var(--accent-weak); border-radius: 9px; padding: 8px 10px; }
.gcard__action b { color: var(--accent-hover); }
.growth-filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.gfilter { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--border);
  background: var(--panel); border-radius: 999px; padding: 6px 8px 6px 13px; font: inherit; font-size: 13px;
  color: var(--text); cursor: pointer; transition: background .12s, border-color .12s; }
.gfilter:hover { background: #f3f5f7; }
.gfilter--on { background: var(--accent-weak); border-color: #bbf7d0; color: var(--accent-hover); font-weight: 600; }
.gfilter__n { font-size: 11.5px; color: var(--muted); background: #eef1f4; border-radius: 999px;
  padding: 1px 7px; min-width: 20px; text-align: center; font-weight: 600; }
.gfilter--on .gfilter__n { background: #fff; color: var(--accent-hover); }
.growth-empty { color: var(--muted); padding: 28px; text-align: center; }
.gcard__foot { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--border);
  padding-top: 10px; margin-top: 2px; }
.gcard__status { font: inherit; font-size: 12.5px; padding: 5px 8px; border: 1px solid var(--border);
  border-radius: 8px; background: #fff; color: var(--text); cursor: pointer; }
.gcard__more { margin-left: auto; }
/* цвет левой полосы и вид по статусу */
.gcard[data-status="in_progress"] { border-left-color: #f59e0b; }
.gcard[data-status="done"] { border-left-color: #16a34a; opacity: .72; }
.gcard[data-status="dismissed"] { border-left-color: #9ca3af; opacity: .55; }
.gcard[data-status="dismissed"] .gcard__title { text-decoration: line-through; }
.growth-building { max-width: 560px; margin: 8vh auto; text-align: center; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 14px; }
/* модалка «Подробнее» */
.modal__card--wide { max-width: 760px; }
.growth-detail { max-height: 60vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 12px;
  padding: 6px 14px; background: #fbfcfd; }
.growth-detail .bubble { box-shadow: none; padding: 8px 2px; }

/* ── модалка ────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(16, 24, 40, .45); }
.modal__card { position: relative; background: var(--panel); border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.25);
  width: 100%; max-width: 520px; padding: 22px; display: flex; flex-direction: column; gap: 12px; }
.modal__title { font-size: 17px; font-weight: 700; }
.modal__card textarea { font: inherit; border: 1px solid var(--border); border-radius: 12px; padding: 12px;
  resize: vertical; min-height: 90px; outline: none; }
.modal__card textarea:focus { border-color: #bbf7d0; box-shadow: 0 0 0 3px var(--accent-weak); }
.modal__hint { color: var(--muted); font-size: 12.5px; }
.modal__err { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; border-radius: 10px; padding: 8px 11px; font-size: 13px; }
.modal__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* уважение к настройке «меньше движения» */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ── мобильная ──────────────────────────────────── */
@media (max-width: 760px) {
  .sidebar { position: fixed; z-index: 20; height: 100%; left: 0; top: 0; transform: translateX(-100%);
    transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.15); }
  .app.sidebar-open .sidebar { transform: translateX(0); }
  .burger { display: grid; place-items: center; }
  .bubble { max-width: 88%; }
  .chips { margin-left: 0; }
}
