/* Met4 Pro Web — под телефон в первую очередь. Цвета — фирменная тема программы и сайта met4pro.pages.dev. */
:root {
  --bg: #0D0F1A;
  --side: #0A0C16;
  --card: #141729;
  --card-2: #1A1E36;
  --line: #232842;
  --text: #E7E9F5;
  --muted: #9AA0C0;
  --accent: #6C5CE7;
  --accent-2: #8475F2;
  --accent-soft: rgba(108, 92, 231, .16);
  --up: #2DD4BF;
  --down: #F87171;
  --warn: #F5B94B;
  --on-accent: #FFFFFF;
  --radius: 18px;
  --radius-sm: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input, textarea { font: inherit; color: inherit; }
a { color: var(--accent-2); }

#app { min-height: 100%; max-width: 560px; margin: 0 auto; }
.splash { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--muted); }

/* экраны */
.screen { min-height: 100vh; padding: calc(var(--safe-top) + 20px) 16px calc(var(--safe-bottom) + 24px); display: flex; flex-direction: column; gap: 16px; }
.screen.with-tabs { padding-bottom: calc(var(--safe-bottom) + 88px); }
.screen.center { justify-content: center; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; letter-spacing: -.03em; }
.brand img { width: 34px; height: 34px; }
.brand .four { color: var(--accent-2); }
.pill { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; padding: 3px 8px; border-radius: 999px; background: var(--accent-soft); border: 1px solid rgba(108, 92, 231, .45); color: var(--accent-2); }

h1 { font-size: 26px; line-height: 1.2; margin: 4px 0 0; letter-spacing: -.02em; }
h2 { font-size: 18px; margin: 0; }
.lead { color: var(--muted); margin: 0; }
.small { font-size: 13px; color: var(--muted); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; }

label.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
textarea, input[type=text], input[type=password], input[type=tel] {
  width: 100%; background: var(--side); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 14px; font-size: 16px; /* 16px — iOS не увеличивает страницу при вводе */
  outline: none;
}
textarea { min-height: 96px; resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: 14px; word-break: break-all; }
textarea:focus, input:focus { border-color: var(--accent); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px; border-radius: 14px; border: 1px solid var(--line); background: var(--card-2); font-weight: 700; cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.link { background: none; border: none; color: var(--accent-2); min-height: 40px; padding: 0 4px; }
.btn.danger { color: var(--down); }
.btn[disabled] { opacity: .55; cursor: default; }
.btn.block { width: 100%; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.msg { border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px; }
.msg.error { background: rgba(248, 113, 113, .12); color: #FCA5A5; border: 1px solid rgba(248, 113, 113, .35); }
.msg.ok { background: rgba(45, 212, 191, .12); color: #99F6E4; border: 1px solid rgba(45, 212, 191, .35); }
.msg.info { background: var(--accent-soft); color: var(--text); border: 1px solid rgba(108, 92, 231, .35); }
.msg:empty { display: none; }

/* ПИН */
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 8px 0; }
.pin-dots span { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--muted); }
.pin-dots span.on { background: var(--accent-2); border-color: var(--accent-2); }
.pin-dots.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 300px; margin: 0 auto; width: 100%; }
.keypad button { height: 64px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); font-size: 26px; font-weight: 600; cursor: pointer; }
.keypad button:active { background: var(--card-2); }
.keypad button.ghost { background: none; border: none; font-size: 15px; color: var(--muted); }

/* аккаунт */
.account { display: flex; align-items: center; gap: 12px; }
.avatar { width: 52px; height: 52px; border-radius: 50%; background: var(--card-2); object-fit: cover; flex: none; display: grid; place-content: center; font-weight: 800; color: var(--accent-2); }
.account .name { font-weight: 700; }
.choice { text-align: left; width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; cursor: pointer; }
.choice:active, .choice.sel { border-color: var(--accent); }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; }
.tile .k { font-size: 13px; color: var(--muted); }
.tile .v { font-size: 24px; font-weight: 800; letter-spacing: -.02em; margin-top: 4px; }

.list { display: flex; flex-direction: column; }
.list > div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list > div:last-child { border-bottom: none; }
.list .k { color: var(--muted); }
.list .v { text-align: right; font-weight: 600; word-break: break-word; }

details { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; }
details summary { cursor: pointer; font-weight: 700; }
details[open] summary { margin-bottom: 10px; }
ol.steps { margin: 0; padding-left: 20px; display: grid; gap: 6px; color: var(--muted); font-size: 14px; }

/* нижние вкладки */
nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; background: rgba(10, 12, 22, .94); border-top: 1px solid var(--line); padding: 6px 8px calc(var(--safe-bottom) + 6px); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); z-index: 10; }
nav.tabs .inner { display: flex; width: 100%; max-width: 560px; }
nav.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; font-size: 11px; color: var(--muted); text-decoration: none; font-weight: 600; }
nav.tabs a svg { width: 24px; height: 24px; }
nav.tabs a.on { color: var(--accent-2); }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); display: grid; place-content: center; cursor: pointer; }
.icon-btn svg { width: 20px; height: 20px; }
.badge-demo { font-size: 12px; font-weight: 700; color: var(--warn); border: 1px solid rgba(245, 185, 75, .4); border-radius: 999px; padding: 2px 10px; }
.spinner { width: 18px; height: 18px; border: 2px solid rgba(255, 255, 255, .3); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Сводка */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 9px 14px; font-size: 14px; font-weight: 700; cursor: pointer; }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.period { margin: -6px 0 0; }
.tile .d { font-size: 12.5px; font-weight: 700; margin-top: 4px; }
.tile .d.up { color: var(--up); }
.tile .d.down { color: var(--down); }
.tile .d.muted { color: var(--muted); font-weight: 600; }
.small-tiles .tile .v { font-size: 20px; }
.list .v.num { white-space: nowrap; flex: none; }
.chart svg { width: 100%; height: 110px; display: block; }
.chart rect { fill: var(--accent-2); }

/* Контент, Stories, Аккаунт, Аудитория */
.row.between { justify-content: space-between; }
.post { gap: 10px; }
.caption { margin: 0; font-size: 15px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.fmt { font-size: 12px; font-weight: 800; letter-spacing: .04em; border-radius: 999px; padding: 3px 10px; background: var(--card-2); }
.fmt.reels { color: var(--accent-2); background: var(--accent-soft); }
.fmt.feed { color: var(--up); background: rgba(45, 212, 191, .12); }
.fmt.story { color: var(--warn); background: rgba(245, 185, 75, .12); }
.mgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 10px; }
.mgrid > div { display: flex; flex-direction: column; min-width: 0; }
.mgrid .k { font-size: 11.5px; color: var(--muted); }
.mgrid .v { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn.small-btn { min-height: 38px; padding: 0 12px; font-size: 14px; border-radius: 10px; text-decoration: none; color: var(--text); }
.sort-label { align-self: center; flex: none; }
.table-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table.t { border-collapse: collapse; width: 100%; font-size: 12.5px; white-space: nowrap; }
table.t th { text-align: right; color: var(--muted); font-weight: 600; padding: 6px 3px; font-size: 11.5px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); }
table.t td { text-align: right; padding: 7px 3px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
table.t th:first-child, table.t td:first-child { text-align: left; }
table.t td.up { color: var(--up); }
table.t td.down { color: var(--down); }
.bar-row { display: flex; flex-direction: column; gap: 4px; }
.bar { height: 8px; border-radius: 99px; background: var(--card-2); overflow: hidden; }
.bar .fill { display: block; height: 100%; background: var(--accent-2); border-radius: 99px; }
.offscreen { position: fixed; left: -9999px; top: 0; }
a.icon-btn { color: var(--text); }
nav.tabs a span { white-space: nowrap; }

/* Каналы */
.channels { display: flex; flex-direction: column; gap: 8px; }
.channel { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "k v" "n v"; align-items: center; column-gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--card-2); border: 1px solid var(--line); color: var(--text); text-decoration: none; }
.channel .k { grid-area: k; font-weight: 700; }
.channel .v { grid-area: v; font-size: 20px; font-weight: 800; white-space: nowrap; }
.channel .small { grid-area: n; font-size: 12.5px; }
.post .name { font-weight: 700; }
.post.own { border-color: var(--accent); }
.add-row input { flex: 1; min-width: 0; }

/* «Что произошло», цели, срок токена */
.story h3 { font-size: 13px; color: var(--accent-2); margin: 10px 0 2px; text-transform: none; }
.story h3:first-child { margin-top: 0; }
.story p { margin: 0; font-size: 15px; }
.story ol { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: 15px; }
.pillx { font-size: 11.5px; font-weight: 800; border-radius: 999px; padding: 2px 9px; }
.pillx.ok { color: var(--up); background: rgba(45, 212, 191, .14); }
.pillx.warn { color: var(--warn); background: rgba(245, 185, 75, .14); }
.pillx.nd { color: var(--muted); background: var(--card-2); }
.msg.token { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.msg.token .btn.link { min-height: 0; padding: 0; }
.kpi-row { flex-direction: row; align-items: center; justify-content: space-between; gap: 10px; font-weight: 600; }
.kpi-row input { max-width: 120px; text-align: right; }

/* ИИ-разбор */
.row.actions > .btn { flex: 1; text-decoration: none; }
a.btn.primary { color: var(--on-accent); }
.md { display: flex; flex-direction: column; gap: 6px; font-size: 15px; }
.md h3 { margin: 10px 0 2px; font-size: 16px; }
.md h3:first-child { margin-top: 0; }
.md p { margin: 0; }
.md ul, .md ol { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.md.live { white-space: pre-wrap; color: var(--muted); }
.qa-list { display: flex; flex-direction: column; gap: 12px; }
.qa { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.qa .q { margin: 0; font-weight: 700; color: var(--accent-2); }

/* Отчёт: на экране — светлый лист, при печати — только он */
.doc { background: #fff; color: #1a1d2e; border-radius: var(--radius); padding: 18px 16px; display: flex; flex-direction: column; gap: 8px; }
.doc h2 { color: #4b3fd1; font-size: 16px; margin: 12px 0 2px; }
.doc .md h3 { color: #1a1d2e; }
.doc-head { display: flex; gap: 12px; align-items: center; border-bottom: 2px solid #6C5CE7; padding-bottom: 10px; }
.doc-head img { width: 40px; height: 40px; }
.doc-title { font-size: 20px; font-weight: 800; }
.doc-sub { font-size: 12.5px; color: #5a607e; margin: 0; }
.doc-t { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.doc-t th { background: #6C5CE7; color: #fff; text-align: left; padding: 6px; font-weight: 700; }
.doc-t td { padding: 6px; border-bottom: 1px solid #e3e5f0; }
.doc-t td:not(:first-child), .doc-t th:not(:first-child) { text-align: right; }
.doc-t td:not(:first-child) { white-space: nowrap; }
.doc-t th, .doc-t td { padding: 5px 4px; font-size: 11.5px; vertical-align: top; }
.doc { overflow-x: auto; }
.doc-foot { font-size: 11px; color: #7a8099; border-top: 1px solid #e3e5f0; padding-top: 8px; margin-top: 8px; }
@media print {
  body { background: #fff; }
  .topbar, nav.tabs, .no-print, .back, .chips, .period { display: none !important; }
  .screen { padding: 0 !important; min-height: 0; }
  #app { max-width: none; }
  .doc { border-radius: 0; padding: 0; }
  .doc-t, .doc h2 { break-inside: avoid; }
}

@media (min-width: 600px) {
  .screen { padding-left: 24px; padding-right: 24px; }
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }
.back { color: var(--accent-2); text-decoration: none; font-weight: 700; font-size: 15px; margin-bottom: -8px; }
