*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
.hide { display: none !important; }

:root {
  --blue:         #2563eb;
  --blue-dark:    #1d4ed8;
  --blue-light:   #eff6ff;
  --blue-mid:     #dbeafe;
  --gray-50:      #f8fafc;
  --gray-100:     #f1f5f9;
  --gray-200:     #e2e8f0;
  --gray-300:     #cbd5e1;
  --gray-400:     #94a3b8;
  --gray-600:     #475569;
  --gray-700:     #334155;
  --gray-800:     #1e293b;
  --green:        #16a34a;
  --green-light:  #f0fdf4;
  --orange:       #ea580c;
  --orange-light: #fff7ed;
  --red:          #dc2626;
  --red-light:    #fef2f2;
  --yellow:       #b45309;
  --yellow-light: #fffbeb;
  --purple:       #7c3aed;
  --purple-light: #f5f3ff;

  --shadow-xs: 0 1px 2px rgba(0,0,0,.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,.05), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.06), 0 4px 6px rgba(0,0,0,.04);
  --radius:    10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── NAV ──────────────────────────────────────────────────── */
nav {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 60%, #3b82f6 100%);
  color: #fff;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  height: 62px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(37,99,235,.35);
}
nav .brand { font-weight: 700; font-size: 1.1rem; letter-spacing: -.3px; white-space: nowrap; }
nav a {
  color: rgba(255,255,255,.82);
  text-decoration: none;
  font-size: .88rem;
  white-space: nowrap;
  padding: .25rem .1rem;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
nav a:hover { color: #fff; border-bottom-color: rgba(255,255,255,.5); }
nav .spacer { flex: 1; }
nav .user { font-size: .83rem; opacity: .75; white-space: nowrap; }
.nav-biznes-switcher {
  display: flex; gap: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.25);
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.nav-biznes {
  color: rgba(255,255,255,.75) !important;
  padding: .28rem .8rem;
  font-size: .78rem !important;
  border-right: 1px solid rgba(255,255,255,.2);
  transition: background .15s;
}
.nav-biznes:last-child { border-right: none; }
.nav-biznes.active { background: rgba(255,255,255,.22); color: #fff !important; font-weight: 600; }
.nav-biznes:hover:not(.active) { background: rgba(255,255,255,.12); }

/* NAV hamburger (mobile) */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.6rem;
  cursor: pointer;
  padding: .2rem .4rem;
  line-height: 1;
  margin-left: auto;
}
.nav-links { display: contents; }

@media (max-width: 768px) {
  nav {
    flex-wrap: wrap;
    height: auto;
    padding: .75rem 1rem;
    gap: 0;
    row-gap: 0;
  }
  nav .brand { flex: 1; font-size: 1rem; }
  .nav-toggle { display: block; }
  .nav-links {
    display: none;
    flex-direction: column;
    width: 100%;
    margin-top: .6rem;
    padding-top: .6rem;
    border-top: 1px solid rgba(255,255,255,.18);
    gap: 0;
  }
  .nav-links.open { display: flex; }
  .nav-links > a,
  .nav-links > span.user {
    padding: .75rem .25rem;
    border-bottom: 1px solid rgba(255,255,255,.1);
    font-size: .95rem !important;
    display: block;
    white-space: normal;
    border-bottom-color: rgba(255,255,255,.1) !important;
  }
  .nav-links > .spacer { display: none; }
  .nav-links > span.user { opacity: .65; font-size: .85rem !important; }
  .nav-biznes-switcher { margin: .5rem 0; align-self: flex-start; }
}

/* ── CONTAINER ────────────────────────────────────────────── */
.container { max-width: 1100px; margin: 0 auto; padding: 1.75rem 1.5rem; }
@media (max-width: 768px) { .container { padding: .9rem .75rem; } }

/* ── FLASH ────────────────────────────────────────────────── */
.flash {
  padding: .75rem 1rem .75rem 1.1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.1rem;
  font-size: .875rem;
  border: 1px solid transparent;
  border-left-width: 4px;
}
.flash.success {
  background: var(--green-light);
  color: #166534;
  border-color: #86efac;
  border-left-color: var(--green);
}
.flash.error {
  background: var(--red-light);
  color: #991b1b;
  border-color: #fca5a5;
  border-left-color: var(--red);
}
.flash.info {
  background: var(--blue-light);
  color: #1e40af;
  border-color: var(--blue-mid);
  border-left-color: var(--blue);
}

/* ── CARDS ────────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(0,0,0,.04);
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--gray-100);
  flex-wrap: wrap;
  gap: .75rem;
}
.card-header h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--gray-800);
  letter-spacing: -.2px;
}
@media (max-width: 768px) {
  .card { padding: 1rem .9rem; border-radius: var(--radius); }
}

/* ── BUTTONS ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1.1rem;
  border-radius: var(--radius-sm);
  border: none;
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: transform .15s, box-shadow .15s, background .15s, opacity .15s;
  min-height: 36px;
  letter-spacing: .01em;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  box-shadow: 0 1px 3px rgba(37,99,235,.3);
}
.btn-primary:hover { box-shadow: 0 4px 12px rgba(37,99,235,.4); }

.btn-success {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff;
  box-shadow: 0 1px 3px rgba(22,163,74,.3);
}
.btn-success:hover { box-shadow: 0 4px 12px rgba(22,163,74,.35); }

.btn-outline {
  background: #fff;
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-xs);
}
.btn-outline:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
  box-shadow: var(--shadow-sm);
}

.btn-sm { padding: .33rem .75rem; font-size: .8rem; min-height: 30px; }
@media (max-width: 768px) {
  .btn { min-height: 44px; }
  .btn-sm { min-height: 38px; }
}

/* ── FORMS ────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-grid .full { grid-column: 1 / -1; }
.form-group { display: flex; flex-direction: column; gap: .35rem; }

label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--gray-600);
  letter-spacing: .01em;
}
input, select, textarea {
  width: 100%;
  padding: .55rem .75rem;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-family: inherit;
  background: #fff;
  color: var(--gray-800);
  transition: border-color .15s, box-shadow .15s;
  box-shadow: var(--shadow-xs);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
textarea { resize: vertical; min-height: 90px; }
.required { color: var(--red); }
@media (max-width: 768px) {
  .form-grid { grid-template-columns: 1fr; }
  input, select, textarea { font-size: 1rem; min-height: 44px; }
  textarea { min-height: 90px; }
}

/* ── BADGES — status ──────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .22rem .7rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .02em;
}
.badge-Przyjęte      { background: #dbeafe; color: #1e40af; }
.badge-Umówione      { background: #fef3c7; color: #92400e; }
.badge-Realizowane   { background: #ffedd5; color: #9a3412; }
.badge-Zakończone    { background: #dcfce7; color: #166534; }
.badge-Przypomnienie { background: #ede9fe; color: #5b21b6; }

/* BADGE typ */
.badge-kotly         { background: #fef3c7; color: #78350f; }
.badge-fitness       { background: #dbeafe; color: #1e40af; }
.badge-typ-Awaria    { background: #fee2e2; color: #991b1b; }
.badge-typ-Przegląd  { background: #e0f2fe; color: #075985; }
.badge-typ-Rozruch   { background: #f0fdf4; color: #166534; }

/* ── TABLE ────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th {
  text-align: left;
  padding: .6rem .85rem;
  font-size: .72rem;
  font-weight: 700;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: .07em;
  border-bottom: 2px solid var(--gray-100);
  background: var(--gray-50);
}
td {
  padding: .75rem .85rem;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
  transition: background .1s;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fbff; }
td a { color: var(--blue); text-decoration: none; font-weight: 500; }
td a:hover { text-decoration: underline; }

/* Widoczne tylko na mobile */
.col-mobile-only { display: none; }
@media (max-width: 640px) { .col-mobile-only { display: block; } }

/* TABLE → karty na mobile */
@media (max-width: 640px) {
  .table-mobile-cards thead { display: none; }
  .table-mobile-cards tbody tr {
    display: block;
    border-radius: var(--radius);
    margin-bottom: .65rem;
    padding: .85rem;
    background: #fff;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0,0,0,.04);
  }
  .table-mobile-cards tbody tr:hover td { background: none; }
  .table-mobile-cards td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .3rem 0;
    border: none;
    font-size: .875rem;
    gap: .5rem;
  }
  .table-mobile-cards td::before {
    content: attr(data-label);
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--gray-400);
    flex-shrink: 0;
    min-width: 90px;
  }
  .table-mobile-cards td:empty { display: none; }
  .table-mobile-cards td.td-action {
    justify-content: flex-end;
    padding-top: .6rem;
    border-top: 1px solid var(--gray-100);
    margin-top: .3rem;
  }
  .table-mobile-cards td.td-action::before { display: none; }
  .col-mobile-hide { display: none !important; }
}

/* ── FILTERS ──────────────────────────────────────────────── */
.filters { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; margin-bottom: 1.25rem; }
.filters select { width: auto; padding: .4rem .6rem; font-size: .85rem; }

/* ── DETAIL GRID ──────────────────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem 2rem; }
.detail-item label {
  font-size: .72rem;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: .07em;
  font-weight: 700;
}
.detail-item p { font-size: .95rem; margin-top: .2rem; color: var(--gray-800); }

/* ── PHOTOS ───────────────────────────────────────────────── */
.photos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .75rem; }
.photos-grid > div { overflow: hidden; border-radius: var(--radius-sm); min-width: 0; }
.photos-grid img {
  width: 100%; height: 120px; object-fit: cover; display: block;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.photos-grid img:hover { transform: scale(1.03); box-shadow: var(--shadow-md); }

/* ── LOGIN ────────────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #eff6ff 0%, #f8fafc 100%); }
.login-box {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(0,0,0,.05);
}
.login-box h1 { font-size: 1.4rem; margin-bottom: .25rem; font-weight: 700; letter-spacing: -.3px; }
.login-box p  { color: var(--gray-400); font-size: .875rem; margin-bottom: 1.75rem; }

/* ── STEPS ────────────────────────────────────────────────── */
.steps { display: flex; gap: 0; margin-bottom: 0; }
.step {
  flex: 1; text-align: center; padding: .55rem .25rem;
  font-size: .78rem; font-weight: 500;
  background: var(--gray-100); color: var(--gray-400);
  border: 1px solid var(--gray-200); border-right: none;
  cursor: pointer;
  transition: background .15s, color .15s;
  font-family: inherit; line-height: 1.3; min-height: 40px;
  display: flex; align-items: center; justify-content: center;
}
.step:last-child { border-right: 1px solid var(--gray-200); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.step:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.step:not(.active):hover { background: var(--gray-200); color: var(--gray-800); }
.step.active { background: linear-gradient(135deg, #2563eb, #1d4ed8); color: #fff; border-color: var(--blue); cursor: default; }
.step.done   { background: linear-gradient(135deg, #22c55e, #16a34a); color: #fff; border-color: var(--green); }
.step.done:hover { background: linear-gradient(135deg, #16a34a, #15803d); }
@media (max-width: 640px) {
  .step { font-size: .72rem; padding: .6rem .15rem; min-height: 44px; }
}

/* ── TIMELINE ─────────────────────────────────────────────── */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item { display: flex; gap: .75rem; position: relative; padding-bottom: 1.1rem; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 7px; top: 16px; bottom: 0;
  width: 2px;
  background: linear-gradient(to bottom, var(--blue-mid), var(--gray-200));
}
.timeline-dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--blue);
  border: 3px solid var(--blue-light);
  flex-shrink: 0;
  margin-top: 2px;
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.timeline-body { flex: 1; }
.timeline-meta { display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.timeline-meta strong { font-size: .875rem; }
.timeline-who { font-size: .8rem; color: var(--gray-600); }
.timeline-date { font-size: .78rem; color: var(--gray-400); margin-left: auto; }
.timeline-detail {
  margin-top: .25rem;
  font-size: .82rem;
  color: var(--gray-600);
  background: var(--gray-50);
  padding: .35rem .65rem;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--blue-mid);
}

@media (max-width: 640px) {
  .detail-grid { grid-template-columns: 1fr; }
  .login-box { padding: 1.75rem 1.25rem; }
}

/* ── WOW ──────────────────────────────────────────────────── */

/* Płynne wejście strony.
   UWAGA: w klatce `to` nie deklarujemy `transform`. Przy `animation-fill-mode: both`
   końcowa wartość zostaje przyklejona na stałe, a każdy transform inny niż `none`
   robi z elementu układ odniesienia dla `position: fixed` — przez co popupy
   centrowałyby się względem kontenera zamiast względem ekranu. Bez tej deklaracji
   animacja wraca do wartości bazowej (`none`) i fixed znów działa jak trzeba. */
@keyframes pageFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; }
}
.container { animation: pageFadeIn .32s cubic-bezier(.22,.68,0,1.2) both; }

/* Karty wlatują kolejno */
/* Karty — z tego samego powodu co wyżej klatka `to` nie ustawia transformacji. */
@keyframes cardIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; }
}
.card {
  animation: cardIn .38s cubic-bezier(.22,.68,0,1.2) both;
  transition: transform .22s ease, box-shadow .22s ease;
}
.card:nth-child(1) { animation-delay: .03s; }
.card:nth-child(2) { animation-delay: .08s; }
.card:nth-child(3) { animation-delay: .13s; }
.card:nth-child(4) { animation-delay: .18s; }
.card:nth-child(5) { animation-delay: .22s; }

/* Karty unoszą się na hover */
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,.09), 0 2px 6px rgba(0,0,0,.05);
}

/* Ripple na przyciskach */
.btn { position: relative; overflow: hidden; }
@keyframes ripple {
  from { transform: scale(0); opacity: .45; }
  to   { transform: scale(4); opacity: 0; }
}
.btn-ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,.45);
  width: 80px; height: 80px;
  margin-top: -40px; margin-left: -40px;
  animation: ripple .55s ease-out forwards;
  pointer-events: none;
}
.btn-outline .btn-ripple { background: rgba(37,99,235,.15); }

/* Gradient na primary button — powolny ruch */
.btn-primary {
  background: linear-gradient(270deg, #1d4ed8, #2563eb, #3b82f6, #2563eb);
  background-size: 300% 100%;
  animation: btnShimmer 6s ease infinite;
}
@keyframes btnShimmer {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Aktywny link w nav */
nav a.nav-current {
  color: #fff !important;
  border-bottom-color: #fff !important;
  font-weight: 600;
}

/* Badge poczty — pulsuje gdy są nieprzeczytane */
@keyframes badgePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,.5); }
  60%       { box-shadow: 0 0 0 6px rgba(239,68,68,0); }
}
#poczta-badge { animation: badgePulse 2.2s ease-in-out infinite; }

/* Custom scrollbar */
::-webkit-scrollbar       { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--blue); }

/* Wiersze tabeli — kolorowy flash lewej krawędzi przy hover */
tbody tr { transition: background .12s; position: relative; }
tbody tr:hover td:first-child { box-shadow: inset 3px 0 0 var(--blue); }

/* Flash message slide-in */
@keyframes flashIn {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: translateX(0); }
}
.flash { animation: flashIn .25s ease both; }
