/* =============================================================================
   OTMS — _arkusz.css : tabela "Excel" ładunków
   Arkusz reużywany w 3 miejscach: /loads, /routes/board, /routes/{id}
   ============================================================================= */

.arkusz-wrap {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    position: relative;
}

.arkusz-scroll {
    overflow-x: auto;
    max-width: 100%;
}

.arkusz {
    width: 100%;
    min-width: 1400px;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 12.5px;
}

/* ===== NAGŁÓWEK KOLUMN ===== */
.arkusz thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: linear-gradient(180deg, var(--brand-navy), #0a1830);
    color: #cbd5e1;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: 10px 8px;
    text-align: left;
    border-right: 1px solid rgba(255, 255, 255, .04);
    white-space: nowrap;
    user-select: none;
}
.arkusz thead th:last-child { border-right: none; }

/* Sticky pierwsze 2 kolumny (zleceniodawca, nr zlecenia) */
.arkusz thead th.col-sticky,
.arkusz tbody td.col-sticky {
    position: sticky;
    left: 0;
    z-index: 4;
    background: var(--card);
}
.arkusz thead th.col-sticky {
    background: linear-gradient(180deg, var(--brand-navy), #0a1830);
    z-index: 6;
}
.arkusz thead th.col-sticky-2,
.arkusz tbody td.col-sticky-2 {
    position: sticky;
    left: 140px;
    z-index: 4;
    background: var(--card);
    box-shadow: 2px 0 4px rgba(0, 0, 0, .04);
}
.arkusz thead th.col-sticky-2 {
    background: linear-gradient(180deg, var(--brand-navy), #0a1830);
    z-index: 6;
}

/* ===== BELKA GRUPUJĄCA (route header lub direction header) ===== */
.arkusz tr.ark-group-head td {
    background: linear-gradient(135deg, var(--st-info-bg), color-mix(in srgb, var(--st-info-bg) 70%, var(--card)));
    padding: 10px 14px;
    border-top: 2px solid var(--st-info-border);
    border-bottom: 2px solid var(--st-info-border);
    font-size: 12.5px;
    font-weight: 700;
    color: var(--st-info);
}
.arkusz tr.ark-group-head.export td  { background: linear-gradient(135deg, var(--st-success-bg), color-mix(in srgb, var(--st-success-bg) 70%, var(--card))); border-color: var(--st-success-border); color: var(--st-success); }
.arkusz tr.ark-group-head.import td  { background: linear-gradient(135deg, var(--st-info-bg), color-mix(in srgb, var(--st-info-bg) 70%, var(--card))); border-color: var(--st-info-border); color: var(--st-info); }
.arkusz tr.ark-group-head.transfer td{ background: linear-gradient(135deg, var(--st-warning-bg), color-mix(in srgb, var(--st-warning-bg) 70%, var(--card))); border-color: var(--st-warning-border); color: #b45309; }
.arkusz tr.ark-group-head.route td   { background: linear-gradient(135deg, color-mix(in srgb, var(--brand-blue) 14%, transparent), color-mix(in srgb, var(--brand-blue) 6%, var(--card))); border-color: var(--brand-blue); color: var(--brand-blue-dark); }

.arkusz .ark-group-title {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
}
.arkusz .ark-group-title .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 20%, transparent);
}
.arkusz .ark-group-summary {
    margin-left: 14px;
    font-size: 11.5px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: none;
    letter-spacing: 0;
}
.arkusz .ark-group-toggle {
    background: transparent;
    border: none;
    cursor: pointer;
    color: inherit;
    padding: 2px;
    transition: transform var(--t);
}
.arkusz tr.ark-group-head.collapsed .ark-group-toggle {
    transform: rotate(-90deg);
}

/* ===== WIERSZE ŁADUNKÓW ===== */
.arkusz tbody td {
    padding: 8px 8px;
    border-bottom: 1px solid var(--line);
    border-right: 1px solid var(--line);
    color: var(--text);
    vertical-align: middle;
    line-height: 1.4;
    background: var(--card);
    transition: background var(--t-fast);
}
.arkusz tbody tr:hover td:not(.col-sticky):not(.col-sticky-2) {
    background: var(--card-hover);
}
.arkusz tbody tr:hover td.col-sticky,
.arkusz tbody tr:hover td.col-sticky-2 {
    background: color-mix(in srgb, var(--brand-blue) 4%, var(--card));
}

.arkusz tbody td:last-child { border-right: none; }

/* Wiersz problemu - jaskrawo czerwony pasek z lewej */
.arkusz tbody tr.row-problem td.col-sticky {
    border-left: 3px solid var(--st-danger);
}
.arkusz tbody tr.row-problem td {
    background: linear-gradient(90deg, color-mix(in srgb, var(--st-danger) 5%, var(--card)) 0%, var(--card) 30%);
}
.arkusz tbody tr.row-completed td {
    background: linear-gradient(90deg, color-mix(in srgb, var(--st-success) 4%, var(--card)) 0%, var(--card) 30%);
}
.arkusz tbody tr.row-draft td {
    opacity: .75;
    font-style: italic;
}

/* ===== KOMÓRKI SPECJALNE ===== */

/* Zleceniodawca z badge firmy własnej */
.ark-client {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 120px;
}
.ark-client-name {
    font-weight: 700;
    font-size: 12.5px;
    color: var(--text);
}
.ark-client-meta {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}
.ark-company-letter {
    background: var(--c, var(--brand-blue));
    color: #fff;
    width: 18px;
    height: 18px;
    border-radius: var(--r-xs);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 800;
    font-family: var(--font-mono);
    text-transform: uppercase;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .15);
}
.ark-broker-letter {
    background: var(--st-customs);
    color: #fff;
    width: 18px;
    height: 18px;
    border-radius: var(--r-xs);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 800;
    font-family: var(--font-mono);
    text-transform: uppercase;
    box-shadow: 0 1px 2px rgba(124, 58, 237, .3);
}

/* Numer zlecenia */
.ark-order-no {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 12px;
    color: var(--text);
    letter-spacing: -.01em;
}
.ark-order-no-internal {
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 2px;
}

/* Daty (klikalna komórka realizacji) */
.ark-date-cell {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 80px;
}
.ark-date {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 12px;
    padding: 3px 6px;
    border-radius: var(--r-xs);
    background: var(--bg);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all var(--t-fast);
    white-space: nowrap;
}
.ark-date:hover {
    border-color: var(--brand-blue);
    color: var(--brand-blue);
}
.ark-date.done {
    background: var(--st-success-bg);
    border-color: var(--st-success);
    color: var(--st-success);
}
.ark-date.fix {
    background: var(--st-danger-bg);
    border-color: var(--st-danger);
    color: var(--st-danger);
}
.ark-date.problem {
    background: var(--st-danger);
    border-color: var(--st-danger);
    color: #fff;
    animation: pulseRed 2s infinite;
}
.ark-date-time {
    font-size: 10.5px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

@keyframes pulseRed {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, .4); }
    50%      { box-shadow: 0 0 0 4px rgba(220, 38, 38, 0); }
}

.ark-checkbox-mini {
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--border-strong);
    border-radius: var(--r-xs);
    cursor: pointer;
    background: var(--card);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--t-fast);
}
.ark-checkbox-mini:hover {
    border-color: var(--brand-blue);
}
.ark-checkbox-mini.checked {
    background: var(--st-success);
    border-color: var(--st-success);
    color: #fff;
}

/* Miejsce zał./rozł. */
.ark-place {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 140px;
}
.ark-place-line1 {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 500;
}
.ark-place-postal {
    font-family: var(--font-mono);
    color: var(--text-muted);
    font-size: 11px;
}
.ark-place-city {
    color: var(--text);
}

/* Odprawa - fioletowa pigułka */
.ark-customs-cell {
    padding: 4px 8px;
    border-radius: var(--r-xs);
    font-size: 11px;
    font-weight: 700;
    font-family: var(--font-mono);
    background: var(--st-customs-bg);
    color: var(--st-customs);
    border: 1px solid var(--st-customs-border);
    text-align: center;
    cursor: pointer;
    transition: all var(--t-fast);
}
.ark-customs-cell:hover {
    background: color-mix(in srgb, var(--st-customs) 20%, transparent);
}
.ark-customs-cell.done {
    background: var(--st-success-bg);
    color: var(--st-success);
    border-color: var(--st-success);
}

/* Waga / LDM z kolorowaniem stosunku */
.ark-weight {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 12.5px;
    padding: 3px 8px;
    border-radius: var(--r-xs);
    text-align: right;
}
.ark-weight.wl-green  { background: var(--st-success-bg); color: var(--st-success); }
.ark-weight.wl-yellow { background: var(--st-warning-bg); color: var(--st-warning); }
.ark-weight.wl-red    { background: var(--st-danger-bg);  color: var(--st-danger); }

/* Dokumenty - przyciski-pigułki */
.ark-docs {
    display: inline-flex;
    gap: 3px;
    flex-wrap: wrap;
}
.ark-doc-pill {
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 9.5px;
    font-weight: 800;
    font-family: var(--font-mono);
    letter-spacing: .04em;
    cursor: pointer;
    transition: all var(--t-fast);
    border: 1px solid;
    text-transform: uppercase;
}
.ark-doc-pill.missing  { background: var(--st-danger-bg);  color: var(--st-danger);  border-color: var(--st-danger-border); }
.ark-doc-pill.entered  { background: var(--st-warning-bg); color: var(--st-warning); border-color: var(--st-warning-border); }
.ark-doc-pill.added    { background: var(--st-info-bg);    color: var(--st-info);    border-color: var(--st-info-border); }
.ark-doc-pill.confirmed{ background: var(--st-success-bg); color: var(--st-success); border-color: var(--st-success-border); }
.ark-doc-pill.na       { background: var(--st-neutral-bg); color: var(--st-neutral); border-color: var(--st-neutral-border); }
.ark-doc-pill:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 4px rgba(0, 0, 0, .08);
}

/* Kwota */
.ark-amount {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 13px;
    color: var(--text);
    text-align: right;
    white-space: nowrap;
}
.ark-amount-currency {
    font-size: 10.5px;
    color: var(--text-muted);
    font-weight: 600;
    margin-left: 2px;
}
.ark-amount-extra {
    font-size: 10px;
    color: var(--text-muted);
    text-align: right;
    margin-top: 2px;
}

/* ===== PODSUMOWANIE GRUPY ===== */
.arkusz tr.ark-group-foot td {
    background: var(--card-hover);
    border-top: 1px solid var(--border);
    padding: 8px 14px;
    font-size: 11.5px;
    color: var(--text-soft);
    font-weight: 600;
}
.ark-group-foot strong {
    color: var(--text);
    font-family: var(--font-mono);
}

/* ===== TOOLBAR ===== */
.arkusz-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.arkusz-toolbar .tabs { flex-shrink: 0; }
.arkusz-toolbar .search-mini {
    position: relative;
    width: 280px;
    max-width: 100%;
}
.arkusz-toolbar .search-mini input {
    padding-left: 32px;
}
.arkusz-toolbar .search-mini svg {
    position: absolute;
    left: 9px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}
.arkusz-toolbar .group-toggle {
    display: inline-flex;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    overflow: hidden;
}
.arkusz-toolbar .group-toggle a {
    padding: 6px 10px;
    color: var(--text-muted);
    font-size: 11.5px;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all var(--t);
}
.arkusz-toolbar .group-toggle a:hover {
    background: var(--card-hover);
    color: var(--text);
}
.arkusz-toolbar .group-toggle a.active {
    background: var(--brand-blue);
    color: #fff;
}

/* ===== KLIKALNY HEADER GRUPY (cały button) ===== */
.ark-group-header-btn {
    width: 100%;
    background: transparent;
    border: none;
    text-align: left;
    padding: 0;
    font: inherit;
    color: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Belka grupująca - kolorowanie przez --gc */
.arkusz tr.ark-group-head td {
    background: linear-gradient(135deg,
        color-mix(in srgb, var(--gc, var(--brand-blue)) 14%, var(--card)),
        color-mix(in srgb, var(--gc, var(--brand-blue)) 4%, var(--card))
    );
    padding: 9px 14px;
    border-top: 2px solid color-mix(in srgb, var(--gc, var(--brand-blue)) 35%, transparent);
    border-bottom: 2px solid color-mix(in srgb, var(--gc, var(--brand-blue)) 35%, transparent);
    font-size: 12px;
    font-weight: 700;
    color: var(--gc, var(--brand-blue));
}
.arkusz tr.ark-group-head .dot {
    width: 9px; height: 9px;
    border-radius: 50%;
    background: var(--gc, currentColor);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--gc) 20%, transparent);
}
.ark-group-title-text {
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 800;
    font-size: 11.5px;
}

/* ===== KOLUMNY DODATKOWE ===== */
.ark-place-line {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
}
.ark-place-line .ark-place-postal {
    font-family: var(--font-mono);
    color: var(--text-muted);
    font-size: 11px;
}
.ark-place-line .ark-place-city {
    color: var(--text);
    font-weight: 500;
}

.ark-customs-cell {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 6px;
    border-radius: var(--r-xs);
    background: var(--st-customs-bg);
    color: var(--st-customs);
    border: 1px solid var(--st-customs-border);
    font-size: 10.5px;
    font-weight: 700;
    font-family: var(--font-mono);
}
.ark-customs-cell.done {
    background: var(--st-success-bg);
    color: var(--st-success);
    border-color: var(--st-success);
}
.ark-customs-frac { letter-spacing: -.5px; }
.ark-customs-place {
    font-size: 11.5px;
    color: var(--text-soft);
    font-weight: 500;
}

.ark-cargo-summary {
    font-size: 11.5px;
    color: var(--text-soft);
    font-weight: 500;
}

.ark-extra-count {
    background: var(--st-info-bg);
    color: var(--st-info);
    padding: 1px 5px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 700;
    font-family: var(--font-mono);
}

.ark-notes {
    font-size: 11.5px;
    color: var(--text-soft);
    font-style: italic;
}

/* Dokumenty - dopasowanie do screenu */
.ark-doc-pill {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 9.5px;
    font-weight: 800;
    font-family: var(--font-mono);
    letter-spacing: .04em;
    cursor: pointer;
    transition: all var(--t-fast);
    border: 1px solid;
    text-transform: uppercase;
    line-height: 1.3;
}
.ark-doc-pill .ark-doc-num {
    font-size: 8.5px;
    opacity: .8;
    letter-spacing: 0;
    text-transform: none;
}

/* Data ze stanem */
.ark-date-cell {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.ark-date-cell > div {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.2;
}

/* Stickys */
.arkusz tr.ark-group-head td.col-sticky,
.arkusz tr.ark-group-head td.col-sticky-2 { 
    position: static;  /* belki grupujące mają colspan, więc nie sticky */
}

/* ============================================================
   ARKUSZ v3 — kompaktowo, akcje masowe, context menu
   ============================================================ */

/* Bulk action bar - pojawia się gdy zaznaczono ładunki */
.arkusz-bulk-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, var(--brand-blue), var(--brand-blue-dark));
    color: #fff;
    padding: 10px 16px;
    border-radius: var(--r);
    margin-bottom: 10px;
    box-shadow: 0 6px 20px rgba(37, 99, 235, .25);
    animation: slideInDown .25s ease-out;
    flex-wrap: wrap;
}
@keyframes slideInDown {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}
.arkusz-bulk-bar .arkusz-bulk-count {
    font-size: 13px;
    font-weight: 600;
}
.arkusz-bulk-bar .arkusz-bulk-sep {
    opacity: .4;
    margin: 0 2px;
}
.arkusz-bulk-bar .arkusz-bulk-spacer { flex: 1; }
.arkusz-bulk-bar .btn {
    background: rgba(255, 255, 255, .14);
    border-color: rgba(255, 255, 255, .25);
    color: #fff;
    box-shadow: none;
}
.arkusz-bulk-bar .btn:hover {
    background: rgba(255, 255, 255, .25);
    color: #fff;
    transform: none;
}
.arkusz-bulk-bar .btn-danger {
    background: rgba(239, 68, 68, .9);
    border-color: rgba(255, 255, 255, .3);
}
.arkusz-bulk-bar .btn-ghost {
    background: transparent;
    border-color: transparent;
    color: rgba(255, 255, 255, .8);
}

/* Scalone kolumna Zleceniodawca + Nr Zlecenia */
.ark-client-merged {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 180px;
}
.ark-client-row1 {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}
.ark-client-short {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text);
}
.ark-client-row2 {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.ark-order-num {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 11.5px;
    color: var(--dc, var(--brand-blue));
    background: color-mix(in srgb, var(--dc, var(--brand-blue)) 12%, transparent);
    padding: 1px 7px;
    border-radius: var(--r-xs);
    border: 1px solid color-mix(in srgb, var(--dc, var(--brand-blue)) 25%, transparent);
    text-decoration: none;
    letter-spacing: -.02em;
    transition: all var(--t-fast);
}
.ark-order-num:hover {
    background: color-mix(in srgb, var(--dc, var(--brand-blue)) 22%, transparent);
    text-decoration: none;
}
.ark-order-internal {
    font-size: 10.5px;
    color: var(--text-muted);
    font-weight: 500;
}
.ark-order-broker {
    font-size: 10px;
    color: var(--st-customs);
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

/* Menu wiersza (⋮) */
.ark-row-menu-btn {
    width: 24px;
    height: 24px;
    border-radius: var(--r-xs);
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all var(--t-fast);
}
.ark-row-menu-btn:hover {
    background: var(--card-hover);
    color: var(--brand-blue);
    border-color: var(--border);
}

/* Context menu (PPM lub klik na ⋮) */
.ark-context-menu {
    position: absolute;
    z-index: 200;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--r);
    box-shadow: var(--shadow-lg);
    min-width: 220px;
    padding: 4px;
    animation: dropIn .15s ease-out;
}
.ark-context-menu[hidden] { display: none; }
.ark-context-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 10px;
    font-size: 12.5px;
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
    border-radius: var(--r-xs);
    transition: background var(--t-fast);
}
.ark-context-item:hover {
    background: var(--card-hover);
    color: var(--brand-blue);
    text-decoration: none;
}
.ark-context-item svg { color: var(--text-muted); }
.ark-context-item:hover svg { color: var(--brand-blue); }
.ark-context-item.ark-context-danger { color: var(--st-danger); }
.ark-context-item.ark-context-danger svg { color: var(--st-danger); }
.ark-context-item.ark-context-danger:hover {
    background: var(--st-danger-bg);
    color: var(--st-danger);
}
.ark-context-sep {
    border: none;
    border-top: 1px solid var(--border);
    margin: 4px 0;
}

/* Wiersz - hover state, klikalność */
.arkusz tbody tr.ark-row { cursor: default; }
.arkusz tbody tr.ark-row:hover { background: var(--card-hover); }

/* Zaznaczone wiersze (bulk) */
.arkusz tbody tr.ark-row.bulk-selected td {
    background: color-mix(in srgb, var(--brand-blue) 8%, var(--card));
}

/* Komórka checkboxa bulk */
.ark-bulk-cell {
    text-align: center;
    padding: 6px 4px !important;
}

/* Naprawa: tabela arkusza powinna mieć min-width większy przy 14 kolumnach */
.arkusz {
    min-width: 1500px;
}

/* Group toggle - obrót strzałki gdy collapsed */
.ark-group-head.collapsed .ark-group-toggle {
    transform: rotate(-90deg);
}
.ark-group-toggle {
    transition: transform var(--t);
    display: inline-flex;
    align-items: center;
}

/* ============================================================
   DRAG & DROP w tablicy planowania
   ============================================================ */
.ark-row[draggable="true"] {
    cursor: grab;
}
.ark-row.ark-dragging {
    opacity: .35;
    cursor: grabbing;
}
.ark-row.ark-dragging td {
    background: var(--st-info-bg) !important;
}

/* Strefa upuszczania - podświetlona */
[data-drop-route].dnd-drop-over {
    outline: 3px dashed var(--brand-blue);
    outline-offset: -2px;
    background: color-mix(in srgb, var(--brand-blue) 6%, var(--card));
    transition: all .15s ease;
}
[data-drop-route].dnd-drop-over .planning-route-header {
    background: color-mix(in srgb, var(--brand-blue) 20%, var(--card)) !important;
}
[data-drop-route].dnd-drop-over .arkusz-wrap {
    box-shadow: 0 0 0 3px var(--brand-blue), 0 8px 24px rgba(37, 99, 235, .25);
}

/* ============================================================
   BELKA TRASY v2 - kierowca FIRST, winiety, grafik, mały nr trasy
   ============================================================ */
.planning-route-header {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: linear-gradient(135deg,
        color-mix(in srgb, #f59e0b 10%, var(--card)),
        color-mix(in srgb, #f59e0b 4%, var(--card))
    );
    border-bottom: 1px solid var(--border);
    border-left: 4px solid #f59e0b;
    cursor: pointer;
    font: inherit;
    text-align: left;
    color: var(--text);
    font-size: 13px;
    transition: background var(--t-fast);
    flex-wrap: wrap;
}

.planning-route-driver {
    display: inline-flex;
    flex-direction: column;
    line-height: 1.2;
    font-weight: 700;
    color: var(--text);
}
.planning-route-driver-empty {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--st-danger);
    font-weight: 600;
    font-size: 12px;
}
.planning-route-phone {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 10.5px;
    font-weight: 500;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.planning-route-vehicle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(255, 255, 255, .7);
    padding: 3px 8px;
    border-radius: var(--r-xs);
    border: 1px solid color-mix(in srgb, #f59e0b 25%, transparent);
    font-size: 12px;
}
.planning-route-vehicle svg { color: #d97706; }
.planning-route-vehicle strong { font-family: var(--font-mono); color: var(--text); letter-spacing: -.01em; }
.planning-route-trailer {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 11px;
}

.planning-route-dates {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--text-soft);
}
.planning-route-dates svg { color: var(--text-muted); }

.planning-route-package {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--st-success);
    font-size: 12px;
}
.planning-route-package strong { font-family: var(--font-mono); letter-spacing: -.02em; }

/* Winiety - rząd flag z kolorem ważności */
.planning-route-vignettes {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 6px;
    background: rgba(255, 255, 255, .6);
    border-radius: var(--r-xs);
    border: 1px solid var(--border);
}
.planning-route-vignette {
    display: inline-flex;
    align-items: center;
    padding: 1px;
    border-radius: 3px;
    border: 1.5px solid transparent;
    transition: transform var(--t-fast);
    cursor: help;
}
.planning-route-vignette:hover { transform: scale(1.2); z-index: 1; }
.planning-route-vignette.vignette-ok       { border-color: var(--st-success); }
.planning-route-vignette.vignette-warn     { border-color: var(--st-warning); }
.planning-route-vignette.vignette-expiring {
    border-color: var(--st-danger);
    animation: pulseBorder 1.5s infinite;
}
@keyframes pulseBorder {
    0%, 100% { box-shadow: 0 0 0 0 var(--st-danger); }
    50%      { box-shadow: 0 0 0 3px color-mix(in srgb, var(--st-danger) 30%, transparent); }
}

/* Konflikt grafiku */
.planning-route-conflict {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: var(--st-danger-bg);
    color: var(--st-danger);
    border: 1px solid var(--st-danger);
    border-radius: var(--r-xs);
    font-size: 11px;
    font-weight: 700;
    animation: pulseRed 2s infinite;
}

/* Numer trasy - mniejszy, na końcu */
.planning-route-num-small {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: rgba(0,0,0,.06);
    padding: 2px 7px;
    border-radius: var(--r-xs);
    font-size: 10.5px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    letter-spacing: -.02em;
    margin-left: 6px;
}
.planning-route-num-small svg { opacity: .5; }

/* ============================================================
   WZMOCNIENIE CSS company/broker letter (force render)
   ============================================================ */
.arkusz .ark-company-letter,
.arkusz .ark-broker-letter,
.ark-client-merged .ark-company-letter,
.ark-client-merged .ark-broker-letter {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 800;
    font-family: var(--font-mono);
    text-transform: uppercase;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .15);
    letter-spacing: -.02em;
}

/* Order num - kolorowa pigułka */
.arkusz .ark-order-num,
.ark-client-merged .ark-order-num {
    display: inline-flex !important;
    align-items: center;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 11.5px;
    padding: 1px 7px;
    border-radius: 4px;
    text-decoration: none;
    letter-spacing: -.02em;
    transition: filter var(--t-fast);
}
.arkusz .ark-order-num:hover,
.ark-client-merged .ark-order-num:hover {
    filter: brightness(.95);
    text-decoration: none;
}

/* ============================================================
   PER-PUNKT CHECKBOXY - załadunki/rozładunki w wielu rzędach
   ============================================================ */
.ark-pt-date-row {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 2px 0;
    border-bottom: 1px dashed transparent;
    font-size: 11.5px;
}
.ark-pt-date-row:not(:last-child) {
    border-bottom-color: var(--line);
}
.ark-pt-date-row.is-done {
    background: linear-gradient(90deg, color-mix(in srgb, #16a34a 18%, transparent), color-mix(in srgb, #16a34a 8%, transparent));
    border-left: 3px solid #16a34a;
    border-radius: var(--r-xs);
    padding: 3px 6px;
    margin: 0 -4px 2px;
}
.ark-pt-date-row.is-done .ark-date {
    text-decoration: line-through;
    opacity: .75;
    color: #14532d;
}
.ark-pt-date-row.is-done .ark-checkbox-mini {
    background: #16a34a !important;
    border-color: #16a34a !important;
    color: #fff !important;
}
.ark-pt-date-row.is-problem {
    background: linear-gradient(90deg, color-mix(in srgb, #dc2626 18%, transparent), color-mix(in srgb, #dc2626 8%, transparent));
    border-left: 3px solid #dc2626;
    border-radius: var(--r-xs);
    padding: 3px 6px;
    margin: 0 -4px 2px;
}
.ark-pt-date-row.is-problem {
    background: color-mix(in srgb, var(--st-danger) 6%, transparent);
    margin: 0 -4px;
    padding: 2px 4px;
    border-radius: var(--r-xs);
}
.ark-pt-date-row .ark-date {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--c, var(--text));
}
.ark-pt-date-row .ark-date-time {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    background: var(--card-hover);
    padding: 0 4px;
    border-radius: 3px;
}

.ark-pt-place-row {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 2px 0;
    border-bottom: 1px dashed transparent;
    font-size: 11.5px;
}
.ark-pt-place-row:not(:last-child) {
    border-bottom-color: var(--line);
}
.ark-pt-place-row.is-done {
    background: linear-gradient(90deg, color-mix(in srgb, #16a34a 14%, transparent), transparent);
    border-left: 3px solid #16a34a;
    border-radius: var(--r-xs);
    padding: 3px 6px;
    margin: 0 -4px 2px;
    opacity: 1;
    color: #14532d;
    font-weight: 600;
}
.ark-pt-place-row.is-done .ark-place-city {
    color: #15803d;
    text-decoration: line-through;
    text-decoration-color: color-mix(in srgb, #16a34a 50%, transparent);
}
.ark-pt-place-row .ark-place-postal {
    font-family: var(--font-mono);
    color: var(--text-muted);
    font-size: 10.5px;
}
.ark-pt-place-row .ark-place-city {
    color: var(--text);
    font-weight: 500;
}

.ark-pt-more {
    font-size: 10px;
    color: var(--text-muted);
    font-style: italic;
    padding: 2px 0 0;
    cursor: help;
}

/* Doc placeholder - brakujący wymagany dokument */
.ark-doc-pill.ark-doc-placeholder {
    background: transparent !important;
    border: 1px dashed var(--border-strong) !important;
    color: var(--text-muted) !important;
    opacity: .65;
}
.ark-doc-pill.ark-doc-placeholder:hover {
    opacity: 1;
    border-style: solid !important;
    background: var(--card-hover) !important;
    text-decoration: none;
}

/* ============================================================
   DRAG HANDLE + SORTOWANIE NAGŁÓWKÓW
   ============================================================ */
.ark-bulk-row-wrap {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.ark-drag-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    cursor: grab;
    color: var(--text-dim);
    user-select: none;
    font-size: 14px;
    line-height: 1;
    transition: color var(--t-fast);
}
.ark-drag-handle:hover {
    color: var(--brand-blue);
    background: var(--card-hover);
    border-radius: 3px;
}
.ark-drag-handle:active { cursor: grabbing; }

/* Sortowalne nagłówki - linki */
.ark-sort-link {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    transition: color var(--t-fast);
}
.ark-sort-link:hover {
    color: #fff;
    text-decoration: none;
}
.ark-sort-link.ark-sort-active {
    color: #fff;
}
.ark-sort-arrow {
    font-weight: 700;
    margin-left: 2px;
    color: var(--brand-blue);
    background: rgba(255, 255, 255, .15);
    padding: 0 4px;
    border-radius: 3px;
    font-size: 10px;
}
.ark-sort-link.ark-sort-active .ark-sort-arrow {
    background: rgba(255, 255, 255, .3);
}

/* ============================================================
   TRYBY ARKUSZA (Edycja / Kopiowanie / Do trasy)
   ============================================================ */
.arkusz-modes {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r);
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.ark-mode-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text-muted);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--t-fast);
}
.ark-mode-btn:hover {
    background: var(--card-hover);
    color: var(--text);
    border-color: var(--border-strong);
}
.ark-mode-btn.active {
    background: var(--brand-blue);
    color: #fff;
    border-color: var(--brand-blue);
    box-shadow: 0 2px 6px color-mix(in srgb, var(--brand-blue) 35%, transparent);
}
.ark-mode-btn[data-mode="edit"].active   { background: #2563eb; border-color: #2563eb; }
.ark-mode-btn[data-mode="copy"].active   { background: #16a34a; border-color: #16a34a; }
.ark-mode-btn[data-mode="route"].active  { background: #ea580c; border-color: #ea580c; }

.ark-mode-btn kbd {
    background: rgba(0, 0, 0, .08);
    color: inherit;
    padding: 1px 5px;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 10px;
    margin-left: 3px;
}
.ark-mode-btn.active kbd {
    background: rgba(255, 255, 255, .25);
}

.ark-mode-hint {
    color: var(--text-dim);
    font-size: 11.5px;
    margin-left: 8px;
    font-style: italic;
}

/* Tryb edit - kursor + podświetlenie edytowalnych komórek */
body.ark-mode-edit .ark-editable-cell {
    cursor: cell;
    background: color-mix(in srgb, #2563eb 4%, transparent);
    outline: 1px dashed color-mix(in srgb, #2563eb 30%, transparent);
    outline-offset: -2px;
}
body.ark-mode-edit .ark-editable-cell:hover {
    background: color-mix(in srgb, #2563eb 12%, transparent);
    outline-color: #2563eb;
}

/* Tryb copy - kursor copy + hover wierszy */
body.ark-mode-copy .ark-row {
    cursor: copy;
}
body.ark-mode-copy .ark-row:hover td {
    background: color-mix(in srgb, #16a34a 8%, transparent);
}

/* Tryb route - hover wierszy */
body.ark-mode-route .ark-row {
    cursor: pointer;
}
body.ark-mode-route .ark-row:hover td {
    background: color-mix(in srgb, #ea580c 8%, transparent);
}
body.ark-mode-route .ark-bulk-cell {
    background: color-mix(in srgb, #ea580c 12%, transparent);
}

/* Pasek "Do trasy" */
.ark-route-assign-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #ea580c, #c2410c);
    color: #fff;
    padding: 10px 16px;
    border-radius: var(--r);
    margin-bottom: 10px;
    box-shadow: 0 4px 14px rgba(234, 88, 12, .3);
    animation: slideInDown .25s ease-out;
}
.ark-route-assign-bar[hidden] { display: none; }
.ark-route-assign-count strong {
    font-size: 14px;
}
.ark-route-assign-sep {
    opacity: .5;
    font-weight: 700;
}
.ark-route-assign-bar .form-select {
    background: rgba(255, 255, 255, .9);
    border: none;
    color: var(--text);
}
.ark-route-assign-spacer { flex: 1; }
.ark-route-assign-bar .btn {
    background: rgba(255, 255, 255, .2);
    border-color: rgba(255, 255, 255, .35);
    color: #fff;
}
.ark-route-assign-bar .btn:hover {
    background: rgba(255, 255, 255, .35);
}
.ark-route-assign-bar .btn-primary {
    background: #fff;
    color: #ea580c;
    border-color: #fff;
    font-weight: 700;
}
.ark-route-assign-bar .btn-primary:hover {
    background: var(--bg-elevated);
    color: #c2410c;
}

/* ============================================================
   INLINE EDIT INPUT
   ============================================================ */
.ark-inline-input {
    width: 100%;
    background: #fffbeb;
    border: 2px solid #f59e0b;
    border-radius: var(--r-xs);
    padding: 4px 8px;
    font-family: inherit;
    font-size: 12.5px;
    color: var(--text);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, .2);
    outline: none;
    min-width: 60px;
}
.ark-inline-input[type="number"] {
    text-align: right;
    font-family: var(--font-mono);
}
.ark-editable-cell.ark-editing {
    background: #fef3c7 !important;
    outline-color: #f59e0b !important;
}

/* ============================================================
   LOADING MODES PIGUŁKI w arkuszu (ze słownika loading_modes)
   ============================================================ */
.ark-modes-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-top: 2px;
    margin-bottom: 4px;
    margin-left: 22px;  /* żeby było pod adresem nie pod flagą */
}
.ark-mode-pill {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 6px;
    border-radius: 9px;
    font-size: 9.5px;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: .02em;
    cursor: help;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .15);
}
.ark-mode-pill-label {
    text-transform: uppercase;
}

/* ============================================================
   REORDER INDICATOR - linia pokazująca gdzie wstawić wiersz
   ============================================================ */
.ark-row.ark-reorder-indicator.is-before {
    box-shadow: inset 0 4px 0 -1px #ea580c;
}
.ark-row.ark-reorder-indicator.is-after {
    box-shadow: inset 0 -4px 0 -1px #ea580c;
}

/* ============================================================
   VERSION CHAIN MODAL - historia wersji pliku
   ============================================================ */
.version-chain {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 60vh;
    overflow-y: auto;
}
.version-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 12px;
    background: var(--card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--text-muted);
    border-radius: var(--r-sm);
}
.version-item.is-latest {
    border-left-color: #16a34a;
    background: color-mix(in srgb, #16a34a 5%, var(--card));
}
.version-item.is-deleted {
    border-left-color: #dc2626;
    opacity: .65;
    text-decoration: line-through;
    text-decoration-thickness: 1px;
    text-decoration-color: color-mix(in srgb, var(--text) 30%, transparent);
}
.version-num {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 13px;
    color: var(--brand-blue);
    background: var(--card-hover);
    padding: 4px 8px;
    border-radius: var(--r-xs);
    flex-shrink: 0;
}
.version-body { flex: 1; min-width: 0; }
.version-name {
    font-size: 13px;
    color: var(--text);
    margin-bottom: 4px;
    word-break: break-all;
}
.version-current {
    font-size: 10px;
    background: #16a34a;
    color: #fff;
    padding: 1px 6px;
    border-radius: 9px;
    font-weight: 700;
    letter-spacing: .05em;
}
.version-deleted {
    font-size: 10px;
    background: #dc2626;
    color: #fff;
    padding: 1px 6px;
    border-radius: 9px;
    font-weight: 700;
}
.version-reason {
    margin: 4px 0;
    padding: 4px 8px;
    background: var(--st-info-bg);
    color: var(--st-info);
    border-radius: 4px;
    font-size: 12px;
}
.version-meta {
    font-size: 11px;
    color: var(--text-muted);
}
.version-dl {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--card-hover);
    color: var(--brand-blue);
    border-radius: var(--r-xs);
    text-decoration: none;
    font-weight: 700;
}
.version-dl:hover { background: var(--brand-blue); color: #fff; text-decoration: none; }

/* ============================================================
   ATTACHMENT VERSION BADGES (w att-card)
   ============================================================ */
.att-version-badge {
    display: inline-block;
    margin-left: 4px;
    font-size: 10px;
    background: var(--brand-blue);
    color: #fff;
    padding: 1px 5px;
    border-radius: 8px;
    font-weight: 700;
    font-family: var(--font-mono);
}
.att-deleted-badge {
    margin-left: 4px;
    cursor: help;
    opacity: .6;
}
.att-replace-reason {
    margin: 4px 0;
    padding: 3px 7px;
    background: var(--st-info-bg);
    color: var(--st-info);
    border-radius: 4px;
    font-size: 10.5px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* ============================================================
   HOTFIX 022 - Całe komórki zielone gdy wszystkie done
   ============================================================ */
td.cell-all-done {
    background: linear-gradient(135deg, color-mix(in srgb, #16a34a 14%, transparent), color-mix(in srgb, #16a34a 6%, transparent)) !important;
    position: relative;
}
td.cell-all-done-loading {
    border-left: 3px solid #16a34a !important;
}
td.cell-all-done-unloading {
    border-left: 3px solid #16a34a !important;
}
td.cell-all-done-customs {
    background: linear-gradient(135deg, color-mix(in srgb, #7c3aed 14%, transparent), color-mix(in srgb, #7c3aed 6%, transparent)) !important;
    border-left: 3px solid #7c3aed !important;
}
td.cell-all-done::after {
    content: "✓";
    position: absolute;
    top: 4px;
    right: 6px;
    font-size: 10px;
    font-weight: 900;
    color: #16a34a;
    opacity: .5;
}
td.cell-all-done-customs::after { color: #7c3aed; }

/* FIX - czerwona ramka wokół daty */
.ark-pt-date-row.is-fix .ark-date {
    border: 2px solid #dc2626 !important;
    background: color-mix(in srgb, #dc2626 8%, transparent) !important;
    color: #dc2626 !important;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 4px;
    box-shadow: 0 0 0 1px color-mix(in srgb, #dc2626 30%, transparent);
}
.ark-pt-date-row.is-fix .ark-date::before {
    content: "📌 ";
    font-size: 9px;
}

/* Zakres daty */
.ark-date-range {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 10.5px;
}

/* Info icon + custom tooltip dla punktów z notatkami */
.ark-pt-info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    background: var(--brand-blue);
    color: #fff;
    border-radius: 50%;
    font-size: 9px;
    font-weight: 700;
    cursor: help;
    margin-left: 2px;
}
.ark-pt-date-row.has-tooltip {
    position: relative;
    cursor: help;
}
.ark-pt-date-row.has-tooltip:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 0;
    top: 100%;
    z-index: 100;
    background: #1e293b;
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 11.5px;
    line-height: 1.5;
    white-space: pre-wrap;
    box-shadow: 0 4px 14px rgba(0,0,0,.3);
    max-width: 280px;
    pointer-events: none;
    margin-top: 4px;
}

/* Cargo detail icon w komórce towar */
.ark-cargo-summary.has-details {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.ark-cargo-details-icon {
    font-size: 11px;
    cursor: help;
    opacity: .85;
}

/* Mode pill - alert pulsujący */
.ark-mode-pill.is-alert {
    box-shadow: 0 0 0 2px color-mix(in srgb, #dc2626 60%, transparent);
    animation: alert-pulse 1.6s ease-in-out infinite;
}
.ark-mode-pill-alert {
    color: #fef08a;
    font-weight: 900;
    margin-right: 2px;
}
@keyframes alert-pulse {
    0%, 100% { box-shadow: 0 0 0 2px color-mix(in srgb, #dc2626 60%, transparent), 0 0 0 0 color-mix(in srgb, #dc2626 60%, transparent); }
    50%      { box-shadow: 0 0 0 2px color-mix(in srgb, #dc2626 60%, transparent), 0 0 0 6px color-mix(in srgb, #dc2626 0%, transparent); }
}

/* ============================================================
   HOTFIX 026A - Ustalenia specjalne na arkuszu
   ============================================================ */
.ark-special-terms-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 7px;
    background: linear-gradient(135deg, #f97316, #ea580c);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 3px;
    margin-left: 4px;
    cursor: help;
    box-shadow: 0 0 0 2px color-mix(in srgb, #f97316 30%, transparent);
    animation: special-terms-pulse 2.4s ease-in-out infinite;
}
.ark-special-terms-badge span {
    text-transform: uppercase;
    letter-spacing: .04em;
    font-size: 9px;
}
@keyframes special-terms-pulse {
    0%, 100% { box-shadow: 0 0 0 2px color-mix(in srgb, #f97316 30%, transparent), 0 0 0 0 color-mix(in srgb, #f97316 60%, transparent); }
    50%      { box-shadow: 0 0 0 2px color-mix(in srgb, #f97316 30%, transparent), 0 0 0 5px color-mix(in srgb, #f97316 0%, transparent); }
}

/* ============================================================
   HOTFIX 027 - Sprzedane punkty na arkuszu (kolor sold)
   ============================================================ */
.ark-pt-date-row.is-sold {
    background: linear-gradient(135deg, color-mix(in srgb, #2563eb 8%, transparent), transparent);
    border-left: 3px solid #2563eb;
    padding-left: 4px;
}
.ark-pt-date-row.is-sold .ark-date {
    color: #2563eb !important;
    font-weight: 700;
}
.ark-sold-badge {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 1px 5px;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    border-radius: 3px;
    margin-left: 4px;
    line-height: 1.4;
    text-transform: uppercase;
    letter-spacing: .03em;
}

/* ============================================================
   HOTFIX 029 - Klawiszologia J/K - focused row
   ============================================================ */
tr.ark-row.is-kb-focused {
    outline: 3px solid var(--brand-blue);
    outline-offset: -2px;
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand-blue) 60%, transparent);
}
tr.ark-row.is-kb-focused td {
    background: color-mix(in srgb, var(--brand-blue) 7%, var(--card)) !important;
}

/* Klawisze w pomocy */
kbd {
    display: inline-block;
    padding: 2px 8px;
    margin: 0 2px;
    background: var(--card);
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    color: var(--text);
    box-shadow: 0 1px 0 var(--border);
}

/* =============================================================================
   POLISH PREMIUM (addytywny — układ/funkcje arkusza bez zmian) — Faza 2
   ============================================================================= */

/* Głębia: subtelny cień prawej krawędzi pierwszej sticky-kolumny przy scrollu */
.arkusz tbody td.col-sticky { box-shadow: 6px 0 8px -6px rgba(15, 23, 42, .12); }
body.theme-dark .arkusz tbody td.col-sticky { box-shadow: 6px 0 10px -6px rgba(0, 0, 0, .5); }

/* Pigułka wagi: mocniejszy, czytelniejszy kontrast tekstu (premium) */
.ark-weight { font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.ark-weight.wl-green  { color: #15803d; }
.ark-weight.wl-yellow { color: #a16207; }
.ark-weight.wl-red    { color: #b91c1c; box-shadow: inset 0 0 0 1px var(--st-danger-border); }
body.theme-dark .ark-weight.wl-green  { color: #4ade80; }
body.theme-dark .ark-weight.wl-yellow { color: #fbbf24; }
body.theme-dark .ark-weight.wl-red    { color: #f87171; }

/* Rytm pionowy wierszy: minimalnie więcej oddechu, równe wyrównanie do góry */
.arkusz tbody td { vertical-align: top; }

/* Wiersz "problem" — wyraźniejszy lewy akcent bez zmiany layoutu */
.arkusz tbody tr.row-problem td.col-sticky {
    box-shadow: inset 3px 0 0 var(--st-danger), 6px 0 8px -6px rgba(15, 23, 42, .12);
}

/* Hover wiersza: delikatne podświetlenie marki zamiast szarości */
.arkusz tbody tr:hover td:not(.col-sticky):not(.col-sticky-2) {
    background: color-mix(in srgb, var(--brand-blue) 5%, var(--card));
}

/* ============================================================
   ARKUSZ 2.0 — system-aligned polish (later-wins overrides)
   Kolory wyłącznie z tokenów + ze słowników (--mc / --sc / --c).
   ============================================================ */

/* — Sposób załadunku: DELIKATNE oznaczenia (kolor ze słownika) — */
.arkusz .ark-modes-subtle{display:inline-flex;gap:3px;margin-left:6px;vertical-align:middle}
.arkusz .ark-mode-dot{
    width:17px;height:17px;border-radius:5px;display:inline-flex;align-items:center;justify-content:center;
    background:color-mix(in srgb, var(--mc,#64748b) 14%, #fff);
    color:var(--mc,#64748b);
    border:1px solid color-mix(in srgb, var(--mc,#64748b) 36%, #fff);
    flex:0 0 auto;
}
.arkusz .ark-mode-dot svg{width:11px;height:11px;stroke-width:2.4}
.arkusz .ark-mode-dot.is-alert{box-shadow:0 0 0 1.5px var(--st-danger)}

/* — Daty ↔ miejscowości: te same wysokości linii per punkt — */
.arkusz .ark-pt-date-row,
.arkusz .ark-pt-place-row{
    min-height:25px;display:flex;align-items:center;gap:6px;flex-wrap:nowrap;white-space:nowrap;
}
.arkusz .ark-pt-place-row .ark-place-city{overflow:hidden;text-overflow:ellipsis}
.arkusz .ark-pt-date-row + .ark-pt-date-row,
.arkusz .ark-pt-place-row + .ark-pt-place-row{margin-top:4px}
.arkusz .ark-pt-more{margin-top:4px;min-height:18px}
.arkusz .ark-date{font-weight:800}
.arkusz .ark-pt-date-row.is-fix .ark-date{box-shadow:inset 0 0 0 1.5px var(--st-danger);border-radius:5px;padding:1px 5px}

/* — Odprawa: scenariusze ze słownika + ułamek/checkbox w jednej linii — */
.arkusz .ark-customs-cell{display:flex;flex-wrap:wrap;align-items:center;gap:4px}
.arkusz .ark-scenarios{flex-basis:100%;display:flex;flex-wrap:wrap;gap:3px;margin-bottom:1px}
.arkusz .ark-scen-chip{
    display:inline-block;max-width:118px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
    font-size:9.5px;font-weight:800;letter-spacing:.01em;padding:1px 7px;border-radius:5px;
    background:color-mix(in srgb, var(--sc,#7c3aed) 14%, #fff);
    color:var(--sc,#7c3aed);
    border:1px solid color-mix(in srgb, var(--sc,#7c3aed) 38%, #fff);
}
.arkusz .ark-customs-row{display:inline-flex;align-items:center;gap:5px}

/* — LDM · waga: zależność kolorystyczna jako wyrazisty badge — */
.arkusz .ark-weight{
    display:inline-flex;align-items:center;gap:4px;padding:2px 9px;border-radius:999px;
    font-family:var(--font-mono);font-size:11px;font-weight:800;letter-spacing:.01em;border:1px solid;
}
.arkusz .ark-weight.wl-green {background:var(--st-success-bg);color:#166534;border-color:var(--st-success-border)}
.arkusz .ark-weight.wl-yellow{background:var(--st-warning-bg);color:#92400e;border-color:var(--st-warning-border)}
.arkusz .ark-weight.wl-red   {background:var(--st-danger-bg); color:#991b1b;border-color:var(--st-danger-border)}

/* — Kwota: kolorystyka jak w podglądzie finansów (przychód = zielony) — */
.arkusz .ark-amount{
    display:inline-flex;align-items:baseline;gap:4px;justify-content:flex-end;
    font-family:var(--font-mono);font-weight:800;font-size:12.5px;color:var(--text);
    padding:2px 9px;border-radius:8px;
    background:var(--st-success-bg);border:1px solid var(--st-success-border);
}
.arkusz .ark-amount-currency{color:#166534;font-size:9.5px;font-weight:700}
.arkusz .ark-amount-extra{margin-top:3px;font-size:9px;font-weight:800;color:#92400e;
    background:var(--st-warning-bg);border:1px solid var(--st-warning-border);border-radius:5px;padding:0 5px;display:inline-block}

/* — Ustalenia specjalne: sama ikonka (bez napisu) — */
.arkusz .ark-special-terms-badge{
    display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;padding:0;border-radius:5px;
    background:var(--st-warning-bg);color:#92400e;border:1px solid var(--st-warning-border);
}
.arkusz .ark-special-terms-badge svg{width:12px;height:12px}

/* — Podsumowania (belka + stopka): kolorowe, logiczne chipy — */
.arkusz .ark-group-summary{display:inline-flex !important;align-items:center;gap:6px;flex-wrap:wrap}
.ark-sumchips{display:inline-flex;align-items:center;gap:6px;flex-wrap:wrap}
.ark-sumchip{
    display:inline-flex;align-items:center;gap:4px;font-family:var(--font-mono);font-size:10.5px;font-weight:700;
    padding:2px 9px;border-radius:999px;background:#fff;border:1px solid var(--border);color:var(--text-soft);white-space:nowrap;
}
.ark-sumchip strong{font-weight:800}
.ark-sumchip.count{background:var(--st-neutral-bg);border-color:var(--st-neutral-border);color:var(--text)}
.ark-sumchip.money{background:var(--st-success-bg);border-color:var(--st-success-border);color:#166534}
.ark-sumchip.fix  {background:var(--st-warning-bg);border-color:var(--st-warning-border);color:#92400e}
.ark-sumchip.prob {background:var(--st-danger-bg); border-color:var(--st-danger-border); color:#991b1b}
.ark-group-foot .ark-foot-label{font-size:11px;letter-spacing:.04em;color:var(--text-muted);margin-right:2px}

/* ============================================================
   ARKUSZ 2.0 — Faza 1.1: pasek KPI + maksymalna kompaktowość
   ============================================================ */

/* — Pasek KPI (operacyjny snapshot) — */
.ark-kpi{display:flex;gap:7px;flex-wrap:wrap;margin:0 0 12px}
.ark-kpi-item{
    display:inline-flex;align-items:center;gap:7px;padding:6px 12px;border-radius:10px;
    background:var(--card);border:1px solid var(--border);box-shadow:var(--shadow-sm);
    font-size:12px;font-weight:600;color:var(--text-soft);white-space:nowrap;
    transition:border-color var(--t-fast),box-shadow var(--t-fast),transform var(--t-fast);
}
.ark-kpi-item:hover{border-color:color-mix(in srgb,var(--kc) 45%,var(--border));box-shadow:var(--shadow);transform:translateY(-1px)}
.ark-kpi-dot{width:9px;height:9px;border-radius:50%;background:var(--kc);flex:0 0 auto}
.ark-kpi-item svg{color:var(--kc)}
.ark-kpi-label{color:var(--text-soft)}
.ark-kpi-num{font-family:var(--font-mono);font-size:15px;font-weight:800;color:var(--text);line-height:1}

/* — Maksymalna kompaktowość siatki (czytelność zachowana) — */
.arkusz tbody td{padding:5px 9px}
.arkusz thead th{padding:7px 9px}
.arkusz .ark-pt-date-row,
.arkusz .ark-pt-place-row{min-height:22px}
.arkusz .ark-pt-date-row + .ark-pt-date-row,
.arkusz .ark-pt-place-row + .ark-pt-place-row{margin-top:3px}
.arkusz .ark-pt-more{margin-top:3px;min-height:16px;font-size:10px}
.arkusz .ark-client-row2{margin-top:3px}
.arkusz .ark-mode-dot{width:16px;height:16px}
.arkusz .ark-mode-dot svg{width:10px;height:10px}
.arkusz .ark-weight{padding:1px 8px}
.arkusz .ark-amount{padding:1px 8px}
.arkusz .ark-scen-chip{padding:1px 6px}
.ark-sumchip{padding:1px 8px}
/* zwarte odstępy między wierszami przy zachowaniu siatki linii */
.arkusz tbody tr.ark-row td{line-height:1.25}

/* ============================================================
   ARKUSZ 2.0 — Faza 2: pionowe wyśrodkowanie + Odprawa klik + ładne ikony
   ============================================================ */

/* Każda komórka wyśrodkowana w pionie wiersza */
.arkusz tbody td{vertical-align:middle}

/* Odprawa = sam scenariusz (O/O/O), klikalny do podglądu */
.arkusz .ark-customs-cell{display:inline-flex;align-items:center;flex-wrap:wrap;gap:5px;cursor:pointer}
.arkusz .ark-scen-chip{cursor:pointer;transition:filter var(--t-fast),transform var(--t-fast)}
.arkusz .ark-customs-cell:hover .ark-scen-chip{filter:brightness(.96);transform:translateY(-1px)}
.arkusz .ark-scen-chip.ark-scen-generic{display:inline-flex;align-items:center;background:var(--st-neutral-bg);color:var(--text-muted);border-color:var(--border)}
.arkusz .ark-customs-cell.is-done .ark-scen-chip{box-shadow:inset 0 0 0 1px var(--st-success-border)}
.arkusz .ark-customs-done{display:inline-flex;align-items:center;color:var(--st-success)}

/* Ładne ikony Ui zamiast znaczków */
.arkusz .ark-pt-info-icon{display:inline-flex;align-items:center;justify-content:center;width:auto;height:auto;min-width:0;padding:0;background:none;border:0;border-radius:0;color:var(--st-info);cursor:help}
.arkusz .ark-pt-info-icon svg{width:13px;height:13px;stroke-width:2.2}
.arkusz .ark-cargo-details-icon{display:inline-flex;align-items:center;color:var(--st-info);margin-right:3px}
.arkusz .ark-cargo-details-icon svg{width:12px;height:12px}
.arkusz .ark-sold-badge{display:inline-flex;align-items:center;gap:3px}
.arkusz .ark-sold-badge svg{width:11px;height:11px;stroke-width:2.4}
/* drag-handle: zwarte, schludne „uchwyt" (kropki), nie emoji */
.arkusz .ark-drag-handle{font-size:13px;line-height:1;letter-spacing:-1px;color:var(--text-dim)}
.arkusz .ark-drag-handle:hover{color:var(--brand-blue)}

/* ============================================================
   ARKUSZ 2.0 — Faza 3: wpisywanie numeru dokumentu wprost w pigułce
   ============================================================ */
.ark-doc-pill .ark-doc-input{
    border:0;background:transparent;font-family:var(--font-mono);font-size:9.5px;font-weight:700;
    width:74px;min-width:46px;outline:none;color:var(--text);padding:0 0 0 2px;margin:0;
}
.ark-doc-pill[data-editing="1"]{box-shadow:0 0 0 2px var(--brand-blue);cursor:text}
.ark-doc-pill .ark-doc-num{max-width:96px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:inline-block;vertical-align:bottom}

/* ============================================================
   ARKUSZ 2.0 — Faza A: parytet z systemem
   (odprawa-checkbox przed scenariuszem, LDM zwykła/waga kolor,
    kwota niebieska/zielona + tooltip, nazwy plików dokumentów)
   Daty: kolory już z deadlineLevel (.ark-pt-date-row .ark-date),
         godziny przeniesione do tooltipu — bez zmian kolorów.
   ============================================================ */

/* — Odprawa: checkbox „odprawione" przed scenariuszem — */
.arkusz .ark-customs-cell{display:inline-flex;align-items:center;gap:5px;flex-wrap:wrap;justify-content:center}
.arkusz .ark-customs-check{flex:none;cursor:pointer}

/* — LDM zwykłą czcionką, kolorowa tylko WAGA (progi z ustawień systemu) — */
.arkusz .ark-ldmwaga{font-family:var(--font-mono);font-size:11.5px;white-space:nowrap;font-variant-numeric:tabular-nums;letter-spacing:-.01em}
.arkusz .ark-ldm-val{color:var(--text-soft);font-weight:600}
.arkusz .ark-wgt{font-weight:800;padding:1px 6px;border-radius:6px}
.arkusz .ark-wgt.wl-green  {color:var(--st-success);background:var(--st-success-bg)}
.arkusz .ark-wgt.wl-yellow {color:var(--st-warning);background:var(--st-warning-bg)}
.arkusz .ark-wgt.wl-red    {color:var(--st-danger); background:var(--st-danger-bg); box-shadow:inset 0 0 0 1px var(--st-danger-border)}
body.theme-dark .arkusz .ark-wgt.wl-green {color:#4ade80}
body.theme-dark .arkusz .ark-wgt.wl-yellow{color:#fbbf24}
body.theme-dark .arkusz .ark-wgt.wl-red   {color:#f87171}

/* — Kwota: NIEBIESKA bez dodatkowych przychodów, ZIELONA gdy są — */
.arkusz .ark-amount{background:var(--st-info-bg);border:1px solid var(--st-info-border)}
.arkusz .ark-amount .ark-editable-display{color:var(--brand-blue)}
.arkusz .ark-amount .ark-amount-currency{color:var(--brand-blue);opacity:.85}
.arkusz .ark-amount.has-extra{background:var(--st-success-bg);border-color:var(--st-success-border)}
.arkusz .ark-amount.has-extra .ark-editable-display{color:#166534}
.arkusz .ark-amount.has-extra .ark-amount-currency{color:#166534;opacity:.85}
.arkusz .ark-amount-plus{font-size:9px;font-weight:800;color:#166534;background:#fff;border-radius:5px;padding:0 4px;align-self:center}
body.theme-dark .arkusz .ark-amount .ark-editable-display{color:#93c5fd}
body.theme-dark .arkusz .ark-amount .ark-amount-currency{color:#93c5fd}
body.theme-dark .arkusz .ark-amount.has-extra .ark-editable-display{color:#86efac}
body.theme-dark .arkusz .ark-amount.has-extra .ark-amount-currency{color:#86efac}

/* — Dokumenty: nazwa pliku w pigułce gdy jest załącznik — */
.ark-doc-pill .ark-doc-file{display:inline-flex;align-items:center;gap:2px;margin-left:3px;font-family:var(--font-mono);font-size:9px;font-weight:700;max-width:88px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;vertical-align:bottom}
.ark-doc-pill .ark-doc-file svg{flex:none}

/* ─────────────────────────────────────────────────────────────
   Faza D: afordancja edycji w trybie Edycji (E)
   ───────────────────────────────────────────────────────────── */
body.ark-mode-edit .ark-date[data-pt-id]{
    cursor: pointer;
    border-radius: var(--r-xs, 4px);
    transition: background .12s ease, box-shadow .12s ease;
}
body.ark-mode-edit .ark-date[data-pt-id]:hover{
    background: color-mix(in srgb, var(--brand-blue) 14%, transparent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand-blue) 38%, transparent);
}

/* ─────────────────────────────────────────────────────────────
   Faza D (reszta): edycja sposobu załadunku + scenariusza w trybie Edycji
   ───────────────────────────────────────────────────────────── */
body.ark-mode-edit .ark-modes-pills[data-pt-id]{
    cursor: pointer;
    border-radius: var(--r-xs, 4px);
    min-width: 14px; min-height: 14px;
    transition: background .12s ease;
}
body.ark-mode-edit .ark-modes-pills[data-pt-id]:hover{
    background: color-mix(in srgb, var(--brand-blue) 14%, transparent);
}
body.ark-mode-edit .ark-modes-pills[data-pt-id]:empty::before{
    content: "+ sposób";
    font-size: 9px; font-weight: 700;
    color: var(--brand-blue); opacity: .55;
    padding: 1px 4px;
}
body.ark-mode-edit .ark-customs-cell[data-customs-id] .ark-scen-chip{ cursor: pointer; }
body.ark-mode-edit .ark-customs-cell[data-customs-id]:hover .ark-scen-chip{
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand-blue) 40%, transparent);
}
