/* ===== Темы (как в hub) ===== */
:root {
  --bg: #f6f4ef; --card: #ffffff; --text: #2b2a27; --text-2: #8a857c;
  --accent: #c96f4a; --accent-soft: rgba(201,111,74,.10); --stroke: rgba(0,0,0,.07);
  --danger: #d6552f; --ok: #4a8a52;
  --radius: 18px; --shadow-sm: 0 2px 8px rgba(60,50,40,.06);
  --shadow-md: 0 8px 24px rgba(60,50,40,.10); --shadow-lg: 0 16px 40px rgba(60,50,40,.15);
}
html[data-theme="dark"] {
  --bg: #191917; --card: #262522; --text: #ece9e2; --text-2: #97928a;
  --accent: #e08a62; --accent-soft: rgba(224,138,98,.14); --stroke: rgba(255,255,255,.08);
  --danger: #e8765a; --ok: #6bbf74;
  --shadow-sm: 0 2px 8px rgba(0,0,0,.3); --shadow-md: 0 10px 28px rgba(0,0,0,.38); --shadow-lg: 0 18px 44px rgba(0,0,0,.46);
}
html[data-theme="ocean"] {
  --bg: #eef4f7; --card: #ffffff; --text: #1f2e38; --text-2: #7b8d99;
  --accent: #3a7ca5; --accent-soft: rgba(58,124,165,.10); --stroke: rgba(20,60,90,.08);
  --danger: #d6552f; --ok: #3a8f7a;
}
html[data-theme="forest"] {
  --bg: #f0f4ee; --card: #ffffff; --text: #253324; --text-2: #82917e;
  --accent: #4a8a52; --accent-soft: rgba(74,138,82,.10); --stroke: rgba(30,70,30,.08);
  --danger: #c4622f; --ok: #4a8a52;
}
html[data-theme="graphite"] {
  --bg: #15171a; --card: #24282e; --text: #e8eaee; --text-2: #8d939c;
  --accent: #7c9fd4; --accent-soft: rgba(124,159,212,.14); --stroke: rgba(255,255,255,.08);
  --danger: #e8765a; --ok: #6bbf74;
  --shadow-sm: 0 2px 8px rgba(0,0,0,.3); --shadow-md: 0 10px 28px rgba(0,0,0,.38); --shadow-lg: 0 18px 44px rgba(0,0,0,.46);
}

* { box-sizing: border-box; }
body {
  margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
}
input, select, button, textarea { font-family: inherit; font-size: 15px; }

/* ===== Вход ===== */
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
  background: var(--card); border-radius: 22px; padding: 32px 26px; width: 100%; max-width: 360px;
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 12px; text-align: center;
}
.login-logo { font-size: 46px; }
.login-card h1 { margin: 4px 0 0; font-size: 23px; }
.login-sub { margin: 0 0 8px; color: var(--text-2); font-size: 14px; }
.login-card input {
  padding: 13px 15px; border: 1px solid var(--stroke); border-radius: 12px;
  background: var(--bg); color: var(--text);
}
.login-err { color: var(--danger); font-size: 13px; min-height: 16px; margin: 0; }

/* ===== Топбар ===== */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px calc(14px + env(safe-area-inset-top)); background: var(--bg);
  border-bottom: 1px solid var(--stroke);
}
.topbar-title { font-weight: 700; font-size: 18px; }
.topbar-who { color: var(--text-2); font-size: 13px; }

/* ===== Контент ===== */
#tab-root { max-width: 760px; margin: 0 auto; padding: 16px 16px 110px; display: flex; flex-direction: column; gap: 14px; }

.glass-card { background: var(--card); border: 1px solid var(--stroke); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-md); }
.section-title { font-weight: 700; font-size: 16px; margin: 4px 2px; }

.btn-primary {
  background: var(--accent); color: #fff; border: none; border-radius: 14px; padding: 12px 18px;
  font-weight: 600; cursor: pointer; box-shadow: var(--shadow-sm); transition: transform .12s, filter .12s;
}
.btn-primary:active { transform: scale(.97); }
.btn-ghost {
  background: transparent; color: var(--text); border: 1px solid var(--stroke); border-radius: 12px;
  padding: 10px 14px; cursor: pointer; font-weight: 500;
}
.icon-btn { background: transparent; border: none; color: var(--text-2); cursor: pointer; padding: 6px; border-radius: 10px; display: inline-flex; }
.icon-btn svg { width: 20px; height: 20px; }

input.fld, select.fld, textarea.fld {
  width: 100%; padding: 11px 13px; border: 1px solid var(--stroke); border-radius: 12px;
  background: var(--bg); color: var(--text);
}
label.lbl { display: block; font-size: 13px; color: var(--text-2); margin: 10px 0 4px; }

/* ===== KPI ===== */
.kpi-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.kpi { background: var(--card); border: 1px solid var(--stroke); border-radius: 16px; padding: 16px; box-shadow: var(--shadow-sm); }
.kpi .lab { font-size: 12px; color: var(--text-2); }
.kpi .val { font-size: 22px; font-weight: 700; margin-top: 6px; }
.kpi.income .val { color: var(--ok); }
.kpi.expense .val { color: var(--danger); }

/* ===== Список операций ===== */
.tx { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--stroke); }
.tx:last-child { border-bottom: none; }
.tx .ic { width: 42px; height: 42px; border-radius: 12px; background: var(--accent-soft); display: grid; place-items: center; font-size: 20px; flex: none; }
.tx .mid { flex: 1; min-width: 0; }
.tx .mid b { display: block; font-size: 15px; }
.tx .mid small { color: var(--text-2); font-size: 12px; }
.tx .amt { font-weight: 700; white-space: nowrap; }
.tx .amt.income { color: var(--ok); }
.tx .amt.expense { color: var(--danger); }
.author-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 999px;
  border: 1px solid var(--stroke); background: var(--card); color: var(--text); cursor: pointer; font-size: 13px;
}
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.cat-row { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--stroke); }
.cat-row:last-child { border-bottom: none; }
.cat-row.arch { opacity: .5; }

.empty { text-align: center; color: var(--text-2); padding: 26px; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }

/* ===== Тема-свотчи ===== */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 10px; margin-top: 12px; }
.theme-swatch { border: 1px solid var(--stroke); border-radius: 12px; padding: 8px; background: var(--card); color: var(--text); cursor: pointer; font-size: 12px; text-align: center; }
.theme-swatch.active { outline: 2px solid var(--accent); }
.theme-swatch .sw { height: 34px; border-radius: 8px; margin-bottom: 6px; }

/* ===== Модалка ===== */
.fh-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: grid; place-items: center; z-index: 50; padding: 16px; }
.fh-modal { background: var(--card); border-radius: 20px; padding: 22px; width: 100%; max-width: 440px; box-shadow: var(--shadow-lg); max-height: 90vh; overflow: auto; }

/* ===== SVG диаграмма ===== */
.legend { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.legend .li { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.legend .li .sw { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.legend .li .nm { flex: 1; }
.legend .li .vl { color: var(--text-2); }

/* ===== Нижнее меню (как в hub) ===== */
.fh-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex;
  background: var(--card); border-top: 1px solid var(--stroke);
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
}
.fh-nav-btn {
  flex: 1; background: transparent; border: none; cursor: pointer; color: var(--text-2);
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 4px;
}
.fh-nav-btn svg { width: 21px; height: 21px; padding: 5px 16px; box-sizing: content-box; border-radius: 999px; transition: background .15s, color .15s; }
.fh-nav-btn span { font-size: 11px; font-weight: 600; }
.fh-nav-btn.active { color: var(--accent); }
.fh-nav-btn.active svg { background: var(--accent-soft); }

@media (min-width: 760px) {
  .fh-nav { max-width: 760px; margin: 0 auto; border: 1px solid var(--stroke); border-radius: 18px; bottom: 16px; }
}
[hidden] { display: none !important; }
