:root {
  color-scheme: dark;
  --bg: #0d0d0f;
  --card: #1c1c20;
  --card-2: #2a2a30;
  --text: #ffffff;
  --muted: #8e8e96;
  --border: #2e2e35;
  --accent: #ff4f6d;
  --accent-2: #ff8a4c;
  --accent-grad: linear-gradient(135deg, #ff4f6d 0%, #ff8a4c 100%);
  --accent-text: #ffffff;
  --positive: #3ddc84;
  --negative: #ff5c5c;
  --radius: 22px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  background:
    radial-gradient(900px 500px at 10% -10%, rgb(255 79 109 / 0.22), transparent 60%),
    radial-gradient(800px 500px at 100% 0%, rgb(120 80 255 / 0.18), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  accent-color: var(--accent);
}

a { color: var(--text); text-decoration: none; font-weight: 600; }
a:hover { color: var(--accent-2); }
main > p:first-child a { color: var(--muted); font-weight: 500; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: rgb(13 13 15 / 0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.brand { font-weight: 800; font-size: 18px; color: var(--text); letter-spacing: -0.02em; }
#userbox { display: flex; align-items: center; gap: 18px; color: var(--muted); }
.topbar .avatar { width: 32px; height: 32px; font-size: 13px; }

main { max-width: 960px; margin: 0 auto; padding: 20px 16px 60px; }

h1 { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; margin: 0 0 16px; }
h2 { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 12px; }

.card {
  background: var(--card);
  border: none;
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 800px) { .grid { grid-template-columns: 1fr 1fr; } }

form { display: grid; gap: 12px; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1 1 140px; }

input, select, button {
  font: inherit;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: var(--card-2);
  color: var(--text);
  min-width: 0;
}
input::placeholder { color: #6b6b73; }
input:disabled { opacity: 0.6; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
input[type=checkbox] { width: 18px; height: 18px; padding: 0; }

button {
  cursor: pointer;
  background: var(--accent-grad);
  color: var(--accent-text);
  border: none;
  border-radius: 999px;
  padding: 12px 20px;
  font-weight: 700;
  transition: transform 0.08s ease, filter 0.15s ease;
}
button:hover:not(:disabled) { filter: brightness(1.08); }
button:active:not(:disabled) { transform: scale(0.97); }
button.secondary { background: var(--card-2); color: var(--text); }
button.link {
  background: none; border: none; padding: 0 4px; color: var(--muted); font-weight: 400; border-radius: 8px;
}
button.link:hover { color: var(--negative); filter: none; }
button:disabled { opacity: 0.5; cursor: default; }

.auth { max-width: 400px; margin: 40px auto; }
.auth .forgot { justify-self: end; margin-top: -4px; font-size: 14px; color: var(--muted); }
.tabs { display: flex; gap: 4px; margin-bottom: 16px; padding: 4px; background: var(--card-2); border-radius: 999px; }
.tabs button { flex: 1; padding: 10px; }
.tabs button.secondary { background: transparent; color: var(--muted); }
.google-btn { width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 12px; }
.google-icon { display: inline-flex; background: #fff; border-radius: 50%; padding: 3px; }
.divider { display: flex; align-items: center; gap: 10px; margin: 16px 0; color: var(--muted); font-size: 13px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

ul.list { list-style: none; margin: 0; padding: 0; }
ul.list li {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
ul.list li:last-child { border-bottom: none; }
.sub { color: var(--muted); font-size: 13px; }
.actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.amount { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 700; }
.pos { color: var(--positive); }
.neg { color: var(--negative); }
.empty { color: var(--muted); }
ul.list li > button.secondary { padding: 8px 16px; font-size: 14px; }

.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.checks label {
  display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px;
  padding: 8px 14px; border-radius: 999px; background: var(--card-2); cursor: pointer;
}
.checks label:has(input:checked) { background: color-mix(in srgb, var(--accent) 22%, var(--card-2)); }
.shares { display: grid; gap: 6px; }
.shares label { grid-template-columns: 1fr 120px; align-items: center; color: var(--text); }

.error { color: var(--negative); font-size: 14px; min-height: 1em; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 30;
  background: #fff; color: #111; font-weight: 600;
  padding: 12px 20px; border-radius: 999px; max-width: calc(100% - 32px);
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.4);
}

h3 { font-size: 15px; margin: 0 0 4px; }
.invite {
  margin: 14px 0;
  padding: 14px;
  border: none;
  background: var(--card-2);
  border-radius: 16px;
}
.invite .row { align-items: center; margin: 8px 0 6px; }
.invite input { flex: 1 1 200px; font-size: 13px; color: var(--muted); background: var(--card); }
/* Аватари */
.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  border-radius: 50%; object-fit: cover; overflow: hidden;
  background: color-mix(in srgb, var(--accent) 18%, var(--card)); color: var(--accent); font-weight: 700;
}
.avatar-sm { width: 40px; height: 40px; font-size: 16px; }
.avatar-lg { width: 96px; height: 96px; font-size: 38px; }
.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.me { display: flex; align-items: center; gap: 10px; color: var(--text); }
.admin-link { font-weight: 600; color: var(--muted); }
@media (max-width: 480px) { .me-name { display: none; } }
.profile-photo { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.profile-photo .actions { flex-wrap: wrap; margin-bottom: 6px; }

.badge {
  margin-left: 6px; padding: 1px 7px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent);
}
.tag {
  margin-left: 8px; padding: 1px 8px; border-radius: 999px; font-size: 12px; white-space: nowrap;
  background: var(--card-2); color: var(--muted);
}

/* Назва групи */
.title-row { display: flex; align-items: center; gap: 6px; margin-bottom: 16px; }
.title-row h1 { margin: 0; }
.title-row button.link { font-size: 20px; }
.title-row button.link:hover { color: var(--accent-2); }
form.rename { margin-bottom: 16px; }
form.rename input { font-size: 18px; font-weight: 600; }

/* Автопідставлений залишок */
.shares input.auto { background: color-mix(in srgb, var(--accent) 8%, var(--card)); }

/* Адмінка */
ul.tags li { display: block; padding: 6px 0; }
ul.tags form { gap: 4px; }
ul.tags .error:empty { display: none; }
.tag-row { align-items: center; flex-wrap: nowrap; }
.tag-row > input:not(.icon-input) { flex: 1 1 auto; }
.icon-input { flex: 0 0 56px !important; width: 56px; text-align: center; }

.invite-banner {
  padding: 10px 12px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
}

/* Панелі над сторінкою групи */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.card h3 { margin-top: 18px; }

/* Аналітика: плитки та смужки (одна серія — один колір) */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stat { background: var(--card-2); border-radius: 16px; padding: 14px 16px; }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
ul.bars { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 12px; }
.bar-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 4px; }
.bar-label { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bar-label .avatar-sm { width: 24px; height: 24px; font-size: 12px; }
.bar-track { height: 8px; border-radius: 999px; background: var(--card-2); }
.bar-fill { height: 100%; border-radius: 999px; background: var(--accent-grad); }
.bar-row:hover .bar-fill { filter: brightness(1.1); }

/* Історія змін */
ul.history li { display: block; }
ul.changes { margin: 4px 0; padding-left: 18px; color: var(--text); font-size: 14px; }

/* Запрошення за кнопкою */
.invite-toggle { width: 100%; margin-top: 12px; }
.invite-body { margin-top: 4px; }

/* Витрата в режимі редагування */
.card.editing { box-shadow: 0 0 0 2px var(--accent); }
button.link.edit:hover { color: var(--accent-2); }

/* Адмінка: порядок і вибір значка */
.order { display: flex; flex-direction: column; flex: 0 0 auto !important; }
.order button.link { line-height: 1; padding: 2px 4px; font-size: 12px; }
.order button.link:hover:not(:disabled) { color: var(--accent); }
.order button:disabled { opacity: 0.25; }
.icon-picker { position: relative; flex: 0 0 56px !important; }
.icon-button { width: 56px; font-size: 20px; padding: 6px 0; line-height: 1.4; border-radius: 14px; background: var(--card-2); }
.icon-grid {
  position: absolute; z-index: 10; top: calc(100% + 4px); left: 0;
  display: grid; grid-template-columns: repeat(8, 40px); gap: 4px;
  padding: 8px; background: var(--card-2); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.5);
}
.icon-option { background: none; border: 1px solid transparent; border-radius: 10px; color: var(--text); font-size: 20px; padding: 4px 0; font-weight: 400; }
.icon-option:hover, .icon-option.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.icon-option.none { grid-column: 1 / -1; font-size: 13px; color: var(--muted); }
@media (max-width: 480px) { .icon-grid { grid-template-columns: repeat(6, 40px); } }
button.secondary.dirty { background: var(--accent-grad); color: var(--accent-text); }
ul.list ul.changes li { display: list-item; padding: 1px 0; border: none; }

/* Кнопки «Аналітика» / «Історія змін» — як перемикачі-пігулки */
.toolbar button { padding: 10px 18px; }

/* Квитанція у формі витрати */
.receipt { display: grid; gap: 10px; padding: 14px; border-radius: 16px; background: var(--card-2); }
.receipt-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.receipt-actions button { flex: 1 1 auto; padding: 10px 14px; font-size: 14px; }
.receipt-actions button.secondary { background: var(--card); }

/* Маленькі аватари */
.avatar-xs { width: 22px; height: 22px; font-size: 11px; }
.sub .avatar-xs { width: 18px; height: 18px; font-size: 9px; vertical-align: middle; margin-top: -2px; }
.checks label .avatar-xs { margin-left: -2px; }
.avatar-stack { display: inline-flex; align-items: center; }
.avatar-stack .avatar { width: 26px; height: 26px; font-size: 12px; box-shadow: 0 0 0 2px var(--card) !important; }
.avatar-stack .avatar + .avatar { margin-left: -7px; }
.avatar-stack .more { background: var(--card-2); color: var(--muted); font-size: 10px; }

/* Список груп */
a.group-name { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.group-meta { display: flex; align-items: center; gap: 8px; margin-top: 6px; }

/* Поточний користувач — виділений */
.avatar-me { box-shadow: 0 0 0 2px var(--accent) !important; }
ul.list li.is-me {
  margin: 0 -12px; padding-left: 12px; padding-right: 12px;
  border-radius: 14px; border-bottom-color: transparent;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.me-name-strong { font-weight: 700; }
.badge.muted { background: var(--card-2); color: var(--muted); }

/* Дата створення групи */
.created { margin-top: 4px; font-size: 12px; color: #5f5f67; }

/* Архів */
.archive-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  margin-bottom: 16px; padding: 10px 10px 10px 16px; border-radius: 16px; background: var(--card);
}
.archive-bar button { padding: 8px 16px; font-size: 14px; }
.hint { padding: 0 4px; }

/* Вибір «Хто платив» — пігулки з аватарами, сам перемикач прихований */
.field { display: grid; gap: 6px; }
.field-label { font-size: 13px; color: var(--muted); }
.checks.pick input[type=radio] { position: absolute; opacity: 0; pointer-events: none; }
.checks.pick label { position: relative; }
.checks.pick label:has(input:checked) { box-shadow: inset 0 0 0 2px var(--accent); }
.checks.pick label:has(input:focus-visible) { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.checks.pick label:not(:has(input:checked)) { color: var(--muted); }
.shares label .person { gap: 8px; }

/* Нижня панель розділів (як у mono) */
body.has-tabbar main { padding-bottom: 120px; }
body.has-tabbar #toast { bottom: 104px; }
.tabbar {
  position: fixed; z-index: 25; left: 50%; bottom: calc(12px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex; gap: 2px; padding: 6px;
  width: min(420px, calc(100% - 24px));
  background: rgb(36 36 42 / 0.72);
  backdrop-filter: blur(20px) saturate(1.4); -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid rgb(255 255 255 / 0.06);
  border-radius: 999px;
  box-shadow: 0 12px 40px rgb(0 0 0 / 0.45);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px 6px; border-radius: 999px;
  color: var(--muted); font-size: 11px; font-weight: 600;
  transition: color 0.15s ease, background 0.15s ease;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); background: rgb(255 255 255 / 0.06); }
.tab-icon svg { width: 24px; height: 24px; display: block; }
.group-info { flex: 1; min-width: 0; }

/* Шапка групи: назва + меню «☰» */
.group-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.group-head > :first-child { flex: 1; min-width: 0; margin-bottom: 0; }
.menu { position: relative; flex: 0 0 auto; }
.menu-button {
  width: 44px; height: 44px; padding: 0; display: grid; place-items: center;
  background: var(--card); color: var(--text); border-radius: 50%;
}
.menu-button svg { width: 22px; height: 22px; }
.menu-button.open, .menu-button.has-active { background: var(--card-2); color: var(--accent); }
.menu-list {
  position: absolute; z-index: 15; top: calc(100% + 8px); right: 0;
  min-width: 240px; padding: 6px; display: grid; gap: 2px;
  background: rgb(36 36 42 / 0.92);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgb(255 255 255 / 0.06); border-radius: 18px;
  box-shadow: 0 16px 40px rgb(0 0 0 / 0.5);
}
.menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 11px 12px; border-radius: 12px; text-align: left;
  background: none; color: var(--text); font-weight: 600;
}
.menu-item:hover { background: rgb(255 255 255 / 0.06); filter: none; }
.menu-item > span:first-child { flex: 1; }
.menu-item.active { color: var(--accent); }
.menu-count {
  min-width: 22px; padding: 1px 7px; border-radius: 999px; font-size: 12px; text-align: center;
  background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent);
}
.menu-check { color: var(--accent); }

/* Відкритий із меню блок — з хрестиком «закрити» */
.panel { position: relative; scroll-margin-top: 80px; }
button.link.panel-close {
  position: absolute; top: 12px; right: 12px; width: 40px; height: 40px; padding: 0 !important;
  display: grid; place-items: center; border-radius: 50%; font-size: 20px; line-height: 1;
  background: var(--card-2) !important; color: var(--text) !important;
}
button.link.panel-close:hover { filter: brightness(1.1); color: var(--text) !important; }
.panel .card > h2, .panel .card-head { margin-right: 48px; }

/* Список витрат: компактний рядок, що розгортається */
ul.list.expenses li { display: block; padding: 0; }
details.expense > summary {
  display: flex; align-items: center; gap: 10px; padding: 12px 0;
  list-style: none; cursor: pointer;
}
details.expense > summary::-webkit-details-marker { display: none; }
details.expense > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 12px; }
.expense-main { flex: 1; min-width: 0; }
.expense-title { font-weight: 600; }
.chevron {
  color: var(--muted); font-size: 22px; line-height: 1; width: 14px; text-align: center;
  transition: transform 0.15s ease;
}
details.expense[open] .chevron { transform: rotate(90deg); color: var(--accent); }
.expense-body {
  display: grid; gap: 12px; margin-bottom: 12px; padding: 14px;
  border-radius: 16px; background: var(--card-2);
}
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 6px; border-radius: 999px; background: var(--card); font-size: 14px;
}
.pill-amount { color: var(--muted); font-variant-numeric: tabular-nums; }
.expense-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; flex-wrap: wrap; }
.expense-actions button.link { font-size: 14px; }
.menu-count.muted { background: rgb(255 255 255 / 0.08); color: var(--muted); }


/* Загальний баланс — виділений блок */
.card.hero {
  position: relative; overflow: hidden; padding: 22px 22px 24px;
  background:
    radial-gradient(120% 140% at 0% 0%, rgb(255 79 109 / 0.28), transparent 55%),
    radial-gradient(120% 140% at 100% 100%, rgb(120 80 255 / 0.24), transparent 55%),
    var(--card);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.06);
}
.hero-label { color: var(--muted); font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.hero-amount { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.25; }
.hero-sign { display: block; font-size: 14px; font-weight: 600; letter-spacing: 0; opacity: 0.85; }
.hero-amount + .hero-amount { margin-top: 10px; }

/* Нова група: назва, валюта, кнопка; на телефоні — назва на всю ширину */
.create-group { display: grid; gap: 10px; grid-template-columns: 1fr; }

/* Сума + валюта в одному полі */
.amount-field { display: flex; gap: 6px; }
.amount-field input { flex: 1; }
.amount-field select { flex: 0 0 auto; width: 104px; padding-left: 10px; padding-right: 6px; }
.convert-hint:empty { display: none; }
.expense-amount { text-align: right; }
.expense-amount .sub { font-size: 12px; }

/* Курси валют */
ul.list.rates li { flex-wrap: wrap; }
.rate-code { font-weight: 600; }
.rate-row { display: flex; align-items: center; gap: 8px; }
.rate-row input { width: 110px; padding: 8px 12px; text-align: right; }
.rate-row button.secondary { padding: 8px 14px; font-size: 14px; }
.add-rate { display: grid; gap: 10px; grid-template-columns: 120px 1fr auto; }
.add-rate button { padding-left: 18px; padding-right: 18px; }

/* Курси з інтернету */
.refresh-rates { width: 100%; margin-top: 12px; }
.inline-form { display: grid; gap: 10px; grid-template-columns: 1fr auto; }

/* Адмінка на телефоні: рядок тегу не вилазить за край */
main { overflow-x: clip; }
.tag-row { gap: 8px; }
.tag-row > * { flex: 0 0 auto; }
.tag-row > input:not(.icon-input) { flex: 1 1 auto; min-width: 0; width: 0; }
.tag-row .actions { gap: 4px; }
button.save-tag { width: 40px; height: 40px; padding: 0; font-size: 18px; }
button.save-tag:not(.dirty) { opacity: 0.45; }
@media (max-width: 480px) {
  .icon-picker, .icon-input { flex-basis: 48px !important; }
  .icon-button { width: 48px; }
  .tag-row input { padding-left: 12px; padding-right: 12px; }
}

/* Велика сума: копійки й валюта дрібніше */
.big-money .cents { font-size: 0.6em; letter-spacing: 0; opacity: 0.8; }

/* Фото до витрати (до 2): карусель зі свайпом */
.photo-remove {
  position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; padding: 0;
  border-radius: 50%; background: rgb(0 0 0 / 0.6); color: #fff; font-size: 14px; font-weight: 700;
}

/* Додати зі знайомих */
.known-people:empty { display: none; }
.known-people { margin-top: 14px; }
.known-people ul.list li > button.secondary { padding: 8px 16px; font-size: 14px; }

/* Логотип у шапці (пропорція 2:1) */
.brand { display: inline-flex; align-items: center; min-height: 40px; }
.brand-logo { height: 44px; width: 88px; object-fit: contain; display: block; }

textarea {
  font: inherit; padding: 12px 14px; border-radius: 14px; border: 1px solid transparent;
  background: var(--card-2); color: var(--text); resize: vertical; min-height: 72px;
}
textarea:focus { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Адмінка: логотип на темному й світлому тлі */
.logo-preview { display: grid; gap: 10px; }
.logo-frames { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.logo-frame {
  display: grid; place-items: center; aspect-ratio: 2 / 1; border-radius: 14px; padding: 10px;
  font-weight: 800; font-size: 14px; text-align: center;
}
.logo-frame.dark { background: #0d0d0f; color: #fff; box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.08); }
.logo-frame.light { background: #ffffff; color: #0b0b0f; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.08); }
.logo-frame img { width: 100%; height: 100%; min-width: 0; object-fit: contain; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-row button { flex: 1 1 auto; padding: 10px 14px; font-size: 14px; }

/* Адмінка: як виглядатиме посилання в месенджері */
.social-card { border-radius: 14px; overflow: hidden; background: var(--card-2); max-width: 460px; }
.social-card img { display: block; width: 100%; aspect-ratio: 1200 / 630; object-fit: cover; }
.social-text { padding: 10px 14px 12px; display: grid; gap: 2px; }
.social-host { color: var(--muted); font-size: 12px; }
.social-title { font-weight: 700; }
.social-desc { color: var(--muted); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.carousel { position: relative; }
.carousel-track {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scroll-behavior: smooth;
  border-radius: 16px; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.carousel-track::-webkit-scrollbar { display: none; }
.carousel-slide { position: relative; flex: 0 0 100%; scroll-snap-align: center; }
.carousel-slide a { display: block; line-height: 0; }
.carousel-slide img {
  display: block; width: 100%; height: min(60vh, 460px); object-fit: contain;
  background: rgb(0 0 0 / 0.85); border-radius: 16px;
}
.photo-remove { top: 10px; right: 10px; width: 36px; height: 36px; font-size: 16px; }
.carousel-counter {
  position: absolute; top: 10px; left: 10px; padding: 3px 10px; border-radius: 999px;
  background: rgb(0 0 0 / 0.55); color: #fff; font-size: 12px; font-weight: 700; pointer-events: none;
}
.carousel-dots { display: flex; justify-content: center; gap: 6px; margin-top: 8px; }
.carousel-dot { width: 8px; height: 8px; padding: 0; border-radius: 50%; background: var(--muted); opacity: 0.4; }
.carousel-dot.active { opacity: 1; background: var(--accent); }
.carousel-arrow {
  position: absolute; top: calc(50% - 22px); width: 40px; height: 40px; padding: 0; border-radius: 50%;
  background: rgb(0 0 0 / 0.5); color: #fff; font-size: 26px; line-height: 1; display: none;
}
.carousel-arrow.prev { left: 10px; }
.carousel-arrow.next { right: 10px; }
@media (hover: hover) and (pointer: fine) { .carousel-arrow { display: grid; place-items: center; } }

/* Адмінка: логотип для кожного дизайну — на тлі шапки цього дизайну */
.logo-preview { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.logo-slot { display: grid; gap: 8px; padding: 10px; border-radius: 14px; background: var(--card-2); min-width: 0; }
.logo-slot-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.logo-slot .logo-frame {
  aspect-ratio: auto; height: 76px; min-width: 0; overflow: hidden;
  justify-items: start; padding: 10px 14px; /* як ліва частина шапки */
}
.logo-slot .logo-frame img { width: 120px; height: 56px; object-fit: contain; object-position: left center; }
.logo-frame-dark { background: #16161a; color: #fff; box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.08); }
.logo-frame-mono { background: #ffffff; color: #0b0b0f; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.08); }
.logo-frame-nova { background: #ffffff; color: #da291c; box-shadow: inset 0 -2px 0 #e3e3e8, inset 0 0 0 1px rgb(0 0 0 / 0.06); }
.logo-slot .btn-row button { padding: 8px 10px; font-size: 13px; }

/* Перемикач-сегменти (період звіту) */
.segmented { display: flex; flex-wrap: wrap; gap: 6px; }
.segmented button {
  padding: 8px 14px; font-size: 14px; font-weight: 600;
  background: var(--card-2); color: var(--muted); border-radius: 999px;
}
.segmented button.active { background: var(--text); color: var(--card); }

/* Звіт: плитки форматів */
.export-tiles { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.export-tile {
  display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 14px 16px; border-radius: 18px; background: var(--card-2); color: var(--text); font-weight: 400;
}
.export-tile:hover:not(:disabled) { filter: none; box-shadow: inset 0 0 0 1.5px var(--accent); }
.export-tile.busy { opacity: 0.7; }
.file-icon { flex: 0 0 auto; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: #fff; }
.file-icon svg { width: 24px; height: 24px; }
.file-icon.xlsx { background: #1d8a4e; }
.file-icon.pdf { background: #d6453d; }
.file-icon.mail { background: #3b6fd8; }
.mail-panel { display: grid; gap: 12px; margin-top: 12px; padding: 14px 16px; border-radius: 18px; background: var(--card-2); }
.mail-panel .segmented button { background: var(--card); }
.mail-panel .segmented button.active { background: var(--text); color: var(--card); }
.export-text { flex: 1; display: grid; gap: 1px; min-width: 0; }
.export-title { font-weight: 700; font-size: 16px; }
.export-note { color: var(--muted); font-size: 13px; }
.export-arrow { flex: 0 0 auto; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--card); color: var(--text); font-weight: 700; }
.report-status:empty { display: none; }
.report-status { margin: 0; }
.report-help summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.report-help p { margin: 6px 0 0; }
.report-card { display: grid; gap: 14px; }
.report-card > h2 { margin: 0; }
.report-card > .sub { margin: -8px 0 0; }

/* Фото у формі витрати — згорнутий рядок, розгортається за потреби */
.receipt:not(.open) { padding: 0; background: none; }
.receipt-toggle {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 12px 14px; border-radius: 14px; background: var(--card-2); color: var(--text); font-weight: 600;
}
.receipt.open .receipt-toggle { padding: 0 0 4px; background: none; }
.receipt-toggle:hover:not(:disabled) { filter: none; }
.receipt-toggle-icon { font-size: 20px; line-height: 1; }
.receipt-toggle-text { flex: 1; display: grid; gap: 1px; min-width: 0; }
.receipt-toggle-text .sub { font-weight: 400; font-size: 12px; }
.receipt-count {
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; display: grid; place-items: center;
  background: var(--accent); color: #fff; font-size: 12px; font-weight: 700;
}
.receipt-toggle .chevron { transition: transform 0.15s ease; }
.receipt.open .receipt-toggle .chevron { transform: rotate(90deg); color: var(--accent); }

/* Список витрат: колонки «Сума» і «Ваша витрата» */
details.expense > summary,
.expense-cols {
  display: grid; align-items: center; column-gap: 12px;
  grid-template-columns: minmax(0, 1fr) max-content max-content 14px;
}
/* Однакова ширина колонок у шапці, рядках і підсумку — за найдовшою сумою (--amount-w / --mine-w). */
.expense-cols > span:nth-child(2), .expense-amount { min-width: var(--amount-w, 88px); }
.expense-cols > span:nth-child(3), .expense-mine { min-width: var(--mine-w, 80px); }
.expense-amount .amount, .expense-mine .amount { white-space: nowrap; }
.expense-cols > span { white-space: nowrap; }
.expense-cols { padding: 0 0 6px; color: var(--muted); font-size: 12px; font-weight: 600; border-bottom: 1px solid var(--border); }
.expense-cols > span:nth-child(2), .expense-cols > span:nth-child(3) { text-align: right; }
.expense-total { padding: 12px 0 0; border-bottom: none; border-top: 1px solid var(--border); color: var(--text); font-size: 15px; }
.expense-total > span { text-align: right; }
.expense-total > span:first-child { text-align: left; font-weight: 700; }
.expense-mine { text-align: right; }
.expense-mine .sub { font-size: 11px; }
.amount.mine { color: var(--accent); }
.expense-amount .amount, .expense-mine .amount, .expense-total .amount { font-size: 15px; }
@media (max-width: 400px) {
  details.expense > summary, .expense-cols { column-gap: 8px; grid-template-columns: minmax(0, 1fr) max-content max-content 10px; }
  .expense-amount .amount, .expense-mine .amount, .expense-total .amount { font-size: 14px; }
}

/* Рядок витрати: назва й дата зліва, суми праворуч; теги — окремим рядком на всю ширину */
.expense-title { line-height: 1.3; overflow-wrap: break-word; hyphens: auto; }
.expense-meta { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.expense-meta .tag { margin-left: 0; font-size: 12px; line-height: 1.7; white-space: normal; }
details.expense > summary { row-gap: 6px; }

/* Розгорнута витрата — підсвічений блок */
ul.list.expenses li:has(details[open]) { border-bottom-color: transparent; }
details.expense[open] {
  margin: 6px -12px; padding: 0 12px 12px; border-radius: 16px;
  background: color-mix(in srgb, var(--accent) 7%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
}
details.expense[open] > summary .expense-title { color: var(--accent); }

/* Список груп — окремі плитки (у всіх дизайнах); натискається вся плитка */
.card:has(> ul.group-tiles), .card:has(> .group-results) { background: none; padding: 0; box-shadow: none; }
.group-results > .filter-bar { margin-bottom: 14px; }
ul.group-tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
ul.list.group-tiles li.group-tile {
  position: relative; display: grid; gap: 10px; align-items: stretch;
  grid-template-columns: minmax(0, 1fr); justify-content: stretch;
  padding: 16px 18px; border: none; border-radius: var(--radius); background: var(--card);
  transition: box-shadow 0.15s ease, transform 0.1s ease;
}
.group-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
a.group-name { font-size: 19px; font-weight: 800; line-height: 1.25; letter-spacing: -0.01em; color: var(--text); }
a.group-name::after { content: ''; position: absolute; inset: 0; border-radius: inherit; } /* уся плитка — посилання */
.group-go { color: var(--muted); font-size: 26px; line-height: 0.9; }
.group-meta { margin-top: 0; }
.group-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.group-bottom .created { margin: 0; }
.group-tile > button { position: relative; z-index: 1; justify-self: start; } /* «Повернути» в архіві — поверх посилання */
.balance-pill {
  padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; white-space: nowrap;
  background: var(--card-2); color: var(--muted); font-variant-numeric: tabular-nums;
}
.balance-pill.pos { background: color-mix(in srgb, var(--positive) 14%, transparent); color: var(--positive); }
.balance-pill.neg { background: color-mix(in srgb, var(--negative) 14%, transparent); color: var(--negative); }
ul.list.group-tiles li.group-tile:active { transform: scale(0.99); }
@media (hover: hover) {
  ul.list.group-tiles li.group-tile:hover { box-shadow: inset 0 0 0 1.5px var(--accent); }
  ul.list.group-tiles li.group-tile:hover .group-go { color: var(--accent); }
}

/* Нова група: поле, валюта й кнопка — кожне на всю ширину */
.create-group button { width: 100%; }
.create-group + .sub { font-size: 12px; margin: 2px 2px 0; }

/* Пошук і фільтри (групи, витрати) */
.filter-bar { display: grid; gap: 10px; margin-bottom: 12px; }
.filter-row { display: flex; gap: 8px; align-items: stretch; }
.filter-search-wrap { position: relative; flex: 1; min-width: 0; }
.filter-search-wrap::before {
  content: ''; position: absolute; left: 14px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%);
  background: var(--muted); pointer-events: none;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-4-4'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-4-4'/%3E%3C/svg%3E") center / contain no-repeat;
}
.filter-search { width: 100%; padding-left: 40px; }
.filter-toggle { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; padding: 10px 16px; font-size: 14px; }
.filter-toggle.has-active, .filter-toggle.open { box-shadow: inset 0 0 0 1.5px var(--accent); }
.filter-count:empty { display: none; }
.filter-count {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; display: inline-grid; place-items: center;
  background: var(--accent); color: #fff; font-size: 12px; font-weight: 700;
}
.filter-panel { display: grid; gap: 12px; padding: 14px; border-radius: 16px; background: var(--card-2); }
.filter-panel .segmented button { background: var(--card); }
.filter-panel .segmented button.active { background: var(--text); color: var(--card); }
.filter-panel select, .filter-panel input[type=date] { background: var(--card); }
.filter-dates > label, .filter-selects > label { flex: 1 1 140px; }
.filter-switch { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 14px; cursor: pointer; }
.filter-reset { justify-self: start; font-size: 13px; color: var(--accent) !important; padding: 0 !important; }
.filter-empty { padding: 18px 4px; color: var(--muted); text-align: center; }
.group-results { display: grid; gap: 0; }

/* Підсумок під списком: довгий підпис переноситься, а не налазить на суми */
.expense-total > span:first-child { white-space: normal; font-size: 14px; line-height: 1.3; }

/* Небезпечний пункт меню (видалення) — окремо внизу, червоним */
.menu-item.danger { color: var(--negative); margin-top: 4px; box-shadow: 0 -1px 0 var(--border); border-radius: 0 0 12px 12px; }
html[data-design="nova"] .menu-item.danger { color: var(--negative); }
