/* FirmaBudżet — design system w barwach Fullsite (#6024B3 / #9110E1 / #B6A2C5) */
:root {
  --bg: #120c1c;
  --surface: #1a1228;
  --surface2: #241839;
  --border: #37284f;
  --accent: #9110E1;
  --accent-deep: #6024B3;
  --accent2: #B6A2C5;
  --grad: linear-gradient(100deg, #6024B3, #9110E1);
  --warn: #f7a94f;
  --danger: #f75f5f;
  --text: #efe9f7;
  --muted: #9a89b0;
  --lav: #B6A2C5;
  --green: #38e8b0;
  --red: #f75f5f;
  --yellow: #f7d24f;
  --orange: #f7a94f;
  --sans: 'Poppins', sans-serif;
  /* nazwa historyczna: to font danych/etykiet, celowo NIE monospace */
  --mono: 'Inter', 'Poppins', sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  /* cyfry o równej szerokości — kolumny kwot się równają bez monospace */
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  min-height: 100vh;
  overflow-x: hidden;
}

/* SIDEBAR */
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0;
  width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 100;
  padding: 0 0 24px 0;
  overflow-y: auto;
}
.logo { padding: 28px 24px 24px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.logo-text { font-family: var(--sans); font-size: 22px; font-weight: 800; letter-spacing: -0.5px; color: var(--text); }
.logo-text span { color: var(--accent); }
/* logotyp w stylu Fullsite: gradient Full + lawendowe Site + kropka */
.logo-grad {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.logo-lav { color: var(--lav); }
.logo-dot { color: var(--accent); }
.logo-sub { font-size: 11px; color: var(--muted); margin-top: 2px; font-family: var(--mono); letter-spacing: 0.5px; }
.nav-section { padding: 0 12px; margin-bottom: 8px; }
.nav-label { font-size: 10px; color: var(--muted); letter-spacing: 1.5px; text-transform: uppercase; padding: 0 12px; margin: 14px 0 6px; font-family: var(--mono); }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px; cursor: pointer;
  font-size: 13.5px; color: var(--muted); transition: all 0.15s;
  font-weight: 400; text-decoration: none;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: rgba(145,16,225,0.12); color: var(--accent); font-weight: 700; }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }

/* MAIN */
.main { margin-left: 220px; padding: 32px 36px; min-height: 100vh; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; flex-wrap: wrap; gap: 12px; }
.page-title { font-family: var(--sans); font-size: 28px; font-weight: 800; color: var(--text); letter-spacing: -0.5px; }
.page-title span { color: var(--accent); }
.topbar-right { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.btn {
  padding: 9px 18px; border-radius: 8px; font-size: 13px; font-weight: 700;
  cursor: pointer; border: none; transition: all 0.15s; font-family: var(--sans);
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
.btn-primary { background: var(--grad); color: #fff; }
.btn-primary:hover { filter: brightness(1.15); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: rgba(247,95,95,0.12); color: var(--red); }
.btn-danger:hover { background: rgba(247,95,95,0.25); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* STATS */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stats-row.cols-3 { grid-template-columns: repeat(3, 1fr); }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 20px 22px; position: relative; overflow: hidden; transition: border-color 0.2s;
}
.stat-card:hover { border-color: var(--accent); }
.stat-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; border-radius: 14px 14px 0 0; }
.stat-card.green::before { background: var(--green); }
.stat-card.blue::before { background: var(--accent); }
.stat-card.yellow::before { background: var(--yellow); }
.stat-card.red::before { background: var(--red); }
.stat-card.orange::before { background: var(--orange); }
.stat-label { font-size: 11px; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; font-family: var(--mono); margin-bottom: 8px; }
.stat-value { font-family: var(--mono); font-size: 26px; font-weight: 700; letter-spacing: -1px; }
.stat-value.green { color: var(--green); }
.stat-value.blue { color: var(--accent); }
.stat-value.yellow { color: var(--yellow); }
.stat-value.red { color: var(--red); }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
/* druga linijka w nagłówku tabeli — wyjaśnia, co dokładnie znaczy kolumna */
.th-sub { font-size: 10px; font-weight: 400; color: var(--muted); text-transform: none; letter-spacing: 0; margin-top: 2px; }

/* CARDS */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.grid-3 { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-bottom: 20px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 22px 24px; margin-bottom: 20px; }
.card-title {
  font-family: var(--sans); font-size: 14px; font-weight: 700; color: var(--text);
  margin-bottom: 18px; display: flex; align-items: center; justify-content: space-between;
}
.card-title-badge { font-size: 11px; font-family: var(--mono); color: var(--muted); font-weight: 400; }

/* HERO wypłaty */
.hero {
  background: linear-gradient(135deg, rgba(96,36,179,0.22), rgba(145,16,225,0.08));
  border: 1px solid var(--border); border-radius: 16px; padding: 28px 32px; margin-bottom: 24px;
}
.hero-label { font-size: 12px; color: var(--muted); letter-spacing: 1.5px; text-transform: uppercase; font-family: var(--mono); }
.hero-value { font-family: var(--mono); font-size: 46px; font-weight: 700; letter-spacing: -2px; margin: 6px 0 4px; }
.hero-value.green { color: var(--green); }
.hero-value.red { color: var(--red); }
.hero-sub { font-size: 13px; color: var(--muted); }
.hero-row { display: flex; gap: 40px; align-items: flex-end; flex-wrap: wrap; }
.hero-aside { display: flex; gap: 28px; }
.hero-mini-label { font-size: 10.5px; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; font-family: var(--mono); }
.hero-mini-value { font-family: var(--mono); font-size: 19px; font-weight: 700; margin-top: 3px; }
/* linia „maksymalnie możesz wypłacić" — poglądowy limit płynnościowy, drobnym drukiem */
.hero-maxline {
  margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--border);
  font-size: 11.5px; line-height: 1.55; color: var(--muted);
}
.hero-maxline b { font-weight: 700; color: var(--text); }
.hero-maxline .red, .hero-maxline .red b { color: var(--red); }
.hero-maxline .green, .hero-maxline .green b { color: var(--green); }
.hero-maxline-ico { margin-right: 5px; }
.hero-maxline-dim { opacity: 0.75; }
.hero-maxline a { color: var(--accent2); }

/* jawna odejmowanka „ile mogę wypłacić": saldo − podstawowe wydatki − bufor = wynik.
   Każdy składnik jest osobnym kafelkiem, żeby dało się sprawdzić liczbę wzrokiem —
   poprzedni limit (dołek krzywej dziennej) nie dawał się z niczym uzgodnić. */
.hero-calc { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 8px; }
.hero-calc-row {
  display: inline-flex; flex-direction: column; gap: 2px; min-width: 0;
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface2);
}
.hero-calc-row > span {
  font-size: 10.5px; color: var(--muted); letter-spacing: 0.2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 270px;
}
.hero-calc-row > span i { font-style: normal; opacity: 0.6; }
.hero-calc-row > b { font-family: var(--mono); font-size: 13px; color: var(--text); }
.hero-calc-row.total { border-color: var(--accent); background: transparent; }
.hero-calc-row.total > b.green { color: var(--green); }
.hero-calc-row.total > b.red { color: var(--red); }
.hero-calc-op { display: flex; align-items: center; color: var(--muted); font-size: 13px; }

/* ZAKŁADKA PODUSZKA — dwie liczby ze składnikami, każdy wiersz do sprawdzenia okiem */
.pod-big {
  font-family: var(--mono); font-size: 30px; font-weight: 700;
  letter-spacing: -0.8px; margin: 4px 0 10px;
}
.pod-big.green { color: var(--green); }
.pod-big.red { color: var(--red); }
table.pod-table { width: 100%; font-size: 12.5px; }
table.pod-table td { font-family: var(--sans); }
table.pod-table td.num { font-family: var(--mono); white-space: nowrap; }
table.pod-table td:first-child { position: static; min-width: 0; }
table.pod-table tr.pod-total td {
  border-top: 1px solid var(--accent); border-bottom: none;
  padding-top: 10px; font-size: 13.5px;
}
@media (max-width: 720px) {
  .pod-big { font-size: 24px; }
  table.pod-table { font-size: 11.5px; }
}

/* TABELA BUDGET */
.budget-wrap { overflow-x: auto; }
table.budget { border-collapse: collapse; width: 100%; font-size: 12px; }
table.budget th, table.budget td {
  padding: 7px 9px; text-align: right; border-bottom: 1px solid var(--border);
  font-family: var(--mono); white-space: nowrap;
}
table.budget th { color: var(--muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 500; }
table.budget td:first-child, table.budget th:first-child {
  text-align: left; font-family: var(--sans); position: sticky; left: 0;
  background: var(--surface); min-width: 160px;
}
table.budget tr.section-row td { color: var(--accent); font-weight: 700; font-size: 11px; letter-spacing: 1px; text-transform: uppercase; padding-top: 16px; }
table.budget td.pos { color: var(--green); }
table.budget td.neg { color: var(--red); }
table.budget td.muted { color: var(--muted); }
table.budget th.current, table.budget td.current { background: rgba(145,16,225,0.08); }
table.budget tr.hl td { font-weight: 700; }
table.budget tr.total-row td { border-top: 2px solid var(--border); font-weight: 700; }

/* TABELE ogólne */
table.data { border-collapse: collapse; width: 100%; font-size: 13px; }
table.data th, table.data td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border); }
table.data th { color: var(--muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.8px; font-family: var(--mono); font-weight: 500; }
table.data td.num, table.data th.num { text-align: right; font-family: var(--mono); }
table.data tr:hover td { background: rgba(145,16,225,0.04); }
table.data tr.inactive td { opacity: 0.45; text-decoration: line-through; }

/* BADGES statusów */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 700; padding: 2px 9px; border-radius: 20px; font-family: var(--mono); }
.badge.paid, .badge.verified { background: rgba(56,232,176,0.13); color: var(--green); }
.badge.invoiced, .badge.pending { background: rgba(247,210,79,0.13); color: var(--yellow); }
.badge.forecast, .badge.planned { background: rgba(107,116,148,0.15); color: var(--muted); }
.badge.danger { background: rgba(247,95,95,0.13); color: var(--red); }
.badge.info { background: rgba(145,16,225,0.13); color: var(--accent); }
.badge.orange { background: rgba(247,169,79,0.15); color: var(--orange); }

/* TABS */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 22px; flex-wrap: wrap; }
.tab {
  padding: 10px 18px; font-size: 13.5px; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; text-decoration: none;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 700; }

/* FORMS */
input, select, textarea {
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 8px 12px; font-size: 13px; font-family: var(--sans); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input[type="number"] { font-family: var(--mono); text-align: right; }
label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 4px; }
.form-row { display: flex; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.form-row > div { flex: 1; min-width: 140px; }

/* IMPORT drop-zone */
.drop-zone {
  border: 2px dashed var(--border); border-radius: 16px; padding: 48px 24px;
  text-align: center; cursor: pointer; transition: all 0.2s; margin-bottom: 24px;
}
.drop-zone:hover { border-color: var(--accent); }
.drop-zone.drag-over { border-color: var(--green); background: rgba(45,212,160,0.06); }
.drop-icon { font-size: 40px; margin-bottom: 12px; }
.drop-title { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.drop-sub { font-size: 13px; color: var(--muted); margin-bottom: 16px; }

/* MODAL */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 500;
  display: none; align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 26px 28px; width: min(520px, 92vw); max-height: 88vh; overflow-y: auto;
}
.modal h3 { font-size: 17px; margin-bottom: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* WYKRES krzywej */
.chart-wrap { position: relative; }
.chart-tooltip {
  position: absolute; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 12px; font-size: 12px; pointer-events: none;
  display: none; z-index: 10; font-family: var(--mono); white-space: nowrap;
}

/* KOSZTY siatka */
.exp-group-header { cursor: pointer; user-select: none; }
.exp-group-header td { background: var(--surface2); font-weight: 700; }
.exp-group-header .caret { display: inline-block; transition: transform 0.15s; margin-right: 6px; }
.exp-group-header.collapsed .caret { transform: rotate(-90deg); }
.cell-btn { cursor: pointer; border-radius: 5px; padding: 2px 4px; }
.cell-btn:hover { background: rgba(145,16,225,0.15); }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-left: 5px; vertical-align: middle; }
.dot.green { background: var(--green); }
.dot.yellow { background: var(--yellow); }

/* WPISY w modalu komórki przychodów */
.en-row {
  display: flex; gap: 12px; align-items: center;
  padding: 10px 2px; border-bottom: 1px solid var(--border);
}
.en-row:last-child { border-bottom: none; }
.en-main { flex: 1; min-width: 0; }
.en-title {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 13.5px; display: flex; gap: 6px; align-items: center;
}
.en-title .badge { flex-shrink: 0; }
.en-sub { font-size: 11px; color: var(--muted); font-family: var(--mono); margin-top: 2px; }
.en-amount {
  font-family: var(--mono); font-weight: 700; font-size: 14.5px;
  white-space: nowrap; min-width: 110px; text-align: right;
}
.en-flag {
  display: flex; align-items: center; gap: 4px; font-size: 11px;
  white-space: nowrap; color: var(--muted); cursor: pointer;
}
.en-actions { display: flex; gap: 5px; flex-shrink: 0; }

/* TOAST */
#toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 999;
  background: var(--surface2); border: 1px solid var(--border); border-left: 3px solid var(--green);
  padding: 13px 18px; border-radius: 10px; font-size: 13.5px; display: none; max-width: 380px;
}
#toast.error { border-left-color: var(--red); }

/* misc */
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.green { color: var(--green); }
.red { color: var(--red); }
.yellow { color: var(--yellow); }
.mb0 { margin-bottom: 0; }
.warn-banner {
  background: rgba(247,95,95,0.1); border: 1px solid rgba(247,95,95,0.35); color: var(--red);
  border-radius: 10px; padding: 12px 16px; font-size: 13px; margin-bottom: 20px;
}
.info-banner {
  background: rgba(145,16,225,0.08); border: 1px solid rgba(145,16,225,0.3);
  border-radius: 10px; padding: 12px 16px; font-size: 13px; margin-bottom: 20px;
}

/* ===== MOBILE ===== */
.mobile-bar { display: none; }
.nav-backdrop { display: none; }

@media (max-width: 1100px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 800px) {
  /* pasek z hamburgerem, przyklejony do góry */
  .mobile-bar {
    display: flex; align-items: center; gap: 12px;
    position: sticky; top: 0; z-index: 90;
    background: rgba(18,12,28,0.96);
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
    padding: 10px 14px; border-bottom: 1px solid var(--border);
  }
  .nav-burger {
    background: var(--surface2); border: 1px solid var(--border); color: var(--text);
    border-radius: 8px; padding: 6px 12px; font-size: 17px; cursor: pointer; line-height: 1;
  }
  /* sidebar wysuwany zza lewej krawędzi */
  .sidebar { transform: translateX(-100%); transition: transform 0.22s ease; width: 260px; }
  body.nav-open .sidebar { transform: translateX(0); box-shadow: 0 0 44px rgba(0,0,0,0.65); }
  body.nav-open .nav-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 99; }

  .main { margin-left: 0; padding: 16px 12px 32px; }
  .topbar { margin-bottom: 18px; }
  .page-title { font-size: 22px; }

  /* hero i staty ciaśniej */
  .hero { padding: 18px 16px; margin-bottom: 16px; }
  .hero-value { font-size: 31px; letter-spacing: -1px; }
  .hero-row { gap: 18px; }
  .hero-aside { flex-wrap: wrap; gap: 14px 24px; }
  .hero-maxline { margin-top: 14px; padding-top: 10px; font-size: 11px; }
  .hero-calc-row > span { max-width: 150px; }
  .stats-row { gap: 10px; margin-bottom: 16px; }
  .stat-card { padding: 13px 14px; }
  .stat-value { font-size: 19px; letter-spacing: -0.5px; }

  /* karty: szerokie tabele przewijają się w poziomie wewnątrz karty */
  .card { padding: 15px 13px; margin-bottom: 14px; overflow-x: auto; }
  table.budget td:first-child, table.budget th:first-child { min-width: 118px; }

  /* taby przewijane zamiast łamania */
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { white-space: nowrap; padding: 10px 13px; }

  /* formularze: 16px = iOS nie przybliża przy focusie; większe pola dotykowe */
  input, select, textarea { font-size: 16px; padding: 9px 12px; }
  .btn { padding: 10px 15px; }
  .btn-sm { padding: 7px 11px; font-size: 12.5px; }

  .modal { width: 96vw; padding: 18px 14px; max-height: 92vh; border-radius: 14px; }
  #toast { left: 12px; right: 12px; bottom: 12px; max-width: none; }
  .drop-zone { padding: 30px 16px; }
}
