/* Site Monitor page -------------------------------------------------------- */
/* Severity is the whole visual language of this page, so it is built from the status tokens --
   which are tuned to clear 4.5:1 on their own grounds in BOTH themes -- rather than Bootstrap's
   .bg-danger / .bg-warning, whose fixed fills ignore the theme and put dark text on a saturated
   ground. Same construction as .mc-a11y-badge. */

.sm-page { padding-block: 0.25rem; }

/* --- Header --------------------------------------------------------------- */
.sm-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1rem; }
.sm-head h5 { margin: 0; }
.sm-head-meta { color: var(--ct-n-64); font-size: 0.82rem; }
.sm-head-meta > span + span::before { content: "·"; margin: 0 0.45rem; color: var(--ct-n-40); }

/* --- Health and severity pills -------------------------------------------- */
.sm-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 3px 9px;
    border-radius: 6px;
    white-space: nowrap;
    line-height: 1.35;
    /* The severity comes straight from the monitor's JSON, so the class is whatever it sent.
       A value outside SeverityOrder matches none of the rules below; without a default it
       would render as bare text with a transparent border and stop looking like a pill at
       all. Neutral is the right answer for "severity we do not recognise". */
    background: rgba(var(--ct-n-100-rgb), 0.06);
    color: var(--ct-n-64);
    border: 1px solid rgba(var(--ct-n-100-rgb), 0.16);
}
.sm-critical,
.sm-high    { background: rgba(var(--ct-danger-rgb),  0.18); color: var(--ct-danger);  border-color: rgba(var(--ct-danger-rgb),  0.42); }
.sm-medium  { background: rgba(var(--ct-warning-rgb), 0.18); color: var(--ct-warning); border-color: rgba(var(--ct-warning-rgb), 0.40); }
.sm-low     { background: rgba(var(--ct-info-rgb),    0.16); color: var(--ct-info);    border-color: rgba(var(--ct-info-rgb),    0.38); }
.sm-info,
.sm-none    { background: rgba(var(--ct-n-100-rgb),   0.06); color: var(--ct-n-64);    border-color: rgba(var(--ct-n-100-rgb),   0.16); }
.sm-green   { background: rgba(var(--ct-success-rgb), 0.16); color: var(--ct-success); border-color: rgba(var(--ct-success-rgb), 0.38); }
.sm-amber   { background: rgba(var(--ct-warning-rgb), 0.18); color: var(--ct-warning); border-color: rgba(var(--ct-warning-rgb), 0.40); }
.sm-red     { background: rgba(var(--ct-danger-rgb),  0.18); color: var(--ct-danger);  border-color: rgba(var(--ct-danger-rgb),  0.42); }

/* Critical earns one louder treatment than high, without becoming a solid block. */
.sm-critical { border-width: 1px; box-shadow: inset 0 0 0 1px rgba(var(--ct-danger-rgb), 0.25); }

/* --- Count tiles ----------------------------------------------------------- */
/* Tinted, not filled. Solid blocks of colour across a whole row shout at the reader and leave
   nowhere for the numbers to sit legibly. */
.sm-tiles { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-bottom: 1.5rem; }
.sm-tile {
    min-width: 7.5rem;
    padding: 0.6rem 0.9rem;
    border-radius: 8px;
    border: 1px solid var(--ct-line);
    background: var(--ct-n-16);
}
.sm-tile-label { font-size: 0.68rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ct-n-64); }
.sm-tile-value { font-size: 1.45rem; line-height: 1.25; font-weight: 600; color: var(--ct-n-100); margin-top: 0.1rem; }
/* A tile with something in it takes its severity's tint; an empty one stays neutral so the eye
   goes to the counts that matter. */
.sm-tile-critical,
.sm-tile-high   { border-color: rgba(var(--ct-danger-rgb),  0.42); background: rgba(var(--ct-danger-rgb),  0.10); }
.sm-tile-high .sm-tile-value,
.sm-tile-critical .sm-tile-value { color: var(--ct-danger); }
.sm-tile-medium { border-color: rgba(var(--ct-warning-rgb), 0.40); background: rgba(var(--ct-warning-rgb), 0.10); }
.sm-tile-medium .sm-tile-value   { color: var(--ct-warning); }
.sm-tile-low    { border-color: rgba(var(--ct-info-rgb),    0.38); background: rgba(var(--ct-info-rgb),    0.09); }
.sm-tile-low .sm-tile-value      { color: var(--ct-info); }

/* --- Filters --------------------------------------------------------------- */
.sm-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem 1rem;
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
    border: 1px solid var(--ct-line);
    border-radius: 8px;
    background: var(--ct-n-16);
}
.sm-filter { display: flex; flex-direction: column; gap: 0.25rem; }
.sm-filter > label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ct-n-64); margin: 0; }
.sm-filter select, .sm-filter input { min-width: 10rem; }
.sm-filter-site input { min-width: 14rem; }
.sm-filter-count { margin-left: auto; color: var(--ct-n-64); font-size: 0.82rem; padding-bottom: 0.4rem; }

/* --- Table ----------------------------------------------------------------- */
.sm-table { margin-bottom: 2rem; }
/* Pills, timestamps and wrapped subjects sit on one row, and baseline alignment leaves them
   stepped against each other. Centre them instead. */
.sm-table > :not(caption) > * > * {
    padding: 0.55rem 0.6rem;
    vertical-align: middle;
    border-bottom-color: var(--ct-line);
}
.sm-table thead th {
    font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--ct-n-64); font-weight: 600; border-bottom: 1px solid var(--ct-line);
}
/* The row opens a detail panel, so it has to look like it does something. */
/* overflow-wrap: anywhere, NOT word-break: break-word.
   Subjects carry URLs with no spaces in them -- the longest in live data is 83 characters -- and
   an unbreakable token like that sets the column's min-content width, which is what the table
   sizes itself from. break-word does not affect min-content sizing, so it looks like it should
   help and does nothing: the column stays 83 characters wide and pushes the table off the screen.
   `anywhere` is the one that counts for intrinsic sizing. */
.sm-subject { overflow-wrap: anywhere; }

.sm-row { cursor: pointer; }
.sm-row:hover > td { background: rgba(var(--ct-n-100-rgb), 0.04); }
.sm-row-open > td { background: rgba(var(--ct-accent-rgb), 0.08); }
.sm-muted { color: var(--ct-n-64); font-size: 0.82rem; }

/* The expanded detail. Inset and accented so it reads as belonging to the row above rather than
   as another row of the table. */
.sm-detail > td { background: var(--ct-n-16); border-left: 3px solid var(--ct-accent); padding: 0.9rem 1rem !important; }
.sm-detail-text { margin-bottom: 0.6rem; line-height: 1.5; }
.sm-detail-row { margin-bottom: 0.4rem; font-size: 0.85rem; }
.sm-detail-row .sm-label { color: var(--ct-n-64); margin-right: 0.35rem; }
.sm-detail-url { word-break: break-all; }
.sm-history { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.65rem; }
.sm-history-item {
    font-size: 0.68rem; padding: 2px 7px; border-radius: 5px;
    background: rgba(var(--ct-n-100-rgb), 0.06); color: var(--ct-n-64);
    border: 1px solid rgba(var(--ct-n-100-rgb), 0.12); white-space: nowrap;
}

/* A run that failed or was blocked. Tinted from the tokens rather than Bootstrap's
   .table-warning, which sets its own text colour and loses to the theme in dark mode. */
.sm-run-bad > td { background: rgba(var(--ct-warning-rgb), 0.10); }

/* --- AI review -------------------------------------------------------------- */
/* Deliberately set apart from the lead's own facts: inset, bordered, with its own accent rail.
   This is a model's opinion about the finding, not part of the finding, and the layout should
   not let the two blur together.

   The separation is done with the border and the rail rather than a background tint. A tint was
   the first attempt and it cost too much: lifting the ground shrank the headroom for everything
   sitting on it, and the "likely real" pill fell to 4.00:1 in light mode. Measured against the
   real grounds, this version's worst case is 4.53:1. */
.sm-review {
    margin-top: 0.9rem;
    padding: 0.75rem 0.9rem;
    border-radius: 7px;
    border: 1px solid rgba(var(--ct-n-100-rgb), 0.12);
    border-left: 3px solid rgba(var(--ct-info-rgb), 0.55);
}
.sm-review-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; }
.sm-review-head .sm-muted { font-size: 0.78rem; }
.sm-review-meta { margin-left: auto; font-size: 0.74rem; }
.sm-review-summary { line-height: 1.5; margin-bottom: 0.4rem; }
.sm-review-body { font-size: 0.85rem; line-height: 1.5; color: var(--ct-n-88); margin-bottom: 0.35rem; }
.sm-review-evidence { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0.45rem 0 0.2rem; }
/* Evidence entries are file:line references inside the monitor's own run folder, not URLs.
   Plain text is the correct rendering, so they are styled as code and never linked. */
.sm-review-evidence code {
    font-size: 0.72rem; padding: 2px 6px; border-radius: 4px;
    background: rgba(var(--ct-n-100-rgb), 0.04); color: var(--ct-n-64);
    border: 1px solid rgba(var(--ct-n-100-rgb), 0.1);
}

/* The verdict is the model's, so it is tinted from the neutral/info end rather than reusing the
   severity colours. A severity pill states what the monitor found; this states what a model
   thinks, and they should not look like the same kind of claim. */
.sm-verdict-likely-false-positive { background: rgba(var(--ct-info-rgb), 0.12); color: var(--ct-info); border-color: rgba(var(--ct-info-rgb), 0.38); }
.sm-verdict-likely-real { background: rgba(var(--ct-warning-rgb), 0.12); color: var(--ct-warning); border-color: rgba(var(--ct-warning-rgb), 0.38); }
.sm-verdict-unclear { background: rgba(var(--ct-n-100-rgb), 0.04); color: var(--ct-n-64); border-color: rgba(var(--ct-n-100-rgb), 0.18); }

/* The row marker. Small and quiet: it says a review exists, not what it concluded. */
.sm-review-flag {
    display: inline-block; margin-left: 0.4rem; vertical-align: middle;
    font-size: 0.6rem; font-weight: 700; letter-spacing: 0.06em;
    padding: 1px 5px; border-radius: 4px;
    background: rgba(var(--ct-info-rgb), 0.14); color: var(--ct-info);
    border: 1px solid rgba(var(--ct-info-rgb), 0.3);
}

/* --- Fix claims ------------------------------------------------------------- */
/* A claim, not a verdict: the lead is still open and still counted. "Not verified" is the state
   worth noticing, because somebody believes the work is done and a run has since seen otherwise,
   so it takes the danger tint while the other two stay quiet. */
.sm-fix {
    margin-top: 0.8rem;
    padding: 0.6rem 0.8rem;
    border-radius: 7px;
    border: 1px solid rgba(var(--ct-n-100-rgb), 0.12);
    font-size: 0.88rem;
}
.sm-fix-claimed { border-left: 3px solid rgba(var(--ct-info-rgb), 0.55); }
.sm-fix-verified { border-left: 3px solid rgba(var(--ct-success-rgb), 0.6); }
.sm-fix-verified strong { color: var(--ct-success); }
.sm-fix-not-verified { border-left: 3px solid rgba(var(--ct-danger-rgb), 0.6); }
.sm-fix-not-verified strong { color: var(--ct-danger); }

/* --- Mark actions ----------------------------------------------------------- */
/* Separated from the detail text above by a rule, because these buttons change what InfoSec
   sees and should not read as part of the prose. */
.sm-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.9rem;
    padding-top: 0.8rem;
    border-top: 1px solid var(--ct-line);
}
.sm-actions .sm-note { margin-top: 0; }

/* --- Sections -------------------------------------------------------------- */
.sm-section-title { font-size: 0.95rem; font-weight: 600; margin: 2rem 0 0.6rem; color: var(--ct-n-88); }
.sm-note { color: var(--ct-n-64); font-size: 0.8rem; margin-top: 0.4rem; }

@media (max-width: 900px) {
    .sm-filter select, .sm-filter input, .sm-filter-site input { min-width: 0; width: 100%; }
    .sm-filter { flex: 1 1 100%; }
    .sm-filter-count { margin-left: 0; }
}

/* The fix state in the resolved table: the same colour language as the panel, inline. */
.sm-fix-inline { font-weight: 600; }
.sm-fix-inline.sm-fix-verified { color: var(--ct-success); }
.sm-fix-inline.sm-fix-not-verified { color: var(--ct-danger); }
.sm-fix-inline.sm-fix-claimed { color: var(--ct-n-64); }

/* --- Narrow screens ----------------------------------------------------------
   The breakpoint is 900px, not the usual 768. Measured rather than chosen: with wrapping
   restored, the eight-column leads table still needs about 850px before its columns stop
   fighting, so 769-900 was the one range left overflowing -- a tablet showing a table it
   cannot actually fit. Below 900 the cards are simply the honest layout. */
/* Stacked rows on phones rather than pinned columns or a sideways scroll, which is the call
   Anthony made for the cart's results table and the one this follows.

   An eight-column table cannot be read at 375px by any arrangement that keeps it a table, and
   the subject column -- the one people are actually reading -- is the one that loses when
   something has to give. So below the breakpoint each row becomes a card and each cell gets its
   heading back from data-label.

   The ARIA roles below are not decoration. Changing a table's `display` strips its implicit
   table semantics in WebKit, so a screen reader stops announcing rows and cells at exactly the
   width where the visual grouping has gone too. The roles put the structure back. */
@media (max-width: 900px) {
    .sm-filter select, .sm-filter input, .sm-filter-site input { min-width: 0; width: 100%; }
    .sm-filter { flex: 1 1 100%; }
    .sm-filter-count { margin-left: 0; }

    .sm-table, .sm-table tbody, .sm-table tr, .sm-table td { display: block; width: 100%; }
    .sm-table thead { display: none; }

    .sm-table tbody tr {
        border: 1px solid var(--ct-line);
        border-radius: 8px;
        padding: 0.5rem 0.7rem;
        margin-bottom: 0.6rem;
    }
    /* The expanded panel is its own card already; a second border around it reads as a box in
       a box. */
    .sm-table tbody tr.sm-detail { border: 0; padding: 0; }

    .sm-table > :not(caption) > * > * { border-bottom: 0; padding: 0.2rem 0; }

    /* The heading, from the cell's own label. Cells with nothing to announce (the clear-mark
       button) carry an empty data-label and get no heading row. */
    .sm-table td[data-label]:not([data-label=""])::before {
        content: attr(data-label);
        display: block;
        font-size: 0.64rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: var(--ct-n-64);
        margin-bottom: 0.1rem;
    }

    /* Nothing inside a card should be able to push it wider than the screen. */
    .sm-table td { overflow-wrap: anywhere; }
    .sm-detail-cell { padding: 0 !important; }
    .sm-detail > td { border-left-width: 2px; }

    .sm-tile { flex: 1 1 8rem; min-width: 0; }
    .sm-head-meta { font-size: 0.78rem; }
    .sm-actions { gap: 0.4rem; }
    .sm-actions .btn { flex: 1 1 auto; }
}

/* The runs and trends tables are dense numeric grids -- eight short columns whose whole value is
   lining up for comparison. Stacking those produces a column of 48 cards nobody can scan, so
   they scroll sideways inside their own box instead, and only that box scrolls, never the page. */
.sm-scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.sm-scroll-x > .sm-table { margin-bottom: 0; }
.sm-scroll-x { margin-bottom: 2rem; }
@media (max-width: 900px) {
    .sm-scroll-x > .sm-table,
    .sm-scroll-x > .sm-table tbody,
    .sm-scroll-x > .sm-table tr,
    .sm-scroll-x > .sm-table td { display: revert; width: auto; }
    .sm-scroll-x > .sm-table thead { display: revert; }
    .sm-scroll-x > .sm-table tbody tr { border: 0; border-radius: 0; padding: 0; margin: 0; }
    .sm-scroll-x > .sm-table td::before { content: none; }
    .sm-scroll-x > .sm-table > :not(caption) > * > * { padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--ct-line); }
    .sm-scroll-x > .sm-table td { white-space: nowrap; }
}

/* --- Letting text wrap at all -------------------------------------------------
   style.css:3045 has, app-wide:

       .table * { white-space: nowrap !important; }

   Every descendant of every table in snaketrax is forbidden to wrap. That is what makes the
   subject column run off the screen: live subjects reach 270 characters and the longest
   unbreakable token in one is 83, so the cell lays out to ~2000px and takes the page with it.
   It also defeats the obvious fixes from above -- overflow-wrap and word-break have nothing to
   do while white-space is nowrap -- which is why this needs saying out loud rather than
   quietly adding another wrapping property.

   Overridden here rather than changed there: that rule is shared by every table in the app and
   re-pointing it is a change with a blast radius, not a Site Monitor fix. `.table *` is one
   class and important; these are two classes and important, so they win on specificity.

   Cells that genuinely read better on one line keep nowrap below. */
.sm-table .sm-subject,
.sm-table .sm-subject *,
.sm-table .sm-detail-cell,
.sm-table .sm-detail-cell * {
    white-space: normal !important;
}

/* Short, self-contained things that should never be broken across lines. */
.sm-table .sm-pill,
.sm-table .sm-history-item,
.sm-table .sm-review-evidence code {
    white-space: nowrap !important;
}

@media (max-width: 900px) {
    /* Stacked, every cell is its own line anyway, so nothing gains from nowrap -- and a date
       or a site name that cannot wrap is just as able to push the card off screen. */
    .sm-table tbody td,
    .sm-table tbody td * {
        white-space: normal !important;
    }
    .sm-table tbody .sm-pill { white-space: nowrap !important; }

    /* The numeric tables are the exception: they scroll sideways inside their own box, and
       their value is columns that line up. */
    .sm-scroll-x > .sm-table td,
    .sm-scroll-x > .sm-table th { white-space: nowrap !important; }
}
