:root {
  --bg: #070b12;
  --bg-2: #0d121c;
  --card: #151b26;
  --line: rgba(255, 255, 255, 0.10);
  --text: #eef3fa;
  --muted: #9aa7b8;
  --cyan: #00D1FF;
  --red: #E74C3C;
  --green: #27AE60;
  --yellow: #F1C40F;

  /* Apple "liquid glass" tokens */
  --glass: rgba(255, 255, 255, 0.06);
  --glass-strong: rgba(255, 255, 255, 0.10);
  --glass-border: rgba(255, 255, 255, 0.14);
  --glass-hi: rgba(255, 255, 255, 0.22);
  --blur: saturate(180%) blur(22px);
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  --radius: 18px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  /* Ambientowe tło: kolorowe „blobsy" pod warstwami szkła */
  background:
    radial-gradient(60vw 50vw at 12% -10%, rgba(0, 209, 255, 0.18), transparent 60%),
    radial-gradient(55vw 50vw at 110% 10%, rgba(155, 89, 182, 0.16), transparent 60%),
    radial-gradient(70vw 60vw at 50% 120%, rgba(39, 174, 96, 0.10), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}

a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Pasek górny (szkło) ── */
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px max(16px, env(safe-area-inset-left));
  padding-top: max(12px, env(safe-area-inset-top));
  background: rgba(13, 18, 28, 0.55);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--glass-border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { font-weight: 800; letter-spacing: 2px; color: var(--cyan); font-size: 18px; white-space: nowrap; }
.nav { display: flex; gap: 6px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  color: var(--muted); font-weight: 600; font-size: 14px; white-space: nowrap;
  padding: 7px 12px; border-radius: 999px; transition: background .2s, color .2s;
}
.nav a.active { color: #001018; background: var(--cyan); }
.nav a:hover { color: var(--text); text-decoration: none; background: var(--glass); }
.nav a.active:hover { color: #001018; background: var(--cyan); }
.nav-right { display: flex; align-items: center; gap: 10px; }
.nav-user { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.nav-avatar { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; border: 1px solid rgba(255,255,255,.18); flex: 0 0 auto; }
.nav-avatar-empty { display: inline-flex; align-items: center; justify-content: center; background: rgba(0,209,255,.18); color: var(--cyan); font-weight: 700; font-size: 13px; }
.avatar-row { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.avatar-lg { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; border: 1px solid rgba(255,255,255,.18); flex: 0 0 auto; }
.avatar-empty { display: inline-flex; align-items: center; justify-content: center; background: rgba(0,209,255,.18); color: var(--cyan); font-weight: 700; font-size: 34px; }
.avatar-actions { display: flex; flex-direction: column; gap: 8px; }
.site-footer { border-top: 1px solid rgba(255,255,255,.08); margin-top: 40px; padding: 18px 0; }
.footer-inner { max-width: 1100px; margin: 0 auto; padding: 0 max(16px, env(safe-area-inset-left)); display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 16px; }
.footer-links a { color: var(--muted); text-decoration: none; font-size: 13px; }
.footer-links a:hover { color: var(--cyan); }
.legal { max-width: 820px; line-height: 1.6; }
.legal h1 { margin-top: 4px; }
.legal h2 { color: var(--text, #e8eef7); font-size: 17px; margin: 22px 0 8px; }
.legal ul { padding-left: 20px; }
.legal li { margin: 4px 0; }
.legal table { width: 100%; margin: 10px 0; }
.legal a { color: var(--cyan); }
.auth-legal { font-size: 12px; text-align: center; margin: 14px 0 0; line-height: 1.5; }
.auth-legal a { color: var(--cyan); text-decoration: none; }
.consent { display: flex; align-items: flex-start; gap: 8px; font-size: 12.5px; color: var(--muted); line-height: 1.45; margin: 4px 0 12px; cursor: pointer; }
.consent input[type="checkbox"] { width: 16px; height: 16px; margin-top: 1px; flex: 0 0 auto; accent-color: var(--cyan); }
.consent a { color: var(--cyan); text-decoration: none; }

.container { max-width: 1100px; margin: 0 auto; padding: 22px max(16px, env(safe-area-inset-left)); }
h1 { font-weight: 700; font-size: 24px; margin: 4px 0 20px; letter-spacing: -0.02em; }
h2 { font-weight: 600; font-size: 16px; color: var(--muted); margin: 26px 0 12px; }
h3 { font-weight: 600; font-size: 15px; }

/* ── Powierzchnie szkła ── */
.tile, .card, .auth-card {
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow), inset 0 1px 0 var(--glass-hi);
}

/* Kafelki KPI */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.tile { padding: 18px 20px; }
.tile .label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }
.tile .value { font-size: 34px; font-weight: 800; margin-top: 6px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.tile .unit { font-size: 14px; color: var(--muted); font-weight: 500; margin-left: 4px; }
.tile.accent-cyan .value { color: var(--cyan); }
.tile.accent-green .value { color: var(--green); }
.tile.accent-yellow .value { color: var(--yellow); }

.card { padding: 20px; margin-top: 16px; overflow-x: auto; }

/* Tabele */
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 12px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
th { color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: 1px; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255, 255, 255, 0.03); }
td.num, th.num { text-align: right; }
.best { color: var(--green); font-weight: 700; }

/* Formularze / logowanie */
.auth-wrap { min-height: 100svh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 380px; padding: 28px; }
.auth-card .brand { display: block; text-align: center; font-size: 26px; margin-bottom: 4px; }
.auth-sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 22px; }
label { display: block; font-size: 12px; color: var(--muted); margin: 14px 0 6px; }
input, select {
  width: 100%;
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 13px 14px;
  color: var(--text);
  font-size: 16px; /* >=16px: iOS nie zoomuje przy focusie */
}
input:focus, select:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(0, 209, 255, 0.18); }

.btn {
  width: 100%;
  margin-top: 20px;
  background: linear-gradient(180deg, #2ad8ff, var(--cyan));
  color: #04222b;
  border: none;
  border-radius: 12px;
  padding: 14px;
  font-weight: 800;
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 209, 255, 0.28);
  transition: filter .15s, transform .05s;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: scale(0.99); }
.btn-ghost {
  background: var(--glass); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  color: var(--text); border: 1px solid var(--glass-border); box-shadow: none;
}
.btn-ghost:hover { background: var(--glass-strong); }
.toggle { text-align: center; margin-top: 16px; font-size: 13px; color: var(--muted); }
.msg { margin-top: 14px; font-size: 13px; min-height: 18px; }
.msg.err { color: var(--red); }
.msg.ok { color: var(--green); }

.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 40px 20px; text-align: center; }
canvas { max-width: 100%; }

/* Link "Postaw mi kawę" */
.coffee-link {
  display: inline-block; text-decoration: none;
  background: linear-gradient(180deg, #ffd84d, #F1C40F); color: #1A1A1A;
  font-weight: 700; font-size: 13px; padding: 7px 12px; border-radius: 999px; white-space: nowrap;
  box-shadow: 0 4px 12px rgba(241, 196, 15, 0.3);
}
.coffee-link:hover { filter: brightness(1.05); text-decoration: none; }

/* Przełącznik języka PL/EN */
.lang-switch { display: inline-flex; gap: 6px; align-items: center; }
.lang-switch a {
  text-decoration: none; color: var(--muted); font-weight: 700; font-size: 12px;
  padding: 5px 9px; border-radius: 999px; border: 1px solid var(--glass-border);
  background: var(--glass);
}
.lang-switch a.active { color: #001018; background: var(--cyan); border-color: var(--cyan); }

/* ── Mobile ── */
@media (max-width: 720px) {
  .topbar { gap: 10px; flex-wrap: wrap; }
  .nav { order: 3; width: 100%; flex: 1 1 100%; padding-bottom: 2px; }
  .nav-right { margin-left: auto; }
  .container { padding: 16px 14px calc(20px + env(safe-area-inset-bottom)); }
  h1 { font-size: 21px; }
  .tile .value { font-size: 28px; }
  th, td { padding: 10px 9px; font-size: 13px; }
}

@media (max-width: 380px) {
  .tiles { grid-template-columns: 1fr 1fr; }
  .brand { font-size: 16px; }
}

@media (prefers-reduced-transparency: reduce) {
  .topbar, .tile, .card, .auth-card, input, select, .btn-ghost, .lang-switch a {
    -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--card);
  }
  .topbar { background: var(--bg-2); }
}
