/* IKZ Counter — style panelu (mobile first, jasny i ciemny motyw, WCAG AA) */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/inter-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- Tokeny ---------- */
:root {
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;

  --radius: 14px;
  --radius-sm: 10px;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 24px; --space-6: 32px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --dur: 220ms;

  /* Jasny */
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f3f8;
  --border: #e2e6ef;
  --text: #0f172a;
  --text-2: #475569;     /* kontrast 7,5:1 na białym */
  --accent: #4f46e5;     /* indygo */
  --accent-2: #2563eb;   /* niebieski */
  --accent-3: #0891b2;   /* cyjan */
  --accent-text: #4338ca;
  --accent-soft: #eef2ff;
  --on-accent: #ffffff;
  --bar: rgba(79, 70, 229, .10);
  --up: #047857;
  --up-soft: #ecfdf5;
  --down: #b91c1c;
  --down-soft: #fef2f2;
  --warn: #b45309;       /* bursztyn — kontrast 5:1 na białym */
  --warn-soft: #fffbeb;
  --danger: #b91c1c;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .05);
  --focus: 0 0 0 3px rgba(79, 70, 229, .35);
  --gradient: linear-gradient(135deg, #4f46e5 0%, #2563eb 50%, #06b6d4 100%);

  --chart-1: #4f46e5;
  --chart-2: #06b6d4;
  --chart-grid: #e8ebf2;
  --chart-text: #64748b;

  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0b1020;
  --surface: #121a2e;
  --surface-2: #18223a;
  --border: #243150;
  --text: #e8edf7;
  --text-2: #a5b1c8;     /* kontrast 7,9:1 na tle karty */
  --accent: #818cf8;
  --accent-2: #60a5fa;
  --accent-3: #22d3ee;
  --accent-text: #a5b4fc;
  --accent-soft: #1e2547;
  --on-accent: #0b1020;
  --bar: rgba(129, 140, 248, .16);
  --up: #34d399;
  --up-soft: rgba(52, 211, 153, .12);
  --down: #f87171;
  --down-soft: rgba(248, 113, 113, .12);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, .12);
  --danger: #f87171;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  --focus: 0 0 0 3px rgba(129, 140, 248, .5);

  --chart-1: #818cf8;
  --chart-2: #22d3ee;
  --chart-grid: #1f2a44;
  --chart-text: #93a1bb;

  color-scheme: dark;
}

/* Bez JavaScriptu — zgodnie z ustawieniem systemu */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0b1020; --surface: #121a2e; --surface-2: #18223a; --border: #243150;
    --text: #e8edf7; --text-2: #a5b1c8; --accent: #818cf8; --accent-text: #a5b4fc;
    --accent-soft: #1e2547; --on-accent: #0b1020; --bar: rgba(129, 140, 248, .16);
    --up: #34d399; --down: #f87171; --danger: #f87171; --warn: #fbbf24;
    --up-soft: rgba(52, 211, 153, .12); --down-soft: rgba(248, 113, 113, .12); --warn-soft: rgba(251, 191, 36, .12);
    color-scheme: dark;
  }
}

/* ---------- Podstawy ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1rem; font-weight: 600; }
a { color: var(--accent-text); text-underline-offset: 2px; }
code, pre { font-family: var(--mono); font-size: .875em; }
img, svg { display: block; }
.num, .tile-value, .toplist-value { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.small { font-size: .8125rem; }
.inline { display: inline; margin: 0; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
.skip-link {
  position: absolute; left: var(--space-3); top: -48px; z-index: 100;
  padding: var(--space-2) var(--space-3); background: var(--surface); border-radius: var(--radius-sm);
}
.skip-link:focus { top: var(--space-3); }

.icon { width: 20px; height: 20px; flex: none; }
.icon-sm { width: 16px; height: 16px; }
.icon-xl { width: 40px; height: 40px; color: var(--accent); }

/* ---------- Górny pasek ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: var(--space-3);
  padding: calc(var(--space-2) + env(safe-area-inset-top)) var(--space-4) var(--space-2);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex; align-items: center; gap: var(--space-2);
  color: var(--text); text-decoration: none; font-weight: 700; letter-spacing: -0.02em;
}
.topnav { display: none; gap: var(--space-1); margin-left: var(--space-4); }
.topnav a, .bottomnav a {
  display: flex; align-items: center; gap: var(--space-2);
  color: var(--text-2); text-decoration: none; font-weight: 500;
  border-radius: var(--radius-sm);
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.topnav a { padding: var(--space-2) var(--space-3); }
.topnav a:hover { background: var(--surface-2); color: var(--text); }
.topnav a[aria-current="page"] { color: var(--accent-text); background: var(--accent-soft); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: var(--space-1); }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 44px; height: 44px; padding: 0;
  border: 1px solid transparent; border-radius: 12px;
  background: transparent; color: var(--text-2); cursor: pointer;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease), transform 120ms var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(.94); }
.theme-icon { display: grid; place-items: center; grid-area: 1 / 1; transition: transform 400ms var(--ease), opacity var(--dur) var(--ease); }
:root[data-theme="light"] .theme-icon-sun,
:root[data-theme="dark"] .theme-icon-moon { opacity: 0; transform: rotate(-90deg) scale(.6); }

/* ---------- Dolna nawigacja (telefon) ---------- */
.bottomnav {
  position: fixed; inset: auto 0 0 0; z-index: 20;
  display: flex; justify-content: space-around;
  padding: var(--space-1) var(--space-2) calc(var(--space-1) + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}
.bottomnav a {
  flex: 1; flex-direction: column; gap: 2px; justify-content: center;
  min-height: 52px; font-size: .75rem;
}
.bottomnav a[aria-current="page"] { color: var(--accent-text); }

/* ---------- Główna treść ---------- */
.main {
  max-width: 1200px; margin: 0 auto;
  padding: var(--space-4) var(--space-4) calc(88px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: var(--space-4);
}
.main:focus { outline: none; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-4);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); }

/* ---------- Formularze i przyciski ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 44px; padding: 0 var(--space-4);
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), transform 120ms var(--ease), box-shadow var(--dur) var(--ease);
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--gradient); border-color: transparent; color: #fff; box-shadow: 0 4px 14px rgba(79, 70, 229, .28); }
.btn-primary:hover { background: var(--gradient); filter: brightness(1.06); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { color: var(--text); }
.btn-danger { background: var(--danger); border-color: transparent; color: #fff; }
:root[data-theme="dark"] .btn-danger { color: #1a0b0b; }
.btn-block { width: 100%; }

.form { display: flex; flex-direction: column; gap: var(--space-4); }
.field { display: flex; flex-direction: column; gap: var(--space-1); }
.field label { font-weight: 600; font-size: .875rem; }
input[type="text"], input[type="password"], input[type="email"], input[type="date"], input[type="number"], textarea, .select {
  width: 100%; min-height: 44px; padding: 10px 12px;
  font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
textarea { resize: vertical; font-family: var(--mono); font-size: .875rem; }
input:focus, textarea:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
[aria-invalid="true"] { border-color: var(--danger) !important; }
.field-help { margin: 0; color: var(--text-2); font-size: .8125rem; }
.field-error { margin: 0; color: var(--danger); font-size: .8125rem; font-weight: 600; }
.select { appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
.select-lg { font-weight: 700; font-size: 1.0625rem; width: auto; max-width: 100%; }
.check { display: flex; align-items: flex-start; gap: var(--space-2); cursor: pointer; min-height: 32px; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.form-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

.alert { padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm); font-weight: 500; animation: rise 300ms var(--ease); }
.alert-ok { background: var(--up-soft); color: var(--up); }
.alert-error { background: var(--down-soft); color: var(--down); }

/* ---------- Pulpit ---------- */
.site-picker { display: flex; gap: var(--space-2); align-items: center; min-width: 0; }
.live-pill {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: 6px 12px; border-radius: 999px; min-height: 36px; color: var(--text); text-decoration: none;
  background: var(--surface); border: 1px solid var(--border); font-size: .875rem;
  transition: border-color var(--dur) var(--ease);
}
a.live-pill:hover { border-color: var(--accent); }
.live-dot { position: relative; width: 10px; height: 10px; border-radius: 50%; background: #10b981; }
.live-dot::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; background: #10b981;
  animation: pulse 2s var(--ease) infinite;
}

.segmented {
  display: flex; gap: 2px; padding: 3px; overflow-x: auto; scrollbar-width: none;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px;
}
.segmented::-webkit-scrollbar { display: none; }
.segmented a {
  flex: 1 0 auto; text-align: center; white-space: nowrap;
  padding: 8px 12px; min-height: 40px; display: grid; place-items: center;
  border-radius: 9px; color: var(--text-2); text-decoration: none; font-weight: 500; font-size: .875rem;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.segmented a:hover { color: var(--text); }
.segmented a[aria-current="true"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.tile { padding: var(--space-3) var(--space-4); animation: rise 420ms var(--ease) both; }
.tile:nth-child(2) { animation-delay: 40ms; }
.tile:nth-child(3) { animation-delay: 80ms; }
.tile:nth-child(4) { animation-delay: 120ms; }
.tile:nth-child(5) { animation-delay: 160ms; }
.tile:nth-child(6) { animation-delay: 200ms; }
.tile:last-child:nth-child(odd) { grid-column: 1 / -1; }
.tile-label { font-size: .8125rem; font-weight: 500; color: var(--text-2); }
.tile-value { font-size: 1.625rem; font-weight: 700; letter-spacing: -0.02em; margin: 2px 0; }
.tile-change { display: inline-flex; align-items: center; gap: 2px; font-size: .75rem; font-weight: 600; padding: 2px 6px; border-radius: 6px; }
.tile-change.is-up { color: var(--up); background: var(--up-soft); }
.tile-change.is-down { color: var(--down); background: var(--down-soft); }
.tile-change.is-neutral { color: var(--text-2); padding-left: 0; font-weight: 500; }

.chart { width: 100%; height: 280px; }
.data-table { margin-top: var(--space-3); }
.data-table summary { cursor: pointer; color: var(--text-2); font-size: .8125rem; min-height: 32px; display: flex; align-items: center; }
.table-scroll { max-height: 320px; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th, td { padding: 6px 8px; text-align: left; border-bottom: 1px solid var(--border); }
th { font-weight: 600; color: var(--text-2); }
td.num, th.num { text-align: right; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); }
.grid-2 > *, .tiles > * { min-width: 0; }

.toplist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.toplist li {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: 8px 10px; border-radius: 8px; isolation: isolate;
}
.toplist li::before {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: 8px;
  background: var(--bar); width: var(--w, 0%); transform-origin: left;
  animation: grow 700ms var(--ease) both;
}
.toplist-label { display: flex; flex-direction: column; min-width: 0; }
.toplist-main { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.toplist-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .75rem; color: var(--text-2); }
.toplist-value { font-weight: 600; flex: none; }

.empty-inline { display: flex; flex-direction: column; align-items: center; text-align: center; padding: var(--space-6) var(--space-4); gap: var(--space-1); }
.empty-inline p { margin: 0; }
.empty-small { margin: 0; padding: var(--space-4) 0; text-align: center; }
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-3); padding: var(--space-6) var(--space-4); }
.empty-state p { margin: 0; }
.footnote { margin: 0; }

/* ---------- Karty z zakładkami ---------- */
.tabs {
  display: flex; gap: 2px; margin: 0 0 var(--space-3); padding-bottom: 2px;
  overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--border);
}
.tabs::-webkit-scrollbar { display: none; }
.tabs [role="tab"] {
  flex: none; min-height: 40px; padding: 0 12px; margin-bottom: -3px;
  font: inherit; font-size: .875rem; font-weight: 500; color: var(--text-2);
  background: none; border: 0; border-bottom: 2px solid transparent; border-radius: 8px 8px 0 0; cursor: pointer;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.tabs [role="tab"]:hover { color: var(--text); background: var(--surface-2); }
.tabs [role="tab"][aria-selected="true"] { color: var(--accent-text); border-bottom-color: var(--accent); font-weight: 600; }
.tabpanel + .tabpanel { margin-top: var(--space-4); }
.tabpanel-title { font-size: .8125rem; font-weight: 600; color: var(--text-2); margin-bottom: var(--space-2); }
[data-tabs].is-enhanced .tabpanel + .tabpanel { margin-top: 0; }
[data-tabs].is-enhanced .tabpanel-title { display: none; }
[data-tabs].is-enhanced .tabpanel:not([hidden]) { animation: rise 260ms var(--ease); }

/* ---------- Strony ---------- */
.site-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.site-item { display: flex; flex-direction: column; gap: var(--space-3); }
.site-main { flex: 1; min-width: 0; }
.site-title { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.site-title a { color: var(--text); text-decoration: none; }
.site-title a:hover { color: var(--accent-text); }
.site-actions { display: flex; gap: var(--space-1); flex-wrap: wrap; margin-left: calc(-1 * var(--space-3)); }
.badge { font-size: .6875rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 2px 8px; border-radius: 999px; }
.badge-ok { color: var(--up); background: var(--up-soft); }
.badge-off { color: var(--text-2); background: var(--surface-2); }
.badge-good { color: var(--up); background: var(--up-soft); }
.badge-ni { color: var(--warn); background: var(--warn-soft); }
.badge-poor { color: var(--down); background: var(--down-soft); }

/* ---------- Zakres dat i filtry (etap 4) ---------- */
.range-bar { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.custom-range > summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; padding: 8px 12px; border-radius: 10px; font-size: .875rem; font-weight: 500;
  color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border);
}
.custom-range > summary::-webkit-details-marker { display: none; }
.custom-range > summary[aria-current="true"], .custom-range[open] > summary { color: var(--text); font-weight: 600; }
.custom-range-form { display: flex; flex-wrap: wrap; align-items: end; gap: var(--space-2); margin-top: var(--space-2); }
.custom-range-form label { display: flex; flex-direction: column; gap: 2px; font-size: .8125rem; color: var(--text-2); }
.custom-range-form .input { min-height: 44px; }

.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.filter-bar > .muted { display: inline-flex; align-items: center; gap: 4px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-height: 36px;
  padding: 6px 10px 6px 12px; border-radius: 999px; text-decoration: none; font-size: .8125rem;
  color: var(--accent-text); background: var(--accent-soft); border: 1px solid transparent;
  transition: border-color var(--dur) var(--ease), transform 120ms var(--ease);
  animation: rise 260ms var(--ease) both;
}
.pill:hover { border-color: var(--accent); }
.pill:active { transform: scale(.97); }
.pill-key { font-weight: 500; opacity: .8; }
.pill-value { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 22ch; }
.pill-clear { color: var(--text-2); background: transparent; border-color: var(--border); }

a.toplist-label { color: inherit; text-decoration: none; border-radius: 6px; }
a.toplist-label:hover .toplist-main { text-decoration: underline; text-underline-offset: 3px; }
a.toplist-label:focus-visible { outline: none; box-shadow: var(--focus); }
.toplist li.is-active { outline: 2px solid var(--accent); outline-offset: -2px; }
.toplist li.is-active .toplist-main { font-weight: 700; color: var(--accent-text); }

/* ---------- Teraz na stronie, wizyty, widok zbiorczy (etap 4b) ---------- */
.flip { transform: scaleX(-1); }
.icon-btn.is-disabled { opacity: .35; pointer-events: none; }
.live-hero { display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap; }
.live-dot-lg { width: 16px; height: 16px; flex: none; }
.live-count { font-size: 2.5rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.live-updated { margin-left: auto; }

.visit-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.visit-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-2) var(--space-3); padding: var(--space-3) 0; border-bottom: 1px solid var(--border); }
.visit-row:last-child { border-bottom: 0; }
.visit-row.is-new { animation: slide-in 500ms var(--ease) both; }
.visit-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 14rem; }
.visit-main > * { overflow: hidden; text-overflow: ellipsis; }
.visit-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right; flex: none; }
@keyframes slide-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.day-bar { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.day-form { display: flex; align-items: center; gap: var(--space-2); }
.day-label { font-weight: 700; font-size: 1.125rem; }
.day-form .input { min-height: 44px; }

.visit-log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.visit-card { padding: 0; animation: rise 320ms var(--ease) both; }
.visit-card summary {
  list-style: none; cursor: pointer; display: flex; gap: var(--space-3); align-items: flex-start;
  padding: var(--space-3) var(--space-4); border-radius: var(--radius); min-height: 44px;
}
.visit-card summary::-webkit-details-marker { display: none; }
.visit-card summary:focus-visible { outline: none; box-shadow: var(--focus); }
.visit-card summary:hover { background: var(--surface-2); }
.visit-time { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 3.2em; }
.visit-card .visit-main > span { white-space: nowrap; }
.visit-steps { list-style: none; margin: 0; padding: 0 var(--space-4) var(--space-3) calc(var(--space-4) + 3.2em + var(--space-3)); position: relative; }
.visit-steps li { display: flex; gap: var(--space-3); padding: 6px 0 6px var(--space-3); border-left: 2px solid var(--border); position: relative; }
.visit-steps li::before { content: ""; position: absolute; left: -6px; top: 12px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.step-time { min-width: 5em; font-variant-numeric: tabular-nums; }
.step-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.step-main > span { overflow-wrap: anywhere; }
.step-event { display: inline-flex; align-items: center; gap: 4px; color: var(--up); }
.visit-ref { margin: 0; padding: 0 var(--space-4) var(--space-3); overflow-wrap: anywhere; }
.pager { display: flex; align-items: center; justify-content: center; gap: var(--space-3); }

.site-overview {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2) var(--space-4);
  margin-top: var(--space-3); padding: var(--space-3); border-radius: var(--radius-sm);
  background: var(--surface-2); color: inherit; text-decoration: none;
}
.site-overview:hover { outline: 1px solid var(--accent); }
.ov { display: flex; flex-direction: column; }
.ov-num { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.ov-label { font-size: .75rem; color: var(--text-2); }
.spark { grid-column: 1 / -1; width: 100%; height: 36px; }
.spark-line { fill: none; stroke: var(--chart-1); stroke-width: 2; }
.spark-area { fill: var(--bar); }
@media (min-width: 720px) {
  .site-overview { grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(120px, 1.5fr); align-items: center; }
  .spark { grid-column: auto; }
  .visit-steps { padding-left: calc(var(--space-4) + 3.2em + var(--space-3)); }
}
@media (max-width: 719px) {
  .visit-steps { padding-left: var(--space-4); }
  .visit-card summary { flex-wrap: wrap; }
  .visit-card .visit-meta { flex-direction: row; gap: var(--space-2); width: 100%; justify-content: flex-start; padding-left: calc(3.2em + var(--space-3)); }
}

/* ---------- Wejścia: dziennik odsłon z adresem IP ---------- */
.ip-search { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }
.ip-search input { flex: 1 1 16rem; min-width: 0; font-family: var(--mono); }
.ip-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3) var(--space-5); }
.ip-head > div:first-child { display: flex; flex-direction: column; }
.ip-big { font-family: var(--mono); font-size: 1.375rem; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.ip-stats { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); }
.ip-head .btn { margin-left: auto; }
.card.entries-card { padding: 0; overflow: hidden; }
.entries-note { display: flex; align-items: flex-start; gap: var(--space-2); }
.entries-note .icon { flex: none; margin-top: 2px; }
.entries { display: flex; flex-direction: column; }
.entry {
  display: grid; gap: 2px var(--space-3);
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas: "time ip" "page page" "place device" "source source";
  padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border);
  animation: rise 320ms var(--ease) both; animation-delay: calc(var(--i, 0) * 18ms);
}
.entry:last-child { border-bottom: 0; }
.entry > span { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.entry > span > * { overflow-wrap: anywhere; }
.entry.is-entry { box-shadow: inset 3px 0 0 var(--accent); }
.entry-head { display: none; }
.entry-time { grid-area: time; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.entry-ip { grid-area: ip; font-family: var(--mono); font-size: .875rem; align-self: center; }
.entry-ip a { color: var(--accent-text); text-decoration: none; border-radius: 4px; }
.entry-ip a:hover { text-decoration: underline; text-underline-offset: 3px; }
.entry-ip a:focus-visible { outline: none; box-shadow: var(--focus); }
.entry-page { grid-area: page; }
.entry-title { font-weight: 500; }
.entry-place { grid-area: place; font-size: .875rem; }
.entry-device { grid-area: device; font-size: .875rem; }
.entry-source { grid-area: source; flex-direction: row !important; align-items: center; gap: var(--space-2) !important; }
@media (min-width: 1000px) {
  .entry {
    grid-template-columns: 6rem minmax(9rem, 1.1fr) minmax(0, 2.2fr) minmax(0, 1.4fr) minmax(0, 1.4fr) minmax(0, 1.1fr);
    grid-template-areas: "time ip page place device source"; align-items: start; gap: var(--space-3);
  }
  .entry-head { display: grid; font-size: .75rem; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em;
    background: var(--surface-2); animation: none; padding-top: var(--space-2); padding-bottom: var(--space-2); }
  .entry-head > span:nth-child(1) { grid-area: time; } .entry-head > span:nth-child(2) { grid-area: ip; }
  .entry-head > span:nth-child(3) { grid-area: page; } .entry-head > span:nth-child(4) { grid-area: place; }
  .entry-head > span:nth-child(5) { grid-area: device; } .entry-head > span:nth-child(6) { grid-area: source; }
  .entry-ip { align-self: start; }
  .entry-source { flex-direction: column !important; align-items: flex-start; gap: 2px !important; }
  .entry-time { white-space: normal; }
}
.bottomnav a { min-width: 0; }
.bottomnav a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Ustawienia (etap 4c) ---------- */
.settings .card-head h2 { display: flex; align-items: center; gap: var(--space-2); }
.settings p { margin: 0 0 var(--space-3); }
.choice-group { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.choice {
  display: flex; align-items: center; gap: var(--space-3); min-height: 48px; padding: 10px 14px; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
  transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input { width: 18px; height: 18px; accent-color: var(--accent); }
.steps { margin: 0 0 var(--space-3); padding-left: 1.25em; display: flex; flex-direction: column; gap: var(--space-2); }
.secret { display: inline-block; font-family: var(--mono); font-size: 1rem; letter-spacing: .06em; padding: 4px 8px; margin: 4px 0; border-radius: 6px; background: var(--surface-2); user-select: all; overflow-wrap: anywhere; }
.code-input { font-family: var(--mono); font-size: 1.5rem; letter-spacing: .3em; text-align: center; max-width: 12ch; }
.link-list { list-style: none; margin: 0 0 var(--space-3); padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.link-list li { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4); }
.link-list a { display: inline-flex; align-items: center; gap: 4px; min-height: 36px; }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: .8125rem; }
.btn-danger { color: var(--danger); }
.center { text-align: center; }

/* ---------- Szybkość strony (Web Vitals) ---------- */
.vitals { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-4); }
.vital-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }
.vital-name { font-weight: 600; }
.vital-value { display: inline-flex; align-items: center; gap: var(--space-2); font-variant-numeric: tabular-nums; }
.vital-value strong { font-size: 1.125rem; }
.vital-help { margin: 2px 0 var(--space-2); }
.vital-bar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: var(--surface-2); }
.vital-bar span { width: var(--w); transition: width 600ms var(--ease); }
.vital-good { background: var(--up); }
.vital-ni { background: var(--warn); }
.vital-poor { background: var(--down); }
.vital-legend { margin: var(--space-1) 0 0; }
.vital-note { margin: var(--space-4) 0 0; }
.site-status { display: flex; align-items: center; gap: 6px; margin: 4px 0 0; color: var(--text-2); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-2); opacity: .5; flex: none; }
.site-status.is-fresh .status-dot { background: #10b981; opacity: 1; }

.code {
  margin: 0 0 var(--space-3); padding: var(--space-3); overflow-x: auto;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  white-space: pre-wrap; word-break: break-all; font-size: .8125rem; line-height: 1.6;
}
.danger-zone { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); display: flex; flex-direction: column; gap: var(--space-3); align-items: flex-start; }
.danger-zone p { margin: 0; }
.narrow { max-width: 560px; }

/* ---------- Logowanie ---------- */
.bare { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center;
  background:
    radial-gradient(60rem 30rem at 10% -10%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 60%),
    radial-gradient(50rem 30rem at 110% 110%, color-mix(in srgb, var(--accent-3) 16%, transparent), transparent 60%),
    var(--bg); }
.bare-main { width: 100%; padding: var(--space-4); }
.login-card { max-width: 400px; margin: 0 auto; padding: var(--space-6) var(--space-5); display: flex; flex-direction: column; gap: var(--space-4); animation: rise 500ms var(--ease) both; }
.login-brand { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-2); }
.login-brand p { margin: 0; }

/* ---------- Animacje ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes pulse { 0% { transform: scale(1); opacity: .6; } 80%, 100% { transform: scale(2.6); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
  .live-dot::after { display: none; }
}

/* ---------- Tablet i komputer ---------- */
@media (min-width: 720px) {
  .topnav { display: flex; }
  .bottomnav { display: none; }
  .main { padding: var(--space-5) var(--space-5) var(--space-6); gap: var(--space-5); }
  .card { padding: var(--space-5); }
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tile:last-child:nth-child(odd) { grid-column: auto; }
  .tile-value { font-size: 1.875rem; }
  .chart { height: 340px; }
  .segmented { align-self: flex-start; }
  .range-bar { flex-direction: row; align-items: flex-start; flex-wrap: wrap; }
  .segmented a { flex: 0 0 auto; }
  .site-item { flex-direction: row; align-items: center; justify-content: space-between; }
  .site-actions { margin-left: 0; }
}
@media (min-width: 1000px) {
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1180px) {
  .tiles { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .tile-value { font-size: clamp(1.375rem, 1.9vw, 1.875rem); white-space: nowrap; }
}

#live-root { display: flex; flex-direction: column; gap: var(--space-4); }
input[type="date"] { width: auto; font-variant-numeric: tabular-nums; color-scheme: light dark; }

/* ---------- PWA: pasek „brak połączenia” ---------- */
.offline-bar {
  position: fixed; left: 50%; bottom: calc(72px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30;
  padding: 10px 16px; border-radius: 999px; font-size: .875rem; font-weight: 600;
  background: var(--text); color: var(--bg); box-shadow: var(--shadow); animation: rise 300ms var(--ease) both;
}
@media (min-width: 720px) { .offline-bar { bottom: var(--space-5); } }

/* ---------- Powiadomienia mailowe ---------- */
.notice h2 { display: flex; align-items: center; gap: var(--space-2); }
.notice code, .recipient code { overflow-wrap: anywhere; }
.recipient-list { list-style: none; margin: 0 0 var(--space-4); padding: 0; display: flex; flex-direction: column; }
.recipient { border-bottom: 1px solid var(--border); }
.recipient summary { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-3) 0; cursor: pointer; list-style: none; min-height: 44px; }
.recipient summary::-webkit-details-marker { display: none; }
.recipient-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.recipient-main strong { overflow-wrap: anywhere; }
.recipient-form { padding: 0 0 var(--space-4); gap: var(--space-4); }
.recipient-form .form-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.input-row { display: flex; gap: var(--space-2); }
.input-row input { flex: 1; min-width: 0; }
@media (max-width: 480px) { .input-row { flex-direction: column; } }

/* ---------- Mapa odwiedzin ---------- */
.map-card { margin-bottom: var(--space-4); }
.map { width: 100%; height: 220px; }
.map-note { margin: var(--space-2) 0 0; }
@media (min-width: 720px) { .map { height: 340px; } }
@media (min-width: 1180px) { .map { height: 420px; } }

/* ---------- Zadania okresowe ---------- */
.task-list { list-style: none; margin: 0 0 var(--space-3); padding: 0; }
.task-list li { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3);
  padding: var(--space-2) 0; border-bottom: 1px solid var(--border); }
.task-list li > span:first-child { min-width: 0; overflow-wrap: anywhere; }

.mono { font-family: var(--mono); }
