.ect-view-switch {
    display: flex;
    gap: 0;
    margin-bottom: 1rem;
    border: 1px solid var(--surface-border, #e5e7eb);
    border-radius: 10px;
    overflow: hidden;
    width: fit-content;
    max-width: 100%;
}
.ect-view-switch button {
    border: 0;
    background: #fff;
    padding: .7rem 1.25rem;
    font-weight: 700;
    cursor: pointer;
    color: var(--text-secondary, #4b5563);
}
.ect-view-switch button.is-active {
    background: var(--primary, #0f766e);
    color: #fff;
}

/* ---- Summary cards ---- */
.ect-cards {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .75rem;
    margin-bottom: 1rem;
}
.ect-card {
    border: 1px solid var(--surface-border, #e5e7eb);
    border-radius: 10px;
    padding: .9rem 1rem;
    background: #fff;
    text-align: start;
    cursor: pointer;
    width: 100%;
    min-height: 6.5rem;
    display: flex;
    flex-direction: column;
    gap: .35rem;
    align-items: stretch;
}
.ect-card .ect-card-label {
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-secondary, #6b7280);
    line-height: 1.3;
    word-break: break-word;
}
.ect-card .ect-card-value {
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1.15;
    color: var(--text-primary, #111827);
    font-variant-numeric: tabular-nums;
}
.ect-card .ect-card-hint {
    font-size: .72rem;
    color: #9ca3af;
    margin-top: auto;
}
.ect-card.is-active { outline: 2px solid var(--primary, #0f766e); outline-offset: 1px; }
.ect-card.tone-warn { border-color: var(--warning); }
.ect-card.tone-danger { border-color: var(--danger); }
.ect-card.is-clickable { cursor: pointer; }

/* Searchable employee lookup (mirrors reports lookup layout) */
#ectPage .ect-lookup-filter {
    display: inline-flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 0.35rem;
    max-width: 100%;
    vertical-align: middle;
}
#ectPage .ect-lookup-filter .filter-field {
    min-width: 8rem;
    max-width: 11rem;
}
#ectPage .ect-lookup-filter .filter-select {
    min-width: 10rem;
    max-width: 14rem;
}

.ect-qty-in { color: #198754; font-weight: 600; }
.ect-qty-out { color: #dc3545; font-weight: 600; }
.ect-balance {
    font-size: 1.05rem;
    font-weight: 800;
}
.ect-person, .ect-product {
    display: flex;
    align-items: center;
    gap: .5rem;
    min-width: 0;
}
.ect-avatar, .ect-prod-img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex: none;
    background: #e5e7eb;
}
.ect-prod-img { border-radius: 6px; }
.ect-badges { display: flex; flex-wrap: wrap; gap: .25rem; }

/* ---- Flow / recon ---- */
.ect-flow {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-bottom: 1rem;
}
.ect-flow-step {
    border: 1px dashed #d1d5db;
    border-radius: 8px;
    padding: .45rem .7rem;
    font-size: .8rem;
    color: #6b7280;
}
.ect-flow-step.is-done {
    border-style: solid;
    border-color: #0f766e;
    color: #0f766e;
    font-weight: 600;
}
.ect-recon {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: .5rem;
    margin-bottom: 1rem;
}
.ect-recon > div {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: .55rem .7rem;
    display: flex;
    flex-direction: column;
    gap: .2rem;
    min-width: 0;
}
.ect-recon .ect-kv-label {
    font-size: .72rem;
    color: #6b7280;
    line-height: 1.3;
    word-break: break-word;
}
.ect-recon .ect-kv-value {
    font-weight: 700;
    font-size: .95rem;
    line-height: 1.25;
    word-break: break-word;
    font-variant-numeric: tabular-nums;
}

/* ---- Vertical timeline ---- */
.ect-timeline {
    list-style: none;
    padding: 0;
    margin: 0 0 1.25rem;
    position: relative;
}
.ect-timeline.is-empty {
    border: 0;
    padding: .75rem 0;
}
.ect-timeline-day {
    font-size: .78rem;
    font-weight: 700;
    color: var(--text-secondary, #6b7280);
    margin: 1rem 0 .5rem;
    padding-inline-start: 1.6rem;
}
.ect-timeline-day:first-child { margin-top: 0; }
.ect-timeline-item {
    position: relative;
    padding: 0 0 1.1rem 1.6rem;
    border-inline-start: 2px solid var(--surface-border, #e5e7eb);
    margin: 0;
}
.ect-timeline-item:last-child {
    border-inline-start-color: transparent;
    padding-bottom: 0;
}
.ect-timeline-marker {
    position: absolute;
    inset-inline-start: -0.55rem;
    top: 0.15rem;
    width: 1.05rem;
    height: 1.05rem;
    border-radius: 50%;
    background: var(--surface-card, #fff);
    border: 2px solid var(--primary, #0f766e);
    z-index: 1;
}
.ect-timeline-item.is-warn .ect-timeline-marker {
    border-color: var(--warning, #d97706);
}
.ect-timeline-item.is-danger .ect-timeline-marker {
    border-color: var(--danger, #dc2626);
}
.ect-timeline-item.is-success .ect-timeline-marker {
    border-color: var(--success, #16a34a);
}
.ect-timeline-body {
    min-width: 0;
}
.ect-timeline-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .4rem .6rem;
    margin-bottom: .2rem;
}
/* Audit event icon + title: horizontal row with RTL/LTR-safe gap */
.ect-timeline-event-label {
    display: flex;
    align-items: center;
    gap: 0.5rem; /* 8px */
    min-width: 0;
    flex: 1 1 auto;
}
.ect-timeline-event-icon {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    color: var(--primary, #0f766e);
}
.ect-timeline-item.is-warn .ect-timeline-event-icon {
    color: var(--warning, #d97706);
}
.ect-timeline-item.is-danger .ect-timeline-event-icon {
    color: var(--danger, #dc2626);
}
.ect-timeline-item.is-success .ect-timeline-event-icon {
    color: var(--success, #16a34a);
}
.ect-timeline-title {
    flex: 1 1 auto;
    min-width: 0;
    font-weight: 700;
    font-size: .95rem;
    color: var(--text-primary, #111827);
    line-height: 1.3;
    word-break: break-word;
}
.ect-timeline-meta {
    font-size: .78rem;
    color: #6b7280;
    margin-bottom: .25rem;
    line-height: 1.4;
}
.ect-timeline-summary {
    font-size: .875rem;
    color: var(--text-primary, #1f2937);
    line-height: 1.45;
    word-break: break-word;
}
.ect-timeline-details {
    margin-top: .3rem;
    display: grid;
    gap: .15rem;
    font-size: .8rem;
    color: #4b5563;
}
.ect-timeline-details .ect-kv {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem .5rem;
    min-width: 0;
}
.ect-timeline-details .ect-kv-label {
    color: #9ca3af;
    flex: 0 0 auto;
}
.ect-timeline-details .ect-kv-value {
    min-width: 0;
    word-break: break-word;
}
.ect-timeline-actions {
    margin-top: .35rem;
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

/* Employee summary drawer holdings */
.ect-drawer-identity {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    margin-bottom: 1rem;
    min-width: 0;
}
.ect-drawer-identity .ect-drawer-name {
    font-weight: 700;
    word-break: break-word;
}
.ect-drawer-identity .ect-drawer-meta {
    font-size: .8rem;
    color: #6b7280;
    word-break: break-word;
}
.ect-drawer-holdings { list-style: none; padding: 0; margin: 0; }
.ect-drawer-holdings li {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: .75rem;
    padding: .65rem 0;
    border-bottom: 1px solid #f3f4f6;
    align-items: start;
}
.ect-holding-main { min-width: 0; }
.ect-holding-name {
    font-weight: 600;
    word-break: break-word;
}
.ect-holding-sku {
    font-size: .75rem;
    color: #6b7280;
}
.ect-holding-side {
    text-align: end;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: .25rem;
    min-width: 4.5rem;
}
.ect-holding-side .ect-kv-label {
    font-size: .7rem;
    color: #9ca3af;
}
.ect-holding-activity {
    font-size: .72rem;
    color: #6b7280;
    max-width: 12rem;
    word-break: break-word;
    text-align: end;
}

@media (max-width: 1100px) {
    .ect-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 768px) {
    #ectPage .ect-lookup-filter {
        display: flex;
        flex-wrap: wrap;
        width: 100%;
    }
    #ectPage .ect-lookup-filter .filter-field,
    #ectPage .ect-lookup-filter .filter-select {
        min-width: 0;
        max-width: none;
        flex: 1 1 100%;
    }
}
@media (max-width: 640px) {
    .ect-cards { grid-template-columns: 1fr; }
    .ect-view-switch { width: 100%; }
    .ect-view-switch button { flex: 1; }
    .ect-timeline-day { padding-inline-start: 1.4rem; }
    .ect-timeline-item { padding-inline-start: 1.4rem; }
    .ect-drawer-holdings li {
        grid-template-columns: 1fr;
    }
    .ect-holding-side {
        align-items: flex-start;
        text-align: start;
    }
    .ect-holding-activity { text-align: start; max-width: none; }
}
#ectPage .data-table-wrapper {
    overflow-x: auto;
}
html[dir="rtl"] .ect-holding-side {
    text-align: start;
}
html[dir="rtl"] .ect-holding-activity {
    text-align: start;
}
