/* ===== MLD Premium Mini App — UI ===== */

:root {
  /* Строгая палитра: чёрный / серый / зелёный. Тему Telegram НЕ подмешиваем. */
  --bg: #0a0f0d;
  --bg-elev: #0f1613;
  --card: #121b17;
  --card-2: #18231e;
  --text: #eaf2ed;
  --hint: #7d9189;
  --accent: #2fbf71;          /* зелёный акцент */
  --accent-2: #46d885;
  --accent-dim: #1d6b43;
  --accent-text: #04130b;
  --link: #46d885;
  --border: rgba(120, 220, 170, 0.08);
  --border-strong: rgba(120, 220, 170, 0.16);
  --green: #2fbf71;
  --red: #d96a6a;
  --danger: #c95757;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.35);
  --radius: 14px;
  --radius-sm: 11px;
  --grad: var(--accent);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body { height: 100%; }

body {
  background: var(--bg);
  background-image:
    radial-gradient(1100px 620px at 50% -8%, rgba(47, 191, 113, 0.14), transparent 60%),
    radial-gradient(820px 520px at 100% 0%, rgba(20, 120, 80, 0.12), transparent 58%),
    radial-gradient(900px 700px at 0% 100%, rgba(15, 90, 62, 0.10), transparent 60%),
    linear-gradient(180deg, #0c1411 0%, #0a0f0d 45%, #080b0a 100%);
  background-attachment: fixed;
  background-repeat: no-repeat;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

#app {
  max-width: 680px;
  margin: 0 auto;
  padding-bottom: calc(82px + env(safe-area-inset-bottom, 0));
  min-height: 100%;
}

/* ===== Header ===== */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(180deg, rgba(18, 40, 30, 0.55), rgba(12, 20, 17, 0.35));
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  backdrop-filter: saturate(160%) blur(16px);
  border-bottom: 1px solid var(--border);
}
.logo {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 9px;
}
.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 900;
  font-size: 16px;
}
.logo-accent { color: var(--accent); }
.badge {
  background: var(--card);
  border: 1px solid var(--border-strong);
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--hint);
  white-space: nowrap;
}

/* ===== Tabs (нижняя навигация) ===== */
nav#tabs {
  display: flex;
  gap: 2px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0));
  background: linear-gradient(0deg, rgba(16, 34, 26, 0.7), rgba(12, 20, 17, 0.45));
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  backdrop-filter: saturate(160%) blur(16px);
  border-top: 1px solid var(--border);
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  max-width: 680px;
  margin: 0 auto;
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 4px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--hint);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.18s ease, transform 0.1s ease;
}
.tab .tab-ico { width: 23px; height: 23px; transition: transform 0.15s ease; }
.tab .tab-lbl { font-size: 11px; letter-spacing: -0.01em; }
.tab:active { transform: scale(0.92); }
.tab.active { color: var(--accent); }
.tab.active .tab-ico { transform: translateY(-1px); }

/* ===== Layout ===== */
main { padding: 10px 16px; }
.tab-content { display: none; animation: fadeUp 0.28s ease; }
.tab-content.active { display: block; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Buttons ===== */
.btn {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 8px;
  transition: transform 0.1s ease, filter 0.15s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.975); filter: brightness(1.08); }
.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  font-weight: 700;
}
.btn-primary:active { filter: brightness(1.05); }
.btn-danger { background: rgba(201, 87, 87, 0.12); color: var(--red); border-color: rgba(201,87,87,0.28); }
.btn-sm { width: auto; padding: 9px 14px; font-size: 13px; border-radius: 10px; }

/* Главная кнопка действия (Новое уведомление/правило) */
#btn-new-sub, #btn-new-arb {
  position: sticky;
  top: 72px;
  z-index: 12;
}

/* ===== Cards / list ===== */
.list { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.card {
  background: linear-gradient(160deg, rgba(26, 38, 32, 0.92), rgba(18, 27, 23, 0.92));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 0;
  box-shadow: var(--shadow-sm);
  animation: fadeUp 0.25s ease;
}
.card h3 { margin-bottom: 10px; font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.card-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.card-title { font-weight: 700; font-size: 15.5px; display: flex; align-items: center; }
.card-sub { font-size: 13px; color: var(--hint); margin-top: 8px; line-height: 1.65; }
.muted { color: var(--hint); font-size: 13px; margin: 8px 0; }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 8px; flex: none; }
.dot.on { background: var(--green); box-shadow: 0 0 0 3px rgba(47, 191, 113, 0.18); }
.dot.off { background: var(--red); box-shadow: 0 0 0 3px rgba(217, 106, 106, 0.16); }

/* ===== Premium ===== */
#tab-premium .card { background: var(--card-2); }
#premium-info { font-size: 15px; line-height: 1.9; }

/* ===== Modal (bottom sheet) ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-end;
  z-index: 100;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal.hidden, .hidden { display: none !important; }
.modal-content {
  background: var(--bg-elev);
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  border-radius: 22px 22px 0 0;
  padding: 8px 18px calc(28px + env(safe-area-inset-bottom, 0));
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: slideUp 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.sheet-handle {
  width: 40px; height: 4px; border-radius: 999px;
  background: var(--border-strong); margin: 8px auto 16px;
}

.step-title { font-size: 18px; font-weight: 800; margin-bottom: 5px; letter-spacing: -0.02em; }
.step-hint { color: var(--hint); font-size: 13.5px; margin-bottom: 16px; line-height: 1.5; }

/* ===== Chips ===== */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip {
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-strong);
  transition: transform 0.1s ease, background 0.15s ease;
}
.chip:active { transform: scale(0.94); }
.chip.selected { background: var(--accent); color: var(--accent-text); border-color: transparent; }

/* ===== Inputs ===== */
.search-input {
  width: 100%;
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--card);
  color: var(--text);
  font-size: 15px;
  margin-bottom: 12px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,191,113,0.18); }
.search-input::placeholder { color: var(--hint); }

/* ===== Option list (multi-select) ===== */
.opt-list { max-height: 46vh; overflow-y: auto; margin-bottom: 16px; display: flex; flex-direction: column; gap: 6px; }
.opt {
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  background: var(--card);
  border: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14.5px;
  transition: background 0.13s ease, border-color 0.13s ease, transform 0.08s ease;
}
.opt:active { transform: scale(0.99); }
.opt.selected { background: rgba(47, 191, 113, 0.14); border-color: var(--accent); }
.opt .check { width: 20px; text-align: center; flex: none; }

/* ===== Modal actions ===== */
.modal-actions { display: flex; gap: 8px; margin-top: 10px; }
.modal-actions .btn { margin-bottom: 0; }

/* ===== Sales stats ===== */
.sales-stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 12px;
  font-size: 14px;
  line-height: 1.8;
}
.sales-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.sales-row:last-child { border: none; }
.sales-row span:last-child { color: var(--hint); }

/* ===== States ===== */
.loader { text-align: center; color: var(--hint); padding: 28px; }
.loader::after {
  content: ""; display: block; width: 26px; height: 26px; margin: 12px auto 0;
  border: 3px solid var(--border-strong); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty {
  text-align: center;
  color: var(--hint);
  padding: 56px 24px;
  font-size: 14.5px;
  line-height: 1.7;
}
.empty .empty-ico {
  width: 56px;
  height: 56px;
  display: block;
  margin: 0 auto 18px;
  color: var(--accent);
  opacity: 0.92;
}
.empty .empty-title {
  display: block;
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}
.empty .empty-sub { display: block; max-width: 280px; margin: 0 auto; }

/* ===== Settings ===== */
.settings-row { display: flex; align-items: center; gap: 10px; margin: 14px 0; }
.settings-row label { opacity: 0.85; font-size: 14px; font-weight: 600; }
.settings-row select {
  flex: 1;
  padding: 12px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--card);
  color: var(--text);
  font-size: 15px;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%238fa3b8' d='M1 1l5 5 5-5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.settings-row select:focus { border-color: var(--accent); }

/* Строгая тёмная тема — фиксированная, тему Telegram не подмешиваем. */

/* ===== Богатые карточки подписок/арбитража ===== */
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.card-name { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.pill {
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
  flex: none;
}
.pill.on { background: rgba(47, 191, 113, 0.14); color: var(--green); }
.pill.off { background: rgba(217, 106, 106, 0.14); color: var(--red); }

.meta { display: flex; flex-direction: column; gap: 8px; }
.meta-row { display: flex; gap: 8px; font-size: 13.5px; align-items: baseline; }
.meta-row .k { color: var(--hint); min-width: 78px; flex: none; }
.meta-row .v { color: var(--text); font-weight: 500; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 8px;
  background: var(--card-2);
  border: 1px solid var(--border);
  color: var(--hint);
}
.tag.accent { background: rgba(47, 191, 113, 0.14); color: var(--accent-2); border-color: transparent; }

.card-actions { display: flex; gap: 8px; margin-top: 14px; }
.card-actions .btn { margin-bottom: 0; flex: 1; }

/* ===== Premium hero ===== */
.premium-hero {
  position: relative;
  overflow: hidden;
  background: var(--card-2) !important;
  border: 1px solid var(--accent-dim) !important;
}
.premium-hero::before {
  content: "";
  position: absolute;
  top: -50px; right: -50px;
  width: 170px; height: 170px;
  background: radial-gradient(circle, rgba(47, 191, 113, 0.16), transparent 70%);
  pointer-events: none;
}
.premium-badge {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.1em;
  padding: 5px 12px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  margin-bottom: 14px;
}
.pay-grid { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.pay-grid .btn { margin-bottom: 0; }

/* ===== Плитки выбора с картинками (мастер) ===== */
.opt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
  max-height: 52vh;
  overflow-y: auto;
  padding: 2px;
  margin-bottom: 14px;
}
.opt-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  background: var(--card);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.15s ease, background 0.15s ease;
  text-align: center;
}
.opt-tile:active { transform: scale(0.96); }
.opt-tile.selected { border-color: var(--accent); background: rgba(47, 191, 113, 0.12); }
.opt-thumb {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--card-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 22px;
  color: var(--hint);
  overflow: hidden;
}
.opt-thumb.noimg { border: 1px solid var(--border); }
.opt-name {
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.25;
  word-break: break-word;
  color: var(--text);
}
.opt-check {
  position: absolute;
  top: 7px; right: 7px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 13px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.opt-tile.selected .opt-check { opacity: 1; transform: scale(1); }

/* строка «Все коллекции» */
.opt-tile.allrow {
  flex-direction: row;
  justify-content: flex-start;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.opt-tile.allrow .opt-thumb { width: 40px; height: 40px; font-size: 18px; border-radius: 10px; }
.opt-tile.allrow .opt-name { font-size: 15px; }

/* обложка на экране подтверждения */
.confirm-cover {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: var(--radius);
  margin-bottom: 14px;
  border: 1px solid var(--border);
}
