/* ============================================
   Leasing - design system
   Paleta: finanse (zieleń + złoto + granat + krem)
   Typografia: Castoro (display) + Plus Jakarta Sans (body) + JetBrains Mono (cyfry)
   ============================================ */

:root {
  /* Light theme - krem */
  --bg: #f6f1e6;
  --bg-soft: #efe8d8;
  --surface: #fdfaf3;
  --surface-2: #f2ecdf;
  --border-light: #ddd3bd;
  --border: #c9bda1;
  --text: #1a241d;
  --text-secondary: #4d5a4e;
  --text-dim: #5f6b60;
  --accent: #1f6b3a;          /* głęboka zieleń */
  --accent-hover: #17552e;
  --accent-light: #dcebdd;
  --accent-subtle: #e9f2e6;
  --gold: #82621f;            /* złoto (tekst na jasnym) */
  --gold-bright: #c9a24b;     /* złoto (dekoracje) */
  --navy: #1c2f4d;
  --shadow: 0 1px 2px rgba(20, 30, 20, 0.05), 0 8px 24px rgba(20, 30, 20, 0.06);
  --shadow-hover: 0 2px 4px rgba(20, 30, 20, 0.07), 0 14px 34px rgba(20, 30, 20, 0.1);
  --header-height: 60px;
  --sidebar-width: 300px;
  --radius: 12px;
  --radius-sm: 8px;
  --transition: all .2s ease-out;
  --font-display: 'Castoro', Georgia, 'Times New Roman', serif;
  --font-body: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;
  --bg-glow-1: radial-gradient(600px 400px at 85% -5%, rgba(201, 162, 75, 0.16), transparent 70%);
  --bg-glow-2: radial-gradient(700px 500px at -10% 110%, rgba(31, 107, 58, 0.12), transparent 70%);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1a12;
    --bg-soft: #111e14;
    --surface: #16241b;
    --surface-2: #1b2b20;
    --border-light: #24382a;
    --border: #2e4634;
    --text: #e8e4d8;
    --text-secondary: #b3bfb2;
    --text-dim: #8fa393;
    --accent: #35a35c;        /* zieleń na ciemnym */
    --accent-hover: #46b56c;
    --accent-light: #1d3523;
    --accent-subtle: #1a2f20;
    --gold: #d4b265;          /* złoto na ciemnym */
    --gold-bright: #d4b265;
    --navy: #2b4366;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
    --shadow-hover: 0 2px 4px rgba(0, 0, 0, 0.35), 0 14px 34px rgba(0, 0, 0, 0.35);
    --bg-glow-1: radial-gradient(600px 400px at 85% -5%, rgba(201, 162, 75, 0.1), transparent 70%);
    --bg-glow-2: radial-gradient(700px 500px at -10% 110%, rgba(53, 163, 92, 0.09), transparent 70%);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 17px;
  scroll-behavior: smooth;
  overflow-x: clip;
}

body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  background-image: var(--bg-glow-1), var(--bg-glow-2);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
img { max-width: 100%; height: auto; }
::selection { background: var(--accent-light); color: var(--text); }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ============ HEADER ============ */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-light);
  z-index: 100;
}
.app-header::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-bright), transparent);
  opacity: .3;
  pointer-events: none;
}
.logo-mark { font-size: 1.35rem; line-height: 1; }
.brand { font-family: var(--font-display); font-size: 1.35rem; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; }
.brand a { color: var(--text); }
.brand em { font-style: italic; color: var(--accent); }
.header-search {
  position: relative;
  margin-left: auto;
  width: min(340px, 38vw);
}
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: .85rem; opacity: .6; pointer-events: none; }
#search-input {
  width: 100%;
  padding: 9px 14px 9px 36px;
  border: 1px solid var(--border-light);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-body);
  font-size: .88rem;
  transition: var(--transition);
}
#search-input::placeholder { color: var(--text-dim); }
#search-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
#search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
  overflow: hidden;
  z-index: 120;
  display: none;
}
#search-results a {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
  font-size: .875rem;
}
#search-results a:last-child { border-bottom: none; }
#search-results a:hover { background: var(--accent-subtle); }
#search-results .sr-title { font-weight: 600; font-size: .875rem; line-height: 1.35; }
#search-results .sr-excerpt { font-size: .78rem; color: var(--text-secondary); line-height: 1.35; }

.mobile-menu-btn {
  display: none;
  background: none;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 1.15rem;
  width: 40px; height: 40px;
  color: var(--text);
  cursor: pointer;
  transition: var(--transition);
}
.mobile-menu-btn:hover { background: var(--surface-2); }

/* ============ SIDEBAR ============ */
.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--border-light);
  padding: 16px 10px 40px;
  z-index: 90;
  scrollbar-width: thin;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.sidebar-nav { list-style: none; }
.sidebar-nav li.nav-section {
  font-family: var(--font-mono);
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 18px 12px 6px;
}
.sidebar-nav li.nav-section:first-child { padding-top: 4px; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: .9rem;
  line-height: 1.4;
  transition: var(--transition);
  border-left: 2px solid transparent;
}
.sidebar-nav a:hover { background: var(--accent-subtle); color: var(--text); }
.sidebar-nav a.active {
  background: var(--accent-subtle);
  color: var(--accent);
  font-weight: 600;
  border-left-color: var(--accent);
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 10, 0.5);
  z-index: 85;
}

/* ============ MAIN ============ */
.main-content {
  margin-left: var(--sidebar-width);
  padding: calc(var(--header-height) + 32px) 40px 80px;
  max-width: 920px;
  min-height: 100vh;
}
.content-article {
  animation: fadeUp .25s ease-out both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.content-article h1 {
  font-family: var(--font-display);
  font-size: 2.35rem;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -.015em;
  text-wrap: balance;
  margin-bottom: .4em;
  color: var(--text);
}
.content-article h2 {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 600;
  line-height: 1.25;
  text-wrap: balance;
  margin: 1.9em 0 .55em;
  color: var(--text);
  padding-bottom: .3em;
  border-bottom: 1px solid var(--border-light);
}
.content-article h3 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  margin: 1.5em 0 .45em;
  color: var(--text);
  text-wrap: balance;
}
.content-article p { margin: 0 0 1.05em; }
.content-article ul, .content-article ol { margin: 0 0 1.1em 1.4em; }
.content-article li { margin-bottom: .4em; }
.content-article strong { font-weight: 700; }
.content-article em { font-style: italic; }

.article-meta {
  font-size: .95rem;
  color: var(--text-secondary);
  margin-bottom: 1.6em;
  line-height: 1.6;
}

/* TOC */
.article-toc {
  background: var(--surface-2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 0 0 1.8em;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.article-toc h3 {
  font-family: var(--font-mono);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 0 0 4px;
}
.article-toc a { font-size: .9rem; color: var(--text-secondary); line-height: 1.5; }
.article-toc a:hover { color: var(--accent); }
.article-toc a.toc-h3 { padding-left: 16px; font-size: .85rem; }

/* Info box */
.info-box {
  background: var(--accent-subtle);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 14px 18px;
  margin: 0 0 1.2em;
  font-size: .95rem;
  line-height: 1.6;
  color: var(--text);
}
.info-box strong { color: var(--accent); }

/* Warning box */
.warning-box {
  background: color-mix(in srgb, var(--gold-bright) 12%, var(--surface));
  border-left: 4px solid var(--gold);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 14px 18px;
  margin: 0 0 1.2em;
  font-size: .95rem;
  line-height: 1.6;
}
.warning-box strong { color: var(--gold); }

/* Tables */
.table-responsive { overflow-x: auto; margin: 0 0 1.3em; border-radius: var(--radius-sm); border: 1px solid var(--border-light); }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
  background: var(--surface);
}
th, td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
  vertical-align: top;
}
th {
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--accent-subtle); }

/* Error / status table */
.error-table th { background: var(--navy); color: #e8e4d8; }
.error-code {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}

/* FAQ */
.faq-item {
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 18px 20px;
  margin-bottom: 14px;
}
.faq-item h3 {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 8px;
  display: flex;
  gap: 10px;
  align-items: baseline;
}
.faq-item h3::before {
  content: 'Q';
  font-family: var(--font-mono);
  font-size: .75rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-light);
  border-radius: 6px;
  padding: 2px 7px;
  flex-shrink: 0;
}
.faq-item p { margin: 0; font-size: .93rem; color: var(--text-secondary); }

/* Glossary */
.glossary dl { margin: 0; }
.glossary dt {
  font-weight: 700;
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 1.05rem;
  margin: 1.2em 0 .3em;
  padding-top: .6em;
  border-top: 1px dashed var(--border-light);
}
.glossary dt:first-child { border-top: none; }
.glossary dd { margin: 0 0 .4em; color: var(--text-secondary); font-size: .95rem; }

/* ============ HOME ============ */
.home-hero {
  position: relative;
  border-radius: var(--radius);
  padding: 44px 40px;
  margin-bottom: 36px;
  overflow: hidden;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--navy) 85%, var(--bg)) 0%, color-mix(in srgb, var(--accent) 60%, var(--navy)) 100%);
  color: #f2efe4;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow);
}
.home-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(500px 300px at 90% 10%, rgba(201, 162, 75, 0.25), transparent 70%);
  pointer-events: none;
}
.home-hero .hero-icon { font-size: 2.6rem; margin-bottom: 10px; }
.home-hero h1 {
  font-family: var(--font-display);
  font-size: 2.6rem;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -.015em;
  color: #fff;
  margin-bottom: 12px;
  text-wrap: balance;
}
.home-hero h1 em { font-style: italic; color: var(--gold-bright); }
.home-hero p { font-size: 1.05rem; color: rgba(242, 239, 228, 0.92); max-width: 56ch; line-height: 1.6; }
.hero-cta { display: flex; gap: 12px; margin-top: 22px; flex-wrap: wrap; }
.btn-primary {
  display: inline-block;
  background: var(--gold-bright);
  color: #1a241d;
  font-weight: 700;
  font-size: .92rem;
  padding: 11px 22px;
  border-radius: 999px;
  transition: var(--transition);
  border: 1px solid transparent;
}
.btn-primary:hover { background: #d8b45e; color: #1a241d; transform: translateY(-1px); }
.btn-ghost {
  display: inline-block;
  color: #f2efe4;
  font-weight: 600;
  font-size: .92rem;
  padding: 11px 22px;
  border-radius: 999px;
  border: 1px solid rgba(242, 239, 228, 0.4);
  transition: var(--transition);
}
.btn-ghost:hover { background: rgba(242, 239, 228, 0.1); color: #fff; }
.stats-row {
  display: flex;
  gap: 14px;
  margin-top: 26px;
  flex-wrap: wrap;
}
.stat-card {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  display: flex;
  flex-direction: column;
}
.stat-card .num { font-family: var(--font-mono); font-size: 1.5rem; font-weight: 600; color: var(--gold-bright); line-height: 1.2; }
.stat-card .label { font-size: .78rem; color: rgba(242, 239, 228, 0.85); letter-spacing: .03em; }

.home-section-label {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text);
  margin: 34px 0 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-wrap: balance;
}
.accent-bar {
  display: inline-block;
  width: 26px; height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--gold-bright));
  flex-shrink: 0;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.home-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  color: var(--text);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.home-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--gold-bright));
  opacity: 0;
  transition: opacity .2s ease-out;
}
.home-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: var(--border);
  color: var(--text);
}
.home-card:hover::before { opacity: 1; }
.home-card .card-icon { font-size: 1.3rem; line-height: 1.2; margin-bottom: 4px; }
.home-card h3 { font-size: .9rem; font-weight: 700; line-height: 1.4; color: var(--text); }
.home-card p { font-size: .85rem; color: var(--text-secondary); line-height: 1.5; }

/* Loading */
.loading { display: flex; justify-content: center; padding-top: 80px; }
.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--border-light);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ RESPONSIVE ============ */
@media (max-width: 1100px) {
  .home-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-102%);
    transition: transform .25s ease-out;
    box-shadow: none;
    width: min(var(--sidebar-width), 85vw);
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-hover); }
  .sidebar-overlay.show { display: block; }
  .mobile-menu-btn { display: inline-flex; align-items: center; justify-content: center; }
  .main-content { margin-left: 0; padding: calc(var(--header-height) + 24px) 20px 60px; }
  .brand { font-size: 1.15rem; }
  .header-search { width: min(240px, 45vw); }
}
@media (max-width: 600px) {
  .home-grid { grid-template-columns: 1fr; }
  .home-hero { padding: 32px 24px; }
  .home-hero h1 { font-size: 2rem; }
  .content-article h1 { font-size: 1.85rem; }
  .header-search { display: none; }
  .app-header { padding: 0 14px; gap: 10px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
