/* Dexapp Studio dashboard template (owner decision 2026-11-16).
   Banner -> 4 KPI cards -> widgets (12-column grid) -> 4 quick access cards.
   The template follows the width of the dashboard itself (container queries), so the sidebar
   state never breaks it. KPI and quick access rows stay symmetric: 4 in a row, then 2 x 2.
   Colours come only from dex-theme.css tokens. */

:root {
    /* Banner: a deep gradient of the theme colour; text by contrast. */
    --dx-banner-bg:
        radial-gradient(90% 140% at 100% 0%, color-mix(in srgb, var(--dx-accent) 55%, #fff) 0%, transparent 60%),
        linear-gradient(118deg, color-mix(in srgb, var(--dx-accent) 70%, #000) 0%, var(--dx-accent) 58%, color-mix(in srgb, var(--dx-accent) 82%, #fff) 100%);
    --dx-banner-text: var(--dx-on-accent);
    --dx-banner-glass: color-mix(in srgb, var(--dx-banner-text) 14%, transparent);
    --dx-banner-glass-line: color-mix(in srgb, var(--dx-banner-text) 26%, transparent);
    --dx-banner-shadow: 0 18px 40px -22px color-mix(in srgb, var(--dx-accent) 80%, transparent);

    /* Panels (KPI cards, widgets, quick access). Light: white on white with a tinted line.
       Dark (owner decision 2026-11-16): a step above the workspace with a tint of the theme colour,
       a brighter theme-coloured edge, a top highlight and a soft shadow, so panels never fade. */
    --dx-panel-bg: var(--dx-surface);
    --dx-panel-line: color-mix(in srgb, var(--dx-accent) 16%, var(--dx-line));
    --dx-panel-head-line: var(--dx-line);
    --dx-panel-shadow: 0 1px 2px rgba(15, 30, 60, .04), 0 10px 26px -20px rgba(15, 30, 60, .22);
    --dx-quick-bg: color-mix(in srgb, var(--dx-accent) 5%, var(--dx-surface));
}

:root[data-theme="dark"] {
    --dx-banner-bg:
        radial-gradient(90% 140% at 100% 0%, color-mix(in srgb, var(--dx-accent) 42%, transparent) 0%, transparent 62%),
        linear-gradient(118deg, color-mix(in srgb, var(--dx-accent) 30%, #060b14) 0%, color-mix(in srgb, var(--dx-accent) 52%, #0c1422) 60%, color-mix(in srgb, var(--dx-accent) 40%, #0c1422) 100%);
    --dx-banner-text: #ffffff;
    --dx-banner-shadow: 0 18px 40px -24px rgba(0, 0, 0, .8);

    --dx-panel-bg: linear-gradient(180deg, color-mix(in srgb, var(--dx-accent) 11%, #15213a) 0%, color-mix(in srgb, var(--dx-accent) 6%, #101a2d) 100%);
    --dx-panel-line: color-mix(in srgb, var(--dx-accent) 48%, #22324d);
    --dx-panel-head-line: color-mix(in srgb, var(--dx-accent) 24%, #1b2940);
    --dx-panel-shadow: inset 0 1px 0 rgba(255, 255, 255, .07), 0 16px 34px -20px rgba(0, 0, 0, .9);
    --dx-quick-bg: var(--dx-panel-bg);
}

/* .dx-dash is the size container (the workspace height); .dx-dash__inner holds the rows. */
.dx-dash {
    container: dash / inline-size;
    height: 100%;
    max-width: 1680px;
    margin: 0 auto;
}

.dx-dash__inner {
    display: grid;
    gap: 16px;
}

/* ---- Banner ---- */

.dx-banner {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    /* Four squares of the 26px grid (owner decision 2026-11-16): present, but never louder than the content. */
    height: 104px;
    padding: 0 24px;
    overflow: hidden;
    isolation: isolate;
    border-radius: 18px;
    background: var(--dx-banner-bg);
    color: var(--dx-banner-text);
    box-shadow: var(--dx-banner-shadow);
}

/* Sign-in grid, fading in towards the right */
.dx-banner__grid {
    position: absolute;
    inset: 0;
    z-index: -1;
    background-image:
        linear-gradient(color-mix(in srgb, var(--dx-banner-text) 9%, transparent) 1px, transparent 1px),
        linear-gradient(90deg, color-mix(in srgb, var(--dx-banner-text) 9%, transparent) 1px, transparent 1px);
    background-size: 26px 26px;
    -webkit-mask-image: linear-gradient(90deg, transparent 18%, #000 70%);
    mask-image: linear-gradient(90deg, transparent 18%, #000 70%);
}

/* Moving point/line network, right half */
.dx-banner__network {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
    width: 62%;
    height: 100%;
    color: var(--dx-banner-text);
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 40%);
    mask-image: linear-gradient(90deg, transparent, #000 40%);
}

.dx-banner__main {
    display: flex;
    align-items: center;
    gap: 18px;
    min-width: 0;
}

.dx-banner__icon {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    flex: none;
    border: 1px solid var(--dx-banner-glass-line);
    border-radius: 15px;
    background: var(--dx-banner-glass);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: inset 0 1px 0 color-mix(in srgb, var(--dx-banner-text) 22%, transparent);
}

.dx-banner__icon .dx-ico { width: 26px; height: 26px; stroke-width: 1.8; }

.dx-banner__text { min-width: 0; }

.dx-banner__title {
    margin: 0;
    font-size: 24px;
    font-weight: 750;
    line-height: 1.15;
    letter-spacing: -.025em;
}

.dx-banner__context {
    margin: 4px 0 0;
    font-size: var(--dx-text-sm);
    font-weight: 500;
    opacity: .84;
}

/* ---- KPI cards ---- */

.dx-dash__kpis,
.dx-dash__quick {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.dx-kpi {
    container: kpi / inline-size;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
    padding: 16px 18px 14px;
    border: 1px solid var(--dx-panel-line);
    border-radius: 16px;
    background: var(--dx-panel-bg);
    color: var(--dx-text);
    text-decoration: none;
    box-shadow: var(--dx-panel-shadow);
    transition: transform .2s var(--dx-ease), border-color .2s, box-shadow .2s;
}

/* A KPI card that runs an action (button) looks exactly like a linked one. */
button.dx-kpi { width: 100%; font: inherit; text-align: left; cursor: pointer; }

.dx-kpi:hover {
    transform: translateY(-2px);
    border-color: var(--dx-accent-line);
    box-shadow: 0 14px 30px -18px color-mix(in srgb, var(--dx-accent) 55%, transparent);
}

.dx-kpi:focus-visible { outline: 0; box-shadow: var(--dx-focus-ring); }

.dx-kpi__head {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.dx-kpi__icon {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    flex: none;
    border-radius: 50%;
    background: var(--dx-accent-soft);
    color: var(--dx-accent-text);
}

.dx-kpi__icon .dx-ico { width: 18px; height: 18px; }

.dx-kpi__title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    color: var(--dx-muted);
    font-size: var(--dx-text-sm);
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.dx-kpi__live {
    width: 7px;
    height: 7px;
    flex: none;
    border-radius: 50%;
    background: var(--dx-success);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--dx-success) 18%, transparent);
}

.dx-kpi__value {
    font-size: 24px;
    font-weight: 750;
    line-height: 1.1;
    letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.dx-kpi__value-short { display: none; }

.dx-kpi__subs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
    margin-top: -4px;
    color: var(--dx-muted);
    font-size: 12.5px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.dx-kpi__foot {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: auto;
    padding-top: 11px;
    border-top: 1px solid var(--dx-line);
    color: var(--dx-muted);
    font-size: var(--dx-text-xs);
    font-weight: 500;
}

.dx-kpi__note { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.dx-kpi__go { width: 16px; height: 16px; transition: transform .2s var(--dx-ease), color .2s; }
.dx-kpi:hover .dx-kpi__go { color: var(--dx-accent-text); transform: translateX(3px); }

/* Attention: side stripe and coloured icon */
.dx-kpi--warning,
.dx-kpi--danger { overflow: hidden; }

.dx-kpi--warning::before,
.dx-kpi--danger::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--dx-kpi-tone);
}

.dx-kpi--warning { --dx-kpi-tone: var(--dx-warning); }
.dx-kpi--danger { --dx-kpi-tone: var(--dx-danger); }

.dx-kpi--warning .dx-kpi__icon,
.dx-kpi--danger .dx-kpi__icon {
    background: color-mix(in srgb, var(--dx-kpi-tone) 14%, var(--dx-surface));
    color: var(--dx-kpi-tone);
}

.dx-kpi--warning .dx-kpi__note,
.dx-kpi--danger .dx-kpi__note { color: var(--dx-kpi-tone); font-weight: 650; }

/* Narrower cards: a smaller value first; the compact form only when the full one cannot fit. */
@container kpi (max-width: 330px) {
    .dx-kpi__value { font-size: 20px; }
}

@container kpi (max-width: 190px) {
    .dx-kpi__value-full { display: none; }
    .dx-kpi__value-short { display: inline; }
}

@container kpi (max-width: 170px) {
    .dx-kpi__subs { display: none; }
    .dx-kpi__value { font-size: 21px; }
}

/* ---- Widgets ---- */

.dx-dash__widgets {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 16px;
}

.dx-widget {
    display: flex;
    flex-direction: column;
    min-width: 0;
    border: 1px solid var(--dx-panel-line);
    border-radius: 16px;
    background: var(--dx-panel-bg);
    box-shadow: var(--dx-panel-shadow);
}

.dx-widget--span-4 { grid-column: span 4; }
.dx-widget--span-6 { grid-column: span 6; }
.dx-widget--span-8 { grid-column: span 8; }
.dx-widget--span-12 { grid-column: span 12; }

.dx-widget__head {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 54px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--dx-panel-head-line);
}

.dx-widget__icon {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    flex: none;
    border-radius: 9px;
    background: var(--dx-accent-soft);
    color: var(--dx-accent-text);
}

.dx-widget__icon .dx-ico { width: 16px; height: 16px; }

.dx-widget__title {
    flex: 1;
    min-width: 0;
    margin: 0;
    overflow: hidden;
    font-size: var(--dx-text-md);
    font-weight: 650;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.dx-widget__meta {
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--dx-surface-2);
    color: var(--dx-muted);
    font-size: var(--dx-text-xs);
    font-weight: 600;
    white-space: nowrap;
}

.dx-widget__body { flex: 1; min-height: 0; padding: 16px; }
.dx-widget__body--flush { padding: 0; }

/* Table inside a widget */
.dx-dtable {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--dx-text-sm);
}

.dx-dtable th {
    padding: 9px 14px;
    border-bottom: 1px solid var(--dx-line);
    background: var(--dx-surface-2);
    color: var(--dx-muted);
    font-size: var(--dx-text-xs);
    font-weight: 650;
    text-align: left;
    white-space: nowrap;
}

.dx-dtable td {
    height: 40px;
    padding: 6px 14px;
    border-bottom: 1px solid var(--dx-line);
    vertical-align: middle;
}

.dx-dtable tbody tr:last-child td { border-bottom: 0; }
.dx-dtable tbody tr:hover td { background: color-mix(in srgb, var(--dx-accent) 5%, transparent); }
.dx-dtable .is-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dx-dtable .is-strong { font-weight: 650; }

.dx-dtable__main {
    max-width: 0;
    width: 46%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.dx-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    background: var(--dx-surface-2);
    color: var(--dx-muted);
    font-size: var(--dx-text-xs);
    font-weight: 600;
    white-space: nowrap;
}

.dx-days { font-weight: 650; }

.dx-dtable tr.is-danger .dx-days { color: var(--dx-danger); }
.dx-dtable tr.is-warning .dx-days { color: var(--dx-warning); }
.dx-dtable tr.is-danger td:first-child { box-shadow: inset 3px 0 0 var(--dx-danger); }
.dx-dtable tr.is-warning td:first-child { box-shadow: inset 3px 0 0 var(--dx-warning); }

/* Bar chart */
.dx-widget__body:has(> .dx-chart) { display: flex; }

.dx-chart {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 220px;
    margin: 0;
}

.dx-chart__legend {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
    color: var(--dx-muted);
    font-size: var(--dx-text-xs);
    font-weight: 600;
}

.dx-chart__key { display: inline-flex; align-items: center; gap: 6px; }

.dx-chart__key::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 3px;
    background: var(--dx-chart-color);
}

.dx-chart__key--0,
.dx-chart__bar--0 { --dx-chart-color: var(--dx-accent); }
.dx-chart__key--1,
.dx-chart__bar--1 { --dx-chart-color: color-mix(in srgb, var(--dx-accent) 34%, var(--dx-line)); }

.dx-chart__area {
    display: flex;
    flex: 1;
    gap: 8px;
    min-height: 190px;
}

.dx-chart__y {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    margin-bottom: 22px;
    color: var(--dx-muted);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}

.dx-chart__y span { line-height: 0; }

.dx-chart__plot {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
}

/* flex-basis 0 + height 0: the SVG takes the plot's height instead of its own (square) ratio. */
.dx-chart__svg { display: block; flex: 1 1 0; width: 100%; height: 0; min-height: 0; overflow: visible; }
.dx-chart__bar { fill: var(--dx-chart-color); transition: opacity .15s; }
.dx-chart__bar:hover { opacity: .8; }
/* Scale lines: visible in both themes (dark panels are tinted, so the plain line colour vanished). */
.dx-chart { --dx-chart-grid: color-mix(in srgb, var(--dx-text) 16%, transparent); --dx-chart-base: color-mix(in srgb, var(--dx-text) 32%, transparent); }
:root[data-theme="dark"] .dx-chart { --dx-chart-grid: color-mix(in srgb, var(--dx-accent) 22%, rgba(255, 255, 255, .16)); --dx-chart-base: color-mix(in srgb, var(--dx-accent) 30%, rgba(255, 255, 255, .34)); }
.dx-chart__grid { stroke: var(--dx-chart-grid); stroke-width: 1; stroke-dasharray: 4 4; }
.dx-chart__grid--base { stroke: var(--dx-chart-base); stroke-dasharray: none; }

.dx-chart__x {
    display: flex;
    height: 22px;
    align-items: flex-end;
    color: var(--dx-muted);
    font-size: 11px;
}

.dx-chart__x span { flex: 1; text-align: center; }

/* ---- Quick access ---- */

/* Same look and size as the sidebar's profile card (--dx-foot-h, radius, accent-tinted line), so on
   a dashboard that fits the screen the quick access row lines up with it. */
.dx-quick {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    height: var(--dx-foot-h);
    padding: 0 12px 0 10px;
    border: 1px solid var(--dx-panel-line);
    border-radius: 14px;
    /* A light tint of the theme colour, like the profile card, so the card never looks empty. */
    background: var(--dx-quick-bg);
    box-shadow: var(--dx-panel-shadow);
    color: var(--dx-text);
    text-decoration: none;
    transition: border-color .2s, background .2s, transform .2s var(--dx-ease);
}

.dx-quick:hover {
    border-color: var(--dx-accent-line);
    background: color-mix(in srgb, var(--dx-accent) 9%, var(--dx-surface));
    transform: translateY(-1px);
}

.dx-quick:focus-visible { outline: 0; box-shadow: var(--dx-focus-ring); }

.dx-quick__icon {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    flex: none;
    border-radius: 11px;
    /* Same as the sidebar profile avatar: filled theme gradient, readable icon colour. */
    background: var(--dx-accent-gradient);
    color: var(--dx-on-accent);
    box-shadow: 0 6px 14px -8px var(--dx-accent);
}

.dx-quick__icon .dx-ico { width: 18px; height: 18px; stroke-width: 2; }

.dx-quick__text {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
}

.dx-quick__text strong,
.dx-quick__text small {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.dx-quick__text { line-height: 1.25; }
.dx-quick__text strong { font-size: var(--dx-text-sm); font-weight: 650; }
.dx-quick__text small { color: var(--dx-muted); font-size: var(--dx-text-xs); }
.dx-quick__go { width: 16px; height: 16px; color: var(--dx-muted); transition: transform .2s var(--dx-ease), color .2s; }
.dx-quick:hover .dx-quick__go { color: var(--dx-accent-text); transform: translateX(3px); }

/* ---- One screen when it fits, scroll when it does not (owner decision 2026-11-16) ----
   The dashboard fills the workspace: banner, KPI row and quick access keep their size, the widget
   row takes the remaining height and quick access sits at the bottom; a widget whose content is
   taller scrolls inside itself (table header stays). There is no fixed screen-size limit. The only
   rule is that the widget row never gets shorter than --dx-widget-min: when the screen cannot give
   it that much, the page scrolls instead of squeezing the panels. With widgets stacked (narrow
   dashboards: portrait tablets, phones) the page simply scrolls. */
.dx-dash { --dx-widget-min: 230px; }

@media (min-width: 1024px) {
    .dx-workspace:has(> .dx-dash) { padding-top: 20px; padding-bottom: var(--dx-foot-gap); }
}

@container dash (min-width: 761px) {
    .dx-dash__inner {
        min-height: 100%;
        grid-template-rows: auto auto minmax(var(--dx-widget-min), 1fr) auto;
    }

    /* Without a KPI row (e.g. an application whose indicators are not built yet) the widgets take the second row. */
    .dx-dash__inner:not(:has(> .dx-dash__kpis)) { grid-template-rows: auto minmax(var(--dx-widget-min), 1fr) auto; }

    /* Size containment: the row's height comes from the free space, not from its content. */
    .dx-dash__widgets {
        contain: size;
        grid-auto-rows: minmax(0, 1fr);
    }

    .dx-widget { min-height: 0; overflow: hidden; }
    .dx-widget__body { overflow: auto; scrollbar-width: thin; }
    .dx-widget__body:has(> .dx-chart) { overflow: hidden; }
    .dx-chart { min-height: 0; }
    .dx-chart__area { min-height: 0; }

    .dx-dtable thead th { position: sticky; top: 0; z-index: 1; }
}

/* Short desktop windows (e.g. 1366 x 768): the KPI cards and widgets tighten to
   leave room for the widget row. The banner never shrinks: it is part of the brand (owner
   decision 2026-11-16). */
@media (min-width: 1024px) and (max-height: 840px) {
    .dx-workspace:has(> .dx-dash) { padding-top: 14px; padding-bottom: var(--dx-foot-gap); }
    .dx-dash__inner { gap: 12px; }
    .dx-dash__kpis,
    .dx-dash__quick,
    .dx-dash__widgets { gap: 12px; }
    .dx-kpi { gap: 9px; padding: 12px 16px 10px; }
    .dx-kpi__icon { width: 32px; height: 32px; }
    .dx-kpi__value { font-size: 21px; }
    .dx-kpi__foot { padding-top: 8px; }
    .dx-widget__head { min-height: 46px; padding: 7px 14px; }
    .dx-widget__body { padding: 12px 14px; }
    .dx-widget__body--flush { padding: 0; }
    .dx-dtable td { height: 36px; }
}

@media (min-width: 1024px) and (max-height: 720px) {
    .dx-workspace:has(> .dx-dash) { padding-top: 10px; }
    .dx-dash__inner,
    .dx-dash__kpis,
    .dx-dash__quick,
    .dx-dash__widgets { gap: 10px; }
    .dx-kpi { gap: 7px; padding: 10px 14px 9px; }
    .dx-kpi__head { gap: 8px; }
    .dx-kpi__icon { width: 28px; height: 28px; }
    .dx-kpi__icon .dx-ico { width: 15px; height: 15px; }
    .dx-kpi__subs { margin-top: -2px; font-size: 12px; }
    .dx-kpi__foot { padding-top: 7px; }
}

/* ---- Breakpoints (dashboard width) ---- */

/* Widgets take the full width below ~760px (side by side above, so the one-screen layout keeps
   its height for both). */
@container dash (max-width: 760px) {
    .dx-widget--span-4,
    .dx-widget--span-6,
    .dx-widget--span-8 { grid-column: span 12; }
}

/* 2 x 2 */
@container dash (max-width: 860px) {
    .dx-dash__kpis,
    .dx-dash__quick { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Banner stacks */
@container dash (max-width: 720px) {
    .dx-banner { flex-direction: column; align-items: stretch; gap: 16px; height: auto; padding: 20px; }
    .dx-banner__network {
        width: 100%;
        opacity: .7;
        -webkit-mask-image: linear-gradient(200deg, #000, transparent 55%);
        mask-image: linear-gradient(200deg, #000, transparent 55%);
    }
}

/* Phone */
@container dash (max-width: 560px) {
    .dx-quick { height: auto; padding: 11px 12px; }
    .dx-dash__inner { gap: 12px; }
    .dx-dash__kpis,
    .dx-dash__quick,
    .dx-dash__widgets { gap: 10px; }
    .dx-banner { padding: 18px 16px; border-radius: 16px; }
    .dx-banner__icon { width: 48px; height: 48px; border-radius: 14px; }
    .dx-banner__icon .dx-ico { width: 24px; height: 24px; }
    .dx-banner__title { font-size: 21px; }
    .dx-banner__context { font-size: var(--dx-text-xs); }

    .dx-kpi { gap: 10px; padding: 13px 13px 11px; border-radius: 14px; }
    .dx-kpi__icon { width: 30px; height: 30px; }
    .dx-kpi__icon .dx-ico { width: 16px; height: 16px; }
    .dx-kpi__title { font-size: var(--dx-text-xs); }
    .dx-kpi__foot { padding-top: 9px; }

    .dx-quick { gap: 10px; }
    .dx-quick__icon { width: 34px; height: 34px; border-radius: 10px; }
    .dx-quick__text strong { font-size: var(--dx-text-sm); }
    .dx-quick__text small,
    .dx-quick__go { display: none; }

    /* Table rows become cards */
    .dx-dtable thead { display: none; }
    .dx-dtable,
    .dx-dtable tbody,
    .dx-dtable tr,
    .dx-dtable td { display: block; width: auto; }
    .dx-dtable tr { padding: 10px 14px; border-bottom: 1px solid var(--dx-line); }
    .dx-dtable tbody tr:last-child { border-bottom: 0; }
    .dx-dtable td { height: auto; padding: 2px 0; border: 0; }
    .dx-dtable td.is-num { text-align: left; }
    .dx-dtable td[data-label]:not(.dx-dtable__main) { display: inline-flex; gap: 6px; margin-right: 14px; }
    .dx-dtable td[data-label]:not(.dx-dtable__main)::before { content: attr(data-label); color: var(--dx-muted); font-weight: 500; }
    .dx-dtable__main { max-width: none; margin-bottom: 4px; font-weight: 650; white-space: normal; }
    .dx-dtable tr.is-danger td:first-child,
    .dx-dtable tr.is-warning td:first-child { box-shadow: none; }
    .dx-dtable tr.is-danger { box-shadow: inset 3px 0 0 var(--dx-danger); }
    .dx-dtable tr.is-warning { box-shadow: inset 3px 0 0 var(--dx-warning); }
}

/* ---- States and small parts ---- */

/* A card or quick link whose screen is not built yet */
.dx-kpi.is-disabled,
.dx-quick.is-disabled { cursor: default; }

.dx-kpi.is-disabled:hover,
.dx-quick.is-disabled:hover {
    transform: none;
    border-color: var(--dx-panel-line);
    box-shadow: var(--dx-panel-shadow);
}

.dx-quick.is-disabled:hover { background: var(--dx-quick-bg); }

/* Dark: hover brightens the theme-coloured edge. */
:root[data-theme="dark"] .dx-kpi:not(.is-disabled):hover,
:root[data-theme="dark"] .dx-quick:not(.is-disabled):hover { border-color: color-mix(in srgb, var(--dx-accent) 80%, #fff); }

/* Dark: inner surfaces follow the tinted panel instead of the plain surface colour. */
:root[data-theme="dark"] .dx-dtable th { background: color-mix(in srgb, var(--dx-accent) 10%, #16223a); border-bottom-color: var(--dx-panel-head-line); }
:root[data-theme="dark"] .dx-dtable td { border-bottom-color: color-mix(in srgb, var(--dx-accent) 14%, #1b2940); }
:root[data-theme="dark"] .dx-widget__meta,
:root[data-theme="dark"] .dx-tag,
:root[data-theme="dark"] .dx-status--off { background: color-mix(in srgb, var(--dx-accent) 16%, #16223a); }
:root[data-theme="dark"] .dx-kpi__foot { border-top-color: color-mix(in srgb, var(--dx-accent) 20%, #1b2940); }

/* "Yakında" on a quick link: readable in both themes. */
.dx-quick .dx-soon { background: color-mix(in srgb, var(--dx-accent) 14%, var(--dx-surface)); color: var(--dx-accent-text); }

.dx-soon {
    flex: none;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--dx-surface-2);
    color: var(--dx-muted);
    font-size: 11px;
    font-weight: 650;
    white-space: nowrap;
}

/* Error in place of the KPI row */
.dx-dash-message {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 18px;
    border: 1px solid color-mix(in srgb, var(--dx-danger) 35%, var(--dx-line));
    border-radius: 16px;
    background: color-mix(in srgb, var(--dx-danger) 7%, var(--dx-surface));
    color: var(--dx-danger);
    font-size: var(--dx-text-sm);
    font-weight: 600;
}

.dx-widget-empty {
    display: grid;
    place-items: center;
    height: 100%;
    min-height: 120px;
    color: var(--dx-muted);
    font-size: var(--dx-text-sm);
    text-align: center;
}

.dx-muted { color: var(--dx-muted); }

/* Label / value list inside a widget */
.dx-facts {
    display: grid;
    gap: 12px;
    margin: 0;
}

.dx-facts > div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 10px;
    border-bottom: 1px dashed var(--dx-line);
    font-size: var(--dx-text-sm);
}

.dx-facts > div:last-child { padding-bottom: 0; border-bottom: 0; }
.dx-facts dt { color: var(--dx-muted); font-weight: 500; white-space: nowrap; }
.dx-facts dd { margin: 0; font-weight: 650; text-align: right; font-variant-numeric: tabular-nums; }
.dx-facts__block { flex-direction: column; align-items: stretch !important; }
.dx-facts__block dd { display: flex; align-items: center; gap: 10px; text-align: left; }

.dx-meter {
    flex: 1;
    height: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--dx-surface-2);
}

.dx-meter span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--dx-accent-gradient);
}

.dx-chips { flex-wrap: wrap; gap: 6px !important; }

/* Chart colour roles */
/* Failures: a neutral slate that stays distinct from every theme colour (a red accent would
   otherwise blend with a red "failed" bar). */
.dx-chart__key--danger,
.dx-chart__bar--danger { --dx-chart-color: color-mix(in srgb, var(--dx-text) 42%, var(--dx-surface)); }
.dx-chart__key--success,
.dx-chart__bar--success { --dx-chart-color: var(--dx-success); }

/* Phone: no room for the "Yakında" chip; screens that do not exist yet are shown slightly faded. */
@container dash (max-width: 560px) {
    .dx-kpi .dx-soon,
    .dx-quick .dx-soon { display: none; }
    .dx-quick.is-disabled { opacity: .85; }
}

/* Module / status table inside a widget (e.g. licensed modules) */
.dx-mini-table { width: 100%; border-collapse: collapse; font-size: var(--dx-text-sm); }

.dx-mini-table th {
    padding: 0 0 6px;
    border-bottom: 1px solid var(--dx-line);
    color: var(--dx-muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    text-align: left;
    text-transform: uppercase;
}

.dx-mini-table td { height: 34px; border-bottom: 1px dashed var(--dx-line); }
.dx-mini-table tr:last-child td { border-bottom: 0; }
.dx-mini-table th:last-child,
.dx-mini-table td:last-child { width: 1%; text-align: right; white-space: nowrap; }
.dx-mini-table td:first-child { font-weight: 600; }

.dx-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: var(--dx-text-xs);
    font-weight: 650;
}

.dx-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.dx-status--on { background: color-mix(in srgb, var(--dx-success) 14%, var(--dx-surface)); color: var(--dx-success); }
.dx-status--off { background: var(--dx-surface-2); color: var(--dx-muted); }

.dx-facts__section { margin: 16px 0 8px; color: var(--dx-muted); font-size: var(--dx-text-sm); font-weight: 500; }
