/* ============================================
   TABLE STYLES
   ============================================ */

.table-container {
    padding: 0.25rem 1px;
    overflow: hidden;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.table-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1rem;
    color: var(--text-secondary);
}

.table-title strong {
    color: var(--text-primary);
}

.table-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.row-counter {
    font-size: 0.7rem;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.row-counter span {
    color: var(--accent-orange);
    font-weight: 600;
}

/* Excel Wrapper */
.excel-wrapper {
    background: var(--bg-secondary);
    border-radius: 2px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.excel-scroll {
    overflow: overlay;
    max-height: calc(100vh - 340px);
}

/* Excel Table */
.excel-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    min-width: 2400px;
}

.excel-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.excel-table th {
    background: linear-gradient(180deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%);
    border: 1px solid var(--border-color);
    padding: 0.7rem 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 14px;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    white-space: nowrap;
    text-align: center;
    cursor: pointer;
    user-select: none;
    transition: all 0.15s;
}

.excel-table th:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.excel-table th.selected,
.excel-table th.col-selected {
    background: var(--accent-orange);
    color: white;
}

/* Column cell selection */
.excel-table td.col-selected {
    background: rgba(249, 115, 22, 0.1) !important;
    box-shadow: inset 0 2px 0 0 var(--accent-orange), inset 0 -2px 0 0 var(--accent-orange);
}

/* Row Number Column */
.excel-table th:first-child,
.excel-table td:first-child {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    font-weight: 600;
    width: 36px;
    min-width: 36px;
    text-align: center;
    cursor: grab;
    user-select: none;
    position: sticky;
    left: 0;
    z-index: 5;
    font-size: 14px;
}

.excel-table td:first-child:hover {
    background: var(--accent-orange);
    color: white;
}

.excel-table td:first-child.dragging {
    cursor: grabbing;
    background: var(--accent-blue);
    color: white;
}

/* Table Cells */
.excel-table td {
    border: 1px solid #e2e8f0;
    padding: 0.3rem 0;
    background: var(--row-white);
    transition: background 0.15s;
}

.excel-table tbody tr:nth-child(even) td:not(:first-child) {
    background: var(--row-alt);
}

.excel-table tbody tr.selected td {
    background: rgba(147, 197, 253, 0.15) !important;
}

.excel-table tbody tr.drag-over {
    border-top: 3px solid var(--accent-orange);
}

.excel-table tbody tr.dragging {
    opacity: 0.5;
}

/* Table Inputs */
.excel-table input {
    width: 100%;
    padding: 0.45rem 0.5rem;
    border: none;
    background: transparent;
    color: var(--text-dark);
    font-family: 'JetBrains Mono', monospace;
    font-size: 15px;
    outline: none;
    text-align: center;
}

.excel-table input::placeholder {
    color: #94a3b8;
    opacity: 0.4;
}

.excel-table td.selected-cell {
    /* 2px user-color border wins over neighbour 1px borders under
       border-collapse:collapse. No background tint — composes badly with
       warm hashed avatar colors, and the table cell bg is always white
       in both themes (single rule, no theme override needed). */
    border: 2px solid var(--user-color, var(--accent-blue)) !important;
    position: relative;
    z-index: 2;
}

/* Light theme - sharper Harbor table treatment */
[data-theme="light"] .table-container {
    background: #f6f9fc;
}

[data-theme="light"] .table-title {
    color: #435468;
}

[data-theme="light"] .table-title strong {
    color: #102033;
}

[data-theme="light"] .row-counter {
    background: #eef4f8;
    border-color: #d6e2ea;
    color: #6c7b88;
}

[data-theme="light"] .row-counter span {
    color: #0f7ea2;
}

[data-theme="light"] .excel-wrapper {
    background: #ffffff;
    border-color: #b9cedb;
    box-shadow: 0 14px 38px rgba(23, 45, 64, 0.12);
}

[data-theme="light"] .excel-table th {
    background: #0a5989;
    border-color: #084a73;
    color: #ffffff;
}

[data-theme="light"] .excel-table th:hover {
    background: #084a73;
    color: #ffffff;
}

[data-theme="light"] .excel-table th.selected,
[data-theme="light"] .excel-table th.col-selected {
    background: #0f7ea2;
    color: #ffffff;
}

[data-theme="light"] .excel-table th:first-child,
[data-theme="light"] .excel-table td:first-child {
    background: #eef4f8;
    color: #6c7b88;
}

[data-theme="light"] .excel-table td {
    border-color: #d6e2ea;
    background: #ffffff;
}

[data-theme="light"] .excel-table tbody tr:nth-child(even) td:not(:first-child) {
    background: #f8fbfd;
}

[data-theme="light"] .excel-table tbody tr:hover td {
    background: #e6f3f8 !important;
}

[data-theme="light"] .excel-table input {
    color: #1d2c3b;
}

[data-theme="light"] .excel-table td.selected-cell {
    border-color: #0f7ea2 !important;
    background: rgba(15, 126, 162, 0.08) !important;
}

[data-theme="light"] .excel-table td.col-selected {
    background: rgba(15, 126, 162, 0.08) !important;
    box-shadow: inset 0 2px 0 0 #0f7ea2, inset 0 -2px 0 0 #0f7ea2;
}

/* Status Cell */
.status-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.55rem;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    white-space: nowrap;
}

.status-badge .status-icon {
    font-size: 0.8rem;
}

/* Status Colors — one unique color per status */
.status-new              { background: rgba(124, 58, 237, 0.15); color: #7c3aed; }  /* violet    */
.status-in-transit       { background: rgba(99, 102, 241, 0.15); color: #4f46e5; }  /* indigo    */
.status-unload-pending   { background: rgba(245, 158, 11, 0.15); color: #b45309; }  /* amber     */
.status-unload-approved  { background: rgba(16, 185, 129, 0.15); color: #059669; }  /* emerald   */
.status-unload-rejected  { background: rgba(239, 68, 68, 0.15);  color: #dc2626; }  /* red       */
.status-arrived          { background: rgba(59, 130, 246, 0.15); color: #2563eb; }  /* blue      */
.status-checked-in       { background: rgba(59, 130, 246, 0.15); color: #2563eb; }  /* blue      */
.status-in-stock         { background: rgba(34, 197, 94, 0.15);  color: #16a34a; }  /* green     */
.status-released         { background: rgba(14, 165, 233, 0.15); color: #0284c7; }  /* sky       */
.status-dispatched       { background: rgba(13, 148, 136, 0.15); color: #0d9488; }  /* teal      */
.status-archived         { background: rgba(107, 114, 128, 0.15); color: #6b7280; } /* gray      */
.status-compliance-blocked { background: rgba(239, 68, 68, 0.15); color: #dc2626; } /* red       */
/* Legacy aliases */
.status-on-hold          { background: rgba(245, 158, 11, 0.15); color: #b45309; }
.status-blocked          { background: rgba(239, 68, 68, 0.15);  color: #dc2626; }
.status-in-process       { background: rgba(59, 130, 246, 0.15); color: #2563eb; }
.status-needs-action     { background: rgba(245, 158, 11, 0.15); color: #b45309; }
/* Cleared but still in transit — green to differentiate */
.status-cleared-transit  { background: rgba(34, 197, 94, 0.15);  color: #16a34a; }  /* green     */
/* Stock-specific statuses */
.status-in-order         { background: rgba(14, 165, 233, 0.15); color: #0284c7; }  /* sky       */
.status-picked           { background: rgba(124, 58, 237, 0.15); color: #7c3aed; }  /* violet    */
.status-allocated        { background: rgba(14, 165, 233, 0.15); color: #0284c7; }  /* sky       */

/* Column Widths */
.col-status { width: 115px; min-width: 115px; }
.col-notes { width: 85px; min-width: 85px; }
.col-file { width: 90px; min-width: 90px; }
/* File column reads as a code (REF-MYN-001 etc.), not a free-form name —
   keep it 2px smaller than the rest so it doesn't dominate the row. */
.excel-table th.col-file { font-size: 12px; }
.excel-table input[data-col="file"] { font-size: 13px; }
.col-customer { width: 130px; min-width: 130px; }
.col-shipper { width: 200px; min-width: 200px; }
.col-container { width: 120px; min-width: 120px; }
.col-vessel { width: 130px; min-width: 130px; }
.col-cia { width: 75px; min-width: 75px; }
.col-terminal { width: 85px; min-width: 85px; }
.col-whs { width: 75px; min-width: 75px; }
.col-freight { width: 80px; min-width: 80px; }
.col-release { width: 80px; min-width: 80px; }
.col-qc { width: 60px; min-width: 60px; }
.col-phyto { width: 70px; min-width: 70px; }
.col-tdoc { width: 80px; min-width: 80px; }
.col-kcb { width: 80px; min-width: 80px; }
.col-customs { width: 75px; min-width: 75px; }
.col-planned { width: 68px; min-width: 68px; }
.col-arrived { width: 68px; min-width: 68px; }
.col-carrier { width: 90px; min-width: 90px; }

/* Dashboard panes */
.dashboard-pane {
    display: none;
}

.dashboard-pane.active {
    display: block;
}

/* Re-export board */
.table-container.reexport-pane {
    padding-left: 1px;
    padding-right: 1px;
}

.reexport-toolbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 0.25rem 0;
    margin-bottom: 0.25rem;
}

.reexport-pane .excel-wrapper {
    background: #f7faf2;
    border-color: #cfd9bf;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.reexport-help,
.reexport-empty,
.crossdock-placeholder {
    border-radius: 8px;
}

.reexport-help {
    margin-bottom: 0.9rem;
    padding: 0.85rem 1rem;
    border: 1px solid #cdddbb;
    background: #eef6e6;
    color: #29403c;
    font-size: 0.78rem;
    line-height: 1.5;
}

.reexport-empty,
.crossdock-placeholder {
    padding: 1.4rem;
    border: 1px dashed var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    text-align: center;
}

.crossdock-placeholder strong {
    display: inline-block;
    margin-bottom: 0.35rem;
    color: var(--text-primary);
}

.reexport-scroll {
    max-height: calc(100vh - 330px);
}

.reexport-table {
    width: 100%;
}

.reexport-table th {
    background: linear-gradient(180deg, #dae8c9 0%, #edf6e4 100%);
    border-color: #c6d7af;
    color: #243527;
}

.reexport-table td {
    border-color: #d4ddc8;
    background: #eff7e5;
    vertical-align: middle;
}

.reexport-table tbody tr:nth-child(even) td:not(:first-child) {
    background: #e4f0d7;
}

.reexport-table tbody tr:hover td {
    background: #d9ecc6;
}

.reexport-table th:first-child,
.reexport-table td:first-child {
    position: static;
    left: auto;
    width: 120px;
    min-width: 120px;
    cursor: default;
    color: inherit;
    background: inherit;
}

.reexport-table td:first-child:hover,
.reexport-table td:first-child.dragging {
    background: inherit;
    color: inherit;
}

.reexport-table th:hover {
    background: #d2e2bf;
    color: #1d2b20;
}

.reexport-table .status-badge {
    font-size: 0.7rem;
}

.reexport-head-main {
    font-size: 12px;
    line-height: 1.3;
}

.reexport-head-sub {
    font-size: 10px;
    line-height: 1.3;
    text-transform: none;
    color: #5b6d5f;
    font-weight: 500;
}

.reexport-readonly {
    padding: 0.45rem 0.55rem;
    text-align: center;
    color: #1f2937;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
}

.reexport-col-customer,
.reexport-col-shipper,
.reexport-col-vessel {
    font-family: 'Space Grotesk', sans-serif;
}

.reexport-table input,
.reexport-table select {
    width: 100%;
    padding: 0.42rem 0.45rem;
    border: none;
    background: transparent;
    color: #1f2937;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    outline: none;
    text-align: center;
}

.reexport-table select {
    cursor: pointer;
}

.reexport-date-time {
    display: grid;
    grid-template-columns: minmax(55px, 1fr) 70px;
    align-items: center;
}

.reexport-date-time input + input {
    border-left: 1px solid #d4ddc8;
}

.reexport-action-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    width: 100%;
    padding: 0.4rem 0.45rem;
    color: #1f2937;
    font-size: 13px;
    font-family: 'JetBrains Mono', monospace;
}

.reexport-action-toggle input {
    width: auto;
    margin: 0;
}

.reexport-row-focus td {
    box-shadow: inset 0 0 0 2px #16a34a;
}

.reexport-row-archiving td {
    background: #86efac !important;
    transition: background 0.2s ease;
}

.reexport-source-missing td {
    opacity: 0.7;
}

.mono {
    font-family: 'JetBrains Mono', monospace;
}

.reexport-col-status-source { min-width: 110px; }
.reexport-col-notes { min-width: 110px; }
.reexport-col-file { min-width: 85px; }
.reexport-col-customer { min-width: 130px; }
.reexport-col-shipper { min-width: 180px; }
.reexport-col-cargo { min-width: 135px; }
.reexport-col-vessel { min-width: 140px; }
.reexport-col-whs { min-width: 90px; }
.reexport-col-docs { min-width: 140px; }
.reexport-col-workflow { min-width: 100px; }
.reexport-col-label { min-width: 80px; }
.reexport-col-qc { min-width: 70px; }
.reexport-col-weight { min-width: 100px; }
.reexport-col-invoice { min-width: 110px; }
.reexport-col-phyto { min-width: 80px; }
.reexport-col-cvo { min-width: 85px; }
.reexport-col-transport { min-width: 110px; }
.reexport-col-fullset { min-width: 75px; }
.reexport-col-loading { min-width: 125px; }
.reexport-col-deadline { min-width: 140px; }
.reexport-col-slot { min-width: 140px; }
.reexport-col-action { min-width: 95px; }

/* ============================================
   LIGHT THEME - TABLE STYLING
   ============================================ */

[data-theme="light"] .table-container {
    background: transparent !important;
}

[data-theme="light"] .table-title {
    color: #64748b !important;
}

[data-theme="light"] .table-title strong {
    color: #0f172a !important;
}

[data-theme="light"] .row-counter {
    background: #f8fafc !important;
    border-color: #cbd5e1 !important;
    color: #64748b !important;
}

[data-theme="light"] .row-counter span {
    color: #475569 !important;
}

[data-theme="light"] .excel-wrapper {
    background: #ffffff !important;
    border-color: #cbd5e1 !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08) !important;
}

/* Table Headers - Light Theme — marine-blue title bar (matches the
   WMS header navy #0a5989) with white typography so the backoffice
   table title reads like a colored sheet header on white pages. */
[data-theme="light"] .excel-table th {
    background: #0a5989 !important;
    border-color: #084a73 !important;
    color: #ffffff !important;
}

[data-theme="light"] .excel-table th:hover {
    background: #084a73 !important;
    color: #ffffff !important;
}

[data-theme="light"] .excel-table th.selected,
[data-theme="light"] .excel-table th.col-selected {
    background: #063a5a !important;
    color: #ffffff !important;
}

/* Column cell selection - Light Theme */
[data-theme="light"] .excel-table td.col-selected {
    background: rgba(71, 85, 105, 0.1) !important;
    box-shadow: inset 0 2px 0 0 #475569, inset 0 -2px 0 0 #475569 !important;
}

/* Row Number Column - Light Theme */
[data-theme="light"] .excel-table th:first-child,
[data-theme="light"] .excel-table td:first-child {
    background: #e2e8f0 !important;
    color: #475569 !important;
    border-color: #cbd5e1 !important;
}

[data-theme="light"] .excel-table td:first-child:hover {
    background: #475569 !important;
    color: #ffffff !important;
}

[data-theme="light"] .excel-table td:first-child.dragging {
    background: #475569 !important;
    color: #ffffff !important;
}

/* Table Cells - Light Theme */
[data-theme="light"] .excel-table td {
    border-color: #e2e8f0 !important;
    background: #ffffff !important;
}

[data-theme="light"] .excel-table tbody tr:nth-child(even) td:not(:first-child) {
    background: #f8fafc !important;
}

[data-theme="light"] .excel-table tbody tr.selected td {
    background: rgba(71, 85, 105, 0.1) !important;
}

[data-theme="light"] .excel-table tbody tr.drag-over {
    border-top-color: #475569 !important;
}

/* Table Inputs - Light Theme */
[data-theme="light"] .excel-table input {
    color: #0f172a !important;
}

[data-theme="light"] .excel-table input::placeholder {
    color: #94a3b8 !important;
}

/* Light-theme override removed — the theme-agnostic .excel-table
   td.selected-cell rule above serves both themes since the table cell
   background is always white regardless of theme. */

[data-theme="light"] .reexport-pane .excel-wrapper {
    background: #f7faf2 !important;
    border-color: #cfd9bf !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08) !important;
}

[data-theme="light"] .reexport-table th {
    background: linear-gradient(180deg, #dae8c9 0%, #edf6e4 100%) !important;
    border-color: #c6d7af !important;
    color: #243527 !important;
}

[data-theme="light"] .reexport-table th:hover {
    background: #d2e2bf !important;
    color: #1d2b20 !important;
}

[data-theme="light"] .reexport-table td {
    background: #eff7e5 !important;
    border-color: #d4ddc8 !important;
}

[data-theme="light"] .reexport-table tbody tr:nth-child(even) td:not(:first-child) {
    background: #e4f0d7 !important;
}

[data-theme="light"] .reexport-table tbody tr:hover td {
    background: #d9ecc6 !important;
}

[data-theme="light"] .reexport-table th:first-child,
[data-theme="light"] .reexport-table td:first-child {
    background: inherit !important;
    color: inherit !important;
}

[data-theme="light"] .reexport-table td:first-child:hover,
[data-theme="light"] .reexport-table td:first-child.dragging {
    background: inherit !important;
    color: inherit !important;
}

[data-theme="light"] .reexport-help {
    background: #eef6e6 !important;
    border-color: #cdddbb !important;
    color: #29403c !important;
}

/* ============================================
   MINI CALENDAR DATE PICKER
   ============================================ */

.mini-calendar-overlay {
    position: fixed;
    z-index: 9999;
    background: var(--bg-secondary, #1e293b);
    border: 1px solid var(--border-color, #334155);
    border-radius: 8px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    padding: 10px;
    width: 220px;
    display: none;
    font-family: 'Space Grotesk', 'JetBrains Mono', sans-serif;
    font-size: 12px;
}

.mini-calendar-overlay.visible {
    display: block;
}

.mini-cal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.mini-cal-title {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary, #f1f5f9);
}

.mini-cal-nav {
    background: none;
    border: 1px solid var(--border-color, #334155);
    color: var(--text-secondary, #94a3b8);
    cursor: pointer;
    border-radius: 4px;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    transition: all 0.15s;
}

.mini-cal-nav:hover {
    background: var(--bg-hover, #334155);
    color: var(--text-primary, #f1f5f9);
}

.mini-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.mini-cal-day-header {
    text-align: center;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted, #64748b);
    padding: 4px 0;
    text-transform: uppercase;
}

.mini-cal-cell {
    text-align: center;
    padding: 5px 2px;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-secondary, #cbd5e1);
    transition: all 0.1s;
    font-size: 11px;
}

.mini-cal-cell:hover {
    background: var(--accent-orange, #f97316);
    color: white;
}

.mini-cal-cell.today {
    background: rgba(59, 130, 246, 0.25);
    color: #60a5fa;
    font-weight: 700;
}

.mini-cal-cell.today:hover {
    background: var(--accent-orange, #f97316);
    color: white;
}

.mini-cal-cell.empty {
    cursor: default;
}

.mini-cal-cell.empty:hover {
    background: none;
}

.mini-cal-footer {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    border-top: 1px solid var(--border-color, #334155);
    padding-top: 8px;
}

.mini-cal-footer button {
    flex: 1;
    padding: 5px 0;
    border: 1px solid var(--border-color, #334155);
    border-radius: 4px;
    background: var(--bg-tertiary, #0f172a);
    color: var(--text-secondary, #94a3b8);
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    transition: all 0.15s;
}

.mini-cal-footer button:hover {
    background: var(--bg-hover, #334155);
    color: var(--text-primary, #f1f5f9);
}

/* Mini Calendar - Light Theme */
[data-theme="light"] .mini-calendar-overlay {
    background: #ffffff !important;
    border-color: #cbd5e1 !important;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12) !important;
}

[data-theme="light"] .mini-cal-title {
    color: #0f172a !important;
}

[data-theme="light"] .mini-cal-nav {
    border-color: #cbd5e1 !important;
    color: #64748b !important;
}

[data-theme="light"] .mini-cal-nav:hover {
    background: #f1f5f9 !important;
    color: #0f172a !important;
}

[data-theme="light"] .mini-cal-cell {
    color: #334155 !important;
}

[data-theme="light"] .mini-cal-cell:hover {
    background: #475569 !important;
    color: #ffffff !important;
}

[data-theme="light"] .mini-cal-cell.today {
    background: rgba(59, 130, 246, 0.15) !important;
    color: #2563eb !important;
}

[data-theme="light"] .mini-cal-cell.today:hover {
    background: #475569 !important;
    color: #ffffff !important;
}

[data-theme="light"] .mini-cal-footer button {
    background: #f8fafc !important;
    border-color: #cbd5e1 !important;
    color: #475569 !important;
}

[data-theme="light"] .mini-cal-footer button:hover {
    background: #e2e8f0 !important;
    color: #0f172a !important;
}

/* ============================================
   LIVE SYNC — Cell locks, dirty cells, presence
   ============================================ */

/* Cell locked by another user: 2px colored border + tinted background. The
   <td> stays clickable (cursor: pointer) so 3rd users can still click the
   row to select it; the <input> stays focusable and selectable but is
   read-only, with a "not-allowed" cursor making it clear that copy/select
   work but typing does not. The --lock-color custom property is set inline
   by LockOverlay using the owner's avatar color. */
.cell-locked-by-other {
    position: relative;
    cursor: pointer;
    box-shadow: inset 0 0 0 2px var(--lock-color, #a855f7);
    background: color-mix(in srgb, var(--lock-color, #a855f7) 10%, transparent);
}
.cell-locked-by-other input {
    cursor: not-allowed;
    color: inherit;
    opacity: 0.85;
    background: transparent;
}
.cell-lock-chip {
    position: absolute;
    top: 2px;
    right: 2px;
    z-index: 4;
    font-size: 9px;
    font-weight: 700;
    line-height: 1;
    color: #fff;
    padding: 2px 4px;
    border-radius: 3px;
    pointer-events: none;
    letter-spacing: 0.5px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

/* Row with at least one foreign lock: faintly dim the non-locked cells so
   users notice another editor is active in this row. */
.row-has-active-edit > td:not(.cell-locked-by-other):not(:first-child) {
    opacity: 0.78;
}

/* Dirty cell — the local user has typed but the debounced save hasn't
   flushed yet. Subtle yellow left-border, fades automatically once the
   save resolves and clearDirty is called. */
.dirty-cell {
    box-shadow: inset 3px 0 0 0 #f59e0b;
}

/* Presence bar — small avatar list above the table. */
#presenceBar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    font-size: 12px;
    color: var(--text-muted, #94a3b8);
}
#presenceBar .presence-label {
    margin-right: 4px;
}
#presenceBar .presence-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Live sync indicator — green dot when poll is healthy, grey when paused
   (tab hidden), red on consecutive errors. State is set as a data attr by
   ControlBoardPoller._setIndicator. */
#liveSyncIndicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted, #94a3b8);
}
#liveSyncIndicator[data-state="error"] {
    color: #f87171;
    background: rgba(248, 113, 113, 0.08);
}

/* ============================================
   PEER SELECTIONS (live presence cursors)
   ============================================
   Rendered by SelectionOverlay from each poll tick. Distinct from
   .cell-locked-by-other: never blocks input, just shows where peers are
   working. The --peer-color custom property is set inline using the peer's
   avatar color. Multiple peers selecting the same target → last wins
   (acceptable for a soft indicator). */

/* A cell another user has selected. Thin colored border, subtle tint. */
.cell-selected-by-other {
    box-shadow: inset 0 0 0 1px var(--peer-color, #a855f7);
    background: color-mix(in srgb, var(--peer-color, #a855f7) 6%, transparent);
}
/* The cell another user is currently focused on. Stronger border + chip-ish
   inner glow so you can pick out their cursor at a glance. */
.cell-focused-by-other {
    box-shadow: inset 0 0 0 2px var(--peer-color, #a855f7),
                0 0 0 1px color-mix(in srgb, var(--peer-color, #a855f7) 40%, transparent);
}
/* If a peer has BOTH a foreign lock and a peer-selection on the same cell
   (lock wins visually — typing must be blocked, not just shown). */
.cell-locked-by-other.cell-selected-by-other {
    box-shadow: inset 0 0 0 2px var(--lock-color, #a855f7);
    background: color-mix(in srgb, var(--lock-color, #a855f7) 10%, transparent);
}

/* A row another user has selected — left border in their color so it doesn't
   conflict with row-has-active-edit (which dims) or with the local
   .selected class (which highlights). */
/* Peer row selection: thin colored top + bottom borders across every cell
   so the row reads as a "boxed" selection on either theme. NO background
   tint — it composes badly with the dark theme's already-dark cell bg
   (produced muddy / unreadable colors). The :not() guards keep cell-level
   peer styling (locks, per-cell selections) intact on overlap. */
.row-selected-by-other > td:not(.cell-locked-by-other):not(.cell-selected-by-other) {
    box-shadow: inset 0 2px 0 0 var(--peer-color, #a855f7),
                inset 0 -2px 0 0 var(--peer-color, #a855f7);
}

/* Anchor on the row-number cell: keep the 4 px left-bar plus the same top
   and bottom rails so the # column reads as the row's selection label. */
.row-selected-by-other > td:first-child {
    box-shadow: inset 4px 0 0 0 var(--peer-color, #a855f7),
                inset 0 2px 0 0 var(--peer-color, #a855f7),
                inset 0 -2px 0 0 var(--peer-color, #a855f7);
}

/* A column another user has selected — top border on the header. */
.col-selected-by-other {
    box-shadow: inset 0 4px 0 0 var(--peer-color, #a855f7);
}

/* ============================================
   SELECT vs EDIT — visual differentiation
   ============================================
   Read-only cells (display mode): show the Excel-style "cell" cursor so
   it's clear you can click-and-copy but not type. Double-click promotes
   to edit mode (input becomes writable, cursor reverts to text). */
.excel-table input[readonly] {
    cursor: cell;
}
.excel-table input:not([readonly]) {
    cursor: text;
}

/* Cell currently in EDIT mode — 2px green frame (wider than the gray
   default so it wins under border-collapse). Distinguishes "I'm typing"
   from the user-color "selected" frame. */
.excel-table td:has(> input[data-edit-mode="1"]) {
    border: 2px solid var(--accent-green, #22c55e) !important;
    box-shadow: none !important;
    outline: none !important;
    position: relative;
    z-index: 3;
}

/* ============================================
   SEVENSEAS TABLE
   Clone of the shipments excel-table look, but cells are contenteditable
   <div>s with soft text-wrap. Long values wrap to multiple lines and the
   row grows to fit — required by SevenSeas import data.
   ============================================ */
.excel-table.sevenseas-table {
    /* Override the shipments-wide 2400px floor so columns can size to
       their content instead of forcing horizontal scroll on small data. */
    min-width: 0;
    table-layout: auto;
}

.sevenseas-table th {
    /* Headers stay single-line for compactness; cells can wrap. */
    white-space: nowrap;
    cursor: default;
}

.sevenseas-table td {
    padding: 0;
    /* Vertically center the cell-wrap inside its td so a single-line
       value in a row whose neighbours wrap to multiple lines still
       sits on the row's midline. Horizontal centering is `text-align`
       below; both axes need to be set to get true cell-centering. */
    vertical-align: middle;
    white-space: normal;
    /* Default cell alignment is center across the whole SevenSeas table.
       Ribbon-set per-cell alignment writes an inline `text-align:`
       directly on the <td> so it still wins over this rule. */
    text-align: center;
    /* Default cell text color is solid black on both themes (SevenSeas
       cells always paint a white-ish bg via .excel-table defaults).
       The .cell-wrap inside inherits this so contenteditable text is
       legible; ribbon-set per-cell color writes an inline `color:` on
       the td and overrides this rule by inline-style specificity. */
    color: #111111;
}

[data-theme="light"] .sevenseas-table td {
    color: #111111;
}

.sevenseas-table td.row-num {
    text-align: center;
    padding: 0.45rem 0;
}

.sevenseas-table .cell-wrap {
    display: block;
    width: 100%;
    min-height: 1.6em;
    padding: 0.45rem 0.6rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    line-height: 1.45;
    /* Inherit text color from the td so ribbon-set per-cell color
       (applied as inline style on the td) propagates into the wrap. */
    color: inherit;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    outline: none;
    /* Select-mode by default (cell cursor); typed text must stay as entered —
       reset any inherited uppercase from ancestor rules so lowercase isn't
       forced to CAPS. */
    cursor: cell;
    text-transform: none;
    /* Pick up the td's text-align (defaults to center, ribbon override
       on td still wins by inline-style specificity). */
    text-align: inherit;
}
.sevenseas-table td { text-transform: none; }
/* Edit mode (double-click) — text caret + green edit outline, mirroring
   the Shipments Register's data-edit-mode border. */
.sevenseas-table .cell-wrap[contenteditable="true"] { cursor: text; }
.sevenseas-table td:has(> .cell-wrap[contenteditable="true"]) {
    box-shadow: inset 0 0 0 2px var(--accent-green, #22c55e);
}

/* ---- Stock-status picker cell + slide-up popover ---- */
.sevenseas-table .ss-status-cell {
    cursor: pointer;
    display: inline-flex; align-items: center; gap: 6px;
    justify-content: center;
    user-select: none;
}
.sevenseas-table .ss-status-cell:hover { background: rgba(124, 140, 248, 0.10); }
.ss-status-ico { color: var(--accent, #5b5fc7); font-size: 0.95em; }
.ss-status-txt { white-space: nowrap; }

.ss-status-backdrop { position: fixed; inset: 0; z-index: 2400; }
.ss-status-pop {
    position: fixed; z-index: 2401;
    background: var(--bg-secondary, #1e293b);
    border: 1px solid var(--border-color, #334155);
    border-radius: 12px;
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.5);
    padding: 12px;
    transform-origin: bottom center;
    animation: ssStatusSlideUp 0.16s cubic-bezier(0.16, 0.84, 0.44, 1);
}
.ss-status-pop.ss-status-pop--below { transform-origin: top center; }
@keyframes ssStatusSlideUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
.ss-status-row { display: flex; gap: 10px; }
.ss-status-btn {
    flex: 1 1 0; min-width: 84px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    padding: 12px 8px;
    background: var(--bg-tertiary, #334155);
    border: 1px solid var(--border-color, #334155); border-radius: 10px;
    color: var(--text-primary, #f1f5f9); font-size: 0.78rem; font-weight: 700;
    cursor: pointer; text-align: center;
    transition: border-color 0.12s, background 0.12s, transform 0.08s;
}
/* Icon: white on dark theme, accent on light. */
.ss-status-btn i { font-size: 1.45rem; color: #ffffff; }
[data-theme="light"] .ss-status-btn i { color: var(--accent, #5b5fc7); }
/* Light theme: crisp, defined panel + buttons so it doesn't read as a
   washed-out white blur (the backdrop stays fully transparent). */
[data-theme="light"] .ss-status-pop {
    border-color: #cbd5e1;
    box-shadow: 0 12px 30px rgba(15, 32, 51, 0.20);
}
[data-theme="light"] .ss-status-btn { border-color: #cbd5e1; }
.ss-status-btn:hover { border-color: var(--accent-light, #7c8cf8); background: var(--bg-hover, rgba(255,255,255,0.06)); }
.ss-status-btn:active { transform: scale(0.96); }
.ss-status-btn.selected { border-color: var(--accent-green, #22c55e); }
/* Single shared "Poeldijk" toggle, centered below the icons. */
.ss-status-pol {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    margin-top: 10px; font-size: 0.8rem; font-weight: 600;
    color: var(--text-secondary, #cbd5e1); cursor: pointer;
}
.ss-status-pol small { font-weight: 500; color: var(--text-muted, #94a3b8); }
.ss-status-pol input { accent-color: var(--accent, #5b5fc7); cursor: pointer; }
/* Caret pointing back at the cell (tooltip-bubble). Points DOWN when the
   bubble sits above the cell, UP when it had to flip below. */
.ss-status-arrow {
    position: absolute; width: 13px; height: 13px;
    background: var(--bg-secondary, #1e293b);
    transform: translateX(-50%) rotate(45deg);
    bottom: -7px;
    border-right: 1px solid var(--border-color, #334155);
    border-bottom: 1px solid var(--border-color, #334155);
}
.ss-status-pop--below .ss-status-arrow {
    bottom: auto; top: -7px;
    border-right: 0; border-bottom: 0;
    border-left: 1px solid var(--border-color, #334155);
    border-top: 1px solid var(--border-color, #334155);
}
[data-theme="light"] .ss-status-arrow { border-color: #cbd5e1; }

/* Belt-and-braces: any element that survives a paste from Excel /
   Word / etc. inside a cell-wrap gets stripped of inline bg / fonts /
   colors so the table's own styling wins. The JS paste handler
   already coerces clipboard data to plain text — these rules cover
   the edge case of a paste that bypassed the handler (drag-drop,
   programmatic insert, IE-style legacy paths). */
.sevenseas-table .cell-wrap *,
.sevenseas-table .cell-wrap *::before,
.sevenseas-table .cell-wrap *::after {
    background: transparent !important;
    background-color: transparent !important;
    color: inherit !important;
    font-family: inherit !important;
    font-size: inherit !important;
    font-weight: inherit !important;
    text-decoration: inherit !important;
    border: 0 !important;
    box-shadow: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

.sevenseas-table .cell-wrap:empty::before {
    content: '';
    display: inline-block;
}

.sevenseas-table .cell-wrap:focus {
    /* Caret/focus visual ONLY (no ring) — the td.ss-cell-selected
       ring is the single source of truth for the selection indicator.
       Stacking a second ring on the inner cell-wrap was producing the
       "two borders, one bigger one smaller" artifact. */
    background: rgba(147, 197, 253, 0.10);
    border-radius: 2px;
}

.sevenseas-table .ss-row-actions {
    text-align: center;
    padding: 0.3rem 0.4rem;
}

.sevenseas-table .ss-row-delete {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 2px 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-muted);
    transition: all 0.15s;
}

.sevenseas-table .ss-row-delete:hover {
    border-color: #ef4444;
    color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
}

.sevenseas-empty {
    padding: 1rem 1.25rem;
    margin-top: 0.75rem;
    background: var(--bg-secondary);
    border: 1px dashed var(--border-color);
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 13px;
}

[data-theme="light"] .sevenseas-empty {
    background: #f6f9fc;
    border-color: #c8d6e0;
    color: #4a5d6d;
}

/* When a SevenSeas cell is foreign-locked, suppress the cell-wrap's
   own background so the td's --lock-color tint shows through. The
   global .cell-locked-by-other rule paints `inset 0 0 0 2px
   var(--lock-color)` + 10% bg tint on the <td>; without this override
   the cell-wrap's white inherit would mask the tint. The chip
   (.cell-lock-chip) is absolutely positioned and already z-index 4
   so it sits above the cell-wrap. */
.sevenseas-table td.cell-locked-by-other .cell-wrap {
    background: transparent !important;
    cursor: not-allowed;
}

/* SevenSeas ribbon — same layout as the shipments ribbon, just scoped
   to .ss-ribbon so we can tweak independently without touching the
   shipments-side .ribbon rules. */
.ss-ribbon {
    margin-bottom: 0.5rem;
}

/* Selection styling — maps SevenSeas's own selection class names onto
   the same visual language the shipments table uses (`.excel-table
   tbody tr.selected td` blue tint + `.selected-cell` user-color ring).
   No row-hover override here: SevenSeas inherits the global
   `[data-theme="light"] .excel-table tbody tr:hover td` (#e6f3f8) and
   `.excel-table td:first-child:hover` row-num treatments earlier in
   this file — single source of truth for hover across all tables. */
.sevenseas-table tbody tr.ss-row-selected td:not(:first-child) {
    background: rgba(147, 197, 253, 0.15) !important;
}

.sevenseas-table tbody tr.ss-row-selected td.row-num {
    background: var(--user-color, var(--accent-blue)) !important;
    color: #ffffff !important;
}

.sevenseas-table td.ss-cell-selected {
    box-shadow: inset 0 0 0 2px var(--user-color, var(--accent-blue));
    position: relative;
    z-index: 2;
}

/* When the entire row is selected, the row-tint background is the
   indicator — suppress the per-cell rings so the row doesn't look
   like 9 individually-selected cells stitched together. */
.sevenseas-table tbody tr.ss-row-selected td.ss-cell-selected {
    box-shadow: none;
}

/* Color-picker popover variant scoped to SevenSeas (does not clash with
   the shipments-side #colorPickerModal that owns the same class). */
#ssColorPickerModal {
    display: none;
    position: fixed;
    inset: 0;
    background: transparent;
    z-index: 1000;
    pointer-events: none;
}
#ssColorPickerModal.visible {
    display: block;
}
#ssColorPickerModal.visible.popover .color-picker-panel {
    pointer-events: auto;
    position: fixed;
    background: var(--bg-secondary, #ffffff);
    border: 1px solid var(--border-color, #d6e2ea);
    border-radius: 8px;
    padding: 0.75rem;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.22);
    min-width: 260px;
    max-width: 320px;
}
