:root {
  --primary: #e30613;
  --primary-2: #c0050f;
  --ink: #1a1a1a;
  --muted: #6b7280;
  --bg: #f6f7f8;
  --card: #ffffff;
  --border: #e6e7ea;
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --appbar-h: 56px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Nagłówki jak na stronie (Playfair Display) */
.appbar-title, .welcome-title, .screen-title, .section-head h2 { font-family: 'Playfair Display', Georgia, serif; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--ink); overscroll-behavior-y: none; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font: inherit; cursor: pointer; }

#app { min-height: 100vh; display: flex; flex-direction: column; }

/* App bar */
.appbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 8px;
  height: calc(var(--appbar-h) + var(--safe-top));
  padding: var(--safe-top) 12px 0;
  background: var(--primary); color: #fff;
  box-shadow: 0 1px 8px rgba(0,0,0,.12);
}
.appbar-title { font-size: 18px; font-weight: 700; margin: 0; line-height: var(--appbar-h); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar-back {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border: 0; border-radius: 50%;
  background: rgba(255,255,255,.16); color: #fff; flex: 0 0 auto;
}
.appbar-back:active { background: rgba(255,255,255,.3); }

/* Screen */
.screen { flex: 1; padding: 16px 16px calc(24px + var(--safe-bottom)); max-width: 720px; width: 100%; margin: 0 auto; }
.screen-title { font-size: 22px; font-weight: 800; margin: 4px 0 14px; }

/* Loader / states */
.loader { display: flex; justify-content: center; padding: 48px 0; }
.spinner { width: 30px; height: 30px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.state { text-align: center; color: var(--muted); padding: 40px 16px; }
.state button { margin-top: 12px; }

/* Banner */
.banner { border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px; color: #fff; }
.banner-l-pilne, .banner-l-urgent { background: linear-gradient(135deg, #e32636, #b00d22); }
.banner-l-krytyczne, .banner-l-critical { background: linear-gradient(135deg, #7a0a16, #b00d22); }
.banner-l-niskie, .banner-l-low { background: linear-gradient(135deg, #f59e0b, #d97706); }
.banner-text { font-weight: 700; font-size: 15px; }
.banner-groups { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; }
.banner-chip { background: rgba(255,255,255,.22); border-radius: 999px; padding: 2px 10px; font-size: 13px; font-weight: 700; }

/* Welcome */
.welcome { margin-bottom: 18px; }
.welcome-title { font-size: 24px; font-weight: 800; margin: 0 0 4px; }
.welcome-text { color: var(--muted); font-size: 15px; line-height: 1.5; margin: 0; }

/* Tiles */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 22px; }
.tile {
  border: 0; text-align: left; border-radius: var(--radius); padding: 16px;
  color: #fff; min-height: 104px; display: flex; flex-direction: column; justify-content: space-between;
  box-shadow: 0 2px 10px rgba(0,0,0,.08); position: relative; overflow: hidden;
}
.tile:active { transform: scale(.98); }
.tile-icon { width: 30px; height: 30px; }
.tile-icon svg { width: 30px; height: 30px; }
.tile-label { font-weight: 700; font-size: 15px; line-height: 1.25; }

/* Section header */
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 12px; }
.section-head h2 { font-size: 18px; font-weight: 800; margin: 0; }
.link-all { color: var(--primary); font-weight: 700; font-size: 14px; }

/* Messages feed */
.messages { display: flex; flex-direction: column; gap: 10px; }
.msg { background: var(--card); border: 1px solid var(--border); border-left-width: 4px; border-radius: 12px; padding: 12px 14px; }
.msg-info { border-left-color: #3b82f6; }
.msg-success { border-left-color: #16a34a; }
.msg-warning { border-left-color: #f59e0b; }
.msg-urgent { border-left-color: var(--primary); }
.msg-pinned { box-shadow: 0 2px 12px rgba(200,16,46,.10); }
.msg-top { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.msg-title { font-weight: 700; font-size: 15px; }
.msg-pin { margin-left: auto; color: var(--primary); font-size: 12px; font-weight: 700; }
.msg-body { color: var(--muted); font-size: 14px; line-height: 1.5; }
.msg-date { color: #9ca3af; font-size: 12px; margin-top: 6px; }

/* Generic list cards */
.list { display: flex; flex-direction: column; gap: 12px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.card-pad { padding: 14px; }
.card-img { width: 100%; aspect-ratio: 16/9; object-fit: cover; background: var(--bg); }
.card-cat { display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--primary); background: rgba(200,16,46,.08); padding: 2px 8px; border-radius: 999px; }
.card-title { font-weight: 700; font-size: 16px; margin: 8px 0 4px; }
.card-excerpt { color: var(--muted); font-size: 14px; line-height: 1.5; }
.card-date { color: #9ca3af; font-size: 12px; margin-top: 8px; }

/* Blood stock grid */
.blood-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.blood-cell { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px 6px; text-align: center; }
.blood-grp { font-weight: 800; font-size: 17px; }
.blood-dot { width: 12px; height: 12px; border-radius: 50%; margin: 8px auto 0; }
.lvl-wysoki { background: #16a34a; } .lvl-sredni { background: #f59e0b; }
.lvl-niski { background: #ef4444; } .lvl-bardzo_niski { background: #7a0a16; }
.lvl-null, .lvl- { background: #d1d5db; }
.blood-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 14px; color: var(--muted); font-size: 13px; }
.blood-legend span { display: inline-flex; align-items: center; gap: 6px; }
.blood-legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* Branch / contact rows */
.branch { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.branch-name { font-weight: 700; font-size: 16px; }
.branch-row { display: flex; gap: 8px; color: var(--muted); font-size: 14px; margin-top: 6px; align-items: flex-start; }
.branch-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* Attachments */
.files { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.file { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.file-ext { font-size: 11px; font-weight: 800; color: var(--primary); background: rgba(200,16,46,.08); border-radius: 6px; padding: 3px 7px; min-width: 44px; text-align: center; }

/* Gallery */
.albums { display: grid; grid-template-columns: repeat(2,1fr); gap: 12px; }
.album { border-radius: var(--radius); overflow: hidden; background: var(--card); border: 1px solid var(--border); }
.album-cover { width: 100%; aspect-ratio: 1; object-fit: cover; background: var(--bg); }
.album-cap { padding: 8px 10px; font-size: 13px; font-weight: 600; }
.photos { display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; }
.photo { aspect-ratio: 1; object-fit: cover; border-radius: 8px; background: var(--bg); }

/* Buttons / chips */
.btn { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 9px 16px; font-weight: 700; font-size: 14px; border: 1px solid var(--border); background: #fff; color: var(--ink); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }

/* Update bar */
.updatebar { position: fixed; left: 12px; right: 12px; bottom: calc(12px + var(--safe-bottom)); background: var(--ink); color: #fff; border-radius: 14px; padding: 12px 14px; display: flex; align-items: center; gap: 10px; z-index: 100; box-shadow: 0 6px 24px rgba(0,0,0,.25); }
.updatebar .btn { flex: 0 0 auto; }

/* Prose for embedded HTML */
.prose { font-size: 15px; line-height: 1.65; color: #2a2a2a; }
.prose img { border-radius: 12px; margin: 10px 0; }
.prose a { color: var(--primary); text-decoration: underline; }
.prose h2, .prose h3 { line-height: 1.3; }

/* Pasek instalacji */
.installbar { position: fixed; left: 12px; right: 12px; bottom: calc(12px + var(--safe-bottom)); z-index: 130; display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 12px 14px; box-shadow: 0 8px 28px rgba(0,0,0,.18); }
.ib-icon { width: 40px; height: 40px; border-radius: 10px; flex: 0 0 auto; }
.ib-txt { flex: 1; font-size: 13px; line-height: 1.4; color: var(--ink); }
.ib-txt b { font-size: 14px; }
.ib-share { display: inline-flex; align-items: center; gap: 3px; color: #007aff; font-weight: 600; white-space: nowrap; }
.ib-share svg { width: 16px; height: 16px; vertical-align: -3px; }
.ib-go { flex: 0 0 auto; padding: 9px 14px; }
.ib-close { flex: 0 0 auto; width: 30px; height: 30px; border: 0; background: transparent; color: var(--muted); font-size: 22px; line-height: 1; border-radius: 50%; }
.ib-close:active { background: var(--bg); }
