/* Reports Bot Mini App — темна «неонова» тема в смарагдовій гамі: пілюльна шапка зі світінням, великі закруглені картки, градієнтні акценти.
   Тема завжди темна (не залежить від теми Telegram), щоб вигляд був однаковим на телефоні й на ПК. */
:root {
  --bg: #030907; --card: #0a1713; --card2: #0d1e19; --line: rgba(52, 211, 153, .14); --line2: rgba(52, 211, 153, .34);
  --text: #ecfdf5; --hint: #86a698; --em: #10b981; --em2: #34d399; --em3: #6ee7b7; --teal: #14b8a6; --cyan: #22d3ee;
  --grad: linear-gradient(135deg, #10b981 0%, #14b8a6 55%, #22d3ee 100%);
  --good: #34d399; --bad: #fb7185; --warn: #fbbf24; --r: 22px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: radial-gradient(900px 520px at 8% -8%, rgba(16, 185, 129, .20), transparent 62%), radial-gradient(800px 480px at 100% 6%, rgba(20, 184, 166, .13), transparent 58%), radial-gradient(700px 500px at 50% 110%, rgba(16, 185, 129, .08), transparent 60%), var(--bg);
  background-attachment: fixed; color: var(--text); min-height: 100vh;
  font: 15px/1.45 "Segoe UI", ui-sans-serif, system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif; padding-bottom: env(safe-area-inset-bottom);
}
button, input { font: inherit; color: inherit; }
a { color: var(--em3); }
#app { max-width: 1240px; margin: 0 auto; }
.boot, .empty { padding: 40px 16px; text-align: center; color: var(--hint); }
.err { margin: 24px 16px; padding: 18px; border-radius: var(--r); background: var(--card); border: 1px solid var(--line); text-align: center; }
.err button { margin-top: 12px; }
.page { padding: 0 16px 40px; }
.page.narrow { max-width: 600px; margin: 0 auto; }

/* шапка-«пілюля» */
.topbar { position: sticky; top: 0; z-index: 20; padding: calc(10px + var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px)) 14px 8px; }
.pill {
  display: flex; align-items: center; gap: 12px; padding: 8px 10px 8px 10px; border-radius: 999px; border: 1px solid var(--line2);
  background: linear-gradient(90deg, rgba(4, 12, 10, .92) 0%, rgba(8, 44, 33, .92) 52%, rgba(4, 12, 10, .92) 100%);
  box-shadow: 0 10px 40px rgba(16, 185, 129, .20), inset 0 0 36px rgba(16, 185, 129, .08); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.logo { width: 38px; height: 38px; border-radius: 50%; background: var(--grad); color: #03140e; font-weight: 900; font-size: 19px; display: flex; align-items: center; justify-content: center; flex: none; box-shadow: 0 0 22px rgba(52, 211, 153, .55); }
.brand { flex: 1; min-width: 0; }
.bname { font-weight: 800; font-size: 17px; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bsub { color: var(--em3); font-size: 12px; opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tools { display: flex; gap: 8px; flex: none; }
.iconbtn { border: 1px solid var(--line); background: rgba(16, 185, 129, .10); width: 38px; height: 38px; border-radius: 50%; font-size: 18px; cursor: pointer; flex: none; color: var(--em3); transition: box-shadow .15s, border-color .15s; }
.iconbtn:hover { border-color: var(--line2); box-shadow: 0 0 18px rgba(52, 211, 153, .35); }

/* головний екран */
.hero { text-align: center; padding: 34px 8px 8px; }
.badge-pill { display: inline-block; padding: 7px 16px; border: 1px solid var(--line2); border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--em2); background: rgba(16, 185, 129, .06); }
.hero h1 { margin: 18px 0 10px; font-size: clamp(30px, 7vw, 52px); line-height: 1.08; font-weight: 800; letter-spacing: -.025em; }
.grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent; }
.hero p { margin: 0 auto; max-width: 560px; color: var(--hint); font-size: 15px; }
.block { margin-top: 30px; }
.block h2 { margin: 0 0 14px; font-size: 13px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--hint); }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.tilecard {
  display: flex; flex-direction: column; align-items: flex-start; gap: 12px; padding: 16px; min-height: 104px; text-align: left; cursor: pointer; border-radius: var(--r); border: 1px solid var(--line);
  background: linear-gradient(160deg, var(--card2) 0%, var(--card) 70%); transition: border-color .15s, box-shadow .15s, transform .15s;
}
.tilecard:hover { border-color: var(--line2); box-shadow: 0 0 28px rgba(16, 185, 129, .16); transform: translateY(-1px); }
.tilecard:active { transform: scale(.985); }
.ticon { width: 44px; height: 44px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 21px; background: rgba(16, 185, 129, .12); border: 1px solid var(--line); }
.ttext { font-weight: 700; font-size: 14px; line-height: 1.25; }
.tilecard.accent { background: linear-gradient(135deg, rgba(16, 185, 129, .35), rgba(20, 184, 166, .18)); border-color: var(--line2); }
.tilecard.accent .ticon { background: var(--grad); color: #03140e; border-color: transparent; }
.tilecard.danger .ttext { color: var(--bad); }
.tiles.actions { margin-top: 14px; }

/* перемикачі, пошук */
.seg { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 4px; margin-bottom: 12px; }
.seg button { flex: 1; border: 0; background: none; padding: 9px 8px; border-radius: 999px; color: var(--hint); font-weight: 700; cursor: pointer; }
.seg button.on { background: var(--grad); color: #03140e; box-shadow: 0 6px 20px rgba(16, 185, 129, .35); }
.search { width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 12px 18px; outline: none; margin-bottom: 14px; }
.search:focus, .field input:focus, .tinput:focus { border-color: var(--line2); box-shadow: 0 0 0 3px rgba(16, 185, 129, .15); }
.search::placeholder, .tinput::placeholder { color: var(--hint); }

/* списки */
.list.projects { display: grid; grid-template-columns: 1fr; gap: 12px; }
.row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; cursor: pointer; transition: background .12s; }
.list.projects .row { border: 1px solid var(--line); border-radius: var(--r); background: linear-gradient(160deg, var(--card2), var(--card) 70%); transition: border-color .15s, box-shadow .15s; }
.list.projects .row:hover { border-color: var(--line2); box-shadow: 0 0 28px rgba(16, 185, 129, .14); }
.list.projects .empty, .list.projects .boot, .list.projects .err { grid-column: 1 / -1; }
.list:not(.projects) { margin: 14px 0 28px; border: 1px solid var(--line); border-radius: var(--r); background: var(--card); overflow: hidden; }
.list:not(.projects) .row { border-bottom: 1px solid var(--line); }
.list:not(.projects) .row:last-child { border-bottom: 0; }
.row:active { background: rgba(16, 185, 129, .07); }
.avatar { width: 48px; height: 48px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; color: #ecfdf5; font-weight: 800; font-size: 16px; position: relative; box-shadow: 0 0 20px rgba(16, 185, 129, .22); }
.avatar .badge { position: absolute; right: -2px; top: -2px; width: 14px; height: 14px; border-radius: 50%; background: var(--bad); border: 2px solid var(--bg); }
.main { flex: 1; min-width: 0; }
.name { font-weight: 700; display: flex; align-items: center; gap: 6px; }
.name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub { color: var(--hint); font-size: 13px; margin-top: 2px; overflow-wrap: anywhere; }
.sub.skel::after { content: "…"; }
.chev { color: var(--em2); font-size: 20px; flex: none; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--hint); }
.dot.on { background: var(--good); box-shadow: 0 0 10px var(--good); } .dot.off { background: var(--bad); } .dot.warn { background: var(--warn); }
.chip { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: rgba(16, 185, 129, .12); color: var(--em3); white-space: nowrap; border: 1px solid var(--line); }
.chip.bad { background: rgba(251, 113, 133, .12); color: var(--bad); border-color: rgba(251, 113, 133, .3); } .chip.warn { background: rgba(251, 191, 36, .12); color: var(--warn); border-color: rgba(251, 191, 36, .3); }

/* сторінка проєкту */
.tabs { display: flex; gap: 8px; overflow-x: auto; padding: 6px 0 4px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { border: 1px solid var(--line); background: rgba(16, 185, 129, .06); color: var(--hint); padding: 9px 18px; border-radius: 999px; font-weight: 700; white-space: nowrap; cursor: pointer; transition: border-color .15s; }
.tab:hover { border-color: var(--line2); }
.tab.on { background: var(--grad); color: #03140e; border-color: transparent; box-shadow: 0 6px 20px rgba(16, 185, 129, .3); }
.cards { display: grid; grid-template-columns: 1fr; gap: 12px; padding-top: 14px; }
.card { padding: 18px; border-radius: var(--r); background: linear-gradient(160deg, var(--card2), var(--card) 70%); border: 1px solid var(--line); }
.card h3 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .14em; color: var(--hint); }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; }
.kv span:first-child { color: var(--hint); }
.big { font-size: 26px; font-weight: 800; letter-spacing: -.01em; }
button.primary { border: 0; background: var(--grad); color: #03140e; padding: 12px 22px; border-radius: 999px; font-weight: 800; cursor: pointer; box-shadow: 0 8px 26px rgba(16, 185, 129, .38); }
button.primary:hover { box-shadow: 0 10px 34px rgba(52, 211, 153, .5); }
button.primary:disabled { opacity: .6; cursor: default; }
button.wide { width: 100%; }

/* кампанії → адсети → креативи */
.obj { border-bottom: 1px solid var(--line); }
.obj:last-child { border-bottom: 0; }
.list:not(.projects) .obj > .row { border-bottom: 0; }
.obj .children { border-left: 2px solid var(--line2); margin-left: 26px; background: rgba(16, 185, 129, .03); }
.obj .children .row { padding-left: 12px; }
.obj .children .obj .children { margin-left: 16px; }
.thumb { width: 46px; height: 46px; border-radius: 12px; object-fit: cover; background: var(--card2); border: 1px solid var(--line); flex: none; }
.switch { position: relative; width: 48px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; inset: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 999px; background: rgba(134, 166, 152, .3); transition: background .15s, box-shadow .15s; }
.switch i::after { content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0, 0, 0, .4); }
.switch input:checked + i { background: var(--grad); box-shadow: 0 0 14px rgba(52, 211, 153, .5); }
.switch input:checked + i::after { transform: translateX(20px); }
.switch input:disabled + i { opacity: .5; }
.expander { color: var(--em2); width: 18px; flex: none; text-align: center; transition: transform .15s; }
.expander.open { transform: rotate(90deg); }

/* галерея */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 14px 0 24px; }
.tile { background: linear-gradient(160deg, var(--card2), var(--card) 70%); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; display: flex; flex-direction: column; }
.tile .pic { width: 100%; aspect-ratio: 1; object-fit: cover; background: var(--card2); display: block; }
.tile .body { padding: 10px 12px 12px; }
.tile .name { font-size: 13px; }
.tile .sub { font-size: 12px; }
.swrap { margin-top: 8px; display: flex; justify-content: flex-end; }

.rec { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; gap: 10px; }
.rec:last-child { border-bottom: 0; }
.rec .no { font-weight: 800; color: var(--em2); min-width: 28px; }
.note { color: var(--hint); font-size: 13px; padding: 12px 8px; text-align: center; }
.more { display: block; margin: 8px auto 24px; }

/* форма нового проєкту */
.field { display: block; margin: 0 0 16px; }
.field .lbl { display: block; font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--hint); margin-bottom: 7px; }
.field input { width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 16px; padding: 13px 16px; outline: none; }
.field .hint { display: block; font-size: 12px; color: var(--hint); margin-top: 6px; }
.formbox { margin-top: 18px; padding: 22px; border-radius: 28px; background: linear-gradient(160deg, var(--card2), var(--card) 70%); border: 1px solid var(--line); }
.formerr { background: rgba(251, 113, 133, .12); color: var(--bad); padding: 11px 14px; border-radius: 14px; margin-bottom: 14px; font-size: 14px; overflow-wrap: anywhere; }

/* екрани бота всередині застосунку */
.botview { padding: 6px 16px 120px; max-width: 760px; margin: 0 auto; }
.bcard { margin: 12px 0; padding: 18px; border-radius: 26px; background: linear-gradient(160deg, var(--card2), var(--card) 70%); border: 1px solid var(--line); box-shadow: 0 0 30px rgba(16, 185, 129, .07); transition: opacity .15s; }
.bcard.busy { opacity: .55; pointer-events: none; }
.btext { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.btext strong { color: #fff; }
.btext code { background: rgba(16, 185, 129, .14); border: 1px solid var(--line); border-radius: 8px; padding: 1px 6px; font-size: 13px; }
.btext pre { background: rgba(0, 0, 0, .35); border: 1px solid var(--line); border-radius: 14px; padding: 12px; overflow-x: auto; white-space: pre; font-size: 13px; margin: 8px 0; }
.btext blockquote { margin: 8px 0; padding: 4px 0 4px 12px; border-left: 3px solid var(--em); color: var(--hint); }
.btext .spoiler { background: var(--hint); color: transparent; border-radius: 6px; cursor: pointer; }
.btext .spoiler.open { background: none; color: inherit; }
.bmedia { display: block; width: 100%; max-height: 420px; object-fit: contain; border-radius: 18px; background: #000; margin-bottom: 12px; }
.kb { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.kbrow { display: flex; gap: 8px; flex-wrap: wrap; }
.kbtn { flex: 1 1 auto; border: 1px solid var(--line2); background: rgba(16, 185, 129, .09); color: var(--em3); padding: 11px 16px; border-radius: 999px; font-weight: 700; font-size: 14px; cursor: pointer; text-align: center; text-decoration: none; transition: background .15s, box-shadow .15s; }
.kbtn:hover { background: rgba(16, 185, 129, .18); box-shadow: 0 0 20px rgba(52, 211, 153, .25); }
.kbtn:active { transform: scale(.98); }
.typing { display: none; gap: 6px; justify-content: center; padding: 16px; }
.typing.on { display: flex; }
.typing i { width: 8px; height: 8px; border-radius: 50%; background: var(--em2); animation: bounce 1s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(.5); opacity: .4; } 40% { transform: scale(1); opacity: 1; } }
.inputbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; display: flex; gap: 8px; align-items: center; max-width: 760px; margin: 0 auto; padding: 10px 14px calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(0deg, var(--bg) 60%, transparent); }
.inputbar[hidden], .attach[hidden] { display: none; }
.tinput { flex: 1; min-width: 0; border: 1px solid var(--line2); background: var(--card); border-radius: 999px; padding: 13px 18px; outline: none; }
.sendbtn { width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--grad); color: #03140e; font-size: 18px; font-weight: 900; cursor: pointer; flex: none; box-shadow: 0 6px 22px rgba(16, 185, 129, .45); }

#toast { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: rgba(6, 24, 18, .96); border: 1px solid var(--line2); color: var(--text); padding: 12px 20px; border-radius: 999px; opacity: 0; pointer-events: none; transition: all .2s; max-width: 90vw; text-align: center; z-index: 40; box-shadow: 0 10px 40px rgba(16, 185, 129, .25); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ПК / широке вікно (повний екран) */
@media (min-width: 760px) {
  .page { padding: 0 28px 56px; }
  .topbar { padding-left: 28px; padding-right: 28px; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
  .list.projects { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); }
  .cards { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
  .grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
  .hero { padding-top: 56px; }
  .block { margin-top: 44px; }
  .seg { max-width: 420px; }
  .search { max-width: 420px; }
  .err { max-width: 520px; margin-left: 0; }
}
