
  :root {
    --bg: #f4efe6;
    --bg-paper: #faf6ee;
    --ink: #1a1612;
    --ink-soft: #3d3530;
    --muted: #6b6156;
    --line: #c9bfae;
    --line-soft: #e0d6c4;
    --accent: #7a2e1f;
    --accent-deep: #5a1f13;
    --gold: #a07c3a;
    --danger: #a63a2c;
    --success: #3a6b3a;
    --shadow: 0 1px 2px rgba(26,22,18,0.04), 0 8px 24px rgba(26,22,18,0.06);
    --touch: 44px;
  }
  * { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
  html { -webkit-text-size-adjust: 100%; }
  html, body {
    background: var(--bg);
    color: var(--ink);
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 17px;
    line-height: 1.55;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
  }
  body {
    background-image:
      radial-gradient(circle at 20% 10%, rgba(160,124,58,0.06) 0%, transparent 50%),
      radial-gradient(circle at 80% 90%, rgba(122,46,31,0.05) 0%, transparent 50%);
  }
  .wrapper { max-width: 1080px; margin: 0 auto; padding: 48px 32px 80px; }

  /* NAGŁÓWEK */
  header.masthead {
    border-top: 3px double var(--ink);
    border-bottom: 1px solid var(--ink);
    padding: 28px 0 20px;
    margin-bottom: 48px;
    text-align: center;
    position: relative;
  }
  .eyebrow {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10.5px;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 14px;
  }
  h1.title {
    font-family: 'Playfair Display', serif;
    font-weight: 800;
    font-size: clamp(30px, 5vw, 56px);
    letter-spacing: -0.02em;
    line-height: 1;
    margin-bottom: 10px;
  }
  h1.title em {
    font-family: 'Playfair Display', serif;
    font-style: italic;
    font-weight: 400;
    color: var(--accent);
  }
  .subtitle {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-size: clamp(16px, 2.2vw, 20px);
    color: var(--ink-soft);
    max-width: 620px;
    margin: 0 auto;
    padding: 0 8px;
  }
  .issue-line {
    display: flex;
    justify-content: space-between;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--muted);
    margin-top: 22px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    gap: 8px;
    flex-wrap: wrap;
  }

  /* PRZEŁĄCZNIK WIDOKU */
  .view-switch {
    display: flex;
    justify-content: center;
    gap: 0;
    margin-bottom: 40px;
    border: 1px solid var(--ink);
    padding: 4px;
    background: var(--bg-paper);
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
  }
  .view-switch button {
    background: transparent;
    border: none;
    padding: 12px 28px;
    min-height: var(--touch);
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-soft);
    cursor: pointer;
    transition: all 0.2s;
  }
  .view-switch button.active {
    background: var(--ink);
    color: var(--bg-paper);
  }
  .view-switch button:not(.active):hover { color: var(--accent); }

  /* PAPIER */
  .paper {
    background: var(--bg-paper);
    border: 1px solid var(--line);
    padding: 48px 56px;
    box-shadow: var(--shadow);
    position: relative;
  }
  .paper::before {
    content: '';
    position: absolute;
    inset: 6px;
    border: 1px solid var(--line-soft);
    pointer-events: none;
  }
  .paper > * { position: relative; }

  .section {
    margin-bottom: 40px;
    padding-bottom: 32px;
    border-bottom: 1px solid var(--line-soft);
  }
  .section:last-child { border-bottom: none; padding-bottom: 0; margin-bottom: 0; }
  .section-head {
    display: flex;
    align-items: baseline;
    gap: 14px;
    margin-bottom: 24px;
    flex-wrap: wrap;
  }
  .section-num {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.2em;
    color: var(--accent);
    font-weight: 500;
  }
  .section-title {
    font-family: 'Playfair Display', serif;
    font-size: clamp(19px, 3vw, 24px);
    font-weight: 600;
    letter-spacing: -0.01em;
  }
  .section-rule {
    flex: 1;
    height: 1px;
    background: var(--line);
    min-width: 40px;
  }

  /* KATEGORIE — siatka responsywna */
  .category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
  }
  .category-card {
    background: var(--bg);
    border: 1px solid var(--line);
    padding: 22px 10px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s;
    position: relative;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
  }
  .category-card:hover, .category-card:focus-visible {
    border-color: var(--ink);
    transform: translateY(-2px);
    outline: none;
  }
  .category-card.selected {
    background: var(--ink);
    color: var(--bg-paper);
    border-color: var(--ink);
  }
  .category-card.selected .cat-icon { color: var(--gold); }
  .cat-icon {
    font-family: 'Playfair Display', serif;
    font-size: 32px;
    font-style: italic;
    color: var(--accent);
    margin-bottom: 8px;
    line-height: 1;
  }
  .cat-label {
    font-family: 'Playfair Display', serif;
    font-size: 17px;
    font-weight: 500;
    letter-spacing: 0.02em;
  }
  .cat-sub {
    font-family: 'JetBrains Mono', monospace;
    font-size: 8.5px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--muted);
    margin-top: 5px;
    line-height: 1.3;
  }
  .category-card.selected .cat-sub { color: var(--line); }

  /* POLA */
  .field-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 22px 28px;
  }
  .field-grid.three { grid-template-columns: repeat(3, 1fr); }
  .field-full { grid-column: 1 / -1; }
  .field-wide { grid-column: span 2; }

  label.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .label-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-soft);
    font-weight: 500;
  }
  .label-text .req { color: var(--accent); margin-left: 2px; }
  .label-hint {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-size: 14px;
    color: var(--muted);
    margin-top: -4px;
    line-height: 1.35;
  }

  input[type="text"], input[type="number"], input[type="email"], input[type="tel"], input[type="date"], select, textarea {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--line);
    padding: 10px 0 10px;
    min-height: var(--touch);
    font-family: 'Cormorant Garamond', serif;
    font-size: 16px;
    color: var(--ink);
    transition: border-color 0.2s;
    border-radius: 0;
  }
  input:focus, select:focus, textarea:focus {
    outline: none;
    border-bottom-color: var(--accent);
  }
  select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%236b6156' fill='none' stroke-width='1.2'/></svg>");
    background-repeat: no-repeat;
    background-position: right 4px center;
    padding-right: 22px;
    cursor: pointer;
  }
  textarea { resize: vertical; min-height: 88px; line-height: 1.5; padding-top: 10px; }

  .range-group { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: end; }
  .range-group .sep { color: var(--muted); padding-bottom: 14px; font-style: italic; }

  /* CHECKBOXY */
  .checkbox-row { display: flex; flex-wrap: wrap; gap: 8px 10px; margin-top: 4px; }
  .checkbox-row label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px 12px;
    min-height: var(--touch);
    border: 1px solid var(--line);
    background: var(--bg);
    font-size: 15px;
    transition: all 0.15s;
    user-select: none;
  }
  .checkbox-row label:hover { border-color: var(--ink-soft); }
  .checkbox-row input { position: absolute; opacity: 0; pointer-events: none; }
  .checkbox-row label:has(input:checked) {
    background: var(--ink);
    color: var(--bg-paper);
    border-color: var(--ink);
  }

  /* DYNAMICZNE POLA */
  .dynamic-fields { display: none; animation: fadeIn 0.4s ease; }
  .dynamic-fields.active { display: block; }
  @keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
  }

  /* PRIORYTET */
  .priority-group { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .priority-opt {
    border: 1px solid var(--line);
    padding: 14px 10px;
    cursor: pointer;
    text-align: center;
    background: var(--bg);
    transition: all 0.2s;
    min-height: 72px;
  }
  .priority-opt:hover { border-color: var(--ink-soft); }
  .priority-opt.active {
    background: var(--accent);
    color: var(--bg-paper);
    border-color: var(--accent);
  }
  .priority-opt input { display: none; }
  .pr-label { font-family: 'Playfair Display', serif; font-size: 18px; font-weight: 500; }
  .pr-desc { font-size: 13px; color: var(--muted); font-style: italic; margin-top: 2px; }
  .priority-opt.active .pr-desc { color: rgba(250,246,238,0.75); }

  /* ZDJĘCIA REFERENCYJNE */
  .photo-dropzone {
    border: 1.5px dashed var(--ink-soft);
    background: var(--bg);
    padding: 28px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 12px;
  }
  .photo-dropzone:hover,
  .photo-dropzone:focus-visible,
  .photo-dropzone.drag-over {
    border-color: var(--accent);
    background: var(--bg-paper);
    outline: none;
  }
  .photo-dropzone.drag-over {
    border-style: solid;
  }
  .dropzone-inner {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
  }
  .dropzone-icon {
    font-size: 28px;
    color: var(--accent);
    font-family: 'Playfair Display', serif;
    font-weight: 300;
  }
  .dropzone-text {
    font-family: 'Cormorant Garamond', serif;
    font-size: 17px;
    color: var(--ink);
  }
  .dropzone-or {
    display: block;
    font-size: 14px;
    color: var(--muted);
    font-style: italic;
    margin-top: 2px;
  }
  .dropzone-meta {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--muted);
    margin-top: 6px;
  }
  .dropzone-sep { margin: 0 8px; }

  .photo-previews {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    margin-top: 16px;
  }
  .photo-previews:empty { display: none; }

  .photo-thumb {
    position: relative;
    aspect-ratio: 1;
    background: var(--bg);
    border: 1px solid var(--line);
    overflow: hidden;
  }
  .photo-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }
  .photo-thumb .photo-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(26,22,18,0.85);
    color: var(--bg-paper);
    border: none;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
  }
  .photo-thumb .photo-remove:hover {
    background: var(--accent);
  }
  .photo-thumb .photo-meta {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 4px 8px;
    background: linear-gradient(to top, rgba(26,22,18,0.8), transparent);
    color: var(--bg-paper);
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    letter-spacing: 0.1em;
    text-align: center;
  }
  .photo-thumb.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.15em;
  }

  .photo-error {
    color: var(--accent);
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-size: 14px;
    margin-top: 8px;
    min-height: 20px;
  }
  .photo-error:empty { display: none; }

  /* Miniatury w panelu bazy */
  .entry-photos {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 10px;
  }
  .entry-photo-thumb {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border: 1px solid var(--line);
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s;
    display: block;
  }
  .entry-photo-thumb:hover {
    transform: scale(1.05);
    border-color: var(--accent);
  }

  /* Modal pełnego widoku zdjęcia */
  .photo-viewer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(26,22,18,0.92);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    cursor: zoom-out;
    padding: 20px;
  }
  .photo-viewer-backdrop.active { display: flex; }
  .photo-viewer-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    cursor: default;
  }
  .photo-viewer-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: var(--bg-paper);
    color: var(--ink);
    border: 1px solid var(--ink);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    line-height: 1;
  }

  /* PRZYCISKI */
  .actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 36px;
    padding-top: 28px;
    border-top: 3px double var(--ink);
    gap: 12px;
    flex-wrap: wrap;
  }
  .btn {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    padding: 16px 32px;
    min-height: var(--touch);
    border: 1px solid var(--ink);
    background: var(--ink);
    color: var(--bg-paper);
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    border-radius: 0;
  }
  .btn:hover { background: var(--accent); border-color: var(--accent); }
  .btn-ghost { background: transparent; color: var(--ink); }
  .btn-ghost:hover { background: var(--ink); color: var(--bg-paper); }
  .btn:disabled { opacity: 0.5; cursor: not-allowed; }

  /* TOAST */
  .toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    left: 20px;
    max-width: 420px;
    margin-left: auto;
    background: var(--ink);
    color: var(--bg-paper);
    padding: 16px 24px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    letter-spacing: 0.1em;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s;
    z-index: 1000;
    border-left: 4px solid var(--gold);
  }
  .toast.show { opacity: 1; transform: translateY(0); }
  .toast.error { border-left-color: var(--danger); }
  .toast.success { border-left-color: var(--success); }

  /* PANEL BAZY */
  .db-panel { display: none; }
  .db-panel.active { display: block; }

  .db-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 28px;
    flex-wrap: wrap;
    align-items: center;
  }
  .db-search {
    flex: 1 1 200px;
    min-width: 180px;
    border: 1px solid var(--line);
    padding: 12px 14px;
    min-height: var(--touch);
    background: var(--bg-paper);
    font-family: 'Cormorant Garamond', serif;
    font-size: 16px;
    border-radius: 0;
  }
  .db-filter {
    border: 1px solid var(--line);
    padding: 12px 14px;
    min-height: var(--touch);
    background: var(--bg-paper);
    font-family: 'Cormorant Garamond', serif;
    font-size: 15px;
    cursor: pointer;
    border-radius: 0;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%236b6156' fill='none' stroke-width='1.2'/></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
  }
  .db-btn {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    padding: 12px 16px;
    min-height: var(--touch);
    border: 1px solid var(--ink);
    background: transparent;
    color: var(--ink);
    cursor: pointer;
    border-radius: 0;
  }
  .db-btn:hover { background: var(--ink); color: var(--bg-paper); }
  .db-btn.danger { border-color: var(--danger); color: var(--danger); }
  .db-btn.danger:hover { background: var(--danger); color: var(--bg-paper); }

  .db-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 32px;
  }
  .stat-card {
    border: 1px solid var(--line);
    background: var(--bg-paper);
    padding: 20px 14px;
    text-align: center;
  }
  .stat-num {
    font-family: 'Playfair Display', serif;
    font-size: clamp(26px, 5vw, 36px);
    font-weight: 700;
    color: var(--ink);
    line-height: 1;
  }
  .stat-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 9.5px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--muted);
    margin-top: 8px;
    line-height: 1.3;
  }

  .db-entry {
    background: var(--bg-paper);
    border: 1px solid var(--line);
    padding: 22px 24px;
    margin-bottom: 14px;
    position: relative;
  }
  .entry-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    border-bottom: 1px solid var(--line-soft);
    padding-bottom: 12px;
    margin-bottom: 14px;
    gap: 12px;
    flex-wrap: wrap;
  }
  .entry-title {
    font-family: 'Playfair Display', serif;
    font-size: clamp(17px, 3vw, 20px);
    font-weight: 600;
    line-height: 1.3;
  }
  .entry-title .category-tag {
    display: inline-block;
    font-family: 'JetBrains Mono', monospace;
    font-size: 9.5px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    background: var(--accent);
    color: var(--bg-paper);
    padding: 3px 8px;
    margin-right: 8px;
    vertical-align: middle;
    font-weight: 500;
  }
  .entry-meta {
    font-family: 'JetBrains Mono', monospace;
    font-size: 9.5px;
    letter-spacing: 0.1em;
    color: var(--muted);
    text-transform: uppercase;
  }
  .entry-priority {
    display: inline-block;
    padding: 2px 8px;
    margin-left: 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-weight: 600;
  }
  .pr-wysoki { background: var(--accent); color: var(--bg-paper); }
  .pr-średni { background: var(--gold); color: var(--bg-paper); }
  .pr-niski { background: var(--line); color: var(--ink); }

  .entry-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px 28px;
  }
  .entry-field { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
  .entry-field-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .entry-field-val {
    font-family: 'Cormorant Garamond', serif;
    font-size: 16px;
    color: var(--ink);
    word-break: break-word;
  }
  .entry-description {
    grid-column: 1 / -1;
    font-style: italic;
    border-left: 2px solid var(--accent);
    padding-left: 14px;
    margin-top: 8px;
    color: var(--ink-soft);
    word-break: break-word;
  }
  .entry-actions {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--line-soft);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
  }
  .entry-btn {
    font-family: 'JetBrains Mono', monospace;
    font-size: 9.5px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    padding: 10px 14px;
    min-height: 40px;
    border: 1px solid var(--line);
    background: transparent;
    cursor: pointer;
    color: var(--ink-soft);
    border-radius: 0;
  }
  .entry-btn:hover { background: var(--ink); color: var(--bg-paper); border-color: var(--ink); }
  .entry-btn.danger:hover { background: var(--danger); border-color: var(--danger); }

  .empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
    font-style: italic;
    font-size: 18px;
    border: 1px dashed var(--line);
  }

  /* MODAL POTWIERDZENIA */
  .confirm-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease;
  }
  .confirm-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(26,22,18,0.55);
    backdrop-filter: blur(2px);
  }
  .confirm-box {
    position: relative;
    background: var(--bg-paper);
    border: 1px solid var(--ink);
    padding: 32px 36px;
    max-width: 440px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  }
  .confirm-box::before {
    content: '';
    position: absolute;
    inset: 5px;
    border: 1px solid var(--line);
    pointer-events: none;
  }
  .confirm-msg {
    font-family: 'Playfair Display', serif;
    font-size: 19px;
    line-height: 1.4;
    color: var(--ink);
    margin-bottom: 24px;
    position: relative;
  }
  .confirm-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
    position: relative;
  }
  .confirm-actions .btn { padding: 12px 24px; }
  @media (max-width: 480px) {
    .confirm-box { padding: 24px 22px; }
    .confirm-actions { flex-direction: column-reverse; }
    .confirm-actions .btn { width: 100%; }
  }

  /* =============== RESPONSYWNOŚĆ =============== */
  /* TABLET */
  @media (max-width: 900px) {
    .wrapper { padding: 32px 20px 60px; }
    .paper { padding: 36px 32px; }
    .field-grid.three { grid-template-columns: repeat(2, 1fr); }
    .db-stats { grid-template-columns: repeat(4, 1fr); gap: 10px; }
  }

  /* TELEFON */
  @media (max-width: 640px) {
    html, body { font-size: 16px; }
    .wrapper { padding: 20px 14px 40px; }
    header.masthead { padding: 22px 0 16px; margin-bottom: 32px; }
    .eyebrow { font-size: 9.5px; letter-spacing: 0.24em; }
    .issue-line { font-size: 9px; justify-content: center; }
    .issue-line span:nth-child(2) { order: -1; width: 100%; text-align: center; margin-bottom: 4px; }

    .view-switch { width: 100%; }
    .view-switch button { flex: 1; padding: 14px 12px; font-size: 10.5px; letter-spacing: 0.14em; }

    .paper { padding: 24px 18px; }
    .paper::before { inset: 3px; }

    .section { margin-bottom: 32px; padding-bottom: 24px; }
    .section-head { gap: 10px; margin-bottom: 18px; }
    .section-rule { display: none; }

    .field-grid, .field-grid.three { grid-template-columns: 1fr; gap: 18px; }
    .field-wide { grid-column: auto; }

    .category-grid {
      grid-template-columns: repeat(3, 1fr);
      gap: 6px;
    }
    .category-card { padding: 14px 4px 10px; min-height: 96px; }
    .cat-icon { font-size: 22px; margin-bottom: 4px; }
    .cat-label { font-size: 12px; letter-spacing: 0.02em; line-height: 1.2; }
    .cat-sub { display: none; }

    .checkbox-row label { font-size: 14px; padding: 9px 12px; }
    .priority-group { grid-template-columns: 1fr; gap: 8px; }
    .priority-opt { min-height: 64px; padding: 12px; }

    .actions { flex-direction: column-reverse; }
    .actions .btn { width: 100%; }

    /* BAZA — mobilnie */
    .db-stats { grid-template-columns: repeat(2, 1fr); }
    .db-controls { gap: 8px; }
    .db-search { flex-basis: 100%; min-width: 100%; }
    .db-filter, .db-btn { flex: 1 1 auto; }

    .db-entry { padding: 18px 16px; }
    .entry-grid { grid-template-columns: 1fr; gap: 8px; }
    .entry-head { flex-direction: column; align-items: flex-start; gap: 6px; }
    .entry-actions { flex-direction: column; }
    .entry-btn { width: 100%; }

    input, select, textarea { font-size: 16px; } /* zapobiega zoom-in na iOS */
  }

  /* MAŁY TELEFON */
  @media (max-width: 380px) {
    .wrapper { padding: 16px 12px 32px; }
    .paper { padding: 20px 14px; }
    .category-grid { grid-template-columns: repeat(3, 1fr); gap: 4px; }
    .category-card { padding: 10px 3px 8px; min-height: 82px; }
    .cat-icon { font-size: 18px; margin-bottom: 3px; }
    .cat-label { font-size: 11px; }
  }

  /* Tryb drukowania */
  @media print {
    body { background: white; }
    .view-switch, .actions, .db-controls { display: none; }
    .paper { box-shadow: none; border: 1px solid #ccc; }
  }
