/* ── Reset ── */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background: #f0f2f6;
    color: #333;
    font-size: 14px;
}

.app-shell { display: flex; min-height: 100vh; }

/* ═══ SIDEBAR ═══ */
.sidebar {
    width: 252px; min-height: 100vh;
    background: linear-gradient(180deg, #0d1b2e 0%, #14243d 60%, #0f1e35 100%);
    position: fixed; top: 0; left: 0; bottom: 0;
    display: flex; flex-direction: column; z-index: 100;
    box-shadow: 2px 0 16px rgba(0,0,0,0.22);
}
.sidebar-header { padding: 22px 22px 18px; border-bottom: 1px solid rgba(255,255,255,0.07); }
.sidebar-brand { font-size: 21px; font-weight: 800; color: #fff; letter-spacing: 0.8px; line-height: 1; }
.sidebar-brand-sub { font-size: 9.5px; font-weight: 500; color: rgba(255,255,255,0.32); letter-spacing: 2px; text-transform: uppercase; margin-top: 5px; }
.sidebar-user { padding: 14px 22px; background: rgba(255,255,255,0.04); border-bottom: 1px solid rgba(255,255,255,0.07); }
.sidebar-user-label { font-size: 9.5px; color: rgba(255,255,255,0.3); text-transform: uppercase; letter-spacing: 0.9px; margin-bottom: 3px; }
.sidebar-user-name { font-size: 14px; font-weight: 600; color: #fff; margin-bottom: 7px; }
.sidebar-user-badge { display: inline-block; background: rgba(90,171,255,0.18); border: 1px solid rgba(90,171,255,0.38); color: #7ec6ff; font-size: 9px; font-weight: 700; padding: 2px 9px; border-radius: 10px; letter-spacing: 1.2px; text-transform: uppercase; }
.sidebar-nav { flex: 1; padding: 10px 0; display: flex; flex-direction: column; overflow-y: auto; }
.sidebar-link { display: flex; align-items: center; gap: 11px; padding: 10px 22px; color: rgba(255,255,255,0.52); text-decoration: none; font-size: 13.5px; transition: background 0.15s, color 0.15s, border-color 0.15s; border-left: 3px solid transparent; white-space: nowrap; }
.sidebar-link:hover { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.9); border-left-color: rgba(90,171,255,0.35); }
.sidebar-link.active { background: rgba(90,171,255,0.13); color: #fff; border-left-color: #5aabff; font-weight: 600; }
.nav-icon { font-size: 15px; flex-shrink: 0; width: 20px; text-align: center; }
.nav-text { flex: 1; }
.sidebar-section-label { font-size: 9.5px; font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase; color: rgba(255,255,255,0.2); padding: 14px 22px 5px; }
.sidebar-divider { border: none; border-top: 1px solid rgba(255,255,255,0.06); margin: 7px 18px; }
.sidebar-logout { }
.sidebar-footer { padding: 14px 22px 16px; border-top: 1px solid rgba(255,255,255,0.07); background: rgba(0,0,0,0.18); }
.sidebar-footer-title { font-size: 9px; font-weight: 700; color: rgba(255,255,255,0.2); text-transform: uppercase; letter-spacing: 1.2px; margin-bottom: 8px; }
.sidebar-stat { display: flex; justify-content: space-between; align-items: center; padding: 3px 0; }
.sidebar-stat-label { font-size: 11.5px; color: rgba(255,255,255,0.32); }
.sidebar-stat-value { font-size: 12px; font-weight: 700; color: rgba(255,255,255,0.65); min-width: 20px; text-align: right; }

/* ═══ MAIN CONTENT ═══ */
.main-content { margin-left: 252px; flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
.topbar { background: #fff; padding: 0 32px; height: 60px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #e5e7eb; position: sticky; top: 0; z-index: 50; box-shadow: 0 1px 5px rgba(0,0,0,0.06); }
.topbar-title { font-size: 16px; font-weight: 700; color: #131f35; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-badge { background: linear-gradient(135deg, #1a3c6e 0%, #2c508a 100%); color: #fff; font-size: 10px; font-weight: 700; padding: 4px 13px; border-radius: 20px; letter-spacing: 0.8px; text-transform: uppercase; box-shadow: 0 2px 6px rgba(26,60,110,0.28); }
.role-badge { background: #e8edf7; color: #1a3c6e; font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 20px; letter-spacing: 0.6px; text-transform: uppercase; }
.content-area { padding: 28px 32px; flex: 1; }
.content-card { background: #fff; border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,0.06), 0 4px 14px rgba(0,0,0,0.04); padding: 28px 32px; margin-bottom: 24px; border: 1px solid rgba(0,0,0,0.045); }
.content-card h2 { font-size: 16px; font-weight: 700; color: #131f35; margin-bottom: 4px; }
.content-card .card-subtitle { font-size: 13px; color: #8a94a6; margin-bottom: 24px; }
.stat-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 20px; margin-bottom: 24px; }
.stat-card { background: #fff; border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,0.06), 0 4px 14px rgba(0,0,0,0.04); padding: 22px 24px; border: 1px solid rgba(0,0,0,0.045); border-top: 3px solid #e5e7eb; transition: transform 0.15s, box-shadow 0.15s; cursor: default; }
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.stat-card:nth-child(1) { border-top-color: #1a3c6e; }
.stat-card:nth-child(2) { border-top-color: #f0a500; }
.stat-card:nth-child(3) { border-top-color: #2e7d32; }
.stat-icon { font-size: 22px; margin-bottom: 10px; display: block; }
.stat-card .stat-label { font-size: 10.5px; font-weight: 700; letter-spacing: 0.9px; text-transform: uppercase; color: #8a94a6; margin-bottom: 6px; }
.stat-card .stat-value { font-size: 30px; font-weight: 800; color: #131f35; line-height: 1; }

/* ═══ BUTTONS ═══ */
.btn { display: inline-block; background: linear-gradient(135deg, #1a3c6e 0%, #2350a0 100%); color: white; padding: 9px 20px; border: none; border-radius: 6px; font-size: 13.5px; cursor: pointer; text-decoration: none; transition: opacity 0.15s, transform 0.1s, box-shadow 0.15s; font-family: inherit; font-weight: 600; letter-spacing: 0.2px; box-shadow: 0 2px 6px rgba(26,60,110,0.25); }
.btn:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: 0 4px 10px rgba(26,60,110,0.3); }
.btn:active { transform: translateY(0); }
.btn-secondary { background: linear-gradient(135deg, #5a6473 0%, #6c757d 100%); box-shadow: 0 2px 6px rgba(0,0,0,0.12); }
.btn-secondary:hover { box-shadow: 0 4px 10px rgba(0,0,0,0.18); }
.btn-action { display: inline-block; padding: 4px 10px; border-radius: 4px; font-size: 12px; font-weight: 600; text-decoration: none; cursor: pointer; border: none; white-space: nowrap; font-family: inherit; transition: opacity 0.12s; }
.btn-action:hover { opacity: 0.85; }
.btn-edit   { background: #1a3c6e; color: white; }
.btn-delete { background: #c62828; color: white; }
.btn-pdf    { background: #3a7a2e; color: white; }
.btn-fav { display: inline-block; padding: 4px 10px; border-radius: 4px; font-size: 12px; font-weight: 600; background: #e8e8e8; color: #555; border: none; cursor: pointer; font-family: inherit; transition: background 0.12s; }
.btn-fav:hover { background: #d4d4d4; }
.btn-fav.active { background: #f0a500; color: white; }
.btn-fav.active:hover { background: #d4900a; }
.btn-unfav { display: inline-block; padding: 4px 10px; border-radius: 4px; font-size: 12px; font-weight: 600; background: #f0a500; color: white; border: none; cursor: pointer; font-family: inherit; transition: background 0.12s; }
.btn-unfav:hover { background: #d4900a; }

/* ═══ FORMS ═══ */
.form-group { margin-bottom: 18px; }
label { display: block; font-size: 11.5px; font-weight: 700; color: #5a6473; margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.5px; }
input[type="text"], input[type="date"], input[type="password"], textarea { width: 100%; padding: 9px 12px; border: 1.5px solid #e0e4ea; border-radius: 6px; font-size: 14px; font-family: inherit; transition: border-color 0.15s, box-shadow 0.15s; background: #fafbfc; color: #222; }
input[type="text"]:focus, input[type="date"]:focus, input[type="password"]:focus, textarea:focus { outline: none; border-color: #1a3c6e; background: #fff; box-shadow: 0 0 0 3px rgba(26,60,110,0.08); }
textarea { resize: vertical; min-height: 80px; }
.input-select, .role-select-inline { width: 100%; padding: 9px 12px; border: 1.5px solid #e0e4ea; border-radius: 6px; font-size: 14px; background: #fafbfc; font-family: inherit; cursor: pointer; color: #222; transition: border-color 0.15s, box-shadow 0.15s; }
.input-select:focus, .role-select-inline:focus { outline: none; border-color: #1a3c6e; box-shadow: 0 0 0 3px rgba(26,60,110,0.08); }
.role-select-inline { width: auto; }
.form-actions { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; }
.divider { border: none; border-top: 1px solid #eaecef; margin: 24px 0; }
.section-title { font-size: 11px; font-weight: 700; color: #1a3c6e; text-transform: uppercase; letter-spacing: 0.8px; margin: 24px 0 12px; padding-bottom: 6px; border-bottom: 2px solid #dae3f3; }
#status, #userStatus { font-size: 13px; font-weight: 600; }
#status.success, #userStatus.success { color: #2e7d32; }
#status.error, #userStatus.error { color: #c62828; }

/* ═══ TABLES ═══ */
.table-wrapper { overflow-x: auto; margin-top: 16px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead { background: #f5f7fa; }
th { padding: 11px 14px; text-align: left; font-weight: 700; font-size: 11px; letter-spacing: 0.5px; text-transform: uppercase; color: #6b7a8d; border-bottom: 2px solid #e5e7eb; }
td { padding: 11px 14px; border-bottom: 1px solid #f0f2f5; color: #333; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f7f9fc; }
.empty { text-align: center; color: #aaa; padding: 32px; font-size: 13px; }
.users-table th { color: #6b7a8d; }
.users-table td { font-size: 13.5px; }
.role-badge-table { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; letter-spacing: 0.4px; }
.role-admin { background: #dae3f3; color: #1a3c6e; }
.role-user  { background: #e8f5e9; color: #2e7d32; }
.users-role-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.users-wrapper { display: flex; gap: 32px; align-items: flex-start; width: 100%; }
.user-form { flex: 0 0 320px; }
.user-table { flex: 1; overflow-x: auto; }
.user-table table { width: 100%; }

/* ═══ WIDGETS ═══ */
.widgets-row { display: flex; gap: 20px; margin-bottom: 24px; flex-wrap: wrap; }
.widget { flex: 1; min-width: 240px; background: #fff; border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,0.06), 0 4px 14px rgba(0,0,0,0.04); overflow: hidden; border: 1px solid rgba(0,0,0,0.045); }
.widget-header { background: linear-gradient(135deg, #1a3c6e 0%, #2c508a 100%); color: #fff; padding: 12px 18px; font-size: 11.5px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; display: flex; align-items: center; gap: 8px; }
.widget table { font-size: 13px; }
.widget thead { background: rgba(0,0,0,0.025); }
.widget th { color: #6b7a8d; border-bottom: 1px solid #eaecef; font-size: 12px; }
.widget td { padding: 9px 14px; font-size: 13px; }
.widget a { color: #1a3c6e; font-weight: 600; text-decoration: none; }
.widget a:hover { text-decoration: underline; }
.page-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.page-header h2 { font-size: 18px; font-weight: 700; color: #131f35; margin-bottom: 2px; }
.page-header .card-subtitle { font-size: 13px; color: #8a94a6; margin-bottom: 0; }

/* ═══ RESPONSIVE ═══ */
@media (max-width: 900px) { .users-wrapper { flex-direction: column; } .user-form { width: 100%; flex: none; } }
@media (max-width: 860px) { .sidebar { width: 210px; } .main-content { margin-left: 210px; } }
@media (max-width: 768px) {
    .widgets-row { flex-direction: column; }
    .widget { min-width: 100%; }
    table th, table td { padding: 6px 8px; font-size: 12px; }
    .btn-action { padding: 3px 7px; font-size: 11px; }
    .btn-fav { padding: 3px 7px; font-size: 11px; }
    .content-card { padding: 16px; }
}
@media (max-width: 640px) {
    .sidebar { width: 62px; }
    .sidebar-header { padding: 16px 0; text-align: center; }
    .sidebar-brand { font-size: 11px; text-align: center; display: block; padding: 0 4px; }
    .sidebar-brand-sub, .sidebar-user-label, .sidebar-user-name, .sidebar-user-badge { display: none; }
    .sidebar-user { padding: 8px 0; text-align: center; }
    .sidebar-link { padding: 11px 0; justify-content: center; gap: 0; }
    .nav-text, .sidebar-section-label, .sidebar-divider, .sidebar-footer { display: none; }
    .nav-icon { font-size: 17px; width: auto; }
    .main-content { margin-left: 62px; }
    .content-area { padding: 16px; }
    .topbar { padding: 0 16px; }
    .form-grid { grid-template-columns: 1fr; }
    .topbar-badge { display: none; }
}

/* ═══════════════════════════════════════════════════════════
   CMR DOCUMENT — HTML 1:1 z PDF (CmrPdfService.java)
   Sekcje A-G z tymi samymi proporcjami co PDF:
   A=6% B=9% C=56% D=6% E=5% F=13% G=1%
   Podział kolumn: lewa 45% / prawa 55%
   ═══════════════════════════════════════════════════════════ */

.cmr-wrapper { overflow-x: hidden; width: 100%; }

/* Kontener A4 */
.cmr-document {
    width: 210mm;
    min-height: 297mm;
    background: #fff;
    border: 1.5px solid #000;
    font-family: Helvetica, Arial, sans-serif;
    font-size: 7px;
    color: #000;
    box-shadow: 0 4px 24px rgba(0,0,0,0.13);
    position: relative;
    overflow: hidden;
    transform-origin: top left;
}

/* Znak wodny — identyczny jak w PDF (45°, kolor rgba(200,0,0,0.055)) */
.cmr-wm {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) rotate(45deg);
    font-size: 38pt;
    font-weight: 900;
    color: rgba(200, 0, 0, 0.055);
    pointer-events: none;
    white-space: nowrap;
    z-index: 10;
    user-select: none;
}

/* Główna strona z marginesami (7mm ≈ 20pt) */
.cmr-page {
    padding: 7mm;
    box-sizing: border-box;
    min-height: 297mm;
    display: flex;
    flex-direction: column;
    font-family: Helvetica, Arial, sans-serif;
}

/* ── Wspólne ── */
/* Mała szara etykieta pola (5.3pt w PDF) */
.p-lbl {
    font-size: 6.5px;
    color: #505050;
    line-height: 1.3;
    padding: 1px 2px 0;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

/* Input/textarea wtopiony w druk */
.p-inp {
    border: none;
    background: transparent;
    font-family: Helvetica, Arial, sans-serif;
    font-size: 10px;
    color: #000;
    width: 100%;
    padding: 1px 2px;
    outline: none;
    resize: none;
    text-align: center;
    box-sizing: border-box;
    display: block;
    flex: 1;
    min-height: 0;
}
.p-inp:focus { background: rgba(26,60,110,0.03); }
textarea.p-inp { line-height: 1.4; }

/* Input daty — wyrównanie do lewej, mniejsza czcionka */
.p-inp-date {
    text-align: left;
    font-size: 8.5px;
    flex: 0 0 auto;
    min-height: 0;
    height: auto;
}

/* ════════════════════════════════════════════
   SEKCJA A — NAGŁÓWEK (6% = 17mm)
   ════════════════════════════════════════════ */
.cA {
    height: 17mm;
    border-bottom: 0.7px solid #000;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
}

/* A-R1: wiersz z etykietą kopii (25% × 17mm = 4.25mm) */
.cA-r1 {
    display: flex;
    height: 25%;
    border-bottom: 0.5px solid #000;
    flex-shrink: 0;
}
.cA-r1-left { flex: 1; }
.cA-r1-copy {
    width: 37%;
    border-left: 0.5px solid #000;
    font-size: 9px;
    font-weight: 900;
    color: #8c0000;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0 3px;
}

/* A-R2: tytuł po polsku (38% × 17mm = 6.5mm) */
.cA-r2 {
    height: 38%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 900;
    color: #000;
    letter-spacing: 0.2px;
    border-bottom: 0.5px solid #000;
    flex-shrink: 0;
    text-align: center;
    padding: 0 4px;
}

/* A-R3: wielojęzyczny tekst + Nr CMR (37% = ~6.3mm) */
.cA-r3 {
    flex: 1;
    display: flex;
    align-items: stretch;
    overflow: hidden;
}
.cA-r3-lang {
    flex: 1;
    padding: 1px 3px;
    font-size: 6.5px;
    color: #505050;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.cA-r3-nr {
    width: 28%;
    border-left: 0.5px solid #000;
    padding: 2px 3px;
    font-size: 6.5px;
    color: #505050;
}

/* ════════════════════════════════════════════
   SEKCJA B — BLOK GÓRNY (9% = 25.5mm)
   Lewa 45%: pola 1-5 | Prawa 55%: pola 16-18
   ════════════════════════════════════════════ */
.cB {
    height: 25.5mm;
    border-bottom: 0.7px solid #000;
    display: flex;
    flex-shrink: 0;
    overflow: hidden;
}

.cB-L {
    width: 45%;
    border-right: 0.7px solid #000;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}
.cB-R {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

/* Pola lewej kolumny B (wysokości z PDF) */
.cB-f1  { flex: 0 0 27.4%; border-bottom: 0.5px solid #000; display: flex; flex-direction: column; overflow: hidden; padding: 1px 2px; }
.cB-f2  { flex: 0 0 27.4%; border-bottom: 0.5px solid #000; display: flex; flex-direction: column; overflow: hidden; padding: 1px 2px; }
.cB-f3  { flex: 0 0 17.2%; border-bottom: 0.5px solid #000; display: flex; flex-direction: column; overflow: hidden; padding: 1px 2px; }
.cB-f4  { flex: 0 0 14.8%; border-bottom: 0.5px solid #000; display: flex; flex-direction: column; overflow: hidden; padding: 1px 2px; }
.cB-f5  { flex: 0 0 13.2%; display: flex; flex-direction: column; overflow: hidden; padding: 1px 2px; }

/* Pola prawej kolumny B (3 równe) */
.cB-f16 { flex: 0 0 33.33%; border-bottom: 0.5px solid #000; display: flex; flex-direction: column; overflow: hidden; padding: 1px 2px; }
.cB-f17 { flex: 0 0 33.33%; border-bottom: 0.5px solid #000; display: flex; flex-direction: column; overflow: hidden; padding: 1px 2px; }
.cB-f18 { flex: 0 0 33.34%; display: flex; flex-direction: column; overflow: hidden; padding: 1px 2px; }

/* ════════════════════════════════════════════
   SEKCJA C — TABELA TOWARÓW (56% ≈ 158.5mm)
   Nagłówek 6.35mm | 5 wierszy danych 28.9mm | ADR 7.76mm
   Kolumny: 15|9|12|34|10|10|10 %
   ════════════════════════════════════════════ */
.cC {
    border-bottom: 0.7px solid #000;
    flex-shrink: 0;
}

.cC-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

/* Nagłówek kolumn */
.cC-table thead tr.cC-hdr th {
    border-right: 0.5px solid #000;
    border-bottom: 0.5px solid #000;
    border-top: none;
    border-left: none;
    font-size: 6.5px;
    font-weight: bold;
    text-align: center;
    vertical-align: middle;
    padding: 1px 2px;
    height: 6.35mm;
    background: #fff;
    line-height: 1.25;
    color: #000;
}
.cC-table thead tr.cC-hdr th:last-child { border-right: none; }

/* Wiersze danych */
.cC-table tbody td {
    border-right: 0.5px solid #000;
    border-bottom: 0.5px solid #000;
    border-left: none;
    height: 28.9mm;
    vertical-align: top;
    padding: 2px;
}
.cC-table tbody td:last-child { border-right: none; }

/* Wiersz ADR (4 równe sekcje) */
.cC-table tfoot tr.cC-adr td {
    border: none;
    height: 7.76mm;
    padding: 0;
    vertical-align: middle;
}

.cC-adr-inner {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    height: 7.76mm;
}
.cC-adr-inner > div {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 6.5px;
    color: #505050;
    text-align: center;
    padding: 1px;
}
.cC-adr-inner > div + div { border-left: 0.5px solid #000; }

/* ════════════════════════════════════════════
   SEKCJA D — BLOK ŚRODKOWY (6% = 17mm)
   Lewa 45%: 13 (64.8%) + 14 (35.2%)
   Prawa 55%: 19 (64.8%) + 20 (35.2%)
   ════════════════════════════════════════════ */
.cD {
    height: 17mm;
    border-bottom: 0.7px solid #000;
    display: flex;
    flex-shrink: 0;
    overflow: hidden;
}

.cD-L {
    width: 45%;
    border-right: 0.7px solid #000;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}
.cD-R {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.cD-f13 { flex: 0 0 64.8%; border-bottom: 0.5px solid #000; display: flex; flex-direction: column; overflow: hidden; padding: 1px 2px; }
.cD-f14 { flex: 0 0 35.2%; display: flex; flex-direction: column; overflow: hidden; padding: 1px 2px; }
.cD-f19 { flex: 0 0 64.8%; border-bottom: 0.5px solid #000; display: flex; flex-direction: column; overflow: hidden; padding: 1px 2px; }
.cD-f20 { flex: 0 0 35.2%; display: flex; flex-direction: column; overflow: hidden; padding: 1px 2px; }

/* ════════════════════════════════════════════
   SEKCJA E — PŁATNOŚCI (5% = 14mm)
   4 kolumny: 33|22|22|23%, nagłówek + 4 wiersze
   ════════════════════════════════════════════ */
.cE {
    border-bottom: 0.7px solid #000;
    flex-shrink: 0;
}

.cE-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}
.cE-table th {
    border-right: 0.5px solid #000;
    border-bottom: 0.5px solid #000;
    border-top: none;
    border-left: none;
    font-size: 6.5px;
    font-weight: 700;
    color: #505050;
    height: 4.5mm;
    vertical-align: middle;
    padding: 0 3px;
    text-align: left;
    background: #fff;
}
.cE-table th:last-child { border-right: none; }

.cE-table td {
    border-right: 0.5px solid #000;
    border-bottom: 0.5px solid #000;
    border-left: none;
    height: 3.8mm;
    vertical-align: middle;
    font-size: 6.5px;
    color: #505050;
    padding: 0 3px;
}
.cE-table td:last-child  { border-right: none; }
.cE-table tr:last-child td { border-bottom: none; }

/* ════════════════════════════════════════════
   SEKCJA F — PODPISY (13% = 36.8mm)
   Górna 28.5% (10.5mm): pole 21 (lewa 50%) + puste (prawa 50%)
   Dolna 71.5% (26.3mm): pola 22 | 23 | 24 (równe trzecie)
   ════════════════════════════════════════════ */
.cF {
    height: 36.8mm;
    border-bottom: 0.7px solid #000;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
}

.cF-top {
    height: 28.5%;
    border-bottom: 0.5px solid #000;
    display: flex;
    flex-shrink: 0;
    overflow: hidden;
}

.cF-f21 {
    width: 50%;
    border-right: 0.5px solid #000;
    display: flex;
    flex-direction: column;
    padding: 1px 2px;
    overflow: hidden;
}
.cF-f21-empty { flex: 1; }

.cF-sigs {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.cF-sig {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1px 3px;
    overflow: hidden;
}
.cF-sig + .cF-sig { border-left: 0.5px solid #000; }

.cF-sig-space { flex: 1; min-height: 0; }

.cF-sig-foot {
    font-size: 6.5px;
    color: #505050;
    text-align: center;
    margin-top: 2px;
    flex-shrink: 0;
    line-height: 1.3;
}

/* ════════════════════════════════════════════
   SEKCJA G — NOTA PRAWNA (1%)
   ════════════════════════════════════════════ */
.cG {
    font-size: 6px;
    color: #505050;
    text-align: center;
    padding: 2px 4px;
    line-height: 1.4;
    flex-shrink: 0;
}

/* ── Pasek akcji ── */
.cmr-form-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 0 4px;
    width: 210mm;
    margin: 0 auto;
}

/* ── Druk ── */
@media print {
    body { background: white !important; }
    .sidebar, .topbar, .cmr-form-actions { display: none !important; }
    .app-shell { display: block !important; }
    .main-content { margin-left: 0 !important; display: block !important; }
    .content-area { padding: 0 !important; background: white !important; }
    .cmr-wrapper { overflow: visible !important; height: auto !important; }
    .cmr-document { box-shadow: none !important; margin: 0 !important; width: 210mm !important; min-height: 297mm !important; transform: none !important; border: 1.5px solid #000 !important; page-break-inside: avoid; }
    .cmr-wm { opacity: 0.06 !important; }
}

/* ═══════════════════════════════════════════════════════════════════════
   CMR GENERATOR — NOWY UKŁAD (klasy .gen-* / .gf-* / .cmr-plate)
   Dodano jako osobna sekcja — nie modyfikuje klas globalnych ani
   starych reguł CMR powyżej.
   Widok generatora (cmr.html) używa wyłącznie klas poniżej.
   ═══════════════════════════════════════════════════════════════════════ */

.gen-area {
    padding: 28px 32px !important;
    background: #f0f2f6;
}

.gen-title {
    text-align: center;
    font-size: 30px;
    font-weight: 800;
    color: #131f35;
    letter-spacing: 0.3px;
    margin: 4px auto 22px;
    padding: 4px 0 14px;
    line-height: 1.1;
    border-bottom: none;
}

.gen-wrap {
    max-width: 1180px;
    margin: 0 auto;
    display: block;
}

/* ─── Główna plansza CMR ─── */
.cmr-plate {
    background: #fff;
    border: 1.3px solid #c62828;
    width: 100%;
    color: #000;
    font-family: Helvetica, Arial, sans-serif;
    font-size: 12px;
    line-height: 1.3;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* Znak wodny */
.gf-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(45deg);
    font-size: 80px;
    font-weight: 900;
    color: rgba(200, 0, 0, 0.055);
    pointer-events: none;
    white-space: nowrap;
    z-index: 0;
    user-select: none;
    letter-spacing: 6px;
}
.cmr-plate { position: relative; overflow: hidden; }
.cmr-plate > *:not(.gf-watermark) { position: relative; z-index: 1; }

.gf-row { display: flex; align-items: stretch; }
.gf-row + .gf-row { border-top: 1.3px solid #c62828; }
.gf-goods + .gf-row { border-top: 1.3px solid #c62828; }
.gf-row + .gf-goods { border-top: 1.3px solid #c62828; }

.gf-col {
    display: flex;
    flex-direction: column;
    flex: 1 1 50%;
    min-width: 0;
}
.gf-col + .gf-col { border-left: 1.3px solid #c62828; }

/* ─── Sekcja z numerem w rogu ─── */
.gf-sec {
    position: relative;
    padding: 16px 10px 8px 26px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 52px;
    flex: 1;
}
.gf-sec + .gf-sec { border-top: 1px solid #c62828; }

.gf-num {
    position: absolute;
    top: 4px;
    left: 6px;
    font-weight: 800;
    color: #c62828;
    font-size: 12px;
    width: 18px;
    text-align: center;
}

.gf-lbl {
    display: block;
    color: #555;
    font-size: 10px;
    line-height: 1.3;
    margin-bottom: 3px;
    font-weight: 500;
}
.gf-lbl em {
    color: #8a94a6;
    font-style: italic;
    font-size: 9.5px;
}

.gf-sec input,
.gf-sec textarea,
.gf-pay-input,
.gf-hdr-no-input {
    width: 100%;
    border: none;
    background: transparent;
    font-family: Helvetica, Arial, sans-serif;
    font-size: 14px;
    color: #111;
    padding: 2px 4px;
    resize: none;
    outline: none;
}
.gf-sec textarea {
    flex: 1;
    min-height: 32px;
    line-height: 1.35;
}
.gf-sec input {
    border-bottom: 1px dotted #d7a8a8;
    padding-bottom: 3px;
}
.gf-sec input:focus,
.gf-sec textarea:focus,
.gf-pay-input:focus,
.gf-hdr-no-input:focus {
    background: rgba(198, 40, 40, 0.05);
    border-color: #c62828;
}

/* ─── Wysokości sekcji ─── */
.gf-row-top { min-height: 378px; }
.gf-row-top .gf-col-left .gf-sec-tall { flex: 0 0 28%; }
.gf-row-top .gf-col-left .gf-sec:not(.gf-sec-tall):not(.gf-sec-short) { flex: 0 0 17%; }
.gf-row-top .gf-col-left .gf-sec-short { flex: 0 0 10%; }

.gf-row-top .gf-col-right .gf-hdr { flex: 0 0 120px; }
.gf-row-top .gf-col-right .gf-sec-tall { flex: 1 1 0; min-height: 80px; }

.gf-row-mid1 { min-height: 120px; }
.gf-row-mid2 { min-height: 190px; }
.gf-row-mid3 { min-height: 44px; }
.gf-row-sigs { min-height: 130px; }

.gf-sec-grow { flex: 1 1 auto; min-height: 100%; }
.gf-sec-short { min-height: 44px; }

/* ─── Nagłówek urzędowy CMR (prawa kolumna, góra) ─── */
.gf-hdr {
    position: relative;
    padding: 8px 12px 8px 12px;
    border-bottom: 1px solid #c62828;
    display: flex;
    flex-direction: column;
    background: #fff;
}
.gf-hdr-titles {
    text-align: left;
    margin-bottom: 6px;
}
.gf-hdr-pl {
    font-size: 11.5px;
    font-weight: 800;
    color: #000;
    letter-spacing: 0.2px;
    line-height: 1.2;
}
.gf-hdr-en {
    font-size: 10.5px;
    font-weight: 700;
    color: #333;
    font-style: italic;
    margin-top: 2px;
    line-height: 1.2;
}
.gf-hdr-body {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    flex: 1;
}
.gf-hdr-legal {
    flex: 1;
    font-size: 9px;
    color: #555;
    line-height: 1.35;
}
.gf-hdr-legal em {
    display: block;
    margin-top: 2px;
    color: #8a94a6;
    font-size: 8.5px;
    font-style: italic;
}
.gf-hdr-sign {
    display: flex;
    align-items: center;
    gap: 8px;
    align-self: center;
    flex-shrink: 0;
}
.gf-hdr-oval {
    border: 1.4px solid #000;
    border-radius: 50%;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.5px;
    min-width: 38px;
    text-align: center;
    background: #fff;
}
.gf-hdr-no {
    display: flex;
    align-items: center;
    gap: 4px;
}
.gf-hdr-no-sym {
    font-size: 20px;
    font-weight: 900;
    color: #000;
    line-height: 1;
}
.gf-hdr-no-input {
    width: 72px;
    border-bottom: 1px dotted #c62828 !important;
    font-size: 14px;
    font-weight: 600;
    padding: 1px 3px;
}

/* ─── Tabela towarów (6–12) ─── */
.gf-goods {
    background: #fff;
}
.gf-goods-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 11px;
}
.gf-goods-table th,
.gf-goods-table td {
    border-right: 1px solid #c62828;
    border-bottom: 1px solid #c62828;
    padding: 0;
    vertical-align: top;
    background: #fff;
}
.gf-goods-table th:last-child,
.gf-goods-table td:last-child { border-right: none; }

.gf-goods-table thead th {
    text-align: left;
    font-weight: 500;
    color: #333;
    font-size: 10px;
    line-height: 1.25;
    padding: 6px 8px;
    height: 44px;
    background: #fff;
    vertical-align: top;
}
.gf-goods-table thead th b {
    color: #c62828;
    font-weight: 800;
    margin-right: 5px;
    font-size: 12px;
}
.gf-goods-table thead th em {
    color: #8a94a6;
    font-style: italic;
    font-size: 9.5px;
}

.gf-goods-table tbody td {
    height: 34px;
}
.gf-goods-table tbody input {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
    padding: 4px 8px;
    font-family: Helvetica, Arial, sans-serif;
    font-size: 13px;
    color: #111;
    outline: none;
}
.gf-goods-table tbody input:focus {
    background: rgba(198, 40, 40, 0.05);
}
.gf-goods-table tbody tr:last-child td { border-bottom: none; }

/* ADR — wiersz pod tabelą, wewnątrz tej samej sekcji wizualnej */
.gf-adr {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1.6fr;
    border-top: 1px solid #c62828;
    font-size: 10.5px;
    background: #fff;
}
.gf-adr > div {
    padding: 6px 10px;
    min-height: 34px;
    display: flex;
    align-items: baseline;
    gap: 6px;
}
.gf-adr > div + div { border-left: 1px solid #c62828; }
.gf-adr-lbl {
    color: #c62828;
    font-weight: 800;
    font-size: 11px;
    display: inline-block;
}
.gf-adr em {
    color: #8a94a6;
    font-style: italic;
    font-size: 9.5px;
}

/* ─── Sekcja 14 podsekcja (Przewoźne zapł./nieopł.) ─── */
.gf-sec-sub {
    margin-top: 8px;
    border-top: 1px dashed #d7a8a8;
    padding-top: 6px;
    font-size: 10.5px;
    color: #333;
    line-height: 1.5;
}
.gf-sec-sub-row {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}
.gf-sec-sub-row span { font-weight: 600; }
.gf-sec-sub-row em { color: #8a94a6; font-style: italic; font-size: 9.5px; }

/* ─── Sekcja 20 — tabela płatności ─── */
.gf-col-pay {
    padding: 0;
}
.gf-pay-head {
    position: relative;
    padding: 6px 10px 4px 26px;
    border-bottom: 1px solid #c62828;
    background: #fff;
}
.gf-num-pay {
    top: 6px;
    left: 6px;
}
.gf-lbl-pay { margin: 0; }

.gf-pay-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 10.5px;
}
.gf-pay-table th,
.gf-pay-table td {
    border-right: 1px solid #c62828;
    border-bottom: 1px solid #c62828;
    padding: 3px 6px;
    vertical-align: middle;
    height: 22px;
    background: #fff;
}
.gf-pay-table th:last-child,
.gf-pay-table td:last-child { border-right: none; }
.gf-pay-table tr:last-child td { border-bottom: none; }

.gf-pay-table thead th {
    color: #c62828;
    font-weight: 700;
    font-size: 9.5px;
    text-align: center;
    line-height: 1.2;
    background: #fff;
}
.gf-pay-table thead th em {
    color: #8a94a6;
    font-style: italic;
    font-size: 8.5px;
    display: block;
}

.gf-pay-lbl {
    color: #333;
    font-size: 10px;
    width: 34%;
    text-align: left;
}
.gf-pay-lbl em {
    color: #8a94a6;
    font-style: italic;
    font-size: 9px;
}
.gf-pay-total {
    font-weight: 700;
    background: rgba(198, 40, 40, 0.03) !important;
}

.gf-pay-input {
    padding: 3px 6px !important;
    font-weight: 600;
    font-size: 13px;
}

/* ─── Sekcje podpisów (22, 23, 24) ─── */
.gf-col-sig { flex: 1 1 33.333%; }

.gf-sec-sig {
    padding: 16px 12px 6px 26px;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 130px;
}
.gf-lbl-sig {
    font-size: 9.5px;
    line-height: 1.4;
}
.gf-sig-area {
    flex: 1;
    border-bottom: 1px dashed #d7a8a8;
    margin: 4px 0 4px;
    min-height: 54px;
    display: flex;
    align-items: flex-end;
}
.gf-sig-area input {
    width: 100%;
    border: none !important;
    background: transparent;
    padding: 4px;
    outline: none;
    font-family: inherit;
    font-size: 13px;
}
.gf-sig-foot {
    font-size: 9.5px;
    color: #555;
    text-align: center;
    padding: 4px 2px 2px;
    line-height: 1.35;
}
.gf-sig-foot em {
    color: #8a94a6;
    font-style: italic;
    font-size: 9px;
}

/* ─── Stopka i submit ─── */
.gen-footnote {
    max-width: 1180px;
    margin: 8px auto 0;
    padding: 6px 4px 0;
    font-size: 10px;
    color: #8a94a6;
    text-align: left;
    line-height: 1.4;
}

.gen-options-row {
    display: flex;
    align-items: center;
    gap: 24px;
    margin: 12px 0 0;
    flex-wrap: wrap;
}
.gen-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #333;
    cursor: pointer;
    text-transform: none;
    letter-spacing: 0;
}
.gen-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.gen-submit-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin: 16px 0 0;
    flex-wrap: wrap;
}
.gen-btn-save {
    background: linear-gradient(135deg, #c62828 0%, #a31f1f 100%);
    color: #fff;
    border: none;
    padding: 12px 34px;
    font-size: 15px;
    font-weight: 700;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(198, 40, 40, 0.32);
    letter-spacing: 0.3px;
    transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
    font-family: inherit;
}
.gen-btn-save:hover {
    background: linear-gradient(135deg, #a31f1f 0%, #7d1414 100%);
    box-shadow: 0 5px 14px rgba(198, 40, 40, 0.4);
    transform: translateY(-1px);
}
.gen-btn-save:active { transform: translateY(0); }
.gen-btn-cancel {
    display: inline-block;
    background: transparent;
    color: #5a6473;
    text-decoration: none;
    padding: 11px 22px;
    font-size: 14px;
    font-weight: 600;
    border: 1.5px solid #c8cdd6;
    border-radius: 6px;
    transition: background 0.15s, border-color 0.15s;
}
.gen-btn-cancel:hover { background: #eef1f5; border-color: #9aa2ae; }

.gen-status {
    font-size: 13px;
    font-weight: 600;
    color: #5a6473;
    margin-left: 4px;
}
.gen-status.success { color: #2e7d32; }
.gen-status.error   { color: #c62828; }

/* ─── Responsywność (desktop-first; tablety/mobile skalowane) ─── */
@media (max-width: 1140px) {
    .gen-area { padding: 18px 18px 30px !important; }
    .gen-title { font-size: 26px; }
    .cmr-plate { font-size: 11px; }
    .gf-row-top { min-height: 340px; }
    .gf-row-mid2 { min-height: 180px; }
}

@media (max-width: 900px) {
    .gen-title { font-size: 22px; }
    .gf-row { flex-direction: column; }
    .gf-col + .gf-col { border-left: none; border-top: 1.3px solid #c62828; }
    .gf-row-top { min-height: 0; }
    .gf-row-sigs { flex-direction: row; }
    .gf-row-sigs .gf-col + .gf-col { border-left: 1.3px solid #c62828; border-top: none; }
    .gf-hdr-body { flex-direction: column; gap: 8px; }
    .gf-hdr-sign { align-self: flex-start; }
}

@media (max-width: 640px) {
    .gen-area { padding: 10px 8px 24px !important; }
    .gen-title { font-size: 19px; }
    .gf-row-sigs { flex-direction: column; }
    .gf-row-sigs .gf-col + .gf-col { border-left: none; border-top: 1.3px solid #c62828; }
    .gf-goods-table thead th { font-size: 9px; }
    .gen-btn-save { padding: 11px 24px; font-size: 14px; }
}

/* ─── Druk generatora ─── */
@media print {
    .gen-area { background: #fff !important; padding: 0 !important; }
    .gen-title { display: none; }
    .gen-submit-row, .gen-btn-save, .gen-btn-cancel, .gen-footnote { display: none !important; }
    .cmr-plate {
        box-shadow: none !important;
        border-color: #000 !important;
        page-break-inside: avoid;
    }
    .gf-row, .gf-row + .gf-row, .gf-col + .gf-col,
    .gf-sec + .gf-sec, .gf-goods-table th, .gf-goods-table td,
    .gf-adr > div + div, .gf-pay-table th, .gf-pay-table td,
    .gf-hdr, .gf-pay-head { border-color: #000 !important; }
    .gf-num, .gf-adr-lbl, .gf-goods-table thead th b,
    .gf-pay-table thead th { color: #000 !important; }
}

/* ===== Sidebar widget: zegar + kalendarz ===== */
.sidebar-widget {
    margin: 14px 14px 10px;
    margin-top: auto;
    padding: 12px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 10px;
    color: rgba(255,255,255,0.75);
}
.sw-clock {
    text-align: center;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    margin-bottom: 10px;
}
.sw-time {
    font-family: 'SF Mono', Consolas, 'Courier New', monospace;
    font-size: 22px;
    font-weight: 600;
    color: #fff;
    letter-spacing: 1.5px;
    line-height: 1.1;
}
.sw-date {
    font-size: 10.5px;
    color: rgba(255,255,255,0.45);
    margin-top: 3px;
}
.sw-cal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}
.sw-cal-title {
    font-size: 11px;
    font-weight: 600;
    color: rgba(255,255,255,0.75);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}
.sw-cal-nav {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.6);
    width: 22px;
    height: 22px;
    line-height: 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    padding: 0;
}
.sw-cal-nav:hover {
    background: rgba(255,255,255,0.07);
    color: #fff;
    border-color: rgba(90,171,255,0.35);
}
.sw-cal-dow {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    font-size: 9px;
    font-weight: 700;
    color: rgba(255,255,255,0.3);
    text-align: center;
    text-transform: uppercase;
    margin-bottom: 3px;
}
.sw-cal-dow .sw-sun { color: rgba(239,83,80,0.55); }
.sw-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}
.sw-cal-day, .sw-cal-blank {
    font-size: 10.5px;
    text-align: center;
    padding: 4px 0;
    border-radius: 3px;
    color: rgba(255,255,255,0.8);
}
.sw-cal-day { cursor: default; }
.sw-cal-blank { visibility: hidden; }
.sw-cal-weekend { color: rgba(255,255,255,0.4); }
.sw-cal-holiday {
    background: rgba(239,83,80,0.18);
    color: #ff9d99;
    font-weight: 600;
}
.sw-cal-today {
    outline: 1.5px solid #5aabff;
    color: #fff;
    font-weight: 700;
}
.sw-cal-holiday.sw-cal-today { outline-color: #ff9d99; }

@media (max-width: 768px) {
    .sidebar-widget { display: none; }
}
