/* ===========================================================================
   Dashboard - Fine-tuned Typography & Theme Calibration
   =========================================================================== */
:root, [data-theme="light"] {
    --tpt-text-heading: #1E293B;
    --tpt-text-body: #334155;
}

[data-theme="dark"] {
    --tpt-text-heading: #F8FAFC;
    --tpt-text-body: #CBD5E1;
}

/* A computer set to dark, with nothing picked on the toggle, takes the dark
   values too, as tokens.css does. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --tpt-text-heading: #F8FAFC;
        --tpt-text-body: #CBD5E1;
    }
}

.dashboard-container { padding: 10px; }

.tpt-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px var(--tpt-space-4);
    border-bottom: 1px solid var(--tpt-surface-muted);
}

.tpt-card-title {
    font-size: var(--tpt-text-base);
    font-weight: 600;
    color: var(--tpt-text-heading);
    margin: 0;
    letter-spacing: -0.01em;
}

.dash-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: var(--tpt-space-4);
    flex-wrap: wrap;
    margin-bottom: var(--tpt-space-4);
    padding: 0 var(--tpt-space-1);
}

.dash-head h1 {
    font-size: var(--tpt-text-2xl);
    font-weight: 700;
    color: var(--tpt-text-heading);
    margin: 0 0 var(--tpt-space-1) 0;
    letter-spacing: -0.015em;
}

.dash-summary {
    display: flex;
    align-items: center;
    gap: var(--tpt-space-2);
    flex-wrap: wrap;
    margin: 0;
    font-size: var(--tpt-text-md);
    color: var(--tpt-text-muted);
    font-weight: 500;
}
.dash-summary .sep { color: var(--tpt-text-faint); }
.dash-stat { font-weight: 600; color: var(--tpt-text-body); }
.dash-stat--critical { color: var(--tpt-critical); }
.dash-stat--warn { color: var(--tpt-warn); }

.dash-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.85fr) minmax(0, 1fr);
    gap: var(--tpt-space-4);
    align-items: start;
}
@media (max-width: 1080px) {
    .dash-layout { grid-template-columns: minmax(0, 1fr); }
}

.dash-rail {
    display: flex;
    flex-direction: column;
    gap: var(--tpt-space-4);
    min-width: 0;
}

.dash-group {
    display: flex;
    align-items: center;
    gap: var(--tpt-space-2);
    padding: 8px var(--tpt-space-4);
    background: var(--tpt-surface-sunken);
    border-bottom: 1px solid var(--tpt-border);
    border-top: 1px solid var(--tpt-border);
}
.dash-group:first-of-type { border-top: none; }

.dash-row {
    display: flex;
    align-items: center;
    gap: var(--tpt-space-3);
    padding: 11px var(--tpt-space-4);
    border-bottom: 1px solid var(--tpt-surface-muted);
    text-decoration: none;
    color: inherit;
    transition: background-color 0.12s ease;
}
.dash-row:last-child { border-bottom: none; }
.dash-row:hover { background: var(--tpt-accent-tint); }
.dash-row:focus-visible {
    outline: 2px solid var(--tpt-accent);
    outline-offset: -2px;
}

.dash-stripe {
    width: 3px;
    align-self: stretch;
    border-radius: 2px;
    flex-shrink: 0;
    background: var(--tpt-border-strong);
}
.dash-stripe--critical { background: var(--tpt-critical); }
.dash-stripe--warn { background: var(--tpt-warn); }
.dash-stripe--neutral { background: var(--tpt-border-strong); }

.dash-row-main { flex: 1; min-width: 0; }

.dash-row-title {
    display: block;
    font-size: var(--tpt-text-base);
    font-weight: 600;
    color: var(--tpt-text-heading);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dash-row-detail {
    display: block;
    font-size: var(--tpt-text-xs);
    color: var(--tpt-text-subtle);
    font-weight: 400;
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dash-row-go {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: var(--tpt-text-xs);
    font-weight: 600;
    color: var(--tpt-text-body);
    background: var(--tpt-surface);
    border: 1px solid var(--tpt-border-strong);
    border-radius: var(--tpt-radius);
    padding: 6px 11px;
    white-space: nowrap;
}
.dash-row:hover .dash-row-go {
    border-color: var(--tpt-accent);
    color: var(--tpt-accent-deep);
}

.dash-truncated {
    padding: 10px var(--tpt-space-4);
    font-size: var(--tpt-text-xs);
    font-weight: 500;
    color: var(--tpt-text-subtle);
    text-align: center;
}

.dash-funnel {
    display: flex;
    flex-direction: column;
    gap: 9px;
    padding: var(--tpt-space-3) var(--tpt-space-4);
}
.dash-funnel-row {
    display: grid;
    grid-template-columns: 82px minmax(0, 1fr) 30px;
    align-items: center;
    gap: 9px;
    text-decoration: none;
}
.dash-funnel-label {
    font-size: var(--tpt-text-xs);
    font-weight: 500;
    color: var(--tpt-text-muted);
}
.dash-funnel-bar {
    height: 16px;
    background: var(--tpt-surface-muted);
    border-radius: var(--tpt-radius-sm);
    overflow: hidden;
}
.dash-funnel-bar i {
    display: block;
    height: 100%;
    border-radius: var(--tpt-radius-sm);
    background: var(--tpt-accent);
}
.dash-funnel-count {
    font-size: var(--tpt-text-base);
    font-weight: 600;
    color: var(--tpt-text-heading);
    text-align: right;
    font-variant-numeric: tabular-nums;
}


.dash-list {
    display: flex;
    flex-direction: column;
}
.dash-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--tpt-space-3);
    padding: 11px var(--tpt-space-4);
    border-bottom: 1px solid var(--tpt-surface-muted);
    text-decoration: none;
    color: inherit;
}
.dash-item:last-child { border-bottom: none; }
.dash-item:hover { background: var(--tpt-accent-tint); }
.dash-item-main { min-width: 0; }

.dash-item-title {
    display: block;
    font-size: var(--tpt-text-base);
    font-weight: 600;
    color: var(--tpt-text-heading);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dash-item-sub {
    display: block;
    font-size: var(--tpt-text-xs);
    color: var(--tpt-text-subtle);
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tq-group { border-top: 1px solid var(--tpt-border); }
.tq-group:first-of-type { border-top: none; }
.tq-group-head {
    display: flex;
    align-items: center;
    gap: var(--tpt-space-3);
    padding: 11px var(--tpt-space-4);
    background: var(--tpt-surface-sunken);
    cursor: pointer;
    list-style: none;
}
.tq-group-head::-webkit-details-marker { display: none; }
.tq-chev {
    width: 0; height: 0;
    border-left: 5px solid var(--tpt-text-faint);
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    transition: transform 120ms ease;
}
.tq-group[open] > .tq-group-head .tq-chev { transform: rotate(90deg); }
.tq-group-title { font-size: var(--tpt-text-base); font-weight: 600; color: var(--tpt-text-heading); }
.tq-group-sub { font-size: var(--tpt-text-xs); color: var(--tpt-text-subtle); font-weight: 400; }
.tq-spacer { flex: 1; }
.tq-table { width: 100%; border-collapse: collapse; }
.tq-table th {
    text-align: left; padding: 8px var(--tpt-space-4);
    font-size: 11px; font-weight: 600; color: var(--tpt-text-subtle);
    border-bottom: 1px solid var(--tpt-surface-muted);
}
.tq-table td { padding: 11px var(--tpt-space-4); border-bottom: 1px solid var(--tpt-surface-muted); font-size: var(--tpt-text-base); vertical-align: middle; }
.tq-table tr:last-child td { border-bottom: none; }
.tq-t { font-weight: 600; color: var(--tpt-text-heading); }
.tq-s { color: var(--tpt-text-muted); }

[data-theme="dark"] .dash-head h1 { font-weight: 800; }
[data-theme="dark"] .tpt-card-title,
[data-theme="dark"] .dash-row-title,
[data-theme="dark"] .dash-item-title,
[data-theme="dark"] .dash-funnel-count,
[data-theme="dark"] .tq-group-title,
[data-theme="dark"] .tq-t {
    font-weight: 700;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .dash-head h1 { font-weight: 800; }
    :root:not([data-theme="light"]) .tpt-card-title,
    :root:not([data-theme="light"]) .dash-row-title,
    :root:not([data-theme="light"]) .dash-item-title,
    :root:not([data-theme="light"]) .dash-funnel-count,
    :root:not([data-theme="light"]) .tq-group-title,
    :root:not([data-theme="light"]) .tq-t {
        font-weight: 700;
    }
}

/* ---- Dashboard (admin/dashboard/index, _waiting) ---- */
.dash-row .dash-record-avatar { border-radius: var(--tpt-radius); background: var(--tpt-text-muted); color: #FFF; }
.dash-item .dash-item-arrow { color: var(--tpt-text-faint); }

/* ---- Task queue (admin/tasks/index, _row) ---- */
/* Scoped under .tq-page so each rule outranks the shared header, card and avatar rules. */
.tq-page { padding: 24px 32px; }
.tq-page .tq-header { margin-bottom: 4px; }
.tq-page .tq-layout { margin-top: 10px; }
.tq-page .tq-apply {
    border: none;
    cursor: pointer;
    padding: 9px 14px;
    font-weight: 700;
    width: 100%;
}
.tq-page .tq-empty { padding: 48px; text-align: center; color: var(--tpt-text-faint); }
.tq-page .tq-empty-icon { font-size: 28px; margin-bottom: 10px; color: var(--tpt-border-strong); }
.tq-page .tq-empty-text { font-size: 14px; margin: 0; font-weight: 600; }
.tq-page .tq-nomatch { padding: 32px; text-align: center; color: var(--tpt-text-subtle); font-size: 14px; }
.tq-page .tq-role-avatar {
    border-radius: var(--tpt-radius);
    background: var(--tpt-text-muted);
    color: #FFF;
    width: 26px;
    height: 26px;
    font-size: 10px;
}
.tq-page .tq-secondary-card { margin-top: 16px; }
.tq-page .tq-open-cell { text-align: right; }

/* ---- Task queue > Row (admin/tasks/_row) ---- */
.tq-page .tq-row-role { color: var(--tpt-text-faint); }
