/* =============================================================================
   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: center;
    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 {
    cursor: help;
}
/* stary ::after wyłączony — tooltip obsługuje teraz nie-ucinający system .otms-tip */

/* 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:visible;text-overflow:clip}
.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);
}

/* ─────────────────────────────────────────────────────────────
   Faza E: dopracowanie trybów (kontekstowa podpowiedź + wskaźnik zmiany kierunku przy drag)
   ───────────────────────────────────────────────────────────── */
body.ark-mode-edit  #ark-mode-hint{ color: var(--brand-blue); font-weight: 600; }
body.ark-mode-copy  #ark-mode-hint{ color: var(--st-info, #0ea5e9); font-weight: 600; }
body.ark-mode-route #ark-mode-hint{ color: var(--st-customs, #7c3aed); font-weight: 600; }

/* przeciąganie nad wierszem o innym kierunku → „upuść = zmień kierunek" */
tr.ark-row.ark-dir-target > td{
    background: color-mix(in srgb, var(--st-customs, #7c3aed) 13%, var(--card, #fff)) !important;
}
tr.ark-row.ark-dir-target > td:first-child{
    box-shadow: inset 3px 0 0 var(--st-customs, #7c3aed);
}

/* Tryb "D" (Przesuwanie): cały wiersz chwytalny */
body.ark-mode-drag .ark-row{ cursor: grab; }
body.ark-mode-drag .ark-row:active{ cursor: grabbing; }

/* ═══════════════════════════════════════════════════════════════
   ETAP 1: układ + format + kolory (sposób-tekst, checkbox tylko R,
   odprawa-done, elastyczna szerokość, kompaktowa góra)
   ═══════════════════════════════════════════════════════════════ */

/* #4 — sposób załadunku jako kolorowy tekst (zamiast ikon) */
.arkusz .ark-mode-tag{
    display:inline-block; font-size:9.5px; font-weight:800; letter-spacing:.02em; text-transform:uppercase;
    padding:1px 6px; border-radius:5px; line-height:1.55; white-space:nowrap;
    color:var(--mc,#64748b);
    background:color-mix(in srgb, var(--mc,#64748b) 13%, #fff);
    box-shadow:inset 0 0 0 1px color-mix(in srgb, var(--mc,#64748b) 28%, transparent);
}
.arkusz .ark-mode-tag + .ark-mode-tag{ margin-left:3px; }
.arkusz .ark-modes-pills{ display:inline-flex; flex-wrap:wrap; gap:3px; }

/* #9 — separator LDM | waga */
.arkusz .ark-ldm-sep{ color:var(--text-dim); font-weight:600; margin:0 1px; }

/* +1 — odprawa oznaczona jako zrobiona = cała komórka zielona (jak załadunki) */
.arkusz .ark-customs-cell.is-done{
    background: var(--st-success-bg) !important;
    color: var(--st-success) !important;
    border-color: var(--st-success) !important;
}
.arkusz .ark-customs-cell.is-done .ark-scen-chip{
    background: color-mix(in srgb, var(--st-success) 16%, #fff);
    color: var(--st-success);
}

/* #1 — checkboxy zaznaczania widoczne TYLKO w trybie „Do trasy (R)" (uchwyt ⠿ zostaje) */
body:not(.ark-mode-route) .arkusz .ark-bulk-check,
body:not(.ark-mode-route) .arkusz .ark-check-all{ display:none; }

/* #3 — elastyczna szerokość: tabela szeroka na zawartość, bez rozpychania kolumn */
.arkusz{ width:max-content; min-width:100%; }

/* #17 — kompaktowa góra (pasek trybów + toolbar węższe, lista wyżej) */
.arkusz-modes{ padding:3px 8px; margin-bottom:6px; gap:5px; }
.arkusz-modes .ark-mode-btn{ padding:4px 10px; font-size:12px; }
.arkusz-modes .ark-mode-btn kbd{ font-size:9.5px; }
.arkusz-modes .ark-mode-hint{ font-size:11.5px; }
.arkusz-toolbar{ margin-bottom:8px; }

/* ═══════════════════════════════════════════════════════════════
   ETAP 2: nie-ucinający, kolorowy system tooltipów (.otms-tip)
   Portal na <body>, position:fixed, wysoki z-index — nie chowa się
   pod żadnym elementem (pkt 11 + 16). Wariant koloruje akcent.
   ═══════════════════════════════════════════════════════════════ */
.otms-tip{
    position:fixed; z-index:99999; max-width:340px; min-width:180px;
    background:var(--card,#fff); color:var(--text,#0f172a);
    border:1px solid var(--border,#e2e8f0); border-radius:var(--r,10px);
    box-shadow:0 18px 44px rgba(15,23,42,.20), 0 3px 10px rgba(15,23,42,.10);
    padding:9px 12px; font-size:11.5px; line-height:1.5; pointer-events:none;
    overflow:hidden;
    animation:otmsTipIn .12s ease-out;
}
@keyframes otmsTipIn{ from{opacity:0; transform:translateY(3px);} to{opacity:1; transform:none;} }
.otms-tip .otms-tip-head{
    /* pasek nagłówka: nazwa encji na barwionym tle akcentu — tooltip czyta się jak karta */
    margin:-9px -12px 7px; padding:7px 12px 6px;
    font-size:11.5px; font-weight:800; letter-spacing:.01em;
    color:var(--text,#0f172a);
    background:color-mix(in srgb, var(--tip-accent,#64748b) 9%, var(--card,#fff));
    border-bottom:1px solid color-mix(in srgb, var(--tip-accent,#64748b) 22%, var(--border,#e2e8f0));
    box-shadow:inset 0 2.5px 0 var(--tip-accent,#64748b);
}
.otms-tip .otms-tip-row{ display:flex; gap:10px; justify-content:space-between; align-items:baseline; padding:1.5px 0; }
.otms-tip .otms-tip-row .otms-tip-k{ color:var(--text-muted,#64748b); white-space:nowrap; min-width:46px; font-size:10.5px; }
.otms-tip .otms-tip-row .otms-tip-v{ color:var(--text,#0f172a); font-weight:600; text-align:right; }
.otms-tip .otms-tip-row.no-k{ display:block; }
.otms-tip .otms-tip-row.no-k .otms-tip-v{ text-align:left; font-weight:500; white-space:pre-wrap; }
.otms-tip .otms-tip-row.is-base .otms-tip-v{ color:var(--brand-blue,#2563eb); font-family:var(--font-mono); }
.otms-tip .otms-tip-row.is-extra .otms-tip-v{ color:var(--st-success,#16a34a); font-family:var(--font-mono); }
.otms-tip .otms-tip-note{ color:var(--text-dim,#94a3b8); font-style:italic; }
.otms-tip .otms-tip-sep{ height:1px; background:var(--border,#e2e8f0); margin:6px 0; }
.otms-tip .otms-tip-copy-hint{
    margin-top:7px; padding-top:6px; border-top:1px dashed var(--border,#e2e8f0);
    font-size:8.5px; font-weight:700; letter-spacing:.05em; text-transform:uppercase; color:var(--text-dim,#94a3b8);
}
.otms-tip .otms-tip-modewrap{ display:flex; flex-wrap:wrap; gap:4px; justify-content:flex-end; }
.otms-tip .otms-tip-modechip{
    display:inline-flex; align-items:center; gap:4px;
    font-size:10px; font-weight:700; padding:1.5px 7px; border-radius:999px;
    color:var(--mc,#64748b);
    background:color-mix(in srgb, var(--mc,#64748b) 11%, var(--card,#fff));
    border:1px solid color-mix(in srgb, var(--mc,#64748b) 35%, transparent);
}
.otms-tip .otms-tip-modechip::before{ content:''; width:5px; height:5px; border-radius:50%; background:var(--mc,#64748b); }
.otms-tip.tip-amount{ --tip-accent:var(--brand-blue,#2563eb); }
.otms-tip.tip-cargo{ --tip-accent:#b45309; }
.otms-tip.tip-customs{ --tip-accent:var(--st-customs,#7c3aed); }
.otms-tip.tip-plain{ --tip-accent:var(--text-muted,#64748b); }

/* ═══════════════════════════════════════════════════════════════
   ETAP 3 (#13): edycja towaru i LDM — afordancja w trybie Edycji
   + dialog edytora pozycji towaru (cgd-*)
   ═══════════════════════════════════════════════════════════════ */
body.ark-mode-edit .ark-cargo-cell{ cursor:pointer; }
body.ark-mode-edit .ark-cargo-cell:hover{
    background:color-mix(in srgb, var(--brand-blue) 7%, transparent);
    box-shadow:inset 0 0 0 1px color-mix(in srgb, var(--brand-blue) 30%, transparent);
    border-radius:var(--r-xs);
}
.cgd-wrap{ max-height:60vh; overflow:auto; }
.cgd-item{ border:1px solid var(--border); border-radius:var(--r-sm); padding:8px; margin-bottom:8px; background:var(--bg); }
.cgd-line{ display:flex; gap:6px; align-items:center; }
.cgd-line-top{ margin-bottom:6px; }
.cgd-grid{ flex-wrap:wrap; }
.cgd-line .cg-desc{ flex:1; }
.cgd-grid .form-input{ flex:0 0 auto; }
.cgd-grid .cg-pallets{ width:80px; }
.cgd-grid .cg-weight{ width:95px; }
.cgd-grid .cg-ldm{ width:80px; }
.cgd-grid .cg-pack{ width:130px; }
.cgd-grid .cg-adr{ width:70px; }
.cgd-grid .cg-un{ width:85px; }
.cgd-del{ width:30px; height:30px; flex:0 0 auto; border:1px solid var(--border); border-radius:var(--r-xs); background:#fff; color:var(--st-danger); cursor:pointer; font-size:13px; line-height:1; }
.cgd-del:hover{ background:var(--st-danger-bg); border-color:var(--st-danger); }
#cgd-add{ font-size:12px; }
.cgd-sum{ margin-top:8px; padding-top:8px; border-top:1px solid var(--border); font-size:12px; color:var(--text-muted); }
.cgd-sum strong{ color:var(--text); font-family:var(--font-mono); }

/* ═══════════════════════════════════════════════════════════════
   ETAP 3b (#12): dialog kwoty = ledger przychód/koszt + oddz. faktura
   ═══════════════════════════════════════════════════════════════ */
.apd-wrap{ max-height:60vh; overflow:auto; }
.apd-item{ display:flex; gap:6px; align-items:center; margin-bottom:6px; flex-wrap:wrap; }
.apd-side{ display:inline-flex; border:1px solid var(--border); border-radius:var(--r-xs); overflow:hidden; flex:0 0 auto; }
.apd-side-btn{ padding:5px 9px; font-size:11px; font-weight:700; border:0; background:#fff; color:var(--text-muted); cursor:pointer; }
.apd-side-btn + .apd-side-btn{ border-left:1px solid var(--border); }
.apd-side-btn.is-active[data-side="income"]{ background:var(--st-success-bg); color:var(--st-success); }
.apd-side-btn.is-active[data-side="cost"]{ background:var(--st-danger-bg); color:var(--st-danger); }
.apd-item .apd-desc{ flex:1 1 140px; min-width:110px; }
.apd-item .apd-amt{ width:100px; flex:0 0 auto; }
.apd-item .apd-cur{ width:58px; flex:0 0 auto; text-transform:uppercase; }
.apd-sep{ display:inline-flex; align-items:center; gap:4px; font-size:11px; color:var(--text-muted); flex:0 0 auto; white-space:nowrap; cursor:pointer; }
.apd-del{ width:30px; height:30px; flex:0 0 auto; border:1px solid var(--border); border-radius:var(--r-xs); background:#fff; color:var(--st-danger); cursor:pointer; font-size:13px; line-height:1; }
.apd-del:hover{ background:var(--st-danger-bg); border-color:var(--st-danger); }
.apd-addbar{ display:flex; gap:8px; margin:8px 0; }
.apd-summary{ display:flex; gap:16px; flex-wrap:wrap; padding-top:8px; border-top:1px solid var(--border); font-size:12px; color:var(--text-muted); }
.apd-summary strong{ font-family:var(--font-mono); color:var(--text); }
.apd-summary span:last-child strong{ color:var(--brand-blue); }

/* ═══════════════════════════════════════════════════════════════
   POPRAWKI (feedback): sticky off, paski sposobu, tryby u góry, FIX ramka
   ═══════════════════════════════════════════════════════════════ */

/* #3 — zleceniodawca NIE jest już przyklejony przy przewijaniu w poziomie */
.arkusz thead th.col-sticky, .arkusz tbody td.col-sticky,
.arkusz thead th.col-sticky-2, .arkusz tbody td.col-sticky-2{
    position: static !important; left: auto !important; z-index: auto !important; box-shadow: none !important;
}

/* #5 — sposób załadunku jako kolorowy PASEK (dict kolor), bez tekstu i ikon */
.arkusz .ark-mode-dot{
    display:inline-block; width:13px; height:5px; border-radius:3px;
    background:var(--mc,#64748b); vertical-align:middle;
    box-shadow:inset 0 0 0 1px color-mix(in srgb, var(--mc,#64748b) 55%, transparent);
}
.arkusz .ark-mode-dot + .ark-mode-dot{ margin-left:3px; }
.arkusz .ark-modes-pills{ display:inline-flex; gap:3px; align-items:center; flex-wrap:wrap; }

/* #1 — tryby E/C/R/D w górnym wierszu (page-actions) */
.ark-modes-top{ display:inline-flex; gap:4px; margin-right:6px; padding-right:8px; border-right:1px solid var(--border); }
.ark-modes-top .ark-mode-btn{
    display:inline-flex; align-items:center; gap:5px; padding:7px 11px; font-size:12.5px; font-weight:600;
    border:1px solid var(--border); border-radius:var(--r-sm); background:var(--card); color:var(--text-soft); cursor:pointer; line-height:1;
}
.ark-modes-top .ark-mode-btn:hover{ border-color:var(--brand-blue); color:var(--brand-blue); }
.ark-modes-top .ark-mode-btn kbd{ font-size:9.5px; font-weight:700; background:var(--bg); border:1px solid var(--border); border-radius:3px; padding:1px 4px; color:var(--text-muted); }
body.ark-mode-edit  .ark-modes-top .ark-mode-btn[data-mode="edit"],
body.ark-mode-copy  .ark-modes-top .ark-mode-btn[data-mode="copy"],
body.ark-mode-route .ark-modes-top .ark-mode-btn[data-mode="route"],
body.ark-mode-drag  .ark-modes-top .ark-mode-btn[data-mode="drag"]{ background:var(--brand-blue); border-color:var(--brand-blue); color:#fff; }
body.ark-mode-edit  .ark-modes-top .ark-mode-btn[data-mode="edit"] kbd,
body.ark-mode-copy  .ark-modes-top .ark-mode-btn[data-mode="copy"] kbd,
body.ark-mode-route .ark-modes-top .ark-mode-btn[data-mode="route"] kbd,
body.ark-mode-drag  .ark-modes-top .ark-mode-btn[data-mode="drag"] kbd{ background:rgba(255,255,255,.25); border-color:transparent; color:#fff; }

/* #1/#2 — pasek pod toolbarem to już tylko wąski hint; znika gdy żaden tryb nieaktywny (lista wyżej) */
.arkusz-modes{ padding:0 !important; margin:0 0 6px !important; border:0 !important; background:none !important; min-height:0 !important; display:block; }
body:not(.ark-mode-edit):not(.ark-mode-copy):not(.ark-mode-route):not(.ark-mode-drag) .arkusz-modes{ display:none; }
.arkusz-modes .ark-mode-hint{ display:inline-block; font-size:11.5px; color:var(--text-muted); padding:2px 0; }

/* #4 — FIX = tylko czerwona RAMKA; data zachowuje swój kolor terminu (jak w podglądzie) */
.arkusz .ark-date.fix{ background:transparent; border-color:transparent; color:var(--c); }
.arkusz .ark-pt-date-row.is-fix .ark-date{ box-shadow: inset 0 0 0 1.6px var(--st-danger); border-radius:5px; }

/* #7 — tooltip PRZYPIĘTY (po „C"): zaznaczalny + wyraźna ramka */
.otms-tip.is-locked{ pointer-events:auto; user-select:text; -webkit-user-select:text; box-shadow:0 0 0 2px var(--brand-blue), 0 16px 36px rgba(15,23,42,.22); }
.otms-tip.is-locked .otms-tip-copy-hint{ color:var(--brand-blue); font-weight:800; }

/* ═══════════ Faza 3: winieta UK na belce (kolor wg pokrycia PLANOWANEGO okresu trasy) ═══════════ */
.planning-route-vignette-uk{ display:inline-flex; align-items:center; gap:5px; padding:2px 9px 2px 5px; border-radius:999px; border:1.5px solid var(--border); background:var(--card); font-size:11px; font-weight:700; line-height:1; cursor:help; transition:transform var(--t-fast); }
.planning-route-vignette-uk:hover{ transform:translateY(-1px); }
.planning-route-vignette-uk .prv-uk-txt{ font-weight:800; letter-spacing:.03em; }
.planning-route-vignette-uk svg{ flex:none; }
.planning-route-vignette-uk.vignette-ok       { border-color:var(--st-success); background:var(--st-success-bg); color:#15803d; }
.planning-route-vignette-uk.vignette-warn     { border-color:var(--st-warning); background:var(--st-warning-bg); color:#a16207; }
.planning-route-vignette-uk.vignette-expiring { border-color:var(--st-danger);  background:var(--st-danger-bg);  color:#b91c1c; animation:pulseBorder 1.6s infinite; }
body.theme-dark .planning-route-vignette-uk.vignette-ok       { color:#4ade80; }
body.theme-dark .planning-route-vignette-uk.vignette-warn     { color:#fbbf24; }
body.theme-dark .planning-route-vignette-uk.vignette-expiring { color:#f87171; }

/* ═══════════ Faza 3: WYRAŹNY pływający baner aktywnego trybu (board + Ładunki) ═══════════ */
#ark-mode-banner{ position:fixed; left:50%; bottom:22px; transform:translateX(-50%) translateY(120%); z-index:1200;
    display:flex; align-items:center; gap:10px; max-width:min(760px, calc(100vw - 32px));
    padding:9px 10px 9px 14px; border-radius:999px; background:var(--card); color:var(--text);
    border:1px solid var(--border); box-shadow:0 10px 32px rgba(15,23,42,.22); opacity:0; pointer-events:none;
    transition:transform .22s cubic-bezier(.2,.8,.2,1), opacity .22s; }
#ark-mode-banner.show{ transform:translateX(-50%) translateY(0); opacity:1; pointer-events:auto; }
#ark-mode-banner .amb-tag{ flex:none; font-size:12px; font-weight:800; letter-spacing:.02em; color:#fff; background:var(--brand-blue); border-radius:999px; padding:4px 11px; }
#ark-mode-banner .amb-txt{ font-size:12.5px; color:var(--text-soft); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
#ark-mode-banner .amb-x{ flex:none; width:24px; height:24px; border:none; background:color-mix(in srgb, var(--text) 8%, transparent); color:var(--text-muted); border-radius:50%; cursor:pointer; font-size:13px; line-height:1; display:flex; align-items:center; justify-content:center; }
#ark-mode-banner .amb-x:hover{ background:color-mix(in srgb, var(--st-danger) 14%, transparent); color:var(--st-danger); }
#ark-mode-banner[data-mode="edit"]  .amb-tag{ background:#2563eb; }
#ark-mode-banner[data-mode="copy"]  .amb-tag{ background:#16a34a; }
#ark-mode-banner[data-mode="route"] .amb-tag{ background:#ea580c; }
#ark-mode-banner[data-mode="drag"]  .amb-tag{ background:#7c3aed; }
#ark-mode-banner[data-mode="edit"]  { border-color:color-mix(in srgb,#2563eb 40%,var(--border)); }
#ark-mode-banner[data-mode="copy"]  { border-color:color-mix(in srgb,#16a34a 40%,var(--border)); }
#ark-mode-banner[data-mode="route"] { border-color:color-mix(in srgb,#ea580c 40%,var(--border)); }
#ark-mode-banner[data-mode="drag"]  { border-color:color-mix(in srgb,#7c3aed 40%,var(--border)); }
/* Kursory wierszy zależne od trybu — sygnał „co teraz robię" (też na Ładunkach) */
body.ark-mode-copy  .ark-row[data-load-id]{ cursor:copy; }
body.ark-mode-drag  .ark-row[data-load-id]{ cursor:grab; }
body.ark-mode-route .ark-row[data-load-id]{ cursor:grab; }
body.ark-mode-drag  .ark-row[data-load-id]:active,
body.ark-mode-route .ark-row[data-load-id]:active{ cursor:grabbing; }

/* ═══════════════════════════════════════════════════════════════════
   ARKUSZ — PREMIUM FAZA 1
   towar-stos · kolor wagi na belce · podkreślenia sposobów ·
   miejsce odpr.+agencja · sprytne chowanie nr · kompaktowy wiersz
   (dopisane na końcu = wygrywa nad wcześniejszymi regułami)
   ═══════════════════════════════════════════════════════════════════ */

/* Kompaktowy wiersz */
.arkusz tbody td { padding-top: 5px; padding-bottom: 5px; }

/* TOWAR — pozycje jedna pod drugą (sam opis; pełne dane w tooltipie) */
.ark-cargo-stack { display: flex; flex-direction: column; gap: 2px; cursor: help; }
.ark-cargo-line  { font-size: 12px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; color: var(--text); }
.ark-cargo-stack:hover .ark-cargo-line { color: var(--brand-blue); }

/* SPOSÓB ZAŁADUNKU = podkreślenie kodu+miasta (pojedyncze / podwójne wg liczby sposobów) */
.ark-place-cc { display: inline-flex; align-items: baseline; gap: 4px; }
.ark-place-cc.ark-mug { cursor: help; padding-bottom: 2px; background-repeat: no-repeat; background-position: 0 100%; background-size: 100% 2px; }
.ark-place-cc.ark-mug-two { padding-bottom: 5px; background-size: 100% 2px, 100% 2px; background-position: 0 100%, 0 calc(100% - 3px); }

/* MIEJSCE ODPRAWY — miejsce + dyskretny znacznik agencji */
.ark-customs-place-row { cursor: help; }
.ark-agency-flag { color: var(--st-customs); margin-left: 3px; opacity: .75; display: inline-flex; vertical-align: -1px; }

/* BELKA / STOPKA — kolor wagi wg progu (te same zależności co w wierszu) */
.ark-sumchip.ark-sum-ldm,
.ark-sumchip.ark-sum-wgt { font-variant-numeric: tabular-nums; }
.ark-sumchip.ark-sum-wgt.wl-green  { background: var(--st-success-bg); border-color: var(--st-success-border); color: #166534; }
.ark-sumchip.ark-sum-wgt.wl-yellow { background: var(--st-warning-bg); border-color: var(--st-warning-border); color: #92400e; }
.ark-sumchip.ark-sum-wgt.wl-red    { background: var(--st-danger-bg);  border-color: var(--st-danger-border);  color: #991b1b; }

/* NR ZLECENIA — schowany, ale widoczny: przygaszony+zwinięty, pełny na hover wiersza */
.arkusz .ark-client-row2 .ark-order-num {
    max-width: 108px; display: inline-block; overflow: hidden; text-overflow: ellipsis;
    white-space: nowrap; vertical-align: bottom; opacity: .62; filter: saturate(.5);
    transition: max-width .16s ease, opacity .16s ease, filter .16s ease;
}
.arkusz tbody tr.ark-row:hover .ark-order-num { max-width: 280px; opacity: 1; filter: none; }

/* ═══ FAZA 2 + POPRAWKI (2026-06-11, po wdrożeniu fazy 1) ═══ */
/* Daty — zakres tej samej wielkości co data główna (koniec „różnych czcionek") */
.arkusz .ark-date-range { font-size: 12px; font-weight: 600; }

/* Mocniejszy tekst wiersza (koniec efektu „blade") */
.arkusz tbody td { color: var(--text); }
.arkusz .ark-place-city   { color: var(--text); font-weight: 600; }
.arkusz .ark-place-postal { color: var(--text-soft); font-weight: 600; }
.arkusz .ark-cargo-line   { color: var(--text); font-weight: 500; }
body.theme-dark .arkusz tbody td { color: var(--text); }

/* ADR — czerwone oznaczenie przy pozycji towaru */
.ark-cargo-adr {
    display: inline-block; margin-left: 6px; padding: 0 4px;
    font-size: 9px; font-weight: 800; letter-spacing: .3px;
    color: #fff; background: var(--st-danger);
    border-radius: 4px; vertical-align: 1px; cursor: help;
}

/* Tooltip — kropka koloru sposobu załadunku (wariant address) */
.otms-tip-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 0; flex: 0 0 auto; }

/* Nr zlecenia — przycisk kopiowania (pojawia się na hover wiersza) */
.ark-order-copy {
    display: none; margin-left: 4px; padding: 1px;
    border: 0; background: transparent; color: var(--text-muted);
    cursor: pointer; border-radius: 4px; vertical-align: middle; line-height: 0;
}
.arkusz tbody tr.ark-row:hover .ark-order-copy { display: inline-flex; }
.ark-order-copy:hover { color: var(--brand-blue); background: var(--st-info-bg, #e0f2fe); }

/* Szybki filtr — ukryte wiersze i puste nagłówki grup */
.arkusz tr.ark-row.ark-filtered, .arkusz tr.ark-group-head.ark-filtered { display: none; }

/* ── Rozwijanie towaru inline (chevron) ── */
.ark-cargo-cell{position:relative;}
.ark-cargo-expand{position:absolute;right:2px;top:50%;transform:translateY(-50%);width:16px;height:16px;
    border:0;background:transparent;color:var(--text-dim,#94a3b8);cursor:pointer;border-radius:4px;
    display:inline-flex;align-items:center;justify-content:center;padding:0;opacity:0;transition:opacity .12s, transform .15s;}
.ark-cargo-cell:hover .ark-cargo-expand{opacity:1;}
.ark-cargo-expand:hover{color:var(--brand-blue,#2563eb);background:var(--st-info-bg,#e0f2fe);}
.ark-cargo-expand.is-open{opacity:1;transform:translateY(-50%) rotate(180deg);color:var(--brand-blue,#2563eb);}
.ark-cargo-detail{margin-top:3px;padding:4px 6px;border-radius:6px;background:var(--bg,#f6f8fb);
    border:1px solid var(--border,#e2e8f0);display:flex;flex-direction:column;gap:2px;}
.ark-cd-row{display:flex;align-items:baseline;gap:7px;min-width:0;}
.ark-cd-name{font-size:10.5px;font-weight:700;color:var(--text,#0f172a);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:46%;}
.ark-cd-meta{font-size:10px;color:var(--text-soft,#334155);white-space:nowrap;}

/* ── PPM: nagłówek kontekstu ── */
.ark-context-head{padding:7px 10px 6px;font-size:11px;font-weight:800;color:var(--text-muted,#64748b);
    letter-spacing:.02em;border-bottom:1px solid var(--border,#e2e8f0);margin:0 0 4px;
    white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:280px;}
