/**
 * Lekka warstwa ciemnego motywu dla prywatnych aplikacji *.nowa-tech.eu.
 * Jasny tryb pozostaje bez zmian — wszystkie reguły są scoped do
 * html[data-nr-dark="1"] (oraz html[data-theme-dark="1"] zgodnie z istniejącym
 * stylem Kosztorysów).
 */
html[data-nr-dark="1"],
html[data-theme-dark="1"] {
  color-scheme: dark !important;

  --background: #0f172a !important;
  --app-bg-2: #0b1220 !important;
  --foreground: #e2e8f0 !important;
  --card: #1b2436 !important;
  --card-foreground: #e2e8f0 !important;
  --popover: #1b2436 !important;
  --popover-foreground: #e2e8f0 !important;
  --secondary: #233049 !important;
  --secondary-foreground: #e2e8f0 !important;
  --muted: #233049 !important;
  --muted-foreground: #a9b7c9 !important;
  --border: rgba(255, 255, 255, 0.14) !important;
  --input: transparent !important;
  --input-background: #162033 !important;
  --switch-background: #3b4a63 !important;
  --ring: #fbbf24 !important;
  --primary: #fbbf24 !important;
  --primary-foreground: #0f172a !important;
  --accent: #42301b !important;
  --accent-foreground: #fbbf24 !important;
  --destructive: #f87171 !important;
  --destructive-foreground: #1a0f0f !important;
  --chart-1: #fbbf24 !important;
  --chart-2: #34d399 !important;
  --chart-3: #60a5fa !important;
  --chart-4: #a78bfa !important;
  --chart-5: #f87171 !important;
  --sidebar: #101725 !important;
  --sidebar-2: #0a0f1d !important;
  --sidebar-foreground: #e2e8f0 !important;
  --sidebar-primary: #fbbf24 !important;
  --sidebar-primary-foreground: #0f172a !important;
  --sidebar-accent: #233049 !important;
  --sidebar-accent-foreground: #f1f5f9 !important;
  --sidebar-border: rgba(255, 255, 255, 0.12) !important;
  --sidebar-ring: #fbbf24 !important;
  --grad-from: #fcd34d !important;
  --grad-to: #b45309 !important;
}

/* Tło — odpowiednik mesh gradientu, w ciemnej palecie. */
html[data-nr-dark="1"] body,
html[data-theme-dark="1"] body {
  background-color: #070b16 !important;
  background-image:
    radial-gradient(1100px 760px at 8% -8%, color-mix(in srgb, var(--primary) 36%, transparent), transparent 62%),
    radial-gradient(900px 640px at 100% 0%, rgba(56, 189, 248, 0.22), transparent 64%),
    radial-gradient(950px 720px at 46% 32%, rgba(129, 140, 248, 0.2), transparent 66%),
    radial-gradient(900px 700px at 72% 74%, rgba(45, 212, 191, 0.14), transparent 66%),
    radial-gradient(1000px 820px at 84% 104%, color-mix(in srgb, var(--primary) 24%, transparent), transparent 62%),
    linear-gradient(165deg, #0d1526, #070b16 60%, #0a1020) !important;
  background-repeat: no-repeat !important;
  background-size: cover !important;
  background-attachment: fixed !important;
  color: var(--foreground) !important;
}

/* Kafle „szkła” — zachowujemy blur i refleksy, zmieniamy tylko barwę. */
html[data-nr-dark="1"] .bg-card,
html[data-theme-dark="1"] .bg-card {
  background-color: #161f32e6 !important;
  background-image: linear-gradient(140deg, rgba(255,255,255,.12), rgba(255,255,255,.02) 40%, rgba(255,255,255,.07)) !important;
  border-color: rgba(255,255,255,.16) !important;
  box-shadow: inset 0 1px rgba(255,255,255,.14), inset 0 -1px rgba(0,0,0,.25), 0 22px 48px -24px rgba(0,0,0,.8) !important;
  color: var(--card-foreground) !important;
}
html[data-nr-dark="1"] .bg-card:hover,
html[data-theme-dark="1"] .bg-card:hover { border-color: rgba(255,255,255,.28) !important; }

html[data-nr-dark="1"] .bg-secondary,
html[data-nr-dark="1"] .bg-secondary\/30,
html[data-nr-dark="1"] .bg-secondary\/40,
html[data-nr-dark="1"] .bg-secondary\/50,
html[data-nr-dark="1"] .bg-secondary\/60,
html[data-nr-dark="1"] .bg-secondary\/70,
html[data-theme-dark="1"] .bg-secondary,
html[data-theme-dark="1"] .bg-secondary\/30,
html[data-theme-dark="1"] .bg-secondary\/40,
html[data-theme-dark="1"] .bg-secondary\/50,
html[data-theme-dark="1"] .bg-secondary\/60,
html[data-theme-dark="1"] .bg-secondary\/70 {
  background-color: #263450d6 !important;
  color: var(--secondary-foreground) !important;
}
html[data-nr-dark="1"] .bg-muted,
html[data-theme-dark="1"] .bg-muted { background-color: #263450a3 !important; }
html[data-nr-dark="1"] .bg-popover,
html[data-theme-dark="1"] .bg-popover { background-color: #161f32e6 !important; color: var(--popover-foreground) !important; }
html[data-nr-dark="1"] .hover\:bg-secondary:hover,
html[data-nr-dark="1"] .hover\:bg-muted:hover,
html[data-theme-dark="1"] .hover\:bg-secondary:hover,
html[data-theme-dark="1"] .hover\:bg-muted:hover { background-color: #364768c7 !important; }
html[data-nr-dark="1"] tr.bg-card,
html[data-nr-dark="1"] thead.bg-card,
html[data-nr-dark="1"] thead.bg-secondary,
html[data-theme-dark="1"] tr.bg-card,
html[data-theme-dark="1"] thead.bg-card,
html[data-theme-dark="1"] thead.bg-secondary { background-color: #161f32db !important; background-image: none !important; }
html[data-nr-dark="1"] .fixed.inset-0 > .bg-card,
html[data-theme-dark="1"] .fixed.inset-0 > .bg-card {
  background-color: #131b2ce6 !important;
  background-image: linear-gradient(150deg, rgba(255,255,255,.12), rgba(255,255,255,.02) 50%, rgba(255,255,255,.07)) !important;
  border-color: rgba(255,255,255,.18) !important;
}
html[data-nr-dark="1"] input.bg-background,
html[data-nr-dark="1"] select.bg-background,
html[data-nr-dark="1"] textarea.bg-background,
html[data-theme-dark="1"] input.bg-background,
html[data-theme-dark="1"] select.bg-background,
html[data-theme-dark="1"] textarea.bg-background { background-color: #162033 !important; color: var(--foreground) !important; }

/* Neutralne kolory Tailwind, które w jasnym trybie są ciemne. */
html[data-nr-dark="1"] .bg-white,
html[data-theme-dark="1"] .bg-white,
html[data-nr-dark="1"] .bg-slate-50,
html[data-theme-dark="1"] .bg-slate-50,
html[data-nr-dark="1"] .bg-slate-100,
html[data-theme-dark="1"] .bg-slate-100,
html[data-nr-dark="1"] .bg-gray-50,
html[data-theme-dark="1"] .bg-gray-50,
html[data-nr-dark="1"] .bg-gray-100,
html[data-theme-dark="1"] .bg-gray-100 {
  background-color: #1b2436 !important;
  color: var(--foreground) !important;
}
html[data-nr-dark="1"] .text-slate-900,
html[data-nr-dark="1"] .text-slate-800,
html[data-nr-dark="1"] .text-slate-700,
html[data-nr-dark="1"] .text-gray-900,
html[data-nr-dark="1"] .text-gray-800,
html[data-nr-dark="1"] .text-gray-700,
html[data-nr-dark="1"] .text-black,
html[data-theme-dark="1"] .text-slate-900,
html[data-theme-dark="1"] .text-slate-800,
html[data-theme-dark="1"] .text-slate-700,
html[data-theme-dark="1"] .text-gray-900,
html[data-theme-dark="1"] .text-gray-800,
html[data-theme-dark="1"] .text-gray-700,
html[data-theme-dark="1"] .text-black { color: #e2e8f0 !important; }
html[data-nr-dark="1"] .text-slate-600,
html[data-nr-dark="1"] .text-slate-500,
html[data-nr-dark="1"] .text-gray-600,
html[data-nr-dark="1"] .text-gray-500,
html[data-theme-dark="1"] .text-slate-600,
html[data-theme-dark="1"] .text-slate-500,
html[data-theme-dark="1"] .text-gray-600,
html[data-theme-dark="1"] .text-gray-500 { color: #a9b7c9 !important; }
html[data-nr-dark="1"] .border-slate-200,
html[data-nr-dark="1"] .border-slate-300,
html[data-nr-dark="1"] .border-gray-200,
html[data-nr-dark="1"] .border-gray-300,
html[data-theme-dark="1"] .border-slate-200,
html[data-theme-dark="1"] .border-slate-300,
html[data-theme-dark="1"] .border-gray-200,
html[data-theme-dark="1"] .border-gray-300 { border-color: rgba(255,255,255,.14) !important; }

/* Formularze i kontrolki — spójny ciemny input. */
html[data-nr-dark="1"] input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
html[data-nr-dark="1"] select,
html[data-nr-dark="1"] textarea,
html[data-theme-dark="1"] input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
html[data-theme-dark="1"] select,
html[data-theme-dark="1"] textarea {
  background-color: #162033 !important;
  color: var(--foreground) !important;
  border-color: rgba(255,255,255,.16) !important;
}
html[data-nr-dark="1"] input::placeholder,
html[data-nr-dark="1"] textarea::placeholder,
html[data-theme-dark="1"] input::placeholder,
html[data-theme-dark="1"] textarea::placeholder { color: #8595ab !important; }
html[data-nr-dark="1"] ::selection,
html[data-theme-dark="1"] ::selection { background: rgba(251,191,36,.35) !important; }
html[data-nr-dark="1"] ::-webkit-scrollbar,
html[data-theme-dark="1"] ::-webkit-scrollbar { width: 10px; height: 10px; }
html[data-nr-dark="1"] ::-webkit-scrollbar-thumb,
html[data-theme-dark="1"] ::-webkit-scrollbar-thumb { background: #334155; border-radius: 8px; }

/* Wyższa specyficzność dla istniejących reguł glass (Kosztorysy). */
html.glass[data-nr-dark="1"] .bg-card,
html.glass[data-theme-dark="1"] .bg-card {
  background-color: #161f32e6 !important;
  background-image: linear-gradient(140deg, rgba(255,255,255,.12), rgba(255,255,255,.02) 40%, rgba(255,255,255,.07)) !important;
  border-color: rgba(255,255,255,.16) !important;
}
html.glass[data-nr-dark="1"] .bg-secondary,
html.glass[data-nr-dark="1"] .bg-secondary\/30,
html.glass[data-nr-dark="1"] .bg-secondary\/40,
html.glass[data-nr-dark="1"] .bg-secondary\/50,
html.glass[data-nr-dark="1"] .bg-secondary\/60,
html.glass[data-nr-dark="1"] .bg-secondary\/70,
html.glass[data-theme-dark="1"] .bg-secondary,
html.glass[data-theme-dark="1"] .bg-secondary\/30,
html.glass[data-theme-dark="1"] .bg-secondary\/40,
html.glass[data-theme-dark="1"] .bg-secondary\/50,
html.glass[data-theme-dark="1"] .bg-secondary\/60,
html.glass[data-theme-dark="1"] .bg-secondary\/70 { background-color: #263450d6 !important; }
html.glass[data-nr-dark="1"] .bg-muted,
html.glass[data-theme-dark="1"] .bg-muted { background-color: #263450a3 !important; }
html.glass[data-nr-dark="1"] .bg-popover,
html.glass[data-theme-dark="1"] .bg-popover { background-color: #161f32e6 !important; }
html.glass[data-nr-dark="1"] tr.bg-card,
html.glass[data-nr-dark="1"] thead.bg-card,
html.glass[data-nr-dark="1"] thead.bg-secondary,
html.glass[data-theme-dark="1"] tr.bg-card,
html.glass[data-theme-dark="1"] thead.bg-card,
html.glass[data-theme-dark="1"] thead.bg-secondary { background-color: #161f32db !important; background-image: none !important; }
html.glass[data-nr-dark="1"] .fixed.inset-0 > .bg-card,
html.glass[data-theme-dark="1"] .fixed.inset-0 > .bg-card { background-color: #131b2ce6 !important; }

/* Ekran logowania Kosztorysów ma własne, bardzo silne reguły koloru. */
html[data-nr-dark="1"] .login-glass,
html[data-nr-dark="1"] .login-glass *,
html[data-theme-dark="1"] .login-glass,
html[data-theme-dark="1"] .login-glass * { color: #e2e8f0 !important; }
html[data-nr-dark="1"] .login-glass input,
html[data-theme-dark="1"] .login-glass input {
  color: #e2e8f0 !important;
  background: #162033 !important;
  border-color: rgba(255,255,255,.2) !important;
}
html[data-nr-dark="1"] .login-glass input::placeholder,
html[data-theme-dark="1"] .login-glass input::placeholder { color: #8595ab !important; }

/* Etykiety kategorii w Sprzęcie mają kolory wpisane inline przez React. */
html[data-nr-dark="1"] [style*="rgb(124, 58, 237)"],
html[data-theme-dark="1"] [style*="rgb(124, 58, 237)"] { color: #c4b5fd !important; }
html[data-nr-dark="1"] [style*="rgb(37, 99, 235)"],
html[data-theme-dark="1"] [style*="rgb(37, 99, 235)"] { color: #93c5fd !important; }
html[data-nr-dark="1"] [style*="rgb(5, 150, 105)"],
html[data-theme-dark="1"] [style*="rgb(5, 150, 105)"] { color: #6ee7b7 !important; }
html[data-nr-dark="1"] [style*="rgb(8, 145, 178)"],
html[data-theme-dark="1"] [style*="rgb(8, 145, 178)"] { color: #67e8f9 !important; }
html[data-nr-dark="1"] [style*="rgb(220, 38, 38)"],
html[data-theme-dark="1"] [style*="rgb(220, 38, 38)"] { color: #fca5a5 !important; }

/* ---- Prywatny Najem (PHP + style.css) ---- */
html[data-nr-dark="1"],
html[data-theme-dark="1"] {
  --bg: #070b16 !important;
  --surface: #1b2436 !important;
  --ink: #e2e8f0 !important;
  --ink-2: #b9c6d6 !important;
  --muted: #9aa9bd !important;
  --line: rgba(255,255,255,.14) !important;
  --good: #6ee7b7 !important;
  --bad: #fca5a5 !important;
  --free: #123b2c !important;
  --busy: #4a1f2c !important;
}
html[data-nr-dark="1"] body.admin-body,
html[data-theme-dark="1"] body.admin-body { background: #070b16 !important; }
html[data-nr-dark="1"] .nav-drawer,
html[data-theme-dark="1"] .nav-drawer,
html[data-nr-dark="1"] .mobile-topbar,
html[data-theme-dark="1"] .mobile-topbar {
  background: #101725 !important;
  border-color: rgba(255,255,255,.12) !important;
  color: #e2e8f0 !important;
}
html[data-nr-dark="1"] .nav-drawer a,
html[data-theme-dark="1"] .nav-drawer a,
html[data-nr-dark="1"] .nav-drawer-link,
html[data-theme-dark="1"] .nav-drawer-link { color: #cbd5e1 !important; }
html[data-nr-dark="1"] .nav-drawer-link-active,
html[data-theme-dark="1"] .nav-drawer-link-active { background: #263450 !important; color: #fbbf24 !important; }
html[data-nr-dark="1"] .card,
html[data-theme-dark="1"] .card,
html[data-nr-dark="1"] .panel,
html[data-theme-dark="1"] .panel,
html[data-nr-dark="1"] .table-wrap,
html[data-theme-dark="1"] .table-wrap,
html[data-nr-dark="1"] .stat-card,
html[data-theme-dark="1"] .stat-card,
html[data-nr-dark="1"] .estimate-box,
html[data-theme-dark="1"] .estimate-box,
html[data-nr-dark="1"] .help-card,
html[data-theme-dark="1"] .help-card,
html[data-nr-dark="1"] .tour-card,
html[data-theme-dark="1"] .tour-card {
  background-color: #1b2436 !important;
  border-color: rgba(255,255,255,.14) !important;
  color: #e2e8f0 !important;
}
html[data-nr-dark="1"] table.data td,
html[data-theme-dark="1"] table.data td { border-bottom-color: rgba(255,255,255,.09) !important; }
html[data-nr-dark="1"] label,
html[data-theme-dark="1"] label { color: #b9c6d6 !important; }
html[data-nr-dark="1"] .badge-booking,
html[data-theme-dark="1"] .badge-booking { background: #1e3a5f !important; color: #bfdbfe !important; }
html[data-nr-dark="1"] .badge-direct,
html[data-theme-dark="1"] .badge-direct { background: #3f2d16 !important; color: #fcd34d !important; }
html[data-nr-dark="1"] .alert-ok,
html[data-theme-dark="1"] .alert-ok { background: #123b2c !important; color: #a7f3d0 !important; border-color: #1d5b45 !important; }
html[data-nr-dark="1"] .alert-err,
html[data-theme-dark="1"] .alert-err { background: #4a1f2c !important; color: #fecaca !important; border-color: #7f3545 !important; }
html[data-nr-dark="1"] input,
html[data-nr-dark="1"] select,
html[data-nr-dark="1"] textarea,
html[data-theme-dark="1"] input,
html[data-theme-dark="1"] select,
html[data-theme-dark="1"] textarea { background: #162033 !important; color: #e2e8f0 !important; border-color: rgba(255,255,255,.16) !important; }
html[data-nr-dark="1"] input:focus,
html[data-nr-dark="1"] select:focus,
html[data-nr-dark="1"] textarea:focus,
html[data-theme-dark="1"] input:focus,
html[data-theme-dark="1"] select:focus,
html[data-theme-dark="1"] textarea:focus { background: #162033 !important; box-shadow: 0 0 0 2px rgba(251,191,36,.3) !important; }
html[data-nr-dark="1"] input[type=checkbox],
html[data-nr-dark="1"] input[type=radio],
html[data-theme-dark="1"] input[type=checkbox],
html[data-theme-dark="1"] input[type=radio] { background: #162033 !important; }

/* Logowanie Najmu — reguły z inline <style> w admin/login.php. */
html[data-nr-dark="1"] body .wrap .card,
html[data-theme-dark="1"] body .wrap .card {
  background-color: #161f32e6 !important;
  background-image: linear-gradient(140deg, rgba(255,255,255,.12), rgba(255,255,255,.02) 40%, rgba(255,255,255,.07)) !important;
  border-color: rgba(255,255,255,.18) !important;
  color: #e2e8f0 !important;
}
html[data-nr-dark="1"] .card-label,
html[data-nr-dark="1"] label.field,
html[data-theme-dark="1"] .card-label,
html[data-theme-dark="1"] label.field { color: #a9b7c9 !important; }
html[data-nr-dark="1"] .brand-name,
html[data-theme-dark="1"] .brand-name { color: #e2e8f0 !important; }
html[data-nr-dark="1"] .brand-sub,
html[data-theme-dark="1"] .brand-sub { color: #a9b7c9 !important; }
html[data-nr-dark="1"] .back-link,
html[data-theme-dark="1"] .back-link { color: #a9b7c9 !important; }
html[data-nr-dark="1"] .back-link:hover,
html[data-theme-dark="1"] .back-link:hover { color: #fbbf24 !important; }
html[data-nr-dark="1"] input[type=password],
html[data-theme-dark="1"] input[type=password] { background: #162033 !important; color: #e2e8f0 !important; border-color: rgba(255,255,255,.2) !important; }
html[data-nr-dark="1"] input[type=password]:focus,
html[data-theme-dark="1"] input[type=password]:focus { background: #162033 !important; border-color: #fbbf24 !important; }
html[data-nr-dark="1"] .wrap button,
html[data-theme-dark="1"] .wrap button { color: #0f172a !important; }
html[data-nr-dark="1"] .nt-dark-toggle,
html[data-theme-dark="1"] .nt-dark-toggle { color: #fbbf24 !important; }

/* Przełącznik — lekki, własny przycisk (bez zmiany grafiki aplikacji). */
.nt-dark-toggle {
  position: fixed;
  right: calc(12px + env(safe-area-inset-right, 0px));
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  z-index: 2147483000;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 999px;
  background: rgba(15,23,42,.82);
  color: #fbbf24;
  box-shadow: 0 8px 24px -8px rgba(0,0,0,.55);
  backdrop-filter: blur(12px) saturate(150%);
  -webkit-backdrop-filter: blur(12px) saturate(150%);
  cursor: pointer;
  font: 600 18px/1 ui-sans-serif, system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
.nt-dark-toggle:hover { border-color: rgba(251,191,36,.6); }
.nt-dark-toggle:focus-visible { outline: 3px solid rgba(251,191,36,.55); outline-offset: 2px; }
.nt-dark-toggle span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
html[data-nr-dark="1"] .nt-dark-toggle,
html[data-theme-dark="1"] .nt-dark-toggle {
  background: rgba(30,41,59,.92);
  border-color: rgba(251,191,36,.45);
  color: #fbbf24;
}
/* W panelu Najmu na telefonie dół ekranu zajmuje stały pasek zakładek. */
@media (max-width: 1023px) {
  body.admin-body .nt-dark-toggle {
    top: calc(10px + env(safe-area-inset-top, 0px));
    bottom: auto;
    right: calc(10px + env(safe-area-inset-right, 0px));
  }
}
@media print { .nt-dark-toggle { display: none !important; } }
