/* ═══════════════ Дизайн «Ліміт тижня» ═══════════════
   Чорнильно-синя шапка з головним числом, помаранчевий акцент.
   Шрифти: Unbounded — суми, Golos Text — текст. Підключається ПІСЛЯ styles.css,
   усе під body.tl, тож перекриває старі шари стилів. */
@import url('https://fonts.googleapis.com/css2?family=Golos+Text:wght@400;500;600;700&family=Unbounded:wght@500;600;700&display=swap');

body.tl {
  --ink: #121a2e;
  --ink-2: #2e3a57;
  --ground: #f3f5fa;
  --card: #ffffff;
  --line: #e2e6ef;
  --muted: #5b6478;
  --soft: #9faacb;
  --accent: #ff8a3d;
  --accent-ink: #9a3d10;
  --accent-pale: #fde9de;
  --blue: #24399f;
  --blue-2: #6f8cff;
  --blue-pale: #e6ebff;
  --green: #1f7a63;
  --green-pale: #ddf1ea;
  --red: #c2412d;
  --red-pale: #fdebe7;
  --num: 'Unbounded', sans-serif;
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: 'Golos Text', sans-serif;
}
body.tl button, body.tl input, body.tl select { font-family: 'Golos Text', sans-serif; }
.tl .tl-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tl .app-shell { min-height: 100vh; }

/* ───────── Шапка ───────── */
.tl .tl-header { background: var(--ink); color: #fff; }
.tl .tl-bar {
  max-width: 1320px; margin: 0 auto; padding: 16px 32px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px 28px;
}
.tl .brand { display: flex; align-items: center; gap: 10px; margin: 0; color: #fff; text-decoration: none; font: 600 16px var(--num); letter-spacing: 0; white-space: nowrap; }
.tl .brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: var(--ink); box-shadow: none; display: grid; place-items: center; font: 700 17px var(--num); }
.tl #nav { display: flex; flex-wrap: wrap; gap: 4px; flex: 1 1 auto; }
.tl .nav-item {
  display: flex; align-items: center; gap: 7px; padding: 9px 14px; border-radius: 999px;
  background: transparent; color: #c9d0e4; font-size: 14px; font-weight: 500; transform: none; white-space: nowrap;
}
.tl .nav-item:hover { background: var(--ink-2); color: #fff; transform: none; }
.tl .nav-item.active { background: #fff; color: var(--ink); font-weight: 600; }
.tl .nav-item .nav-icon { width: 18px; height: 18px; color: currentColor; }
.tl .nav-item.active .nav-icon { color: var(--blue); }
.tl .nav-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tl .top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tl .month-picker { display: block; }
.tl .month-picker select {
  min-width: 170px; min-height: 44px; border-radius: 12px; border: 1px solid var(--ink-2);
  background: var(--ink); color: #fff; font-weight: 600; padding: 0 12px; box-shadow: none;
}
.tl .month-picker select:focus { border-color: var(--soft); box-shadow: 0 0 0 3px #ffffff22; }
.tl .tl-header .button.secondary {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px;
  background: transparent; border: 1px solid var(--ink-2); color: #fff;
}
.tl .tl-header .button.secondary svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.tl .tl-header .button.secondary:hover { background: var(--ink-2); }

/* ───────── Кнопки ───────── */
.tl .button { border-radius: 12px; padding: 0 18px; min-height: 44px; font-weight: 700; font-size: 14px; transform: none; box-shadow: none; transition: background .15s; }
.tl .button:hover { transform: none; }
.tl .button.primary, .tl .primary { background: var(--accent); color: var(--ink); box-shadow: none; }
.tl .button.primary:hover { background: #ff7a22; box-shadow: none; }
.tl .button.secondary, .tl .secondary { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.tl main .button.secondary:hover { background: var(--ground); }
.tl label.button { display: inline-flex; align-items: center; cursor: pointer; }

/* ───────── Головне число ───────── */
.tl .tl-hero {
  max-width: 1320px; margin: 0 auto; padding: 20px 32px 56px;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 28px 48px; align-items: end;
}
.tl .tl-hero[hidden] { display: none; }
.tl .tl-eyebrow { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--soft); font-weight: 600; }
.tl .tl-big { font: 700 72px/1.05 var(--num); margin-top: 8px; letter-spacing: -.01em; }
.tl .tl-big span { font-size: 38px; color: var(--soft); }
.tl .tl-big.is-over { color: #ffb08a; }
.tl .tl-sub { margin-top: 12px; font-size: 16px; color: #c9d0e4; }
.tl .tl-sub b { color: #fff; }
.tl .tl-hero-empty { margin: 12px 0 18px; font-size: 18px; line-height: 1.5; color: #c9d0e4; max-width: 560px; }
.tl .tl-hero-empty b { color: #fff; }
.tl .tl-bar-head { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; color: #c9d0e4; margin-bottom: 10px; }
.tl .tl-bar-head b { color: #fff; }
.tl .tl-track { height: 14px; border-radius: 999px; background: var(--ink-2); overflow: hidden; display: flex; gap: 2px; }
.tl .tl-track i { display: block; height: 100%; }
.tl i.tl-var { background: var(--blue-2); }
.tl i.tl-hab { background: var(--accent); }
.tl .tl-legend { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 12px; font-size: 13px; color: #c9d0e4; }
.tl .tl-legend span { display: flex; align-items: center; gap: 6px; }
.tl .tl-legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--ink-2); display: inline-block; }

/* ───────── Основна частина ───────── */
.tl .main { margin: 0 auto; max-width: 1320px; padding: 28px 32px 64px; }
.tl .tl-header:has(.tl-hero:not([hidden])) + .main { margin-top: -28px; padding-top: 0; }
.tl .welcome { display: none; }
.tl .eyebrow { color: var(--muted); letter-spacing: .1em; font-size: 11px; }
.tl h2, .tl h3 { color: var(--ink); }

/* Картки-показники */
.tl .stats { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 20px; }
.tl .plan-summary { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 20px; }
.tl .stat {
  background: var(--card); border: 0; border-radius: 18px; padding: 20px 22px; min-height: 0;
  box-shadow: 0 10px 30px #121a2e0f; transform: none;
}
.tl .stat:hover { transform: none; box-shadow: 0 10px 30px #121a2e14; }
.tl .stat:before { display: none; }
.tl .stat-label { font-size: 12px; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.tl .stat-value { font: 600 26px var(--num); letter-spacing: -.01em; color: var(--ink); margin: 8px 0 6px; }
.tl .stat-note { font-size: 13px; color: var(--muted); }
.tl .stat-note.positive { color: var(--green); font-weight: 600; }
.tl .stat-note.negative { color: var(--red); font-weight: 600; }

/* Панелі */
.tl .panel, .tl .plan-group {
  background: var(--card); border: 0; border-radius: 22px; box-shadow: 0 10px 30px #121a2e0f;
}
.tl .panel { padding: 24px 26px; }
.tl .panel-head { margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.tl .panel-head h3, .tl .section-title { font: 600 18px var(--num); letter-spacing: 0; color: var(--ink); }
.tl .section-title { margin: 28px 0 12px; }
.tl .subtle { color: var(--muted); font-size: 13px; }
.tl .content-grid { gap: 24px; }
.tl .telegram-income strong { font: 600 24px var(--num); color: var(--green); }

/* Прогрес «факт проти плану» */
.tl .progress { height: 12px; border-radius: 999px; background: var(--line); margin-top: 6px; }
.tl .progress span { background: var(--blue); border-radius: 999px; }

/* Стовпчики по тижнях */
.tl .chart { height: 230px; gap: 18px; border-bottom: 1px solid var(--line); }
.tl .bar-area { width: min(56px, 80%); background: var(--ground); border-radius: 10px 10px 4px 4px; }
.tl .bar-fill { background: var(--blue-2); border-radius: 10px 10px 4px 4px; }
.tl .bar-column.current .bar-fill { background: var(--blue); }
.tl .bar-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.tl .bar-column.current .bar-label { color: var(--ink); }
.tl .bar-value { color: var(--ink) !important; font-size: 12px !important; }

/* Категорії */
.tl .category-list { gap: 16px; }
.tl .category-row { grid-template-columns: 36px minmax(80px, 1fr) auto; gap: 10px; font-size: 14px; }
.tl .cat-icon { width: 36px; height: 36px; border-radius: 11px; background: var(--blue-pale); display: grid; place-items: center; font-size: 17px; }
.tl .cat-name { font-size: 14px; color: var(--ink); font-weight: 600; }
.tl .cat-amount { font-size: 14px; color: var(--ink); font-weight: 700; }
.tl .cat-track { height: 8px; background: var(--line); border-radius: 999px; margin-top: -2px; }
.tl .cat-track i { background: var(--blue); border-radius: 999px; }

/* Записи */
.tl .transaction-row { grid-template-columns: 42px minmax(0, 1fr) auto; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.tl .transaction-icon { width: 42px; height: 42px; border-radius: 13px; background: var(--blue-pale); font-size: 18px; }
.tl .transaction-title { font-size: 15px; font-weight: 600; color: var(--ink); }
.tl .transaction-meta { font-size: 12px; color: var(--muted); }
.tl .transaction-value { font-size: 15px; font-weight: 700; color: var(--ink); }
.tl .empty { color: var(--muted); font-size: 14px; }
.tl .empty strong { font-family: 'Golos Text', sans-serif; color: var(--ink); font-size: 16px; }

/* Заголовок сторінки розділу */
.tl .page-intro { margin: 0 0 20px; gap: 16px; flex-wrap: wrap; }
.tl .page-intro h2 { font: 600 26px var(--num); letter-spacing: -.01em; }
.tl .page-intro p { font-size: 14px; color: var(--muted); margin-top: 6px; }

/* Таблиці */
.tl .data-table { font-size: 14px; }
.tl .data-table th { background: transparent; color: var(--muted); font-size: 12px; letter-spacing: .04em; padding: 12px 10px; border-bottom: 1px solid var(--line); }
.tl .data-table td { padding: 14px 10px; border-bottom: 1px solid var(--line); }
.tl .amount-cell { font-weight: 700; }
.tl .row-delete, .tl .row-edit { width: 36px; height: 36px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; font-size: 17px; }
.tl .row-delete:hover { background: var(--red-pale); color: var(--red); }
.tl .row-edit:hover { background: var(--blue-pale); color: var(--blue); }
.tl .badge { background: var(--ground); color: var(--muted); font-size: 12px; }
.tl .badge.ok { background: var(--green-pale); color: var(--green); }
.tl .badge.over { background: var(--accent-pale); color: var(--accent-ink); }

/* Поля */
.tl select, .tl input { border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); min-height: 44px; padding: 0 12px; }
.tl input:focus, .tl select:focus { border-color: var(--blue-2); box-shadow: 0 0 0 3px var(--blue-pale); outline: none; }

/* ───────── План ───────── */
.tl .plan-layout { gap: 24px; }
.tl .plan-group { padding: 22px 24px; margin-bottom: 20px; }
.tl .plan-group-head { margin-bottom: 14px; gap: 12px; }
.tl .plan-group-head h3 { font: 600 17px var(--num); }
.tl .plan-group-head .subtle { display: block; margin-top: 4px; }
.tl .plan-group-head > b { font: 600 18px var(--num); color: var(--ink); white-space: nowrap; }
.tl .plan-head-labels, .tl .plan-item { grid-template-columns: minmax(160px, 1fr) 130px 130px; gap: 12px; }
.tl .plan-head-labels { font-size: 12px; color: var(--muted); padding-bottom: 8px; }
.tl .plan-item { padding: 10px 0; border-top: 1px solid var(--line); }
.tl .plan-item-name { font-size: 14px; font-weight: 600; color: var(--ink); }
.tl .plan-item small { color: var(--accent-ink); font-weight: 600; font-size: 12px; }
.tl .plan-item input { font-size: 15px; font-weight: 600; text-align: right; padding: 0 12px; background: #fff; }
.tl .plan-item input[readonly] { background: var(--ground); border-color: transparent; color: var(--muted); }
/* Кольорові мітки кошиків у плані (порядок груп: дохід, обовʼязкове, буфер, ціль, змінне, звички) */
.tl .plan-group h3::before { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-right: 10px; vertical-align: 1px; background: var(--green); }
.tl .plan-layout > div:first-child > .plan-group:nth-of-type(1) h3::before { background: var(--green); }
.tl .plan-layout > div:first-child > .plan-group:nth-of-type(2) h3::before { background: var(--blue); }
.tl .plan-layout > div:first-child > .plan-group:nth-of-type(3) h3::before,
.tl .plan-layout > div:first-child > .plan-group:nth-of-type(4) h3::before { background: #1f7a63; }
.tl .plan-layout > div:first-child > .plan-group:nth-of-type(5) h3::before { background: var(--blue-2); }
.tl .plan-layout > div:first-child > .plan-group:nth-of-type(6) h3::before { background: var(--accent); }
.tl .unallocated { border: 0; border-radius: 16px; padding: 16px 18px; font-size: 15px; background: var(--ground); }
.tl .unallocated.good { background: var(--green-pale); color: var(--green); }
.tl .unallocated.bad { background: var(--red-pale); color: var(--red); }
.tl .week-card { border: 1px solid var(--line) !important; background: #fff !important; border-radius: 16px !important; }
.tl .weekly-grid b { color: var(--ink); }
.tl .helper { font-size: 13px; color: var(--muted); line-height: 1.55; }

/* ───────── Місяці ───────── */
.tl .history-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.tl .month-card { border: 0; border-radius: 20px; background: #fff; padding: 20px; box-shadow: 0 10px 30px #121a2e0f; transform: none; }
.tl .month-card:hover { box-shadow: 0 0 0 2px var(--blue-2), 0 10px 30px #121a2e14; transform: none; }
.tl .month-card strong { font: 600 15px var(--num); color: var(--ink); }
.tl .month-card .month-total { font: 600 24px var(--num); margin: 14px 0 4px; }
.tl .month-card small { font-size: 12px; color: var(--muted); }

/* ───────── Вікна ───────── */
.tl dialog { border: 0; border-radius: 24px; padding: 26px; background: #fff; box-shadow: 0 30px 90px #121a2e55; width: min(500px, calc(100% - 24px)); }
.tl dialog::backdrop { background: #121a2ecc; }
.tl .dialog-head h2 { font: 600 22px var(--num); }
.tl dialog label { color: var(--muted); font-size: 13px; font-weight: 600; }
.tl dialog input, .tl dialog select { background: #fff; border-color: var(--line); }
.tl dialog input[name="amount"] { font: 600 24px var(--num); min-height: 56px; }
.tl .icon-button { width: 44px; height: 44px; background: var(--ground); color: var(--ink); }
.tl .sync-status { background: var(--ground); color: var(--muted); border-radius: 12px; font-size: 13px; }
.tl .sync-status.error { background: var(--red-pale); color: var(--red); }
.tl .sync-status.success { background: var(--green-pale); color: var(--green); }

/* ───────── Телефон і планшет ───────── */
.tl .mobile-nav, .tl .tl-fab { display: none; }
@media (max-width: 850px) {
  .tl #nav { display: none; }
  .tl .tl-bar { padding: 14px 16px; gap: 10px; }
  .tl .brand { flex: 1 1 auto; }
  .tl .top-actions { width: 100%; }
  .tl .month-picker { flex: 1 1 auto; }
  .tl .month-picker select { width: 100%; min-width: 0; }
  .tl .tl-header .button.secondary span { display: none; }
  .tl .tl-header .button.secondary { padding: 0 12px; }
  .tl #add-expense { display: none; }
  .tl .tl-hero { padding: 12px 16px 48px; gap: 22px; grid-template-columns: 1fr; }
  .tl .tl-big { font-size: 52px; }
  .tl .tl-big span { font-size: 26px; }
  .tl .tl-sub { font-size: 14px; }
  .tl .main { padding: 20px 16px 120px; }
  .tl .tl-header:has(.tl-hero:not([hidden])) + .main { margin-top: -24px; }
  .tl .stats, .tl .plan-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tl .stat { padding: 14px; border-radius: 16px; }
  .tl .stat-value { font-size: 18px; }
  .tl .stat-note { font-size: 12px; }
  .tl .panel, .tl .plan-group { padding: 18px; border-radius: 18px; }
  .tl .content-grid, .tl .plan-layout { grid-template-columns: 1fr; }
  .tl .page-intro h2 { font-size: 21px; }
  .tl .plan-head-labels, .tl .plan-item { grid-template-columns: minmax(100px, 1fr) 90px 90px; gap: 8px; }
  .tl .plan-item-name { font-size: 13px; }
  .tl .plan-item input { font-size: 14px; padding: 0 8px; }
  .tl .history-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tl .mobile-nav {
    position: fixed; z-index: 5; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); height: 66px; padding: 6px;
    display: grid; grid-template-columns: repeat(5, 1fr); background: var(--ink); border: 0; border-radius: 22px; box-shadow: 0 12px 30px #121a2e40;
  }
  .tl .mobile-nav button { border: 0; background: none; color: var(--soft); font-size: 11px; display: grid; place-items: center; gap: 2px; border-radius: 16px; min-height: 44px; }
  .tl .mobile-nav button.active { color: #fff; background: var(--ink-2); font-weight: 600; }
  .tl .mobile-nav .nav-icon svg { width: 21px; height: 21px; }
  .tl .tl-fab {
    position: fixed; z-index: 6; right: 20px; bottom: calc(92px + env(safe-area-inset-bottom));
    width: 60px; height: 60px; border: 0; border-radius: 20px; background: var(--accent); color: var(--ink);
    display: grid; place-items: center; box-shadow: 0 12px 26px #121a2e55; cursor: pointer;
  }
  .tl .tl-fab svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
  .tl .data-table { min-width: 640px; }
}
@media (max-width: 420px) {
  .tl .tl-big { font-size: 44px; }
  .tl .stats, .tl .plan-summary { grid-template-columns: 1fr 1fr; }
}

/* Телефон: iPhone збільшує сторінку, якщо шрифт поля менший за 16px, — тут поля завжди 16px */
@media (max-width: 767px) {
  input,
  select,
  textarea {
    font-size: 16px !important;
  }
}
