/* Archive and data workbenches extend the existing Files & Media system.
 * The restrained navy/green palette keeps dense manifests readable while
 * one live result surface gives each tool a clear operational focus. */
.kiv-archive-data {
    --ad-grid: #dfe9e3;
    --ad-ink: #263d35;
    --ad-muted: #6f8179;
    --ad-soft: #f5f9f7;
    --ad-accent: #159b63;
    --ad-warning: #a76a18;
}

.kiv-archive-data .ad-tabs > li > a {
    white-space: nowrap;
}

.kiv-archive-data .ad-file-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.kiv-archive-data .ad-folder-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    margin: 0;
    padding: 6px 11px;
    border: 1px solid #c9d9d1;
    border-radius: 3px;
    background: #f8fbf9;
    color: #3b6554;
    cursor: pointer;
    font-size: 12px;
    font-weight: 650;
}

.kiv-archive-data .ad-folder-button:hover,
.kiv-archive-data .ad-folder-button:focus-within {
    border-color: #79bd98;
    background: #eef7f2;
    color: #177248;
}

.kiv-archive-data .ad-folder-button input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.kiv-archive-data .ad-search {
    position: relative;
    margin-bottom: 10px;
}

.kiv-archive-data .ad-search::before {
    position: absolute;
    top: 50%;
    left: 10px;
    color: #7b9086;
    content: "⌕";
    font: 15px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    transform: translateY(-50%);
}

.kiv-archive-data .ad-search .fm-input {
    padding-left: 30px;
}

.kiv-archive-data .ad-table-wrap {
    max-height: 430px;
    overflow: auto;
    border-top: 1px solid var(--ad-grid);
    border-bottom: 1px solid var(--ad-grid);
    background: #fff;
}

.kiv-archive-data .ad-table {
    width: 100%;
    margin: 0;
    border-collapse: collapse;
    color: var(--ad-ink);
    font-size: 12px;
}

.kiv-archive-data .ad-table th,
.kiv-archive-data .ad-table td {
    padding: 8px 9px;
    border-bottom: 1px solid #e8efeb;
    text-align: left;
    vertical-align: middle;
}

.kiv-archive-data .ad-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f2f7f4;
    color: #536c61;
    font-size: 10px;
    font-weight: 750;
    letter-spacing: .045em;
    text-transform: uppercase;
}

.kiv-archive-data .ad-table tbody tr:last-child td {
    border-bottom: 0;
}

.kiv-archive-data .ad-table tbody tr:hover {
    background: #f5faf7;
}

.kiv-archive-data .ad-name {
    max-width: 340px;
    overflow: hidden;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.kiv-archive-data .ad-digest {
    min-width: 240px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 11px;
    word-break: break-all;
}

.kiv-archive-data .ad-state {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 3px 7px;
    border-radius: 999px;
    background: #eaf6ef;
    color: #23734e;
    font-size: 10px;
    font-weight: 700;
}

.kiv-archive-data .ad-state.is-warning {
    background: #fff4df;
    color: #8d5915;
}

.kiv-archive-data .ad-empty {
    min-height: 180px;
}

.kiv-archive-data .ad-chart-stage {
    min-height: 380px;
    overflow: auto;
    background:
        linear-gradient(#edf3f0 1px, transparent 1px),
        linear-gradient(90deg, #edf3f0 1px, transparent 1px),
        #fbfdfc;
    background-size: 24px 24px;
}

.kiv-archive-data .ad-chart-stage svg {
    display: block;
    width: 100%;
    min-width: 0;
    height: auto;
}

.kiv-archive-data .ad-series-select {
    min-height: 112px;
}

.kiv-archive-data textarea[data-ad-expected] {
    min-height: 86px;
}

.kiv-archive-data .ad-manifest {
    max-height: 310px;
    margin: 0;
    padding: 0;
    overflow: auto;
    list-style: none;
}

.kiv-archive-data .ad-manifest li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 34px;
    padding: 7px 2px;
    border-bottom: 1px solid #e7efeb;
    color: #3c554b;
    font-size: 12px;
}

.kiv-archive-data .ad-manifest li:last-child {
    border-bottom: 0;
}

.kiv-archive-data .ad-manifest code {
    overflow: hidden;
    color: #2d5041;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.kiv-archive-data .ad-manifest small {
    flex: 0 0 auto;
    color: var(--ad-muted);
}

.kiv-archive-data .ad-chart-copy {
    margin: 0 0 10px;
    color: var(--ad-muted);
    font-size: 11px;
    line-height: 1.55;
}

html.kiv-shell-dark .kiv-archive-data {
    --ad-grid: #344b41;
    --ad-ink: #dbe7e1;
    --ad-muted: #9cb0a7;
    --ad-soft: #17241e;
}

html.kiv-shell-dark .kiv-archive-data .ad-folder-button,
html.kiv-shell-dark .kiv-archive-data .ad-table-wrap,
html.kiv-shell-dark .kiv-archive-data .ad-table,
html.kiv-shell-dark .kiv-archive-data .ad-chart-stage {
    border-color: #344b41;
    background-color: #111a16;
    color: var(--ad-ink);
}

html.kiv-shell-dark .kiv-archive-data .ad-table th {
    background: #1b2a23;
    color: #a9bdb3;
}

html.kiv-shell-dark .kiv-archive-data .ad-table th,
html.kiv-shell-dark .kiv-archive-data .ad-table td,
html.kiv-shell-dark .kiv-archive-data .ad-manifest li {
    border-color: #2d4037;
}

html.kiv-shell-dark .kiv-archive-data .ad-table tbody tr:hover {
    background: #1a2a22;
}

html.kiv-shell-dark .kiv-archive-data .ad-name,
html.kiv-shell-dark .kiv-archive-data .ad-digest,
html.kiv-shell-dark .kiv-archive-data .ad-manifest code {
    color: #d7e6df;
}

html.kiv-shell-dark .kiv-archive-data .ad-series-select {
    color-scheme: dark;
}

html.kiv-shell-dark .kiv-archive-data .ad-series-select option:checked {
    background: #294a3a linear-gradient(#294a3a, #294a3a);
    color: #dff2e7;
}

html.kiv-shell-dark .kiv-archive-data .ad-state {
    background: #234333;
    color: #b6e2c5;
}

html.kiv-shell-dark .kiv-archive-data .ad-state.is-warning {
    background: #46351e;
    color: #e3bd79;
}

html.kiv-shell-dark .kiv-archive-data .ad-chart-stage {
    background-image:
        linear-gradient(#25372f 1px, transparent 1px),
        linear-gradient(90deg, #25372f 1px, transparent 1px);
}

/* Keep downloaded SVG/PNG files portable on a light canvas, but adapt the
 * live preview to the workbench theme. Presentation attributes in the
 * generated SVG remain untouched and are overridden only while displayed. */
html.kiv-shell-dark .kiv-archive-data .ad-chart-stage svg > rect:first-of-type {
    fill: #111a16;
}

html.kiv-shell-dark .kiv-archive-data .ad-chart-stage svg line {
    stroke: #31443a;
}

html.kiv-shell-dark .kiv-archive-data .ad-chart-stage svg text {
    fill: #c5d5cd;
}

@media (max-width: 767px) {
    .kiv-archive-data .ad-table-wrap {
        max-height: 360px;
    }

    .kiv-archive-data .ad-table {
        min-width: 650px;
    }

    .kiv-archive-data .ad-folder-button {
        min-height: 40px;
        padding: 8px 12px;
        font-size: 14px;
    }

    .kiv-archive-data .ad-chart-stage {
        min-height: 300px;
    }

    .kiv-archive-data .fm-button {
        min-height: 42px;
        font-size: 12px;
    }

    .kiv-archive-data .fm-input,
    .kiv-archive-data .fm-select {
        min-height: 44px;
        font-size: 14px;
    }

    .kiv-archive-data .fm-textarea {
        font-size: 13px;
    }
}
