/* Portal sDMT - style bazowe. Mobile-first, 18px+, jedna kolumna, kontrast AA.
   Motyw sterowany atrybutem data-theme na <html>: auto | light | dark.
   Akcent = gleboki indygo/fiolet (placeholder do identyfikacji sDMT, spec 6). */

:root {
  --accent: #5b4bdb;
  --accent-strong: #4636c9;
  --accent-contrast: #ffffff;

  --radius: 14px;
  --maxw: 640px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* JASNY (domyslny) */
:root, :root[data-theme="light"] {
  --bg: #f4f5fa;
  --surface: #ffffff;
  --text: #1a1c24;
  --muted: #565a68;
  --border: #e2e4ee;
  --ok-bg: #e6f5ec; --ok-fg: #1b6b3a;
  --err-bg: #fdeaea; --err-fg: #a01b1b;
  --warn-bg: #fff4e0; --warn-fg: #8a5a00;
  --off-bg: #eceef4; --off-fg: #6a6f7d;
  --shadow: 0 1px 3px rgba(20,22,40,.08), 0 6px 20px rgba(20,22,40,.05);
}

/* CIEMNY */
:root[data-theme="dark"] {
  --bg: #14151c;
  --surface: #1e2029;
  --text: #eceef5;
  --muted: #a4a9b8;
  --border: #313442;
  --accent: #8b7df0;
  --accent-strong: #a99cff;
  --accent-contrast: #14151c;
  --ok-bg: #163122; --ok-fg: #6fe0a1;
  --err-bg: #3a1a1a; --err-fg: #ff9d9d;
  --warn-bg: #3a2e12; --warn-fg: #ffcf7a;
  --off-bg: #262935; --off-fg: #9aa0af;
  --shadow: 0 1px 3px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.3);
}

/* AUTO = jasny domyslnie, ciemny gdy system woli ciemny */
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #14151c;
    --surface: #1e2029;
    --text: #eceef5;
    --muted: #a4a9b8;
    --border: #313442;
    --accent: #8b7df0;
    --accent-strong: #a99cff;
    --accent-contrast: #14151c;
    --ok-bg: #163122; --ok-fg: #6fe0a1;
    --err-bg: #3a1a1a; --err-fg: #ff9d9d;
    --warn-bg: #3a2e12; --warn-fg: #ffcf7a;
    --off-bg: #262935; --off-fg: #9aa0af;
    --shadow: 0 1px 3px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.3);
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* TOPBAR */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  font-weight: 800;
  font-size: 22px;
  letter-spacing: .5px;
  color: var(--accent);
  text-decoration: none;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.theme-btn {
  background: var(--off-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 15px;
  min-height: 40px;
  cursor: pointer;
}
.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 16px;
  padding: 8px 6px;
  min-height: 40px;
  cursor: pointer;
}

/* CONTENT */
.content {
  flex: 1;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 20px 16px 40px;
}

h1 { font-size: 26px; line-height: 1.25; margin: 0 0 8px; }
h2 { font-size: 21px; margin: 0 0 12px; }

.muted { color: var(--muted); }
.small { font-size: 15px; }
.center { text-align: center; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 14px; }

a { color: var(--accent); }

/* KARTY */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card.narrow { max-width: 440px; margin: 24px auto; }

.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-lg { display: flex; flex-direction: column; gap: 20px; }

/* FORMULARZE */
label { font-weight: 600; font-size: 16px; }
input, select {
  width: 100%;
  font-size: 18px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  min-height: 52px;
}
input:focus, select:focus {
  outline: 3px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-color: var(--accent);
}

.btn {
  display: inline-block;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  padding: 15px 22px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  min-height: 54px;
  text-decoration: none;
}
.btn.primary { background: var(--accent); color: var(--accent-contrast); }
.btn.primary:hover { background: var(--accent-strong); }

.inline { display: inline; }

/* ALERTY */
.alert { padding: 14px 16px; border-radius: 10px; font-size: 16px; margin: 4px 0; }
.alert.error { background: var(--err-bg); color: var(--err-fg); }
.alert.ok { background: var(--ok-bg); color: var(--ok-fg); }

/* PILL / STATUSY */
.pill { display: inline-block; font-size: 13px; padding: 3px 10px; border-radius: 999px; font-weight: 600; }
.pill.ok { background: var(--ok-bg); color: var(--ok-fg); }
.pill.off { background: var(--off-bg); color: var(--off-fg); }
.pill.warn { background: var(--warn-bg); color: var(--warn-fg); }

/* STANY PUSTE */
.empty { color: var(--muted); }
.empty p { margin: 6px 0; }

/* QUICKLINKS (kafle nawigacji na START) */
.quicklinks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 16px;
  text-align: center;
  font-weight: 700;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
}

/* TABELA ADMINA (na mobile scroll poziomy w kontenerze) */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; font-size: 15px; min-width: 640px; }
.tbl th, .tbl td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tbl th { color: var(--muted); font-weight: 600; }
.actions { white-space: nowrap; }
.actions .link-btn { display: block; }

.reset-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 16px; }
.reset-list li { border-bottom: 1px solid var(--border); padding-bottom: 12px; }
.reset-link input { margin: 6px 0; }

/* FOOTER */
.foot {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  padding: 20px 16px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}
.foot.has-nav { padding-bottom: calc(72px + max(20px, env(safe-area-inset-bottom))); }

/* ====== E2: WIDOKI DELIVERABLES ====== */

/* Pasek podgladu admina */
.preview-bar {
  background: var(--warn-bg); color: var(--warn-fg);
  text-align: center; font-size: 14px; padding: 8px 16px;
  border-bottom: 1px solid var(--border);
}
.preview-bar a { color: var(--warn-fg); text-decoration: underline; }

/* Dolna nawigacja (mobile-first) */
.content.has-nav { padding-bottom: 24px; }
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 6px 4px; padding-bottom: max(6px, env(safe-area-inset-bottom));
  box-shadow: 0 -2px 12px rgba(0,0,0,.06);
}
.bottomnav a {
  flex: 1; text-align: center; text-decoration: none;
  color: var(--muted); font-size: 13px; font-weight: 600;
  padding: 8px 2px; border-radius: 10px; min-height: 48px;
  display: flex; align-items: center; justify-content: center;
}
.bottomnav a.on { color: var(--accent); background: var(--off-bg); }

/* Naglowek z odznaka */
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* Pasek postepu */
.progress {
  height: 10px; background: var(--off-bg); border-radius: 999px;
  overflow: hidden; margin: 10px 0 16px;
}
.progress-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }

/* Mini-lista na START */
.mini-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.mini-item { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 1px solid var(--border); border-radius: 12px; }
.mini-item.is-done { opacity: .6; }
.mini-item.is-done .mini-title { text-decoration: line-through; }
.mini-body { flex: 1; min-width: 0; }
.mini-title { font-weight: 700; }
.mini-hook { color: var(--muted); font-size: 15px; margin: 3px 0 6px; }
.mini-link { font-size: 15px; font-weight: 600; }

/* Checkbox (duzy, mobilny) */
.chk, .mark-done { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.chk input, .mark-done input { position: absolute; opacity: 0; width: 0; height: 0; }
.chk-box {
  width: 28px; height: 28px; flex: 0 0 28px; border-radius: 8px;
  border: 2px solid var(--border); background: var(--bg); position: relative;
}
input:checked + .chk-box { background: var(--accent); border-color: var(--accent); }
input:checked + .chk-box::after {
  content: ""; position: absolute; left: 9px; top: 4px;
  width: 6px; height: 12px; border: solid var(--accent-contrast);
  border-width: 0 3px 3px 0; transform: rotate(45deg);
}
input:focus-visible + .chk-box { outline: 3px solid color-mix(in srgb, var(--accent) 40%, transparent); }
.mark-done {
  margin-top: 16px; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: 12px; font-weight: 700; width: 100%; justify-content: flex-start;
}

/* Przelacznik zestawow */
.switcher select { margin-top: 6px; }

/* Karta pozycji (rolka / karuzela / czesc stories) */
.item-card { scroll-margin-top: 80px; }
.item-head { display: flex; align-items: baseline; gap: 12px; }
.item-num {
  flex: 0 0 auto; font-weight: 800; color: var(--accent-contrast);
  background: var(--accent); border-radius: 999px; min-width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center; font-size: 15px;
}
.item-title { margin: 0; font-size: 20px; }
.item-sub { color: var(--muted); font-size: 15px; margin: 6px 0 0; }
.item-hook {
  font-size: 21px; font-weight: 700; line-height: 1.35; margin: 12px 0 4px;
  padding: 12px 14px; background: var(--off-bg); border-radius: 12px;
  border-left: 4px solid var(--accent);
}

/* Sekcje informacyjne (details) */
.info-card { padding: 0; }
.info-card > summary {
  padding: 16px 20px; font-weight: 700; cursor: pointer; list-style: none;
}
.info-card > summary::-webkit-details-marker { display: none; }
.info-card > summary::after { content: " +"; color: var(--muted); float: right; }
.info-card[open] > summary::after { content: " -"; }
.info-card > .rich { padding: 0 20px 18px; }

/* Lista dokumentow */
.doc-list { display: flex; flex-direction: column; gap: 10px; }
.doc-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px 18px; text-decoration: none;
  color: var(--text); font-weight: 700; box-shadow: var(--shadow);
}
.doc-arrow { color: var(--muted); font-size: 24px; }
.back-link { font-weight: 600; text-decoration: none; }

/* Tresc renderowana z markdown */
.rich { font-size: 18px; line-height: 1.6; overflow-wrap: break-word; }
.rich h1, .rich h2, .rich h3, .rich h4 { line-height: 1.3; margin: 20px 0 10px; }
.rich h1 { font-size: 24px; } .rich h2 { font-size: 21px; } .rich h3 { font-size: 19px; }
.rich p { margin: 10px 0; }
.rich ul, .rich ol { padding-left: 22px; margin: 10px 0; }
.rich li { margin: 6px 0; }
.rich strong { font-weight: 700; }
.rich blockquote {
  margin: 12px 0; padding: 10px 16px; border-left: 4px solid var(--accent);
  background: var(--off-bg); border-radius: 0 10px 10px 0; color: var(--muted);
}
.rich code { background: var(--off-bg); padding: 2px 6px; border-radius: 6px; font-size: 15px; }
.rich pre { background: var(--off-bg); padding: 14px; border-radius: 10px; overflow-x: auto; }
.rich pre code { background: none; padding: 0; }
.rich hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.rich a { overflow-wrap: break-word; }
/* Tabele w tresci: scroll poziomy w kontenerze zamiast rozpychac stronę */
.rich table { display: block; overflow-x: auto; border-collapse: collapse; width: 100%; font-size: 15px; }
.rich th, .rich td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; }
.rich th { background: var(--off-bg); }
