/* Tabular document viewer */
.doc-layer.table-mode {
    padding: 1.35rem;
    background:
        radial-gradient(circle at 12% 0%, rgba(42, 139, 255, 0.14), transparent 34%),
        linear-gradient(180deg, #f4f8ff 0%, #edf3fc 100%);
}

.doc-layer.table-mode .doc-canvas {
    border: 1px solid rgba(176, 201, 232, 0.78);
    border-radius: 24px;
    background: rgba(247, 251, 255, 0.94);
    box-shadow: 0 28px 70px rgba(18, 46, 92, 0.18);
}

.doc-layer.table-mode .title-bar,
.doc-layer.table-mode .doc-toolbar {
    display: none;
}

.doc-layer.table-mode #docHost,
.doc-layer.table-mode #docHostGeneric {
    min-height: 0;
    height: 100%;
    overflow: hidden;
    background: transparent;
}

.doc-layer.table-portal-mode .records-doc-close {
    width: 42px;
    height: 42px;
    min-width: 42px;
    padding: 0;
    border-color: rgba(127, 159, 205, 0.72);
    background: rgba(255, 255, 255, 0.86);
    box-shadow: 0 10px 24px rgba(18, 46, 92, 0.14);
}

.doc-layer.table-portal-mode .records-doc-close img {
    width: 22px;
    height: 22px !important;
    object-fit: contain;
}

.table-viewer-shell {
    height: 100%;
    display: grid;
    grid-template-rows: auto auto auto minmax(0, 1fr) auto;
    gap: 1rem;
    padding: clamp(1rem, 2vw, 1.45rem);
    color: #102754;
}

.table-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
    color: #5f789f;
    font-size: 0.78rem;
    font-weight: 850;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.table-breadcrumb .arc-flow-crumb-link {
    border: 0;
    padding: 0;
    background: transparent;
    color: inherit;
    font: inherit;
}

.table-breadcrumb .is-current {
    color: #1f62f0;
}

.table-hero {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid rgba(176, 201, 232, 0.74);
    border-radius: 18px;
    background:
        radial-gradient(circle at 92% 10%, rgba(31, 98, 240, 0.14), transparent 30%),
        linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(235, 244, 255, 0.92));
}

.table-back-btn {
    width: 46px;
    height: 46px;
    border: 1px solid rgba(127, 159, 205, 0.72);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.86);
    color: #153768;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.table-hero-copy {
    min-width: 0;
}

.table-kicker {
    display: inline-flex;
    margin-bottom: 0.28rem;
    color: #1f62f0;
    font-size: 0.76rem;
    font-weight: 850;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.table-hero-copy h2 {
    margin: 0;
    color: #0f2447;
    font-size: clamp(1.2rem, 1.6vw, 1.7rem);
    font-weight: 850;
    line-height: 1.16;
    padding-block: 2px;
    overflow-wrap: anywhere;
}

.table-hero-copy p {
    margin: 0.35rem 0 0;
    color: #60739a;
    font-size: 0.9rem;
    font-weight: 650;
    overflow-wrap: anywhere;
}

.table-meta {
    display: flex;
    align-items: stretch;
    gap: 0.6rem;
    margin: 0;
}

.table-meta div {
    min-width: 92px;
    padding: 0.65rem 0.75rem;
    border: 1px solid rgba(176, 201, 232, 0.74);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.62);
}

.table-meta dt {
    color: #6a7fa2;
    font-size: 0.68rem;
    font-weight: 850;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.table-meta dd {
    margin: 0.18rem 0 0;
    color: #132a54;
    font-size: 0.82rem;
    font-weight: 800;
}

.table-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.table-search {
    flex: 1 1 320px;
    min-height: 46px;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0 0.9rem;
    border: 1px solid rgba(127, 159, 205, 0.72);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.8);
    color: #55709c;
}

.table-search input {
    width: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    color: #102754;
    font-weight: 650;
}

.table-count,
.table-action {
    min-height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0 0.95rem;
    border-radius: 12px;
    font-weight: 850;
}

.table-count {
    color: #1f62f0;
    background: rgba(31, 98, 240, 0.1);
}

.table-viewer-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
}

.table-action {
    border: 1px solid rgba(31, 98, 240, 0.48);
    background: #1f62f0;
    color: #fff;
    text-decoration: none;
}

.table-surface {
    min-height: 0;
    overflow: auto;
    border: 1px solid rgba(176, 201, 232, 0.8);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.88);
}

.table-preview {
    width: max-content;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    color: #132a54;
}

.table-preview th,
.table-preview td {
    max-width: 420px;
    padding: 0.72rem 0.85rem;
    border-right: 1px solid rgba(176, 201, 232, 0.58);
    border-bottom: 1px solid rgba(176, 201, 232, 0.58);
    vertical-align: top;
    overflow-wrap: anywhere;
}

.table-preview th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #dceaff;
    color: #143b75;
    font-size: 0.78rem;
    font-weight: 850;
    text-align: left;
}

.table-preview tbody tr:nth-child(even) td {
    background: rgba(239, 246, 255, 0.74);
}

.table-preview tbody tr:hover td {
    background: rgba(218, 234, 255, 0.9);
}

.table-empty {
    min-height: 320px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    padding: 2rem;
    color: #60739a;
    text-align: center;
}

.table-empty i {
    color: #1f62f0;
    font-size: 2.25rem;
}

.table-empty strong {
    color: #102754;
    font-size: 1.05rem;
}

.table-footer {
    color: #60739a;
    font-size: 0.84rem;
    font-weight: 700;
}

html[data-theme="dark"] .doc-layer.table-mode,
body[data-theme="dark"] .doc-layer.table-mode {
    background:
        radial-gradient(circle at 12% 0%, rgba(68, 215, 255, 0.1), transparent 34%),
        linear-gradient(180deg, #061a33 0%, #071528 100%) !important;
}

html[data-theme="dark"] .doc-layer.table-mode .doc-canvas,
body[data-theme="dark"] .doc-layer.table-mode .doc-canvas {
    border-color: rgba(76, 114, 177, 0.58) !important;
    background: rgba(9, 29, 55, 0.96) !important;
    box-shadow: 0 28px 70px rgba(0, 0, 0, 0.42) !important;
}

html[data-theme="dark"] .doc-layer.table-portal-mode .records-doc-close,
body[data-theme="dark"] .doc-layer.table-portal-mode .records-doc-close {
    border-color: rgba(100, 168, 248, 0.42) !important;
    background: rgba(18, 50, 91, 0.92) !important;
    color: #f3f8ff !important;
    box-shadow: 0 8px 18px rgba(1, 8, 22, 0.34) !important;
}

html[data-theme="dark"] .doc-layer.table-portal-mode .records-doc-close:hover,
html[data-theme="dark"] .doc-layer.table-portal-mode .records-doc-close:focus-visible,
body[data-theme="dark"] .doc-layer.table-portal-mode .records-doc-close:hover,
body[data-theme="dark"] .doc-layer.table-portal-mode .records-doc-close:focus-visible {
    border-color: rgba(68, 215, 255, 0.58) !important;
    background: rgba(28, 73, 130, 0.96) !important;
}

html[data-theme="dark"] .doc-layer.table-portal-mode .records-doc-close img,
body[data-theme="dark"] .doc-layer.table-portal-mode .records-doc-close img {
    filter: brightness(0) invert(1);
}

html[data-theme="dark"] .table-viewer-shell,
body[data-theme="dark"] .table-viewer-shell {
    color: #edf5ff;
}

html[data-theme="dark"] .table-breadcrumb,
body[data-theme="dark"] .table-breadcrumb {
    color: #a9c1e8;
}

html[data-theme="dark"] .table-breadcrumb .is-current,
body[data-theme="dark"] .table-breadcrumb .is-current,
html[data-theme="dark"] .table-kicker,
body[data-theme="dark"] .table-kicker {
    color: #8dbbff;
}

html[data-theme="dark"] .table-hero,
body[data-theme="dark"] .table-hero {
    border-color: rgba(76, 114, 177, 0.58);
    background:
        radial-gradient(circle at 92% 10%, rgba(68, 215, 255, 0.12), transparent 30%),
        linear-gradient(145deg, rgba(18, 50, 91, 0.96), rgba(12, 35, 68, 0.96));
}

html[data-theme="dark"] .table-back-btn,
body[data-theme="dark"] .table-back-btn,
html[data-theme="dark"] .table-meta div,
body[data-theme="dark"] .table-meta div,
html[data-theme="dark"] .table-search,
body[data-theme="dark"] .table-search,
html[data-theme="dark"] .table-surface,
body[data-theme="dark"] .table-surface {
    border-color: rgba(87, 137, 205, 0.52);
    background: rgba(9, 30, 58, 0.82);
    color: #dceaff;
}

html[data-theme="dark"] .table-hero-copy h2,
body[data-theme="dark"] .table-hero-copy h2,
html[data-theme="dark"] .table-meta dd,
body[data-theme="dark"] .table-meta dd,
html[data-theme="dark"] .table-empty strong,
body[data-theme="dark"] .table-empty strong,
html[data-theme="dark"] .table-search input,
body[data-theme="dark"] .table-search input {
    color: #f2f7ff;
}

html[data-theme="dark"] .table-hero-copy p,
body[data-theme="dark"] .table-hero-copy p,
html[data-theme="dark"] .table-meta dt,
body[data-theme="dark"] .table-meta dt,
html[data-theme="dark"] .table-empty,
body[data-theme="dark"] .table-empty,
html[data-theme="dark"] .table-footer,
body[data-theme="dark"] .table-footer {
    color: #a8bfdf;
}

html[data-theme="dark"] .table-preview,
body[data-theme="dark"] .table-preview {
    color: #dbeaff;
}

html[data-theme="dark"] .table-preview th,
body[data-theme="dark"] .table-preview th {
    border-color: rgba(87, 137, 205, 0.48);
    background: #123b6c;
    color: #eff6ff;
}

html[data-theme="dark"] .table-preview td,
body[data-theme="dark"] .table-preview td {
    border-color: rgba(87, 137, 205, 0.28);
}

html[data-theme="dark"] .table-preview tbody tr:nth-child(even) td,
body[data-theme="dark"] .table-preview tbody tr:nth-child(even) td {
    background: rgba(15, 43, 80, 0.72);
}

html[data-theme="dark"] .table-preview tbody tr:hover td,
body[data-theme="dark"] .table-preview tbody tr:hover td {
    background: rgba(31, 88, 153, 0.66);
}

@media (max-width: 860px) {
    .doc-layer.table-mode {
        padding: 0.65rem;
    }

    .table-hero {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .table-meta {
        grid-column: 1 / -1;
        flex-wrap: wrap;
    }
}

/* Phase 8 responsive pass: tabular documents and spreadsheet previews. */
.doc-layer.table-mode,
.doc-layer.table-mode *,
.table-viewer-shell,
.table-hero,
.table-toolbar,
.table-surface,
.table-preview,
.table-viewer-actions {
    box-sizing: border-box;
}

.table-viewer-shell,
.table-hero-copy,
.table-meta,
.table-toolbar,
.table-search,
.table-surface,
.table-footer {
    max-width: 100%;
    min-width: 0;
}

.table-hero-copy h2,
.table-hero-copy p,
.table-meta dd,
.table-count,
.table-action,
.table-footer {
    overflow-wrap: anywhere;
    word-break: break-word;
}

@media (max-width: 1280px) {
    .doc-layer.table-mode {
        overflow-x: hidden;
        padding: 0.6rem;
    }

    .doc-layer.table-mode .doc-canvas {
        width: 100% !important;
        min-width: 0 !important;
        border-radius: 18px;
        overflow: hidden;
    }

    .doc-layer.table-mode #docHost,
    .doc-layer.table-mode #docHostGeneric {
        overflow: hidden;
    }

    .table-viewer-shell {
        height: 100%;
        grid-template-rows: auto auto auto minmax(0, 1fr) auto;
        gap: 0.7rem;
        padding: 0.75rem;
    }

    .table-breadcrumb {
        width: 100%;
        overflow-x: auto;
        text-overflow: clip;
        white-space: nowrap;
        font-size: 0.68rem;
        letter-spacing: 0.04em;
    }

    .table-hero {
        grid-template-columns: 42px minmax(0, 1fr);
        gap: 0.65rem;
        padding: 0.75rem;
        border-radius: 14px;
    }

    .table-back-btn {
        width: 42px;
        height: 42px;
        border-radius: 12px;
    }

    .table-kicker {
        font-size: 0.68rem;
        letter-spacing: 0.04em;
    }

    .table-hero-copy h2 {
        font-size: 1.12rem;
        line-height: 1.2;
        padding-block: 2px;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .table-hero-copy p {
        font-size: 0.82rem;
        line-height: 1.3;
    }

    .table-meta {
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
        gap: 0.5rem;
    }

    .table-meta div {
        min-width: 0;
        padding: 0.55rem 0.65rem;
        border-radius: 10px;
    }

    .table-toolbar {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0.55rem;
    }

    .table-search {
        width: 100%;
        flex-basis: auto;
        min-height: 42px;
        border-radius: 10px;
    }

    .table-count,
    .table-viewer-actions,
    .table-action {
        width: 100%;
        min-width: 0;
    }

    .table-count,
    .table-action {
        min-height: 42px;
        padding-inline: 0.7rem;
    }

    .table-viewer-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .table-surface {
        border-radius: 14px;
        overflow: auto;
    }

    .table-preview {
        min-width: 640px;
    }

    .table-preview th,
    .table-preview td {
        max-width: 240px;
        padding: 0.58rem 0.65rem;
        font-size: 0.82rem;
        line-height: 1.35;
    }

    .table-empty {
        min-height: 260px;
        padding: 1.2rem;
    }

    .table-footer {
        font-size: 0.78rem;
        line-height: 1.35;
    }
}

@media (max-width: 420px) {
    .table-preview {
        min-width: 560px;
    }

    .table-preview th,
    .table-preview td {
        max-width: 200px;
    }
}
