/* ============================================
   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;
}
