/* Wspólne zmienne i style dla całej aplikacji */
:root {
  --bg: #ffffff;
  --fg: #0f172a;
  --muted: #64748b;
  --card: #ffffff;
  --card-border: #e5e7eb;
  --shadow: 0 1px 2px rgba(0,0,0,.06);
  --brand: #04AA6D;
  --btn-fg: #ffffff;
  --err: #ef4444;
  --ok: #16a34a;
  --input-border: #d1d5db;
  --input-bg: #ffffff;
  --chip-bg: #eef2ff;
  --chip-fg: #3730a3;
  --danger: #dc2626;
  --log-badge: #e2e8f0;
  --btn2: #0ea5e9;
  --btn3: #6366f1;
  --btn4: #6b7280;
  --bar-bg: #e5e7eb;
  --bar-w: #ef4444;
  --icon-filter: none;
  --icon-overlay: rgba(0,0,0,0.02);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f14;
    --fg: #e5e7eb;
    --muted: #9aa5b1;
    --card: #0f151c;
    --card-border: #1f2937;
    --shadow: none;
    --brand: #23c27a;
    --btn-fg: #0b0f14;
    --err: #f87171;
    --ok: #34d399;
    --input-border: #334155;
    --input-bg: #0b0f14;
    --chip-bg: #243146;
    --chip-fg: #c7d2fe;
    --danger: #ef4444;
    --log-badge: #111827;
    --btn2: #38bdf8;
    --btn3: #8b5cf6;
    --btn4: #9ca3af;
    --bar-bg: #1f2937;
    --bar-w: #f87171;
    --icon-filter: brightness(0) invert(1) drop-shadow(0 0 2px rgba(255,255,255,.25));
    --icon-overlay: rgba(255,255,255,0.04);
  }
}

/* Reset i podstawy */
* { box-sizing: border-box; }
html, body { min-height: 100svh; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px;
  padding-top: 4vh;
}

/* Górny pasek */
.top {
  width: 100%;
  max-width: 900px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

/* Przyciski */
a.btn {
  background: var(--brand);
  color: var(--btn-fg);
  text-decoration: none;
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 14px;
}

button {
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  touch-action: manipulation;
  padding: 10px 12px;
  font-size: 14px;
}

.btn-primary { background: var(--brand); color: var(--btn-fg); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-q { background: var(--btn2); color: #fff; }
.btn-q2 { background: var(--btn3); color: #fff; }
.btn-q3 { background: var(--btn4); color: #fff; }

button.big {
  width: 100%;
  padding: 16px;
  font-size: 18px;
  font-weight: 600;
  background: var(--brand);
  color: var(--btn-fg);
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .1s ease, opacity .1s ease;
}

button.big:active { transform: scale(0.97); opacity: 0.9; }
button.big:disabled { opacity: 0.5; cursor: not-allowed; }

button.submit {
  background: var(--brand);
  color: var(--btn-fg);
  border: 0;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 16px;
  cursor: pointer;
  touch-action: manipulation;
  min-width: 140px;
}

/* Chipy i tagi */
.chip, .pill {
  background: var(--chip-bg);
  color: var(--chip-fg);
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
}

.pill { padding: 4px 10px; font-weight: 600; }

.tag {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--chip-fg);
}

/* Grid i karty */
.grid {
  display: grid;
  gap: 12px;
  width: 100%;
  max-width: 900px;
  grid-template-columns: 1fr;
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 16px;
}

/* Home - grid 2 kolumnowy */
.grid-home {
  display: grid;
  gap: 16px;
  width: 100%;
  max-width: 720px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.card-center { text-align: center; padding: 20px; }

/* Nagłówki */
h2 { margin: 0 0 12px; font-size: 20px; }

/* Formularze */
.row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

label { font-size: 14px; color: var(--muted); }

input[type=text],
input[type=password],
input[type=date],
select {
  padding: 10px 12px;
  border: 1px solid var(--input-border);
  border-radius: 10px;
  font-size: 16px;
  background: var(--input-bg);
  color: var(--fg);
}

.inline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Komunikaty */
.msg { margin: 6px 0; font-size: 14px; }
.msg.err { color: var(--err); }
.msg.ok { color: var(--ok); }

.response { min-height: 24px; margin: 12px 0; font-size: 14px; }
.response.ok { color: var(--ok); }
.response.err { color: var(--err); }

/* Status obrazki */
.status {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  margin: 6px 0 10px;
  border-radius: 12px;
  background: linear-gradient(180deg, var(--icon-overlay), transparent 70%);
}
.status img {  width: clamp(100px, 40vw, 160px);  height: auto;  display: block;  filter: var(--icon-filter);  opacity: .95;}@media (min-width: 480px) { .status img { width: clamp(110px, 36vw, 180px); } }@media (min-width: 768px) { .status img { width: clamp(120px, 28vw, 200px); } }
/* Pomocnicze */
.muted { color: var(--muted); font-size: 12px; }
.hr { height: 1px; background: var(--card-border); margin: 10px 0; }

/* Kolumny */
.cols { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .cols { grid-template-columns: repeat(2, 1fr); } }

/* Admin - użytkownicy */
details.user {
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 10px;
  background: var(--card);
}

details.user + details.user { margin-top: 10px; }

summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

summary::-webkit-details-marker { display: none; }

/* Admin - logi */
.filters { display: grid; gap: 8px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .filters { grid-template-columns: repeat(5, 1fr); } }

.quick { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }

.log-list { display: grid; gap: 8px; }

.log-item {
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 10px;
  background: var(--card);
}

.log-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.log-title { display: flex; gap: 8px; align-items: center; }

.badge {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--log-badge);
}

.log-meta { font-size: 12px; color: var(--muted); }

.log-data {
  font-family: ui-monospace, SFMono-Regular, Consolas, Monaco, monospace;
  font-size: 12px;
  margin-top: 6px;
  overflow: auto;
}

/* Account - hasło */
.pass-field {
  position: relative;
  display: flex;
  align-items: center;
}

.pass-field input {
  width: 100%;
  padding: 10px 42px 10px 12px;
  border: 1px solid var(--input-border);
  border-radius: 10px;
  font-size: 16px;
  background: var(--input-bg);
  color: var(--fg);
  scroll-margin-top: 20vh;
}

.toggle-eye {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  width: 32px;
  height: 32px;
  padding: 0;
  cursor: pointer;
  display: grid;
  place-items: center;
  border-radius: 8px;
}

.toggle-eye svg { width: 22px; height: 22px; stroke: var(--muted); }
.toggle-eye:active { transform: translateY(-50%) scale(0.96); }

.meter { margin-top: 6px; }

.meter-bar {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--bar-bg);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 0%;
  background: var(--bar-w);
  transition: width .25s ease, background-color .25s ease;
}

.meter-label { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Responsywność */
@media (max-width: 600px) {
  .grid-home { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .actions { justify-content: stretch; }
  button.submit { width: 100%; }
}

/* Login page */
.login-card {
  width: 100%;
  max-width: 420px;
  padding: 18px;
}
.login-card h1 {
  margin: 0 0 12px;
  font-size: 20px;
}
.login-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 2px;
}
.login-btn {
  background: var(--brand);
  color: var(--btn-fg);
  border: 0;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 16px;
  cursor: pointer;
  width: 40%;
  touch-action: manipulation;
}
.error { color: var(--err); margin: 6px 0; font-size: 14px; }
.info { color: var(--ok); margin: 6px 0; font-size: 14px; }
@media (max-width: 420px) {
  .login-btn { width: auto; min-width: 120px; }
}
body.login-page {
  align-items: center;
  justify-content: flex-start;
  padding-top: 6vh;
}

/* Home page */
body.home-page {
  padding-top: 12px;
}
body.home-page .top {
  max-width: 100%;
}
body.home-page .grid {
  max-width: 100%;
}
@media (min-width: 768px) {
  body.home-page .grid { grid-template-columns: repeat(2, 1fr); }
}

/* Account page */
body.account-page {
  padding-top: 5vh;
}
body.account-page .top {
  width: 100%;
  max-width: 720px;
}
body.account-page .card {
  width: 100%;
  max-width: 720px;
  padding: 18px;
}
body.account-page .actions {
  justify-content: flex-end;
}
@media (max-width: 480px) {
  body.account-page .actions { justify-content: stretch; }
  body.account-page button.submit { width: 100%; }
}

/* Mobile responsive */
@media (max-width: 600px) {
  body {
    padding: 8px;
    padding-top: 12px;
  }
  
  .top {
    gap: 6px;
    margin-bottom: 10px;
  }
  
  a.btn {
    padding: 8px 10px;
    font-size: 13px;
  }
  
  .chip, .pill {
    padding: 4px 6px;
    font-size: 11px;
  }
  
  .card {
    padding: 12px;
    border-radius: 10px;
  }
  
  h2 {
    font-size: 18px;
  }
  
  .row {
    margin-bottom: 10px;
  }
  
  input[type=text],
  input[type=password],
  input[type=date],
  select {
    padding: 12px;
    font-size: 16px;
  }
  
  button.big {
    padding: 14px;
    font-size: 16px;
    border-radius: 10px;
  }
  
  button.submit {
    width: 100%;
    padding: 14px;
  }
  
  .actions {
    justify-content: stretch;
  }
  
  /* Login mobile */
  body.login-page {
    padding-top: 4vh;
  }
  
  .login-card {
    padding: 16px;
  }
  
  .login-btn {
    width: 100%;
    min-width: unset;
  }
  
  .login-actions {
    flex-direction: column;
    gap: 12px;
  }
  
  /* Account mobile */
  body.account-page {
    padding-top: 3vh;
  }
  
  /* Home mobile */
  body.home-page .grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  
  .status img {
    width: clamp(100px, 35vw, 140px);
  }
}

@media (max-width: 400px) {
  body {
    padding: 6px;
  }
  
  .top {
    flex-wrap: wrap;
  }
  
  a.btn {
    padding: 6px 8px;
    font-size: 12px;
  }
  
  .card {
    padding: 10px;
  }
  
  h2 {
    font-size: 16px;
  }
}

/* Admin mobile */
@media (max-width: 600px) {
  body.admin-page .grid {
    max-width: 100%;
  }
  
  body.admin-page .top {
    max-width: 100%;
  }
  
  body.admin-page .card {
    max-width: 100%;
  }
  
  .filters {
    grid-template-columns: 1fr;
  }
  
  .quick {
    flex-wrap: wrap;
  }
  
  .quick button {
    flex: 1 1 auto;
    font-size: 12px;
    padding: 8px 10px;
  }
  
  details.user {
    padding: 8px;
  }
  
  details.user summary {
    flex-wrap: wrap;
    gap: 6px;
  }
  
  .log-item {
    padding: 8px;
  }
  
  .log-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  
  .log-meta {
    font-size: 11px;
    word-break: break-all;
  }
  
  .log-data {
    font-size: 10px;
    max-width: 100%;
    overflow-x: auto;
  }
  
  .cols {
    grid-template-columns: 1fr;
  }
}

.close-countdown {
  color: #f59e0b;
  font-weight: bold;
  font-size: 14px;
  min-height: 20px;
  margin-bottom: 8px;
  text-align: center;
}
