/* Majestic · Рабочий центр — Apple/iOS стиль, светлая и тёмная темы. */
:root {                      /* по умолчанию — тёмная */
  --bg: #000000;
  --surface: #1c1c1e;
  --surface-2: #2c2c2e;
  --surface-3: #3a3a3c;
  --sep: rgba(255, 255, 255, 0.10);
  --text: #ffffff;
  --muted: #98989f;
  --accent: #ff375f;
  --accent-2: #ff6482;
  --accent-grad: linear-gradient(135deg, #ff375f, #ff6482);
  --ok: #30d158;
  --bar-bg: rgba(20, 20, 22, 0.72);
  --toast-bg: rgba(40, 40, 42, 0.95);
  --radius: 20px;
  --radius-sm: 13px;
  font-synthesis: none;
}

:root[data-theme="light"] {  /* светлая тема */
  --bg: #f2f2f7;
  --surface: #ffffff;
  --surface-2: #ececef;
  --surface-3: #e2e2e7;
  --sep: rgba(0, 0, 0, 0.10);
  --text: #000000;
  --muted: #8a8a8e;
  --accent: #ff2d55;
  --accent-2: #ff5277;
  --accent-grad: linear-gradient(135deg, #ff2d55, #ff5277);
  --ok: #34c759;
  --bar-bg: rgba(255, 255, 255, 0.80);
  --toast-bg: rgba(40, 40, 42, 0.95);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}

main { padding: 0 16px calc(96px + env(safe-area-inset-bottom)); max-width: 620px; margin: 0 auto; }

/* ── Шапка ── */
.hdr {
  max-width: 620px; margin: 0 auto;
  padding: 22px 18px 8px;
  display: flex; flex-direction: column; gap: 3px;
}
.brand { display: flex; align-items: center; gap: 11px; }
.logo { height: 34px; width: auto; }
.word { font-weight: 800; letter-spacing: -0.5px; font-size: 26px; display: inline-flex; align-items: baseline; }
.word .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-grad); margin-left: 5px; }
.brand-sub { color: var(--muted); font-size: 14px; }

/* ── Skeleton loading ── */
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.sk {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: 8px;
}
.sk-line { height: 13px; margin-bottom: 9px; }
.sk-line.w100 { width: 100%; }
.sk-line.w70  { width: 70%; }
.sk-line.w45  { width: 45%; }
.sk-line.w30  { width: 30%; }
.sk-line.h20  { height: 20px; }
.sk-line.h28  { height: 28px; }
.sk-line.h36  { height: 36px; }
.sk-row { display: flex; justify-content: space-between; align-items: center; padding: 11px 0; border-bottom: 0.5px solid var(--sep); }
.sk-row:last-child { border-bottom: none; }
.sk-row-left  { flex: 1; padding-right: 16px; }
.sk-row-right { width: 72px; }

/* ── Карточки / поля ── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px; margin-top: 16px;
  box-shadow: 0 1px 0 rgba(255,255,255,0.03) inset;
}
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.card-head h2 { font-size: 17px; margin: 0; font-weight: 600; letter-spacing: -0.3px; }

.field { display: block; margin-bottom: 16px; }
.label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 7px; font-weight: 500; }

input, select, textarea {
  width: 100%; padding: 14px 15px;
  border: none; border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text); font-size: 17px; outline: none;
  font-family: inherit; resize: vertical;
  transition: background .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { box-shadow: 0 0 0 3px rgba(255,55,95,.35); }
select { appearance: none; background-image: none; }
::placeholder { color: #6b6b70; }

.row { display: flex; gap: 10px; }
.row input { flex: 1; }

/* ── Кнопки ── */
.btn {
  width: 100%; padding: 16px; border: none; border-radius: var(--radius-sm);
  font-size: 17px; font-weight: 600; cursor: pointer; letter-spacing: -0.2px;
  transition: transform .08s ease, filter .15s;
}
.btn.primary { background: var(--accent-grad); color: #fff; }
.btn.ghost { background: var(--surface-2); color: var(--text); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: .5; }
.link { background: none; border: none; color: var(--accent-2); font-size: 15px; font-weight: 500; cursor: pointer; }

.mic {
  width: 52px; min-width: 52px; border: none; border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text); font-size: 20px; cursor: pointer;
  transition: transform .08s;
}
.mic:active { transform: scale(0.94); }
.mic.rec { background: var(--accent-grad); animation: pulse 1.3s infinite; }
.chat-icon-btn.rec { color: var(--accent-2); animation: pulse 1.3s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,55,95,.45);} 50% { box-shadow: 0 0 0 12px rgba(255,55,95,0);} }

.hint {
  font-size: 14px; color: var(--muted);
  background: var(--surface); border-radius: var(--radius-sm);
  padding: 12px 14px; margin: 12px 0;
}
.hint b { color: var(--text); }

/* ── Индикатор записи ── */
.listening {
  position: sticky; top: 10px; z-index: 30;
  max-width: 620px; margin: 8px auto 0; width: calc(100% - 32px);
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,55,95,.16); border: 1px solid rgba(255,55,95,.5);
  border-radius: var(--radius-sm); padding: 11px 15px; backdrop-filter: blur(20px);
}
.rec-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--accent); animation: blink 1s infinite; flex: 0 0 auto; }
@keyframes blink { 0%,100% { opacity: 1;} 50% { opacity: .25;} }
.rec-label { font-weight: 600; }
.interim { color: var(--muted); font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Сегмент-контрол (iOS) ── */
.seg { display: flex; gap: 2px; margin-top: 16px; background: var(--surface-2); border-radius: 11px; padding: 2px; }
.seg-btn {
  flex: 1; padding: 9px 6px; border: none; border-radius: 9px;
  background: transparent; color: var(--muted); font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background .2s, color .2s;
}
.seg-btn.active { background: var(--surface-3); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.4); }

/* ── Навигатор по месяцам ── */
.period-nav { display: flex; align-items: center; gap: 8px; margin-top: 16px; }
.navbtn { width: 44px; height: 44px; border-radius: 12px; border: none; background: var(--surface); color: var(--text); font-size: 22px; cursor: pointer; transition: transform .08s; }
.navbtn:active { transform: scale(0.92); }
.period-label { flex: 1; text-align: center; font-size: 16px; font-weight: 600; letter-spacing: -0.3px; }
.navall { padding: 0 14px; height: 44px; border-radius: 12px; border: none; background: var(--surface); color: var(--text); font-size: 14px; font-weight: 600; cursor: pointer; }
.navall.active { background: var(--accent-grad); color: #fff; }

/* ── Метрики ── */
.metrics { display: flex; gap: 10px; margin-top: 12px; }
.metric { flex: 1; background: var(--surface); border-radius: 16px; padding: 13px; text-align: center; }
.metric .m-cap { font-size: 12px; color: var(--muted); }
.metric .m-val { font-size: 17px; font-weight: 700; margin-top: 3px; }
.net-line { margin-top: 10px; font-size: 14px; color: var(--muted); text-align: center; }
.net-line b.pos { color: var(--ok); }
.net-line b.neg { color: var(--accent); }
.cmp { font-size: 13px; }
.cmp.up { color: var(--accent); }
.cmp.down { color: var(--ok); }

/* ── Динамика ── */
.dyn { display: flex; align-items: flex-end; gap: 7px; height: 116px; margin-top: 8px; }
.dyn-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; height: 100%; justify-content: flex-end; }
.dyn-bar { width: 64%; background: var(--accent-grad); border-radius: 6px 6px 3px 3px; min-height: 4px; }
.dyn-bar.cur { box-shadow: 0 0 12px rgba(255,55,95,.6); }
.dyn-lbl { font-size: 11px; color: var(--muted); }

/* ── Аналитика ── */
.stat-twin { display: flex; gap: 10px; margin-top: 14px; }
.stat-cell { flex: 1; background: var(--surface); border-radius: 16px; padding: 15px; }
.stat-cell .cap { font-size: 13px; color: var(--muted); }
.stat-cell .val { font-size: 21px; font-weight: 800; margin-top: 4px; letter-spacing: -0.5px; }
.stat-cell.inc .val { color: var(--ok); }
.stat-cell.exp .val { color: var(--accent); }

.stat-card { background: var(--surface); border-radius: 16px; padding: 15px; margin-top: 12px; }
.stat-card h3 { margin: 0 0 12px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; font-weight: 600; }
.cat-row { margin: 11px 0; }
.cat-top { display: flex; justify-content: space-between; font-size: 15px; margin-bottom: 6px; }
.cat-top .amt { font-weight: 600; }
.cat-bar { height: 7px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.cat-fill { height: 100%; background: var(--accent-grad); border-radius: 6px; }
.cat-pct { color: var(--muted); font-size: 13px; }

/* ── Баланс ── */
.bal-card { background: var(--surface); border-radius: var(--radius); padding: 18px; margin-top: 14px; }
.bal-name { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; font-weight: 600; }
.bal-sum { font-size: 34px; font-weight: 800; margin: 6px 0 10px; letter-spacing: -1px; }
.bal-sum.neg { color: var(--accent); }
.bal-row { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); padding: 4px 0; }
.bal-row b { color: var(--text); font-weight: 600; }

/* ── История ── */
.history { margin-top: 4px; }
.hist-item { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 0.5px solid var(--sep); }
.hist-item:last-child { border-bottom: none; }
.hist-main { flex: 1; min-width: 0; }
.hist-desc { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist-meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.hist-amount { font-weight: 600; white-space: nowrap; font-size: 16px; }
.del, .edit { width: 40px; min-width: 40px; height: 40px; border-radius: 11px; border: none; background: var(--surface-2); font-size: 15px; cursor: pointer; transition: transform .08s; }
.del:active, .edit:active { transform: scale(0.9); }
.del { color: var(--accent-2); }
.edit { color: var(--text); }
.muted { color: var(--muted); font-size: 15px; padding: 10px 0; }
.modal-card label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 5px; }

/* ── Помощник (чат) — полноэкранный ── */
#tab-assistant {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg);
  z-index: 5;
  display: flex;
  flex-direction: column;
  padding: 0;
  padding-bottom: calc(60px + env(safe-area-inset-bottom));
}
#tab-assistant.hidden { display: none; }

.chat-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: max(env(safe-area-inset-top), 14px) 16px 8px;
  flex-shrink: 0;
}
.chat-head h2 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.4px; }
.chat-head-btns { display: flex; gap: 14px; }

.chat-card {
  flex: 1;
  display: flex; flex-direction: column;
  height: auto; min-height: 0;
  margin: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  padding: 0 16px;
}
.chat { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 9px; padding-bottom: 8px; }

.bubble { max-width: 88%; padding: 10px 14px; border-radius: 20px; font-size: 15px; line-height: 1.5; word-wrap: break-word; }
.bubble.user { align-self: flex-end; background: var(--accent-grad); color: #fff; border-bottom-right-radius: 6px; white-space: pre-wrap; }
.bubble.bot { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 6px; max-width: 96%; white-space: normal; }

/* Markdown внутри пузырей бота */
.bubble.bot .md-p { margin: 0; }
.bubble.bot .md-p + .md-p { margin-top: 5px; }
.bubble.bot .md-h { font-weight: 700; margin: 8px 0 3px; font-size: 1em; }
.bubble.bot .md-ul, .bubble.bot .md-ol { margin: 5px 0; padding-left: 18px; }
.bubble.bot .md-ul li, .bubble.bot .md-ol li { margin-bottom: 3px; line-height: 1.45; }
.bubble.bot .md-gap { height: 6px; }
.md-code { background: rgba(255,255,255,.13); border-radius: 4px; padding: 1px 5px; font-family: "SF Mono", Menlo, monospace; font-size: .83em; }
:root[data-theme="light"] .md-code { background: rgba(0,0,0,.07); }

.md-table-wrap { overflow-x: auto; margin: 8px 0 4px; border-radius: 10px; overflow: hidden; }
.md-table { border-collapse: collapse; font-size: .82em; width: 100%; }
.md-table th { background: rgba(255,255,255,.1); padding: 6px 12px; text-align: left; font-weight: 600; white-space: nowrap; border-bottom: 1px solid rgba(255,255,255,.1); }
.md-table td { padding: 6px 12px; border-top: 1px solid rgba(255,255,255,.07); white-space: nowrap; }
:root[data-theme="light"] .md-table th { background: rgba(0,0,0,.05); border-bottom-color: rgba(0,0,0,.08); }
:root[data-theme="light"] .md-table td { border-top-color: rgba(0,0,0,.05); }

/* Быстрые чипы */
.chat-suggestions { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 12px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chat-suggestions::-webkit-scrollbar { display: none; }
.suggest-chip { background: var(--surface-2); border: 1px solid var(--sep); border-radius: 100px; padding: 7px 14px; font-size: 13px; color: var(--text); cursor: pointer; white-space: nowrap; flex: 0 0 auto; font-weight: 500; transition: opacity .1s; }
.suggest-chip:active { opacity: .5; }

/* Превью прикреплённого фото */
.chat-img-preview { display: flex; align-items: center; gap: 8px; padding: 6px 0 2px; }
.chat-img-preview img { width: 60px; height: 60px; object-fit: cover; border-radius: 10px; flex: 0 0 auto; }
.chat-img-clear { background: var(--surface-3); border: none; border-radius: 50%; width: 22px; height: 22px; font-size: 11px; cursor: pointer; color: var(--text); line-height: 1; }

/* Картинки от DALL-E в пузырях бота */
.md-img { max-width: 100%; border-radius: 14px; display: block; margin: 6px 0; }

/* Поле ввода чата */
.chat-input {
  display: flex; gap: 8px; align-items: center;
  padding: 10px 0 2px; border-top: 0.5px solid var(--sep);
}
.chat-input-wrap {
  flex: 1; display: flex; align-items: flex-end;
  background: var(--surface-2); border-radius: 22px;
  padding: 10px 14px; gap: 8px; min-height: 44px;
}
.chat-input-wrap textarea {
  flex: 1; background: transparent !important; border: none !important;
  outline: none; color: var(--text); font-size: 15px;
  resize: none !important; overflow: hidden; overflow-y: auto;
  line-height: 1.45; min-height: 22px; max-height: 88px;
  padding: 0 !important; border-radius: 0 !important;
  box-shadow: none !important; font-family: inherit;
}
.chat-input-wrap textarea:focus { box-shadow: none !important; }
.chat-icon-btn {
  width: 30px; height: 30px; min-width: 30px;
  border: none; background: none; color: var(--muted);
  font-size: 18px; cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
  transition: opacity .1s; border-radius: 50%; flex-shrink: 0;
}
.chat-icon-btn:active { opacity: .4; }
.send {
  width: 44px; min-width: 44px; height: 44px; flex-shrink: 0;
  border: none; border-radius: 50%;
  background: var(--accent-grad); color: #fff; font-size: 18px;
  cursor: pointer; transition: transform .08s;
}
.send:active { transform: scale(0.94); }
.send:disabled { opacity: .4; transform: none; }

/* ── Контакты ── */
.contact { background: var(--surface); border-radius: 16px; padding: 13px 15px; margin-top: 11px; display: flex; align-items: center; gap: 13px; }
.avatar { width: 46px; height: 46px; min-width: 46px; border-radius: 50%; background: var(--surface-3); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 19px; color: #fff; overflow: hidden; position: relative; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.contact-main { flex: 1; min-width: 0; }
.contact-name { font-size: 16px; font-weight: 600; }
.contact-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.contact-sub .uname { color: var(--accent-2); }

/* ── Нижняя навигация (frosted) ── */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; background: var(--bar-bg); backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  border-top: 0.5px solid var(--sep);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: max(env(safe-area-inset-left), 8px);
  padding-right: max(env(safe-area-inset-right), 8px);
}
.tab-btn {
  flex: 1; background: none; border: none; color: var(--muted);
  padding: 9px 2px 7px; font-size: 10.5px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: color .2s;
}
.tab-btn .ic {
  width: 24px; height: 24px; display: block;
  opacity: .55; transition: opacity .2s, stroke .2s;
}
.tab-btn.active { color: var(--accent-2); }
.tab-btn.active .ic { opacity: 1; }

.tab.hidden, .hidden { display: none !important; }

/* ── Модалка / тост ── */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); backdrop-filter: blur(6px); display: flex; align-items: flex-end; justify-content: center; z-index: 60; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-card { background: var(--surface); width: 100%; max-width: 620px; border-radius: 26px 26px 0 0; padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); animation: slideup .28s cubic-bezier(.2,.8,.2,1); }
@keyframes slideup { from { transform: translateY(40px); } to { transform: translateY(0); } }
.modal-card h3 { margin: 0 0 14px; font-size: 19px; font-weight: 700; letter-spacing: -0.4px; }
.preview { font-size: 16px; line-height: 1.95; }
.preview b { font-weight: 600; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions .btn { margin: 0; }

.toast { position: fixed; left: 50%; bottom: 104px; transform: translateX(-50%); background: var(--toast-bg); backdrop-filter: blur(20px); border: 0.5px solid var(--sep); color: #fff; padding: 12px 18px; border-radius: 14px; font-size: 15px; z-index: 70; max-width: 90%; }

/* ── Главная ── */
.home-greeting { padding: 22px 4px 8px; }
.greeting-name { font-size: 24px; font-weight: 800; letter-spacing: -0.4px; }
.greeting-date { font-size: 14px; color: var(--muted); margin-top: 3px; text-transform: capitalize; }

.home-balance-card { margin-top: 16px; }
.hbc-label { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.hbc-amount { font-size: 44px; font-weight: 800; letter-spacing: -2px; margin: 6px 0 4px; }
.hbc-amount.pos { color: var(--ok); }
.hbc-amount.neg { color: var(--accent); }
.hbc-meta { font-size: 14px; color: var(--muted); }

.home-voice { margin-top: 14px; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 26px 18px; }
.hv-label { font-size: 14px; color: var(--muted); font-weight: 500; align-self: flex-start; }
.voice-fab {
  width: 76px; height: 76px; border: none; border-radius: 50%;
  background: var(--accent-grad); font-size: 30px; cursor: pointer;
  box-shadow: 0 4px 24px rgba(255,55,95,.45);
  transition: transform .1s, box-shadow .1s;
}
.voice-fab:active { transform: scale(0.92); box-shadow: 0 2px 10px rgba(255,55,95,.3); }
.voice-fab.rec { animation: pulse 1.3s infinite; }
.hv-hint { font-size: 13px; color: var(--muted); }
.hv-result { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px 15px; font-size: 15px; width: 100%; }

/* ── Задачи (заглушка) ── */
.tasks-placeholder { display: flex; flex-direction: column; align-items: center; padding: 70px 20px 20px; gap: 14px; text-align: center; }
.tp-icon { font-size: 60px; }
.tp-title { font-size: 24px; font-weight: 800; letter-spacing: -0.5px; }
.tp-sub { font-size: 16px; color: var(--muted); line-height: 1.55; max-width: 280px; }
.tp-badge { background: var(--surface-2); border-radius: 100px; padding: 8px 18px; font-size: 14px; color: var(--muted); font-weight: 500; }

/* ── Ещё: разделы ── */
.more-section { margin-top: 18px; }
.more-section-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; color: var(--muted); text-transform: uppercase;
  letter-spacing: .4px; font-weight: 600; margin-bottom: 10px; padding: 0 4px;
}

/* ── Настройки ── */
.settings-card { padding: 0 !important; overflow: hidden; }
.settings-row { display: flex; justify-content: space-between; align-items: center; padding: 15px 18px; min-height: 52px; }
button.settings-row { background: none; border: none; width: 100%; cursor: pointer; text-align: left; font-size: 17px; font-family: inherit; color: var(--text); }
.settings-label { font-size: 17px; }
.settings-chevron { font-size: 22px; color: var(--muted); line-height: 1; font-weight: 300; }
.settings-badge { font-size: 12px; color: var(--muted); background: var(--surface-2); padding: 4px 10px; border-radius: 100px; font-weight: 500; }
.settings-badge.ok { color: var(--ok); background: rgba(48,209,88,.12); }
.settings-sep { height: 0.5px; background: var(--sep); margin: 0 18px; }
.settings-row-disabled { opacity: .55; pointer-events: none; }

/* ── iOS Toggle ── */
.toggle { position: relative; display: inline-block; width: 51px; height: 31px; cursor: pointer; flex: 0 0 auto; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track { position: absolute; inset: 0; background: var(--surface-3); border-radius: 100px; transition: background .2s; }
.toggle input:checked ~ .toggle-track { background: var(--ok); }
.toggle-thumb { position: absolute; top: 3px; left: 3px; width: 25px; height: 25px; background: #fff; border-radius: 50%; transition: transform .2s ease; box-shadow: 0 2px 5px rgba(0,0,0,.3); }
.toggle input:checked ~ .toggle-track .toggle-thumb { transform: translateX(20px); }

/* ── Медиа выплаты ── */
.media-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 4px 0; }
.media-head h2 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.4px; }

.media-summary { margin-top: 14px; padding: 0 !important; overflow: hidden; }
.media-sum-row { display: flex; align-items: stretch; }
.msm-item { flex: 1; padding: 16px 18px; text-align: center; }
.msm-cap { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.msm-val { font-size: 22px; font-weight: 800; margin-top: 5px; letter-spacing: -0.5px; }
.msm-item.ok .msm-val { color: var(--ok); }
.msm-item.warn .msm-val { color: var(--accent); }
.msm-sep { width: 0.5px; background: var(--sep); align-self: stretch; flex: 0 0 auto; }

.media-card { margin-top: 14px; }
.media-item { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 0.5px solid var(--sep); }
.media-item:last-child { border-bottom: none; }
.media-item-main { flex: 1; min-width: 0; }
.media-name { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.media-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.media-amount { font-size: 16px; font-weight: 700; white-space: nowrap; }
.media-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px; border-radius: 100px; border: none; cursor: pointer;
  font-size: 12px; font-weight: 700; white-space: nowrap;
  transition: transform .1s, opacity .15s;
}
.media-badge:active { transform: scale(0.92); }
.media-badge.paid   { background: rgba(48,209,88,.18); color: var(--ok); }
.media-badge.pending { background: rgba(255,55,95,.14); color: var(--accent); }
.media-amount-block { text-align: right; }
.media-partial { font-size: 11px; color: var(--muted); margin-top: 2px; white-space: nowrap; }
.media-actions-row { display: flex; align-items: center; gap: 8px; }
.media-edit-btn { background: none; border: none; padding: 6px; cursor: pointer; color: var(--muted); border-radius: 8px; display: flex; align-items: center; }
.media-edit-btn:active { opacity: 0.5; }
.media-comment { font-size: 12px; color: var(--muted); margin-top: 3px; font-style: italic; }
.nikita-badge { display: inline-block; background: rgba(100,120,255,.18); color: #7b8fff; border-radius: 6px; padding: 1px 7px; font-size: 11px; font-weight: 700; }

/* ─── Клипы ──────────────────────────────────────────────────────────────── */
.clips-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 4px 0; }
.clips-head h2 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.4px; }
.yadisk-status-badge { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 20px; }
.yadisk-status-badge.connected { background: rgba(48,209,88,.18); color: var(--ok); }
.yadisk-status-badge.disconnected { background: rgba(255,55,95,.14); color: var(--accent); }
.clips-connect-card { margin-top: 14px; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 28px 20px !important; text-align: center; }
.clips-connect-icon { font-size: 40px; line-height: 1; }
.clips-connect-text { font-size: 15px; color: var(--muted); }
.clip-task { background: var(--surface); border-radius: 16px; padding: 16px; margin-bottom: 12px; }
.clip-task-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.clip-task-title { font-size: 15px; font-weight: 600; word-break: break-all; flex: 1; }
.clip-task-status { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 20px; white-space: nowrap; flex-shrink: 0; }
.clip-status-pending, .clip-status-downloading { background: rgba(255,159,10,.15); color: #ff9f0a; }
.clip-status-splitting { background: rgba(100,120,255,.15); color: #7b8fff; }
.clip-status-uploading { background: rgba(10,132,255,.15); color: #0a84ff; }
.clip-status-done { background: rgba(48,209,88,.18); color: var(--ok); }
.clip-status-error { background: rgba(255,55,95,.14); color: var(--accent); }
.clip-progress-bar { height: 4px; background: var(--sep); border-radius: 4px; overflow: hidden; margin-bottom: 8px; }
.clip-progress-fill { height: 100%; background: var(--accent-2); border-radius: 4px; transition: width .4s; }
.clip-parts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.clip-part-badge { font-size: 11px; background: var(--bg); padding: 3px 8px; border-radius: 8px; color: var(--muted); }
.clip-log { margin-top: 10px; font-size: 11px; color: var(--muted); line-height: 1.6; max-height: 80px; overflow-y: auto; font-family: monospace; }
.clip-folder-link { font-size: 13px; color: var(--accent-2); margin-top: 8px; word-break: break-all; }
.clip-elapsed { font-size: 12px; color: var(--muted); margin-top: 4px; }
.clip-error-text { font-size: 12px; color: var(--accent); margin-top: 6px; word-break: break-all; }
.clip-progress-pct { font-size: 12px; color: var(--muted); text-align: right; margin-top: 2px; }
.clip-detail { font-size: 12px; color: var(--muted); margin-top: 6px; }
.clip-steps { display: flex; align-items: center; gap: 4px; margin-bottom: 10px; flex-wrap: wrap; }
.clip-step { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 20px; }
.clip-step.idle  { color: var(--muted); background: var(--bg); opacity: .5; }
.clip-step.active { color: var(--accent-2); background: rgba(var(--accent-2-rgb, 100,120,255),.15); }
.clip-step.done  { color: var(--ok); background: rgba(48,209,88,.12); }
.clip-step-sep { font-size: 12px; color: var(--muted); opacity: .4; }

.bulk-preview-row { display: flex; justify-content: space-between; align-items: baseline; padding: 8px 0; border-bottom: 0.5px solid var(--sep); font-size: 15px; }
.bulk-preview-row:last-child { border-bottom: none; }
.bulk-preview-row b { font-weight: 600; }
.bulk-preview-row span { color: var(--muted); font-size: 14px; margin-left: 10px; text-align: right; flex-shrink: 0; }

/* ── Кнопка Стоп в индикаторе записи ── */
.stop-btn { margin-left: auto; background: none; border: none; color: var(--accent); font-size: 14px; font-weight: 600; cursor: pointer; padding: 0 4px; }

/* ══ Задачи — полный таб ══════════════════════════════════════════════════ */

/* Шапка таба задач */
.task-tab-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 0 4px; }
.task-tab-head h2 { margin: 0; }
.task-fab {
  width: 36px; height: 36px; border: none; border-radius: 50%;
  background: var(--accent-grad); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .1s, opacity .15s; flex-shrink: 0;
}
.task-fab:active { transform: scale(0.9); }

/* Группы */
.task-group-label {
  font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted); padding: 16px 4px 6px; margin: 0;
}

/* Карточка задач */
.task-card { padding: 0; overflow: hidden; }

/* Строка задачи */
.task-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 16px; border-bottom: 0.5px solid var(--sep);
  cursor: default; transition: background .1s;
}
.task-item:last-child { border-bottom: none; }
.task-item:active { background: var(--surface-2); }
.task-item.t-overdue { border-left: 3px solid var(--accent); }

/* Чекбокс */
.task-check {
  width: 24px; height: 24px; min-width: 24px; border-radius: 50%;
  border: 2px solid var(--sep); background: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 1px;
  transition: background .15s, border-color .15s, transform .1s;
}
.task-check:active { transform: scale(0.85); }
.task-check.checked { background: var(--ok); border-color: var(--ok); }

.task-body { flex: 1; min-width: 0; cursor: pointer; }
.task-title { font-size: 15px; line-height: 1.4; word-break: break-word; }
.task-title.t-strike { text-decoration: line-through; opacity: .4; }
.task-meta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; align-items: center; }

/* Статус-бейдж */
.task-badge {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 100px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.01em; white-space: nowrap;
}
.task-badge.todo  { background: rgba(255,55,95,.12); color: var(--accent); }
.task-badge.doing { background: rgba(255,186,0,.14); color: #c49000; }
.task-badge.irl   { background: rgba(10,132,255,.12); color: #0a84ff; }
.task-badge.hold  { background: rgba(160,160,165,.16); color: var(--muted); }

/* Дедлайн-чип */
.deadline-chip {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 100px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.deadline-chip.dl-overdue  { background: rgba(255,55,95,.15); color: var(--accent); }
.deadline-chip.dl-today    { background: rgba(255,130,0,.15); color: #e06000; }
.deadline-chip.dl-tomorrow { background: rgba(255,186,0,.14); color: #c49000; }
.deadline-chip.dl-soon     { background: rgba(10,132,255,.10); color: #0a84ff; }
.deadline-chip.dl-future   { background: var(--surface-2); color: var(--muted); }

/* Аккордеон "Выполнено" */
.tasks-done-toggle {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 12px 4px 6px; color: var(--muted); font-size: 13px; font-weight: 600;
  background: none; border: none; cursor: pointer;
}
.tasks-done-toggle svg { transition: transform .2s; flex-shrink: 0; }
.tasks-done-toggle.open svg { transform: rotate(180deg); }

/* Виджет задач на главной */
.home-task-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-bottom: 0.5px solid var(--sep);
}
.home-task-row:last-child { border-bottom: none; }
.home-task-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.dot-red    { background: var(--accent); }
.dot-orange { background: #ff8c00; }
.dot-yellow { background: #ffb800; }
.dot-blue   { background: #0a84ff; }
.home-task-text { flex: 1; font-size: 14px; line-height: 1.3; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Таб-бейдж (счётчик просроченных) */
.tab-btn { position: relative; }
.tab-badge {
  position: absolute; top: 2px; right: 4px;
  background: var(--accent); color: #fff; font-size: 10px; font-weight: 700;
  min-width: 16px; height: 16px; border-radius: 8px; padding: 0 4px;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}

/* Шестерёнка настроек */
.settings-ico-btn {
  width: 36px; height: 36px; border: none; background: var(--surface-2);
  border-radius: 50%; color: var(--muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: opacity .15s;
}
.settings-ico-btn:active { opacity: .6; }
.home-greeting { display: flex; justify-content: space-between; align-items: flex-start; padding: 12px 0 8px; }

/* Модал задачи */
.task-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  z-index: 200; display: flex; align-items: flex-end;
  animation: fadeIn .18s ease;
}
.task-modal-overlay.hidden { display: none; }
.task-modal-card {
  width: 100%; background: var(--surface); border-radius: 20px 20px 0 0;
  padding: 0 0 calc(env(safe-area-inset-bottom) + 12px);
  max-height: 90vh; overflow-y: auto;
  animation: slideUp .22s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.task-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 4px;
}
.task-modal-head h3 { margin: 0; font-size: 18px; font-weight: 700; }
.icon-close-btn {
  width: 30px; height: 30px; border: none; background: var(--surface-2);
  border-radius: 50%; color: var(--muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.task-modal-body { padding: 12px 20px 4px; display: flex; flex-direction: column; gap: 2px; }
.task-modal-actions {
  display: flex; gap: 10px; padding: 14px 20px 0; justify-content: flex-end;
}
.task-modal-actions .btn { flex: 1; }
.btn.danger { color: var(--accent); border-color: rgba(255,55,95,.3); }
.task-modal-body textarea, .task-modal-body select, .task-modal-body input[type="date"] {
  width: 100%; background: var(--surface-2); border: none; border-radius: 12px;
  padding: 10px 14px; font-size: 15px; color: var(--text); outline: none;
  font-family: inherit; resize: none;
}
.task-modal-body input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(0.5); }

/* ─── PIN overlay ─────────────────────────────────────────────────────────── */
#pin-overlay {
  position: fixed; inset: 0; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}
.pin-card {
  display: flex; flex-direction: column; align-items: center; gap: 20px;
  padding: 40px 32px; width: 100%; max-width: 320px;
}
.pin-logo {
  width: 72px; height: 72px; border-radius: 20px;
  background: linear-gradient(135deg, #1e1e2a, #2a2a3a);
  border: 1px solid rgba(201,168,76,0.3);
  display: flex; align-items: center; justify-content: center;
  font-size: 36px; font-weight: 800; color: #c9a84c;
  letter-spacing: -1px;
}
.pin-title { font-size: 20px; font-weight: 700; color: var(--text); }
.pin-dots { display: flex; gap: 16px; }
.pin-dots span {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--text-muted); transition: all .15s;
}
.pin-dots span.filled { background: var(--accent); border-color: var(--accent); }
.pin-error { color: #e05; font-size: 13px; }
.pin-error.hidden { display: none; }
.pin-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; width: 100%;
}
.pin-key {
  aspect-ratio: 1; border-radius: 50%; border: none;
  background: var(--surface-2); color: var(--text);
  font-size: 22px; font-weight: 600; cursor: pointer;
  transition: background .12s, transform .08s;
}
.pin-key:active { background: var(--accent); color: #000; transform: scale(.92); }
.pin-key[data-key=""] { visibility: hidden; }
.pin-key[data-key="⌫"] { font-size: 18px; }
