/* Dashboard-specific sections: protection panel, auth gate, pipeline, lookup form, events table, trend chart,
   structured views (summary/workflow tables, investigation case view, raw email), search. */

.protection-panel {
    position: relative;
    align-self: stretch;
    padding: 20px;
    background: rgba(7, 16, 31, 0.56);
    border: 1px solid rgba(148, 163, 184, 0.14);
    border-radius: 16px;
    backdrop-filter: blur(14px);
}

.protection-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.protection-score {
    margin: 18px 0 4px;
    font-size: 2.25rem;
    font-weight: 760;
    letter-spacing: -0.04em;
}

.protection-caption {
    color: var(--muted);
    font-size: 0.86rem;
}

.progress {
    height: 8px;
    overflow: hidden;
    margin: 18px 0;
    background: rgba(148, 163, 184, 0.16);
    border-radius: 999px;
}

.progress-bar {
    width: 0;
    height: 100%;
    background:
        linear-gradient(
            90deg,
            var(--cyan),
            var(--blue),
            var(--purple)
        );
    border-radius: inherit;
    transition: width 500ms ease;
}

.mini-statuses {
    display: grid;
    gap: 9px;
}

.mini-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    color: var(--text-secondary);
    font-size: 0.84rem;
}

.refresh-block {
    display: grid;
    gap: 10px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.refresh-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.refresh-text {
    min-width: 0;
}

.refresh-updated {
    color: var(--text);
    font-size: 0.84rem;
    font-variant-numeric: tabular-nums;
}

.refresh-label {
    margin-right: 6px;
    color: var(--muted);
}

.refresh-detail {
    color: var(--muted);
    font-size: 0.76rem;
    font-variant-numeric: tabular-nums;
}

.refresh-detail {
    display: flex;
    flex-wrap: wrap;
    column-gap: 8px;
}

.refresh-countdown {
    white-space: nowrap;
}

.refresh-row .button {
    flex-shrink: 0;
}

.auth-gate {
    display: grid;
    min-height: 320px;
    place-items: center;
    margin-top: 20px;
    padding: 35px;
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-large);
    box-shadow: var(--shadow);
}

.auth-gate[hidden] {
    display: none;
}

.auth-gate-icon {
    display: grid;
    width: 72px;
    height: 72px;
    margin: 0 auto 18px;
    place-items: center;
    color: #bfdbfe;
    background: rgba(37, 99, 235, 0.17);
    border: 1px solid rgba(96, 165, 250, 0.22);
    border-radius: 22px;
}

.auth-gate-icon svg {
    width: 36px;
    height: 36px;
}

.auth-gate h2 {
    margin: 0 0 8px;
    font-size: 1.35rem;
}

.auth-gate p {
    max-width: 520px;
    margin: 0 auto 20px;
    color: var(--muted);
}

.dashboard[hidden] {
    display: none;
}

.workflow {
    display: grid;
    gap: 13px;
}

.workflow-step {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(8, 17, 32, 0.42);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.workflow-number {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    color: #bfdbfe;
    background: rgba(37, 99, 235, 0.18);
    border: 1px solid rgba(96, 165, 250, 0.20);
    border-radius: 10px;
    font-size: 0.78rem;
    font-weight: 750;
}

.workflow-name {
    color: var(--text-secondary);
    font-size: 0.86rem;
    font-weight: 650;
}

.workflow-detail {
    margin-top: 2px;
    color: var(--muted);
    font-size: 0.73rem;
}

.analysis-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 11px;
}

.analysis-item {
    padding: 13px;
    background: rgba(8, 17, 32, 0.42);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.analysis-item strong {
    display: block;
    margin-bottom: 4px;
    color: var(--text-secondary);
    font-size: 0.83rem;
}

.analysis-item span {
    color: var(--muted);
    font-size: 0.73rem;
}

.lookup-form {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(150px, 0.58fr) auto;
    gap: 10px;
}

.lookup-button-wrap {
    display: flex;
    align-items: flex-end;
}

/* Analyst event list: 30-day operational view. */
.events-region {
    min-height: 180px;
}

.events-region > .search-toolbar {
    padding: 12px 12px 0;
}

.events-summary {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
    color: var(--muted);
    font-size: 0.8rem;
}

.events-table-wrap,
.table-wrap {
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 12px;
}

.events-table,
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(3, 8, 17, 0.48);
}

.events-table {
    min-width: 920px;
}

.events-table th,
.events-table td,
.data-table th,
.data-table td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
    font-size: 0.78rem;
}

.events-table th,
.data-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    color: var(--muted);
    background: var(--surface-strong);
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.events-table tbody tr:hover,
.data-table tbody tr:hover {
    background: var(--surface-hover);
}

.events-table tbody tr:last-child td,
.data-table tbody tr:last-child td {
    border-bottom: 0;
}

.event-subject {
    max-width: 260px;
    color: var(--text-secondary);
    font-weight: 650;
}

.event-sender {
    max-width: 245px;
    overflow: hidden;
    color: var(--muted);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.events-empty {
    padding: 28px;
    color: var(--muted);
    text-align: center;
}

/* 90-day trend chart (summary panel). Segment colors match the risk badges. */

.trend {
    margin: 0;
}

.trend-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.trend-title {
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 600;
}

.trend-heading {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.trend-total {
    color: var(--muted);
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
}

/* "By risk | By response" view switch. */
.segmented {
    display: inline-flex;
    padding: 3px;
    background: rgba(30, 47, 73, 0.82);
    border: 1px solid var(--border);
    border-radius: 999px;
}

.segmented button {
    padding: 6px 14px;
    color: var(--text-secondary);
    background: transparent;
    border: 0;
    border-radius: 999px;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 620;
    cursor: pointer;
}

.segmented button[aria-pressed="true"] {
    color: #ffffff;
    background: linear-gradient(135deg, var(--blue-strong), #4f46e5);
}

.segmented button:focus-visible {
    outline: none;
    box-shadow: var(--focus);
}

.trend-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    margin: 10px 0 6px;
    padding: 0;
    color: var(--text-secondary);
    font-size: 0.75rem;
    list-style: none;
}

.trend-legend li {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.trend-swatch {
    width: 10px;
    height: 10px;
    border-radius: 3px;
}

.trend-swatch.trend-seg-high { background: var(--red); }
.trend-swatch.trend-seg-medium { background: var(--yellow); }
.trend-swatch.trend-seg-low { background: var(--green); }
.trend-swatch.trend-seg-other { background: var(--muted); }
.trend-swatch.trend-seg-automatic { background: var(--blue); }
.trend-swatch.trend-seg-analyst { background: var(--purple); }
.trend-swatch.trend-seg-noAction { background: var(--muted); }

.trend-chart {
    position: relative;
    min-width: 0;
    min-height: 220px;
}

/* Fluid width so the SVG never props its grid column open; the chart
   redraws at the new width via ResizeObserver. */
.trend-svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

.trend-empty {
    display: grid;
    place-items: center;
    min-height: 220px;
    margin: 0;
    color: var(--muted);
    font-size: 0.85rem;
}

.trend-grid {
    stroke: rgba(148, 163, 184, 0.10);
    stroke-width: 1;
}

.trend-baseline {
    stroke: rgba(148, 163, 184, 0.32);
    stroke-width: 1;
}

.trend-axis-label {
    fill: var(--muted);
    font-size: 11px;
}

.trend-seg-high { fill: var(--red); }
.trend-seg-medium { fill: var(--yellow); }
.trend-seg-low { fill: var(--green); }
.trend-seg-other { fill: var(--muted); }
.trend-seg-automatic { fill: var(--blue); }
.trend-seg-analyst { fill: var(--purple); }
.trend-seg-noAction { fill: var(--muted); }

.trend-hit {
    fill: transparent;
}

.trend-column {
    cursor: default;
    outline: none;
}

.trend-column.is-active .trend-hit {
    fill: rgba(148, 163, 184, 0.08);
}

.trend-column:focus-visible .trend-hit {
    stroke: var(--blue);
    stroke-width: 1.5;
}

.trend-readout {
    min-height: 1.5em;
    margin: 6px 0 0;
    color: var(--text-secondary);
    font-size: 0.78rem;
}

/* Response-view key: what each response group means. */
.trend-notes {
    margin: 14px 0 0;
    padding: 14px 0 0;
    border-top: 1px solid var(--border);
}

.trend-notes-intro {
    margin: 0 0 12px;
    color: var(--text-secondary);
    font-size: 0.78rem;
}

.trend-notes-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin: 0;
}

.trend-notes-list div {
    min-width: 0;
}

.trend-notes-list dt {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 650;
}

.trend-notes-list dd {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 0.76rem;
}

@media (max-width: 640px) {
    .trend-notes-list {
        grid-template-columns: 1fr;
    }
}

/* Structured views: readable panel content. */

.structured-view {
    min-height: 120px;
    padding: 16px;
}

.structured-view > .message {
    margin-top: 0;
}

.view-placeholder {
    margin: 0;
    color: var(--muted);
    font-size: 0.85rem;
}

.view-summary {
    margin: 0 0 12px;
    color: var(--muted);
    font-size: 0.8rem;
}

.view-summary-warning {
    color: #fde68a;
}

.case-details > summary {
    padding: 10px 16px;
    color: var(--muted);
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 650;
}

.case-details > summary:hover {
    color: var(--text-secondary);
}

.case-details > summary:focus-visible {
    outline: none;
    box-shadow: var(--focus);
}

.data-table .numeric {
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.mono {
    font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
    font-size: 0.76rem;
    word-break: break-all;
}

.cell-note {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 0.72rem;
}

/* Share bars (summary and workflow tables); the % is always shown as text too. */

.share {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 140px;
}

.share-bar {
    flex: 1;
    height: 8px;
    overflow: hidden;
    background: rgba(148, 163, 184, 0.14);
    border-radius: 999px;
}

.share-fill {
    display: block;
    height: 100%;
    border-radius: inherit;
}

.share-fill-high { background: var(--red); }
.share-fill-medium { background: var(--yellow); }
.share-fill-low { background: var(--green); }
.share-fill-other { background: var(--muted); }
.share-fill-neutral { background: var(--blue); }

.share-value {
    min-width: 3ch;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    text-align: right;
}

/* Search toolbar (events, workflow, investigation). */

.search-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 14px;
    margin-bottom: 12px;
}

.search-input {
    flex: 1 1 260px;
    max-width: 420px;
    min-height: 36px;
    padding: 7px 11px;
    font-size: 0.82rem;
}

.search-count {
    color: var(--muted);
    font-size: 0.78rem;
}

.search-body mark {
    padding: 0 1px;
    color: inherit;
    background: rgba(251, 191, 36, 0.35);
    border-radius: 3px;
}

/* Investigation case view. */

.case-header {
    padding: 14px;
    margin-bottom: 14px;
    background: rgba(15, 29, 51, 0.6);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.case-subject {
    margin: 0 0 10px;
    font-size: 1.05rem;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.case-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.case-section {
    padding: 14px 0;
    border-top: 1px solid var(--border);
}

.case-section-title {
    margin: 0 0 10px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.case-subtitle {
    margin: 14px 0 8px;
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 700;
}

.case-fields {
    display: grid;
    gap: 6px;
    margin: 0;
}

.case-field {
    display: grid;
    grid-template-columns: minmax(130px, 220px) minmax(0, 1fr);
    gap: 12px;
    font-size: 0.82rem;
}

.case-field dt {
    color: var(--muted);
}

.case-field dd {
    margin: 0;
    color: var(--text);
    overflow-wrap: anywhere;
}

.case-fields-compact .case-field {
    grid-template-columns: 90px minmax(0, 1fr);
}

.case-note {
    margin: 0 0 10px;
    color: var(--muted);
    font-size: 0.8rem;
}

.case-details {
    margin-top: 10px;
    background: rgba(3, 8, 17, 0.4);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.case-details > .table-wrap {
    margin: 0 12px 12px;
}

.case-pre {
    max-height: 360px;
    margin: 0;
    overflow: auto;
    padding: 0 16px 14px;
    color: var(--text-secondary);
    font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
    font-size: 0.76rem;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
}

.case-list {
    display: grid;
    gap: 4px;
    margin: 0;
    padding-left: 18px;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.header-table .header-name {
    width: 170px;
    color: var(--muted);
    white-space: nowrap;
}

.header-table .header-value,
.data-table .hash {
    max-width: 520px;
}

/* Original email: actions, download warning, preview. */

.raw-email-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.warning-box {
    margin-top: 12px;
    padding: 12px 14px;
    color: #fde68a;
    background: rgba(161, 98, 7, 0.16);
    border: 1px solid rgba(251, 191, 36, 0.32);
    border-radius: 10px;
    font-size: 0.82rem;
}

.warning-box p {
    margin: 0 0 10px;
}

.warning-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.raw-email-preview:not(:empty) {
    margin-top: 14px;
}

@media (max-width: 820px) {
    .lookup-form {
        grid-template-columns: 1fr;
    }

    .lookup-button-wrap .button {
        width: 100%;
    }
}

@media (max-width: 560px) {
    .analysis-grid {
        grid-template-columns: 1fr;
    }

    .case-field,
    .case-fields-compact .case-field {
        grid-template-columns: 1fr;
        gap: 2px;
    }

    .search-input {
        max-width: none;
    }
}
