:root {
  --accent: #FF6A00;
  --accent-dark: #E05A00;
  --accent-tint: #FFF1E6;
  --bg: #f5f5f7;
  --card-bg: #ffffff;
  --text: #1d1d1f;
  --text-muted: #6e6e73;
  --border: #e5e5e7;
  --danger: #d92d20;
  --radius: 16px;
  --sidebar-bg: #2a221c;
  --sidebar-bg-2: #3a2f26;
  --sidebar-text: #bcb2a8;
  --sidebar-text-active: #ffffff;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 2px 12px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 78px; /* miejsce na dolną nawigację mobilną */
}

/* ---------- layout ogólny ---------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.main {
  flex: 1;
  min-width: 0;
}

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
}

.topbar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1 {
  font-size: 17px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -.01em;
}

.topbar .user {
  font-size: 13px;
  color: var(--text-muted);
}
.topbar .user a { color: inherit; }

/* ---------- sidebar (tylko desktop) ---------- */

.sidebar {
  display: none;
}

/* ---------- karty ---------- */

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 14px;
}

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

/* ---------- formularze ---------- */

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  margin-top: 14px;
}
label:first-of-type { margin-top: 0; }

input[type=text],
input[type=number],
input[type=date],
input[type=password],
select,
textarea {
  width: 100%;
  padding: 13px 14px;
  font-size: 16px; /* zapobiega auto-zoomowi na iOS */
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font-family: inherit;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

textarea { resize: vertical; min-height: 60px; }

/* pole, które ma rzucać się w oczy jako "tu wpisz nazwę" */
.input-highlight {
  background: var(--accent-tint);
  border-color: #ffd9b8;
}
.input-highlight::placeholder { color: #c98a55; }

/* wiersz z polem edytowalnym inline (np. nazwa kategorii/kanału w Ustawieniach) */
.inline-edit-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}
.inline-edit-input {
  padding: 8px 10px;
  font-size: 14px;
  min-width: 140px;
}

.icon-btn {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 6px;
  border-radius: 8px;
  line-height: 1;
}
.icon-btn:hover { background: #f0f0f2; }

.btn {
  display: inline-block;
  width: 100%;
  text-align: center;
  padding: 15px 18px;
  font-size: 15px;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  margin-top: 18px;
  cursor: pointer;
  transition: background .15s ease, transform .05s ease;
}
.btn:hover { background: var(--accent-dark); }
.btn:active { transform: scale(0.99); }
.btn.secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn.secondary:hover { background: #fafafa; border-color: #d5d5d7; }
.btn.danger { background: var(--danger); }

.toggle-group {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
}
.toggle-group label {
  flex: 1;
  margin: 0;
  text-align: center;
  padding: 12px 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  color: var(--text-muted);
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.toggle-group input { display: none; }
.toggle-group input:checked + span {
  color: #fff;
}
.toggle-group label:has(input:checked) {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ---------- KPI ---------- */

.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}
.kpi {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}
.kpi .label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 700;
}
.kpi .value {
  font-size: 21px;
  font-weight: 800;
  margin-top: 4px;
  letter-spacing: -.01em;
}
.kpi .value.positive { color: #1a7f37; }
.kpi .value.negative { color: var(--danger); }

/* ---------- paski / progres ---------- */

.bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 13px;
}
.bar-row .bar-label {
  width: 150px;
  flex-shrink: 0;
  color: var(--text-muted);
}
.bar-track {
  flex: 1;
  background: #f0f0f2;
  border-radius: 6px;
  height: 14px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 6px;
}
.bar-value {
  width: 90px;
  text-align: right;
  flex-shrink: 0;
  font-weight: 600;
}

.progress-track {
  background: #f0f0f2;
  border-radius: 10px;
  height: 20px;
  overflow: hidden;
  margin-top: 8px;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

/* ---------- tabele ---------- */

table.entries {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.entries th, table.entries td {
  text-align: left;
  padding: 10px 6px;
  border-bottom: 1px solid var(--border);
}
table.entries th { color: var(--text-muted); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; }

/* ---------- filtry listy wpisów ---------- */

.filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.filter-grid label { margin-top: 0; }
.filter-grid select { padding: 11px 12px; }

/* ---------- lista wpisów (kompaktowa na mobile) ---------- */

.entries-list td { padding: 9px 6px; vertical-align: top; }
.date-short { display: inline; }
.date-full { display: none; }

.amount-cell { font-weight: 700; white-space: nowrap; }
.amount-cell.amount-cost { color: var(--danger); }
.amount-cell.amount-sale { color: #1a7f37; }

.hide-mobile { display: none; }

.row-actions { white-space: nowrap; text-align: right; }

.tag {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: var(--accent-tint);
  color: var(--accent-dark);
}
.tag.cost { background: #fdecea; color: #b42318; }
.tag.sale { background: #e7f6ec; color: #1a7f37; }

.alert {
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 14px;
  font-size: 14px;
}
.alert.error { background: #fdecea; color: #b42318; border: 1px solid #f6c6c1; }
.alert.success { background: #e7f6ec; color: #1a7f37; border: 1px solid #b9e6c6; }

.muted { color: var(--text-muted); font-size: 12px; }

.month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 14px;
}
.month-nav a {
  text-decoration: none;
  font-size: 20px;
  color: var(--text);
  padding: 4px 10px;
  border-radius: 8px;
}
.month-nav a:hover { background: #ececee; }
.month-nav .month-label {
  font-weight: 700;
  font-size: 15px;
  background: var(--accent);
  color: #fff;
  padding: 7px 18px;
  border-radius: 999px;
}

details summary { list-style: none; }
details summary::-webkit-details-marker { display: none; }

.trend-toggle {
  display: inline-flex;
  background: #f0f0f2;
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.trend-toggle button {
  border: none;
  background: transparent;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
}
.trend-toggle button.active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}

.grid-2 {
  display: block;
}
.grid-2 > .card:last-child { margin-bottom: 14px; }

/* ---------- nawigacja dolna (mobile) ---------- */

.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: rgba(255,255,255,.92);
  backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 20;
}
.bottom-nav a {
  flex: 1;
  text-align: center;
  padding: 10px 4px 12px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
}
.bottom-nav a.active { color: var(--accent); }
.bottom-nav .icon { display: flex; align-items: center; justify-content: center; margin: 0 auto 3px; width: 22px; height: 22px; }
.bottom-nav .icon svg { width: 22px; height: 22px; }

/* =========================================================
   Desktop (>=960px): stały ciemny sidebar, pełna szerokość,
   dolna nawigacja i górny pasek mobilny znikają.
   ========================================================= */

@media (min-width: 960px) {
  body { padding-bottom: 0; }

  .bottom-nav { display: none; }
  .topbar { display: none; }

  .sidebar {
    display: flex;
    flex-direction: column;
    width: 250px;
    flex-shrink: 0;
    min-height: 100vh;
    background: linear-gradient(180deg, var(--sidebar-bg-2), var(--sidebar-bg));
    padding: 22px 16px;
    position: sticky;
    top: 0;
    align-self: flex-start;
  }

  .sidebar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
    font-weight: 800;
    font-size: 16px;
    letter-spacing: -.01em;
    padding: 6px 10px 26px;
  }
  .sidebar-brand .dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 4px rgba(255,106,0,.18);
  }

  .sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
  }
  .sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: 10px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
  }
  .sidebar-nav a .icon { width: 19px; height: 19px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
  .sidebar-nav a .icon svg { width: 19px; height: 19px; }
  .sidebar-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
  .sidebar-nav a.active {
    background: var(--accent);
    color: #fff;
  }

  .sidebar-user {
    border-top: 1px solid rgba(255,255,255,.1);
    padding-top: 14px;
    margin-top: 10px;
  }
  .sidebar-user .name {
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    padding: 0 10px;
    margin-bottom: 4px;
  }
  .sidebar-user a {
    display: block;
    color: var(--sidebar-text);
    font-size: 13px;
    padding: 0 10px;
    text-decoration: none;
  }
  .sidebar-user a:hover { color: #fff; }

  .container {
    max-width: 1180px;
    padding: 32px 40px;
  }

  .kpi-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
  }

  .grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    align-items: start;
  }
  .grid-2 > .card { margin-bottom: 0; }

  .card { padding: 24px; }

  .filter-grid { grid-template-columns: repeat(4, 1fr); }

  .date-short { display: none; }
  .date-full { display: inline; }
  .hide-mobile { display: table-cell; }
}

@media (min-width: 1280px) {
  .container { max-width: 1320px; }
}
