/* ========================================
   GRAYSCALE DESIGN SYSTEM UTILITIES
   ======================================== */

/* ===================
   BADGE OVERRIDES
   =================== */

/* Neutral badges with accent borders */
.badge-neutral {
    background-color: var(--active-bg);
    color: var(--text-secondary);
    border: 1px solid var(--border-default);
    font-weight: 500;
}

/*
 * NOTE: We intentionally do NOT override Bootstrap badge colors globally.
 * Role badges (Superadmin, Admin, User) need distinct colors for clarity.
 * Use the badge-*-accent classes below when you want grayscale badges
 * with semantic accent borders.
 */

/* Semantic badges with left border accent */
.badge-success-accent {
    background-color: var(--hover-bg);
    color: var(--text-secondary);
    border-left: 3px solid #10b981;
}

.badge-warning-accent {
    background-color: var(--hover-bg);
    color: var(--text-secondary);
    border-left: 3px solid #f59e0b;
}

.badge-danger-accent {
    background-color: var(--hover-bg);
    color: var(--text-secondary);
    border-left: 3px solid #ef4444;
}

.badge-info-accent {
    background-color: var(--hover-bg);
    color: var(--text-secondary);
    border-left: 3px solid #3b82f6;
}

/* ===================
   ALERT OVERRIDES
   =================== */

/* Base neutral alert */
.alert-neutral {
    background-color: var(--hover-bg);
    color: var(--text-secondary);
    border: 1px solid var(--border-default);
    border-left: 4px solid var(--text-muted);
}

/* Override Bootstrap alert colors */
.alert.alert-success {
    background-color: var(--hover-bg) !important;
    color: var(--text-secondary) !important;
    border: 1px solid var(--border-default) !important;
    border-left: 4px solid #10b981 !important;
}

.alert.alert-warning {
    background-color: var(--hover-bg) !important;
    color: var(--text-secondary) !important;
    border: 1px solid var(--border-default) !important;
    border-left: 4px solid #f59e0b !important;
}

.alert.alert-danger {
    background-color: var(--hover-bg) !important;
    color: var(--text-secondary) !important;
    border: 1px solid var(--border-default) !important;
    border-left: 4px solid #ef4444 !important;
}

.alert.alert-info {
    background-color: var(--hover-bg) !important;
    color: var(--text-secondary) !important;
    border: 1px solid var(--border-default) !important;
    border-left: 4px solid #3b82f6 !important;
}

.alert.alert-primary {
    background-color: var(--hover-bg) !important;
    color: var(--text-secondary) !important;
    border: 1px solid var(--border-default) !important;
    border-left: 4px solid var(--text-primary) !important;
}

/* ===================
   CARD OVERRIDES
   =================== */

/* Standard grayscale card — depth (shadow/radius) comes from app.css tokens. */
.card {
    background-color: var(--content-bg);
    border: 1px solid var(--border-default);
}

.card-header {
    background-color: var(--hover-bg);
    border-bottom: 1px solid var(--border-default);
    color: var(--text-primary);
}

/* Override Bootstrap card header colors */
.card-header.bg-primary,
.card-header.bg-secondary,
.card-header.bg-success,
.card-header.bg-warning,
.card-header.bg-danger,
.card-header.bg-info {
    background-color: var(--hover-bg) !important;
    color: var(--text-primary) !important;
}

/* Metric cards with accent borders */
.metric-card {
    background-color: var(--content-bg);
    border: 1px solid var(--border-default);
    border-left: 4px solid var(--text-muted);
}

.metric-card.metric-success {
    border-left-color: #10b981;
}

.metric-card.metric-warning {
    border-left-color: #f59e0b;
}

.metric-card.metric-danger {
    border-left-color: #ef4444;
}

.metric-card.metric-info {
    border-left-color: #3b82f6;
}

.metric-card .metric-value {
    color: var(--text-primary);
    font-size: 2rem;
    font-weight: 700;
}

.metric-card .metric-label {
    color: var(--text-muted);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ===================
   BUTTON OVERRIDES
   =================== */

/* Grayscale primary button */
.btn-grayscale-primary {
    background-color: var(--text-primary);
    border-color: var(--text-primary);
    color: var(--content-bg);
}

.btn-grayscale-primary:hover {
    background-color: var(--text-secondary);
    border-color: var(--text-secondary);
    color: var(--content-bg);
}

/* Grayscale outline button */
.btn-grayscale-outline {
    background-color: transparent;
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
}

.btn-grayscale-outline:hover {
    background-color: var(--hover-bg);
    color: var(--text-primary);
}

.btn-grayscale-outline.active {
    background-color: var(--active-bg);
    color: var(--text-primary);
    font-weight: 600;
}

/* Filter button group */
.btn-filter {
    background-color: var(--content-bg);
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
    padding: 0.375rem 0.75rem;
}

.btn-filter:hover {
    background-color: var(--hover-bg);
    color: var(--text-primary);
}

.btn-filter.active {
    background-color: var(--active-bg);
    color: var(--text-primary);
    border-color: var(--active-border);
    font-weight: 600;
}

/* ===================
   TEXT COLOR UTILITIES
   =================== */

/* Override Bootstrap text colors for consistency */
.text-primary {
    color: var(--text-primary) !important;
}

.text-secondary {
    color: var(--text-secondary) !important;
}

.text-muted {
    color: var(--text-muted) !important;
}

/* Semantic accent colors (use sparingly) */
.text-accent-success {
    color: #10b981 !important;
}

.text-accent-warning {
    color: #f59e0b !important;
}

.text-accent-danger {
    color: #ef4444 !important;
}

.text-accent-info {
    color: #3b82f6 !important;
}

/* ===================
   ICON STYLING
   =================== */

/* Neutral icon container */
.icon-neutral {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    background-color: var(--hover-bg);
    border-radius: 0.5rem;
    color: var(--text-secondary);
}

.icon-neutral.icon-sm {
    width: 2rem;
    height: 2rem;
    font-size: 0.875rem;
}

.icon-neutral.icon-lg {
    width: 3rem;
    height: 3rem;
    font-size: 1.25rem;
}

/* ===================
   TABLE STYLING
   =================== */

.table {
    border-color: var(--border-default);
}

.table thead th {
    background-color: var(--hover-bg);
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-default);
    font-weight: 600;
}

.table tbody tr:hover {
    background-color: var(--hover-bg);
}

/* ===================
   FORM STYLING
   =================== */

.form-control:focus,
.form-select:focus {
    border-color: var(--text-muted);
    box-shadow: 0 0 0 0.2rem rgba(55, 65, 81, 0.15);
}

/* ===================
   STATUS INDICATORS
   =================== */

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-muted);
}

.status-dot.status-active {
    background-color: #10b981;
}

.status-dot.status-pending {
    background-color: #f59e0b;
}

.status-dot.status-inactive {
    background-color: #ef4444;
}

/* ===================
   PROGRESS INDICATORS
   =================== */

.progress {
    background-color: var(--hover-bg);
    border-radius: 0.25rem;
}

.progress-bar {
    background-color: var(--text-primary);
}

/* ===================
   TIMELINE FIXES
   =================== */

/* Hide timeline connector line that overlaps cards */
.timeline::before {
    display: none !important;
    content: none !important;
}


/* ===================
   EXPENSE OVERVIEW DRILL-DOWN
   =================== */

/* One line per movement. The columns are fixed so the dates and the amounts hold a column down
   the list; everything that can be long - the description, the route - shares what is left and
   is cut rather than wrapped, because a wrapped row breaks the alignment the list is for.
   Global rather than scoped to one component: the transaction list and the bank movement list
   are the same row wearing different contents, and two copies would drift. */
.drill-rows {
    list-style: none;
    margin: 0;
    padding: 0;
}

.drill-rows > li {
    position: relative;
    padding: 7px 10px 9px;
    border-bottom: 1px solid var(--border-default);
}

.drill-rows > li:last-child {
    border-bottom: 0;
}

.drill-rows > li:hover {
    background-color: var(--hover-bg);
}

.drill-rows .row-line {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
}

.drill-rows .row-date {
    flex: none;
    width: 38px;
    font-size: 11px;
    color: var(--text-subtle);
    font-variant-numeric: tabular-nums;
}

.drill-rows .row-main {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 9px;
    color: inherit;
    text-decoration: none;
}

.drill-rows .row-label {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 58%;
}

.drill-rows .row-label.unknown {
    font-weight: 400;
    font-style: italic;
    color: var(--text-muted);
}

.drill-rows .row-main:hover .row-label {
    text-decoration: underline;
}

.drill-rows .row-route {
    flex: 1;
    min-width: 0;
    font-size: 11.5px;
    color: var(--text-subtle);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* A bank movement has no route, so its empty slot must not hold 42% of the line back from the
   label. An operation's description is a full phrase - what was bought and from whom - and it
   was being cut at "Consultoria de dese…" beside an empty gap. */
.drill-rows .row-route:empty {
    display: none;
}

.drill-rows .row-label:has(+ .row-route:empty) {
    max-width: 100%;
}

/* The chip a bank movement wears instead of a route. */
.drill-rows .row-cat {
    flex: none;
    font-size: 11px;
    color: var(--text-muted);
    border: 1px solid var(--border-default);
    border-radius: 5px;
    padding: 1px 6px;
    white-space: nowrap;
}

.drill-rows .row-jumps {
    flex: none;
    display: flex;
    gap: 4px;
}

/* The jump to the bank movement, and the jump to the document. Shown only when there is one to
   go to, so an empty slot says "nothing behind this row" rather than "button broken". */
.drill-rows .jump {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 22px;
    border: 1px solid var(--border-default);
    border-radius: 6px;
    background-color: var(--content-bg);
    color: var(--text-muted);
    font-size: 11px;
    text-decoration: none;
}

.drill-rows .jump:hover {
    background-color: var(--hover-bg);
    border-color: var(--text-subtle);
    color: var(--text-primary);
}

.drill-rows .jump:focus-visible {
    outline: 2px solid var(--sigo-primary);
    outline-offset: 1px;
}

.drill-rows .row-amt {
    flex: none;
    width: 104px;
    text-align: right;
    font-size: 13px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.drill-rows .row-share {
    flex: none;
    width: 32px;
    text-align: right;
    font-size: 11px;
    color: var(--text-subtle);
    font-variant-numeric: tabular-nums;
}

/* How much of the clicked bar this one row is, drawn where a third line of text used to be. */
.drill-rows .share-rule {
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 3px;
    height: 2px;
    border-radius: 2px;
    background-color: var(--hover-bg);
}

.drill-rows .share-rule > i {
    display: block;
    height: 100%;
    border-radius: 2px;
    opacity: .55;
}

/* The bank movement list's fund strip, layout switches and details. The strip replaces the share
   rule's single colour with the funds the row's money went to, in the chart's column colours. */
.drill-rows .jump.mv-no-doc { position: relative; border-color: #e0a100; background-color: #fff6db; color: #a86b00; }
.drill-rows .jump.mv-unallocated { padding: 0; font: inherit; border-color: #d97706; background-color: #f59e0b; color: #fff; font-size: 13px; line-height: 1; cursor: pointer; box-shadow: 0 0 0 2px rgba(245, 158, 11, .25); }
.drill-rows .jump.mv-unallocated:hover { background-color: #d97706; }
.drill-rows .jump.mv-no-doc b { position: absolute; top: -6px; right: -6px; width: 13px; height: 13px; border-radius: 50%; background: #e0a100; color: #fff; font-size: 9px; line-height: 13px; text-align: center; }
.mv-switches { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 8px; font-size: 11.5px; color: var(--text-muted); }
.mv-switches > span { display: inline-flex; align-items: center; gap: 6px; }
.mv-switches button { font: inherit; border: 1px solid var(--border-default); background: var(--content-bg); color: var(--text-primary); padding: 1px 8px; cursor: pointer; }
.mv-switches button + button { border-left: 0; }
.mv-switches button:first-of-type { border-radius: 5px 0 0 5px; }
.mv-switches button:last-of-type { border-radius: 0 5px 5px 0; }
.mv-switches button[aria-pressed="true"] { background: var(--sigo-primary); border-color: var(--sigo-primary); color: #fff; }
.mv-body { display: flex; flex-direction: column; gap: 8px; }
.mv-list { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.mv-bar { display: flex; gap: 2px; height: 26px; }
.mv-seg { border: 0; padding: 0 6px; min-width: 0; min-height: 0; border-radius: 3px; cursor: pointer; background: var(--c); color: #fff; font-size: 11px; font-weight: 600; text-align: left; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; transition: opacity .15s; }
.mv-seg > span { display: block; overflow: hidden; text-overflow: ellipsis; }
.mv-seg.is-unk, .mv-strip i.is-unk, .mv-mark.is-unk { background-image: repeating-linear-gradient(135deg, transparent 0 4px, rgba(255, 255, 255, .45) 4px 7px); }
.mv-bar.has-sel .mv-seg:not(.on) { opacity: .3; }
.mv-seg:focus-visible { outline: 2px solid var(--text-primary); outline-offset: 2px; }
.mv-callout { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12.5px; padding: 6px 10px; border-radius: 6px; border: 1px solid var(--c); }
.mv-clear { font: inherit; background: none; border: 0; padding: 0; color: var(--sigo-primary); cursor: pointer; }
.mv-section { display: flex; justify-content: space-between; gap: 8px; padding: 10px 10px 4px; font-size: 12.5px; font-weight: 700; border-bottom: 2px solid var(--c); }
.mv-section em { font-style: normal; font-weight: 400; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.drill-rows.mv-dim > li:not(.mv-hit) { opacity: .3; }
.drill-rows .mv-strip { height: 4px; background: transparent; }
/* ShareList: the drill-down rows outside a drill-down. A fold button or an icon where the date goes,
   children indented under their parent, and the bar a little apart from the rows. */
.sl-bar { margin-bottom: 6px; }
.drill-rows .sl-fold { width: 34px; flex-shrink: 0; border: 0; background: transparent; color: var(--text-muted); font-size: 11px; cursor: pointer; padding: 0; text-align: left; }
.drill-rows .sl-icon { width: 34px; flex-shrink: 0; color: var(--text-muted); font-size: 13px; }
.drill-rows .sl-icon.is-warn { color: #d97706; }
.drill-rows .sl-note { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; }
.drill-rows > li.sl-child .row-line, .drill-rows > li.sl-child .mv-strip { margin-left: var(--sl-indent, 0); }
.drill-rows > li.sl-child .row-label { font-weight: 500; }
.drill-rows .mv-strip > span { display: flex; gap: 1px; height: 100%; }
.drill-rows .mv-strip i { display: block; height: 100%; border-radius: 1px; }
.mv-part { font-size: 11px; color: var(--text-subtle); padding-left: 50px; }
.mv-details { display: flex; flex-direction: column; gap: 6px; padding: 6px 0 8px 50px; font-size: 12.5px; }
.mv-details table { border-collapse: collapse; max-width: 460px; }
.mv-details td { padding: 2px 12px 2px 0; border-bottom: 1px dashed var(--border-default); }
.mv-details td:first-child { display: flex; align-items: center; gap: 8px; }
.mv-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mv-muted { color: var(--text-muted); }
.mv-mark { display: inline-block; width: 4px; height: 14px; border-radius: 2px; flex: none; }
.mv-allocate { align-self: flex-start; font: inherit; font-weight: 600; font-size: 12.5px; border: 1px solid var(--sigo-primary); color: var(--sigo-primary); background: none; border-radius: 6px; padding: 3px 10px; cursor: pointer; }
.mv-allocate:hover { background: var(--sigo-primary); color: #fff; }
@media (prefers-reduced-motion: reduce) { .mv-seg { transition: none; } }

/* The list and the graphs beside it. The rail keeps its width and the list takes the rest; on a
   narrow window the rail drops under the list rather than squeezing both. */
.drill-grid {
    display: grid;
    /* Three parts list to two parts graphs. The rail used to be a fixed 328px, which read as an
       afterthought beside a list twice its width; the graphs are the other half of the answer
       and are sized like it. */
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    gap: 16px;
    align-items: start;
    margin-top: 12px;
}

@media (max-width: 1100px) {
    .drill-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* The rail follows the reader down the list, so the three graphs stay beside whichever row is
   being read. Sticky only where it has room to be. */
.drill-rail {
    position: sticky;
    top: 76px;
}

@media (max-width: 1100px) {
    .drill-rail {
        position: static;
    }
}

.drill-rail .rail-section {
    padding: 13px 14px 14px;
    border-bottom: 1px solid var(--border-default);
}

.drill-rail .rail-section:last-child {
    border-bottom: 0;
}

.drill-rail .rail-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 9px;
}

.drill-rail .rail-head span {
    font-size: 12px;
    color: var(--text-muted);
}

.drill-rail .rail-head b {
    font-size: 14px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.drill-rail .rail-pie {
    display: flex;
    align-items: center;
    gap: 12px;
}

.drill-rail .rail-legend {
    flex: 1;
    min-width: 0;
    list-style: none;
    margin: 0;
    padding: 0;
}

.drill-rail .rail-legend li {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 11.5px;
    padding: 2px 0;
}

.drill-rail .rail-legend .dot {
    flex: none;
    width: 9px;
    height: 9px;
    border-radius: 50%;
}

.drill-rail .rail-legend .name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-secondary);
}

.drill-rail .rail-legend .value {
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}

/* The Options button and the panel it opens. The backdrop is a transparent sheet under the
   panel and over everything else, so a click anywhere outside closes it without a document
   listener to unsubscribe. */
.opts-menu {
    position: relative;
}

.opts-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1040;
}

.opts-pop {
    position: absolute;
    right: 0;
    top: calc(100% + 7px);
    z-index: 1050;
    width: 300px;
    padding: 6px;
    background-color: var(--content-bg);
    border: 1px solid var(--border-default);
    border-radius: 10px;
    box-shadow: var(--shadow-card);
}

.opts-pop:focus {
    outline: none;
}

.opts-group + .opts-group {
    margin-top: 4px;
    padding-top: 6px;
    border-top: 1px solid var(--border-default);
}

.opts-cap {
    padding: 6px 10px 2px;
    font-size: 11px;
    color: var(--text-subtle);
}

/* A switch and its explanation, as one row of the panel. */
.opts-switch {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 7px 10px;
    border-radius: 7px;
}

.opts-switch:hover {
    background-color: var(--hover-bg);
}

.opts-switch .form-check {
    margin: 0;
    min-height: 0;
}

.opts-switch .opts-text b {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.opts-switch .opts-text span {
    display: block;
    font-size: 11.5px;
    color: var(--text-muted);
}

.opts-action {
    padding: 4px 10px 8px;
}

/* The panel charts' tooltip. Lives on the body, not inside the card, so a list of ten
   movements is never cut off by a 150px pie or by the rail around it. */
.fund-tip {
    position: fixed;
    z-index: 1080;
    min-width: 230px;
    max-width: min(460px, 92vw);
    padding: 9px 11px 10px;
    background-color: var(--content-bg);
    border: 1px solid var(--border-default);
    border-radius: 8px;
    box-shadow: var(--shadow-card);
    pointer-events: none;
    opacity: 0;
    transition: opacity .1s;
}

.fund-tip .h {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 14px;
    padding-bottom: 6px;
    margin-bottom: 5px;
    border-bottom: 1px solid var(--border-default);
    font-size: 12px;
    color: var(--text-muted);
}

.fund-tip .h b {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.fund-tip ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.fund-tip li {
    display: flex;
    align-items: baseline;
    gap: 9px;
    font-size: 11.5px;
    padding: 1.5px 0;
}

.fund-tip .d {
    flex: none;
    width: 34px;
    color: var(--text-subtle);
    font-variant-numeric: tabular-nums;
}

.fund-tip .l {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-secondary);
}

.fund-tip .a {
    flex: none;
    font-variant-numeric: tabular-nums;
}

.fund-tip .a.pos { color: #008300; }
.fund-tip .a.neg { color: #e02d2d; }

[data-bs-theme="dark"] .fund-tip .a.pos { color: #34c759; }
[data-bs-theme="dark"] .fund-tip .a.neg { color: #ff5a5a; }

/* The monthly-spend tooltip: one large rectangle in two parts. Above, what the hovered column
   or pie is made of, the hovered category marked; below, that category's own movements. The
   rule between them is the whole of the layout - it is what says the lower list belongs to
   one line of the upper one. */
.fund-tip.fund-tip-split {
    width: min(400px, 92vw);
    padding: 0;
    overflow: hidden;
}

.fund-tip-split .sec {
    padding: 10px 12px;
}

.fund-tip-split .sec-rows {
    border-top: 1px solid var(--border-default);
    background-color: var(--hover-bg);
}

.fund-tip-split li {
    font-size: 12px;
    padding: 2px 6px;
    margin: 0 -6px;
    border-radius: 4px;
    color: var(--text-primary);
}

.fund-tip-split li.on {
    background-color: var(--hover-bg);
    font-weight: 600;
}

.fund-tip-split li.on .l {
    color: var(--text-primary);
}

.fund-tip-split .k {
    flex: none;
    align-self: center;
    width: 9px;
    height: 9px;
    border-radius: 2px;
}

.fund-tip-split .m {
    margin-top: 3px;
    font-size: 11px;
    color: var(--text-subtle);
}

/* The mark a movement or a transaction wears when it belongs to an operation. The only coloured
   chip on the row on purpose: the jumps beside it are neutral because they are navigation, and
   this one is a statement about the row - it is part of a larger payment. Not scoped to
   .drill-rows, because the transaction table wears the same mark. */
.op-mark {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 1px solid var(--sigo-primary);
    border-radius: 999px;
    background-color: transparent;
    color: var(--sigo-primary);
    font-size: 10px;
    line-height: 1;
    cursor: pointer;
    vertical-align: middle;
}

.op-mark:hover,
.op-mark.is-open {
    background-color: var(--sigo-primary);
    color: var(--content-bg);
}

.op-mark:focus-visible {
    outline: 2px solid var(--sigo-primary);
    outline-offset: 1px;
}

/* The operation's story, opened under the row that wears the mark. */
.op-story {
    margin: 6px 0 4px;
    padding: 8px 10px;
    border-left: 3px solid var(--sigo-primary);
    border-radius: 0 6px 6px 0;
    background-color: var(--hover-bg);
    font-size: 12.5px;
    line-height: 1.45;
    color: var(--text-secondary);
    white-space: normal;
    text-align: left;
}

.op-story-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 3px;
    font-size: 11px;
    color: var(--sigo-primary);
}

.op-story-head strong {
    font-size: 12.5px;
    color: var(--text-primary);
}

/* Editing an operation's text in place, inside its story. */
.op-story-edit { margin-left: auto; font: inherit; font-size: 11px; background: none; border: 0; padding: 0; color: var(--sigo-primary); cursor: pointer; }
.op-story-form { display: flex; flex-direction: column; gap: 6px; }
.op-story-form label { display: flex; flex-direction: column; gap: 2px; font-size: 11px; color: var(--text-muted); }
.op-story-form input, .op-story-form textarea { font: inherit; font-size: 12.5px; color: var(--text-primary); background: var(--content-bg); border: 1px solid var(--border-default); border-radius: 5px; padding: 4px 6px; }
.op-story-actions { display: flex; gap: 6px; }
.op-story-error { color: var(--bs-danger, #c0392b); font-size: 12px; }

.op-story-empty {
    font-style: italic;
    color: var(--text-subtle);
}

/* An operation nobody has confirmed, or one still missing a kind of record. Warning colour and a
   dashed ring, so it cannot be mistaken for a settled one in a column of marks. */
.op-mark.is-pending {
    border-style: dashed;
    border-color: #c77700;
    color: #c77700;
}

.op-mark.is-pending:hover,
.op-mark.is-pending.is-open {
    background-color: #c77700;
    color: var(--content-bg);
}

.op-story.is-pending {
    border-left-color: #c77700;
}

.op-story.is-pending .op-story-head {
    color: #c77700;
}

.op-flag {
    padding: 0 6px;
    border: 1px solid currentColor;
    border-radius: 999px;
    font-size: 10.5px;
    white-space: nowrap;
}

/* The documents of a row's operation, on hovering its document button. Fixed at the pointer so the
   scrolling drill-down list cannot clip it. */
.op-docs-hover {
    display: inline-flex;
}

.op-docs-pop {
    position: fixed;
    z-index: 1080;
    display: flex;
    width: 660px;
    max-width: calc(100vw - 16px);
    height: 420px;
    border: 1px solid var(--border-default);
    border-radius: 10px;
    background-color: var(--content-bg);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.22);
    overflow: hidden;
    text-align: left;
    white-space: normal;
    animation: op-docs-pop-in 140ms ease-out;
}

@keyframes op-docs-pop-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .op-docs-pop { animation: none; }
}

.op-docs-pop__list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 260px;
    flex: none;
    padding: 10px;
    border-right: 1px solid var(--border-default);
    overflow-y: auto;
}

.op-docs-pop__title {
    margin-bottom: 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-subtle);
}

.op-docs-pop__item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 7px 8px;
    border: 1px solid transparent;
    border-radius: 7px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 12.5px;
}

.op-docs-pop__item:hover,
.op-docs-pop__item.is-current {
    border-color: var(--border-default);
    background-color: var(--hover-bg);
}

.op-docs-pop__head {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.op-docs-pop__head strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.op-docs-pop__meta {
    font-size: 11.5px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.op-docs-pop__what {
    font-size: 11.5px;
    color: var(--text-secondary);
}

.op-docs-pop__preview {
    flex: 1;
    min-width: 0;
    display: flex;
    background-color: var(--hover-bg);
}

.op-docs-pop__preview iframe {
    width: 100%;
    height: 100%;
    border: 0;
}

.op-docs-pop__nofile {
    margin: auto;
    font-size: 12px;
    color: var(--text-subtle);
}
