/* ============================================================
   FinBot Mini App — тема «чернильный + золото».
   Вся гамма живёт в токенах ниже: меняете здесь — меняется везде.
   ============================================================ */

:root {
  --bg:        #0E1621;
  --bg-2:      #16212E;
  --card:      #1B2836;
  --card-2:    #223142;
  --line:      #2B3B4E;
  --text:      #E9EEF5;
  --muted:     #8DA2B8;
  --accent:    #D4AF37;   /* золото */
  --accent-dim:#9C8129;
  --up:        #4CC38A;   /* доход */
  --down:      #E5695B;   /* расход */
  --radius:    16px;
  --radius-sm: 12px;
  --gap:       12px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
}

/* --- Альтернативная тема: тёмно-зелёная. Раскомментируйте блок целиком ---
:root {
  --bg: #0C1A14; --bg-2: #10241B; --card: #142E22; --card-2: #1B3B2C;
  --line: #24503B; --text: #E7F2EB; --muted: #8FB3A1;
  --accent: #34C77B; --accent-dim: #238754; --up: #34C77B; --down: #E5695B;
}
*/

/* --- Альтернативная тема: светлая ---
:root {
  --bg: #F4F6F9; --bg-2: #FFFFFF; --card: #FFFFFF; --card-2: #F0F3F7;
  --line: #E1E7EF; --text: #14202C; --muted: #6B7C8F;
  --accent: #B08D1F; --accent-dim: #8A6E17; --up: #17A25F; --down: #D2472F;
}
*/

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

body {
  margin: 0; padding: 0 0 84px;
  background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 15px; line-height: 1.4;
  /* без этого WebView приближает страницу по двойному тапу и щипком */
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Поля ввода — не мельче 16px: на меньшем размере телефон сам зумит страницу
   при фокусе и обратно уже не отъезжает. */
input, select, textarea, button { font-size: 16px; }

h1 { font-size: 19px; margin: 0; }
h2 { font-size: 14px; margin: 0; color: var(--muted); font-weight: 600;
     text-transform: uppercase; letter-spacing: .04em; }

/* ---------------------------------------------------------- шапка */

.top { padding: 18px 16px 8px; background: linear-gradient(180deg, var(--bg-2), var(--bg)); }
.top.compact { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.top-label { color: var(--muted); font-size: 13px; }
.top-balance { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.top-balance .amount { font-size: 30px; font-weight: 700; letter-spacing: -.5px; }
.top-sub { color: var(--muted); font-size: 13px; margin-top: 2px; min-height: 18px; }

.icon-btn {
  background: var(--card); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; width: 34px; height: 34px; font-size: 15px; cursor: pointer;
}
.icon-btn:active { background: var(--card-2); }
.back { background: none; border: none; color: var(--accent); font-size: 26px;
        line-height: 1; cursor: pointer; padding: 0 4px; }
.link-btn { background: none; border: none; color: var(--accent); font-size: 14px;
            cursor: pointer; padding: 0; }
.link-btn.gold { font-weight: 600; }

/* ---------------------------------------------------------- чипы */

.chips { display: flex; gap: 8px; padding: 10px 16px; overflow-x: auto;
         scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips.tight { padding: 8px 0; }
.chips.center { justify-content: center; }
.chip {
  flex: 0 0 auto; padding: 7px 14px; border-radius: 999px; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); color: var(--muted);
  font-size: 13px; font-family: var(--font);
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #1A1206;
               font-weight: 600; }

/* ---------------------------------------------------------- секции и карточки */

.section { padding: 6px 16px 14px; }
.section-head { display: flex; align-items: center; justify-content: space-between;
                margin: 10px 0 8px; gap: 8px; }
.hint { color: var(--muted); font-size: 12px; }

.card { background: var(--card); border: 1px solid var(--line);
        border-radius: var(--radius); padding: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }

.stat-card .stat-top { display: flex; justify-content: space-between; align-items: center; }
.stat-card .stat-label { color: var(--muted); font-size: 13px; }
.stat-card .stat-value { font-size: 19px; font-weight: 700; margin-top: 6px; }
.stat-card .stat-value.up { color: var(--up); }
.stat-card .stat-value.down { color: var(--down); }
.pct { font-size: 12px; padding: 2px 7px; border-radius: 999px; background: var(--card-2);
       color: var(--muted); }
.pct.up { color: var(--up); } .pct.down { color: var(--down); }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag { font-size: 11px; color: var(--muted); background: var(--card-2);
       border-radius: 8px; padding: 3px 8px; }

.hscroll { display: flex; gap: var(--gap); overflow-x: auto; padding-bottom: 4px;
           scrollbar-width: none; }
.hscroll::-webkit-scrollbar { display: none; }
.wallet {
  flex: 0 0 150px; background: linear-gradient(140deg, var(--card-2), var(--card));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
}
.wallet .w-name { color: var(--muted); font-size: 12px; }
.wallet .w-sum { font-size: 18px; font-weight: 700; margin-top: 8px; }
.wallet.add { display: flex; align-items: center; justify-content: center;
              color: var(--muted); font-size: 13px; text-align: center;
              border-style: dashed; cursor: pointer; }

.networth .nw-total { font-size: 24px; font-weight: 700; color: var(--accent); }
.networth .nw-rows { margin-top: 10px; display: grid; gap: 6px; }
.rows .row, .nw-rows .row { display: flex; justify-content: space-between;
                            align-items: center; gap: 10px; }
.rows .row { padding: 10px 0; border-bottom: 1px solid var(--line); }
.rows .row:last-child { border-bottom: none; }
.nw-rows .row span { color: var(--muted); font-size: 13px; }
.gold { color: var(--accent); }

/* ---------------------------------------------------------- списки */

.list { display: flex; flex-direction: column; gap: 8px; }
.list.collapsed { display: none; }
.item {
  display: flex; align-items: center; gap: 12px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 11px 12px;
}
.item .ic { width: 36px; height: 36px; border-radius: 10px; background: var(--card-2);
            display: flex; align-items: center; justify-content: center; font-size: 17px;
            flex: 0 0 auto; }
.item .mid { flex: 1; min-width: 0; }
.item .t1 { font-size: 14px; white-space: nowrap; overflow: hidden;
            text-overflow: ellipsis; }
.item .t2 { font-size: 12px; color: var(--muted); margin-top: 2px; }
.item .right { text-align: right; flex: 0 0 auto; }
.item .sum { font-weight: 600; font-size: 14px; }
.item .sum.up { color: var(--up); } .item .sum.down { color: var(--down); }
.item .time { font-size: 11px; color: var(--muted); margin-top: 2px; }
.day-sep { color: var(--muted); font-size: 12px; margin: 10px 2px 2px; }

.empty { text-align: center; color: var(--muted); padding: 26px 16px; font-size: 14px; }
.empty b { display: block; color: var(--text); margin-bottom: 4px; font-size: 15px; }

.loader { text-align: center; color: var(--muted); padding: 14px; font-size: 13px; }

/* ---------------------------------------------------------- скелетоны */

.skeleton { display: block; border-radius: var(--radius-sm);
            background: linear-gradient(90deg, var(--card) 25%, var(--card-2) 37%, var(--card) 63%);
            background-size: 400% 100%; animation: shine 1.3s ease infinite; }
.chip-skel { width: 90px; height: 32px; border-radius: 999px; }
.card-skel { height: 92px; }
.row-skel { height: 58px; }
@keyframes shine { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* ---------------------------------------------------------- статистика */

.period { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.period span { font-size: 14px; min-width: 150px; text-align: center; }
.custom-range { display: flex; align-items: center; gap: 8px; padding: 8px 0; }
.custom-range input { background: var(--card); border: 1px solid var(--line);
                      color: var(--text); border-radius: 10px; padding: 8px;
                      font-family: var(--font); font-size: 16px; }

.donut-wrap { position: relative; margin: 8px auto 14px; max-width: 260px; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column;
                align-items: center; justify-content: center; pointer-events: none; }
.donut-center span { font-size: 18px; font-weight: 700; }
.donut-center small { color: var(--muted); font-size: 11px; }

/* ---------------------------------------------------------- «Больше» */

.menu { display: flex; flex-direction: column; gap: 8px; }
.menu-item { display: flex; align-items: center; gap: 12px; text-align: left;
             background: var(--card); border: 1px solid var(--line); color: var(--text);
             border-radius: var(--radius-sm); padding: 14px; font-size: 15px;
             font-family: var(--font); cursor: pointer; }
.menu-item em { margin-left: auto; color: var(--muted); font-style: normal; font-size: 12px; }
.cat-groups { display: flex; flex-direction: column; gap: 14px; }
.cat-group h3 { font-size: 13px; color: var(--muted); margin: 0 0 8px; font-weight: 600; }
.cat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding: 6px 0; }
.cat-cell { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm);
            padding: 10px 4px; text-align: center; cursor: pointer; font-size: 11px;
            color: var(--muted); font-family: var(--font); }
.cat-cell .ce { display: block; font-size: 20px; margin-bottom: 4px; }
.cat-cell.active { border-color: var(--accent); color: var(--text); }
.cat-cell .del { color: var(--down); font-size: 11px; }

/* ---------------------------------------------------------- формы и модалки */

.modal { position: fixed; inset: 0; background: rgba(4, 9, 15, .6);
         display: flex; align-items: flex-end; z-index: 50; }
.sheet { width: 100%; max-height: 92vh; overflow-y: auto; background: var(--bg-2);
         border-radius: 20px 20px 0 0; padding: 14px 16px 26px;
         border-top: 1px solid var(--line); animation: rise .18s ease; }
@keyframes rise { from { transform: translateY(24px); opacity: .6; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between;
              padding-bottom: 12px; }
.amount-input { display: flex; align-items: center; gap: 10px; justify-content: center;
                padding: 12px 0 4px; }
.amount-input input { width: 60%; background: none; border: none; color: var(--text);
                      font-size: 38px; font-weight: 700; text-align: right;
                      font-family: var(--font); outline: none; }
/* Строки выбора в окне записи: компактно, значение уже подставлено */
.pick-rows { margin-top: 16px; border: 1px solid var(--line); border-radius: var(--radius-sm);
             overflow: hidden; }
.pick-row { width: 100%; display: flex; align-items: center; gap: 10px; padding: 14px;
            background: var(--card); border: none; border-bottom: 1px solid var(--line);
            color: var(--text); font-family: var(--font); font-size: 15px; cursor: pointer; }
.pick-row:last-child { border-bottom: none; }
.pick-label { color: var(--muted); font-size: 14px; }
.pick-value { margin-left: auto; font-weight: 600; white-space: nowrap; overflow: hidden;
              text-overflow: ellipsis; max-width: 55%; }
.pick-arrow { color: var(--muted); font-size: 20px; line-height: 1; }
.tx-save-btn { width: 100%; margin-top: 16px; padding: 15px; font-size: 17px; }
.item.picked { border-color: var(--accent); }
.edit-actions { display: flex; gap: 6px; margin-left: auto; }
.edit-actions .icon-btn { width: 38px; height: 38px; }
.edit-actions .icon-btn[disabled] { opacity: .35; }
.icon-btn.danger { color: var(--down); border-color: var(--down); }
.right.gold { color: var(--accent); font-size: 18px; }

.cur-toggle { background: var(--card); border: 1px solid var(--line); color: var(--accent);
              border-radius: 10px; padding: 8px 12px; font-size: 15px; cursor: pointer;
              font-family: var(--font); }
.text-input { width: 100%; background: var(--card); border: 1px solid var(--line);
              color: var(--text); border-radius: var(--radius-sm); padding: 12px;
              font-size: 16px; font-family: var(--font); margin-top: 10px; outline: none; }
.text-input::placeholder { color: var(--muted); }
.field { margin-top: 10px; }
.field label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.btn { background: var(--accent); color: #1A1206; border: none; border-radius: var(--radius-sm);
       padding: 12px 16px; font-size: 15px; font-weight: 600; font-family: var(--font);
       cursor: pointer; }
.btn.small { padding: 8px 12px; font-size: 13px; }
.switch { width: 46px; height: 27px; appearance: none; background: var(--card-2);
          border: 1px solid var(--line); border-radius: 999px; position: relative;
          cursor: pointer; transition: background .15s; }
.switch:checked { background: var(--accent); }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 21px;
                 height: 21px; border-radius: 50%; background: var(--text); transition: left .15s; }
.switch:checked::after { left: 21px; background: #1A1206; }
.num { width: 68px; background: var(--card); border: 1px solid var(--line); color: var(--text);
       border-radius: 10px; padding: 8px; text-align: center; font-family: var(--font);
       font-size: 16px; }

.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
         background: var(--card-2); border: 1px solid var(--line); color: var(--text);
         padding: 10px 18px; border-radius: 999px; font-size: 14px; z-index: 60;
         animation: rise .18s ease; }

/* ---------------------------------------------------------- страница входа */

.login-body { padding: 0; display: flex; align-items: center; justify-content: center;
              min-height: 100vh; }
.login-wrap { width: 100%; max-width: 380px; padding: 24px 20px 40px; text-align: center; }
.login-logo { font-size: 44px; }
.login-title { font-size: 26px; margin: 8px 0 2px; letter-spacing: -.5px; }
.login-sub { color: var(--muted); margin: 0 0 22px; font-size: 14px; }
.login-card { background: var(--card); border: 1px solid var(--line);
              border-radius: var(--radius); padding: 18px; text-align: left; }
.login-card .field span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.login-btn { width: 100%; margin-top: 14px; }
.login-hint { color: var(--muted); font-size: 12px; line-height: 1.5; margin: 14px 0 0; }
.login-hint a { color: var(--accent); }
.login-hint code { background: var(--card-2); padding: 1px 6px; border-radius: 6px; }
.code-input { text-align: center; letter-spacing: .4em; font-size: 24px; font-weight: 600; }
.login-error { margin-top: 14px; color: var(--down); font-size: 13px; }

/* ---------------------------------------------------------- нижняя навигация */

/* Пока открыта клавиатура, нижняя панель только мешает — она всплывает поверх полей */
body.kb-open .tabbar { display: none; }
body.kb-open { padding-bottom: 12px; }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; display: flex;
          background: var(--bg-2); border-top: 1px solid var(--line);
          padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 40; }
.tab { flex: 1; background: none; border: none; color: var(--muted); font-size: 10px;
       font-family: var(--font); display: flex; flex-direction: column; align-items: center;
       gap: 3px; padding: 6px 0; cursor: pointer; }
.tab span { font-size: 18px; }
.tab.active { color: var(--accent); }
.tab.plus { flex: 0 0 58px; color: #1A1206; font-size: 28px; font-weight: 300;
            background: var(--accent); border-radius: 50%; width: 54px; height: 54px;
            margin: -18px 6px 0; align-self: flex-start; line-height: 1;
            align-items: center; justify-content: center;
            box-shadow: 0 6px 16px rgba(212, 175, 55, .3); }
