/* Visual reference: design/modelo-a.jpeg */

:root {
    --app-font: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --app-accent: #16a34a;
    --app-accent-strong: #15803d;
    --app-warning: #f59e0b;
    --app-danger: #dc2626;

    /* The sidebar stays dark in both themes, as in the reference */
    --sidebar-bg: #050605;
    --sidebar-text: #d4d4d4;
    --sidebar-muted: #6b7280;
    --sidebar-active-bg: #0f1a12;
}

[data-bs-theme="light"] {
    --bs-body-bg: #f4f6f5;
    --bs-body-color: #111827;
    --app-surface: #ffffff;
    --app-border: #e3e7e5;
    --app-muted: #6b7280;
    --app-input-bg: #f4f6f5;
}

[data-bs-theme="dark"] {
    --bs-body-bg: #0a0c0b;
    --bs-body-color: #e5e7eb;
    --app-surface: #111413;
    --app-border: #1f2523;
    --app-muted: #8b949e;
    --app-input-bg: #0d100f;
}

body {
    font-family: var(--app-font);
    font-size: 0.875rem;
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
}

svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */

.app-sidebar {
    width: 225px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    padding: 1rem 0.75rem;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0 0.5rem 1.25rem;
}

.brand-mark {
    display: block;
    flex: none;
    width: 2rem;
    height: 2rem;
    object-fit: contain;
}

.brand-name {
    display: block;
    font-weight: 600;
    color: #fff;
}

.brand-sub {
    display: block;
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sidebar-muted);
}

.nav-section {
    margin: 1.1rem 0 0.35rem;
    padding: 0 0.5rem;
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sidebar-muted);
}

.nav-item {
    display: flex;
    white-space: nowrap;
    align-items: center;
    gap: 0.65rem;
    padding: 0.42rem 0.5rem;
    border-radius: 0.4rem;
    color: var(--sidebar-text);
    text-decoration: none;
}

.nav-item svg {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
}

.nav-item:hover {
    color: #fff;
    background: #0d0f0e;
}

.nav-item.active {
    color: var(--app-accent);
    background: var(--sidebar-active-bg);
}

.nav-item.disabled {
    color: var(--sidebar-muted);
    cursor: default;
}

.nav-item.disabled:hover {
    background: transparent;
}

/* Main area */

.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.app-topbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.65rem 1.25rem;
    background: var(--app-surface);
    border-bottom: 1px solid var(--app-border);
}

.search-box {
    align-items: center;
    gap: 0.5rem;
    width: 230px;
    padding: 0.35rem 0.6rem;
    border: 1px solid var(--app-border);
    border-radius: 0.45rem;
    background: var(--app-input-bg);
    color: var(--app-muted);
}

.search-box svg {
    width: 0.95rem;
    height: 0.95rem;
}

.search-box input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 0.8rem;
}

.search-box kbd {
    padding: 0.05rem 0.3rem;
    font-family: inherit;
    font-size: 0.6rem;
    color: var(--app-muted);
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 0.25rem;
}

.topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border: 0;
    border-radius: 0.45rem;
    background: transparent;
    color: var(--bs-body-color);
}

.icon-btn:hover {
    background: var(--app-input-bg);
}

.icon-btn svg {
    width: 1.05rem;
    height: 1.05rem;
}

[data-bs-theme="dark"] .icon-moon,
[data-bs-theme="light"] .icon-sun {
    display: none;
}

.app-content {
    padding: 1.5rem 1.25rem;
}

.page-title {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 600;
}

.page-sub {
    margin: 0.25rem 0 1.5rem;
    color: var(--app-muted);
}

/* Panels */

.panel {
    padding: 1.1rem 1rem;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 0.65rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.panel-title {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
}

.panel-sub {
    margin: 0.3rem 0 1rem;
    font-size: 0.75rem;
    color: var(--app-muted);
}

.component-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.component-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.7rem 0.75rem;
    border: 1px solid var(--app-border);
    border-radius: 0.5rem;
}

.component-list li + li {
    margin-top: 0.6rem;
}

.status-dot {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    background: var(--app-muted);
}

.status-dot.is-up {
    background: var(--app-accent);
}

.status-dot.is-down {
    background: var(--app-danger);
}

.badge-status {
    padding: 0.15rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 500;
    border-radius: 0.3rem;
    color: var(--app-muted);
    background: var(--app-input-bg);
    border: 1px solid var(--app-border);
}

.badge-status.is-up {
    color: #fff;
    background: var(--app-accent-strong);
    border-color: var(--app-accent-strong);
}

.badge-status.is-down {
    color: #fff;
    background: var(--app-danger);
    border-color: var(--app-danger);
}

.info-list {
    margin: 0;
}

.info-list > div {
    display: flex;
    justify-content: space-between;
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--app-border);
}

.info-list > div:last-child {
    border-bottom: 0;
}

.info-list dt {
    font-weight: 400;
    color: var(--app-muted);
}

.info-list dd {
    margin: 0;
    font-weight: 600;
}

/* Sidebar footer with the logged-in user */

.side-nav {
    flex: 1;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 0.5rem 0;
    border-top: 1px solid #161a18;
}

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--sidebar-active-bg);
    color: var(--app-accent);
    font-weight: 600;
}

.sidebar-user-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #fff;
    text-decoration: none;
    font-size: 0.8rem;
}

.icon-btn-dark {
    color: var(--sidebar-muted);
}

.icon-btn-dark:hover {
    color: #fff;
    background: #0d0f0e;
}

/* Buttons and forms */

.btn {
    font-size: 0.8rem;
    border-radius: 0.45rem;
}

.btn-accent {
    color: #fff;
    background: var(--app-accent-strong);
    border-color: var(--app-accent-strong);
}

.btn-accent:hover,
.btn-accent:focus {
    color: #fff;
    background: var(--app-accent);
    border-color: var(--app-accent);
}

.form-label {
    margin-bottom: 0.3rem;
    font-size: 0.75rem;
    color: var(--app-muted);
}

.form-control,
.form-select {
    font-size: 0.85rem;
    background-color: var(--app-input-bg);
    border-color: var(--app-border);
    border-radius: 0.45rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--app-accent);
    box-shadow: 0 0 0 0.15rem color-mix(in srgb, var(--app-accent) 25%, transparent);
}

.form-message {
    min-height: 1.25rem;
    margin-bottom: 0.6rem;
    font-size: 0.8rem;
}

.form-message.is-error {
    color: var(--app-danger);
}

.form-message.is-success {
    color: var(--app-accent);
}

.alert-warning-box {
    padding: 0.7rem 0.9rem;
    font-size: 0.8rem;
    border: 1px solid color-mix(in srgb, var(--app-warning) 50%, transparent);
    border-radius: 0.5rem;
    background: color-mix(in srgb, var(--app-warning) 10%, transparent);
}

.alert-warning-box a {
    color: var(--app-warning);
    margin-left: 0.5rem;
}

/* Tables and lists */

.data-table {
    --bs-table-bg: transparent;
    font-size: 0.8rem;
}

.data-table th {
    font-weight: 500;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--app-muted);
    border-bottom-color: var(--app-border);
}

.data-table td {
    vertical-align: middle;
    border-bottom-color: var(--app-border);
}

.data-table tr.clickable {
    cursor: pointer;
}

.text-muted-cell {
    color: var(--app-muted);
    font-size: 0.8rem;
}

.badge-status.is-warning {
    color: #1f1300;
    background: var(--app-warning);
    border-color: var(--app-warning);
}

.contact-list,
.select-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.contact-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.45rem 0;
    border-bottom: 1px solid var(--app-border);
    font-size: 0.8rem;
}

.select-list li {
    display: flex;
    justify-content: space-between;
    padding: 0.55rem 0.65rem;
    border-radius: 0.45rem;
    cursor: pointer;
}

.select-list li:hover {
    background: var(--app-input-bg);
}

.select-list li.active {
    color: var(--app-accent);
    background: color-mix(in srgb, var(--app-accent) 10%, transparent);
}

.check-list {
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid var(--app-border);
    border-radius: 0.5rem;
    padding: 0.35rem 0.6rem;
}

.check-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0;
    font-size: 0.8rem;
    cursor: pointer;
}

.check-item input {
    accent-color: var(--app-accent);
}

.check-detail {
    margin-left: auto;
    font-size: 0.65rem;
    color: var(--app-muted);
}

.check-group-title {
    margin-bottom: 0.3rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--app-muted);
}

/* Login and registration */

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.5rem 1rem;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    padding: 1.75rem 1.5rem;
}

.auth-card-wide {
    max-width: 640px;
}

.auth-brand {
    padding: 0 0 1.25rem;
}

.auth-brand .brand-name {
    color: var(--bs-body-color);
}

.auth-footer {
    margin: 1.25rem 0 0;
    font-size: 0.8rem;
    color: var(--app-muted);
    text-align: center;
}

.auth-footer a,
.app-content a:not(.btn) {
    color: var(--app-accent);
}

/* Small screens: sidebar becomes a top strip */

@media (max-width: 767.98px) {
    .app-shell {
        flex-direction: column;
    }

    .app-sidebar {
        width: auto;
        height: auto;
        position: static;
        padding: 0.75rem;
    }

    .brand {
        padding-bottom: 0;
    }

    .side-nav,
    .sidebar-user .sidebar-user-name {
        display: none;
    }

    .sidebar-user {
        position: absolute;
        top: 0.75rem;
        right: 0.75rem;
        padding: 0;
        border: 0;
    }
}

.form-control::placeholder {
    color: var(--app-muted);
    opacity: 0.55;
}

/* Log viewer and tabs */

.log-output {
    max-height: 65vh;
    margin: 0;
    padding: 0.75rem;
    overflow: auto;
    font-family: var(--app-font);
    font-size: 0.72rem;
    line-height: 1.5;
    white-space: pre;
    color: var(--bs-body-color);
    background: var(--app-input-bg);
    border: 1px solid var(--app-border);
    border-radius: 0.5rem;
}

.tab-bar {
    display: flex;
    gap: 0.25rem;
    border-bottom: 1px solid var(--app-border);
}

.tab-btn {
    padding: 0.45rem 0.85rem;
    font: inherit;
    font-size: 0.8rem;
    color: var(--app-muted);
    background: transparent;
    border: 0;
    border-bottom: 2px solid transparent;
}

.tab-btn.active {
    color: var(--app-accent);
    border-bottom-color: var(--app-accent);
}

.contact-list li.clickable {
    cursor: pointer;
}

.sub-form {
    padding: 0.75rem;
    border: 1px dashed var(--app-border);
    border-radius: 0.5rem;
}

/* Legal One mirror page */
.sync-summary {
    cursor: pointer;
    list-style-position: inside;
}

.section-title {
    margin: 1.25rem 0 0.4rem;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--app-muted);
}

.timeline {
    margin: 0;
    padding: 0;
    list-style: none;
}

.timeline-item {
    position: relative;
    padding: 0 0 1rem 1.1rem;
    border-left: 1px solid var(--app-border);
}

.timeline-item::before {
    content: "";
    position: absolute;
    top: 0.35rem;
    left: -0.3rem;
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    background: var(--app-accent);
}

.timeline-head {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.75rem;
    align-items: baseline;
    font-size: 0.8rem;
}

.timeline-text {
    margin-top: 0.3rem;
    max-height: 18rem;
    overflow: auto;
    font-size: 0.78rem;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* Home terminal (AASP monitor), after trading terminals: dense panels, right axis, live feed */

.app-content.term {
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.term-panel {
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 0.4rem;
    padding: 0.6rem 0.7rem;
    min-width: 0;
}

.term-head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.45rem;
    flex-wrap: wrap;
}

.term-title {
    margin: 0;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.term-hint {
    font-size: 0.68rem;
    color: var(--app-muted);
}

/* Ticker */

.term-ticker {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 0;
    overflow: hidden;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 0.4rem;
}

.term-brand,
.term-kpi {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1 1 auto;
    padding: 0.5rem 0.9rem;
    border-right: 1px solid var(--app-border);
    border-bottom: 1px solid var(--app-border);
    margin-bottom: -1px;
    white-space: nowrap;
}

.term-pair {
    font-size: 0.95rem;
    font-weight: 700;
}

.term-live {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.68rem;
    color: var(--app-muted);
}

.term-live-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: var(--app-muted);
}

.term-live-dot.is-up {
    background: var(--app-accent);
    box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.6);
    animation: term-pulse 2s infinite;
}

.term-live-dot.is-down {
    background: var(--app-danger);
}

@keyframes term-pulse {
    0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.55); }
    70% { box-shadow: 0 0 0 7px rgba(22, 163, 74, 0); }
    100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); }
}

.term-kpi-label {
    font-size: 0.64rem;
    color: var(--app-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.term-kpi-value {
    font-size: 1.05rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.term-kpi-value.is-warn {
    color: var(--app-warning);
}

.term-kpi-small {
    font-size: 0.82rem;
}

.term-kpi-delta {
    font-size: 0.68rem;
    font-variant-numeric: tabular-nums;
}

.term .term-kpi-delta.is-up,
.term .term-num.is-up,
.term .term-readout .is-up {
    color: #22c55e;
}

.term .term-kpi-delta.is-down,
.term .term-num.is-down {
    color: #ef4444;
}

.term .term-kpi-delta.is-flat,
.term .term-num.is-flat {
    color: var(--app-muted);
}

/* Grid: books on the left, chart and pending items in the center, feed on the right */

.term-grid {
    display: grid;
    gap: 0.5rem;
    grid-template-columns: minmax(250px, 300px) minmax(0, 1fr) minmax(280px, 340px);
    grid-template-areas:
        "journals chart feed"
        "types pending feed";
    grid-template-rows: auto 1fr;
}

.term-journals { grid-area: journals; }
.term-types { grid-area: types; }
.term-chart { grid-area: chart; }
.term-pending { grid-area: pending; }
.term-feed { grid-area: feed; display: flex; flex-direction: column; max-height: calc(100vh - 210px); min-height: 520px; }

@media (max-width: 1200px) {
    .term-grid {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: "chart" "pending" "feed" "journals" "types";
    }

    .term-feed {
        max-height: 520px;
    }
}

/* Order books */

.term-book-head,
.term-book-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 2.6rem 2.6rem 3.4rem;
    gap: 0.3rem;
    align-items: center;
    font-size: 0.72rem;
}

.term-book-head {
    color: var(--app-muted);
    font-size: 0.64rem;
    padding: 0 0.3rem 0.25rem;
    border-bottom: 1px solid var(--app-border);
}

.term-book-head span:not(:first-child),
.term-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.term-book {
    list-style: none;
    margin: 0;
    padding: 0;
}

.term-book-row {
    position: relative;
    padding: 0.22rem 0.3rem;
}

.term-book-row.is-clickable {
    cursor: pointer;
}

.term-book-row:hover {
    background: var(--app-input-bg);
}

.term-book-row > *:not(.term-book-bar) {
    position: relative;
}

.term-book-bar {
    position: absolute;
    top: 1px;
    bottom: 1px;
    right: 0;
    border-radius: 2px;
    opacity: 0.16;
    background: var(--app-accent);
}

.term-book-row > .type-badge {
    justify-self: start;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.term-book-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.term-empty {
    padding: 0.6rem 0.3rem;
    color: var(--app-muted);
    font-size: 0.72rem;
}

/* Chart */

.term-tabs {
    margin-left: auto;
    display: inline-flex;
    gap: 0.15rem;
}

.term-tabs button {
    border: 0;
    background: transparent;
    color: var(--app-muted);
    font: inherit;
    font-size: 0.7rem;
    padding: 0.15rem 0.45rem;
    border-radius: 0.3rem;
}

.term-tabs button.active,
.term-tabs button:hover {
    color: var(--bs-body-color);
    background: var(--app-input-bg);
}

.term-readout {
    display: flex;
    gap: 0.9rem;
    flex-wrap: wrap;
    font-size: 0.7rem;
    min-height: 1.1rem;
    font-variant-numeric: tabular-nums;
}

.term-readout-day {
    font-weight: 600;
}

.term-chart-area {
    width: 100%;
    min-height: 260px;
}

.term-svg {
    display: block;
    width: 100%;
}

.term-grid-line {
    stroke: var(--app-border);
    stroke-width: 1;
    stroke-dasharray: 2 3;
}

.term-axis {
    fill: var(--app-muted);
    stroke: none;
    font-size: 10px;
    font-family: var(--app-font);
}

.bar-matched {
    fill: #22c55e;
    stroke: none;
    opacity: 0.85;
}

.bar-other {
    fill: #64748b;
    stroke: none;
    opacity: 0.6;
}

.line-avg {
    fill: none;
    stroke: #f59e0b;
    stroke-width: 1.5;
}

.term-cross {
    stroke: var(--app-muted);
    stroke-width: 1;
    stroke-dasharray: 3 3;
}

.term-legend {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.66rem;
    color: var(--app-muted);
}

.term-legend i {
    display: inline-block;
    width: 0.7rem;
    height: 0.45rem;
    margin-right: 0.3rem;
    border-radius: 1px;
}

.lg-matched { background: #22c55e; }
.lg-other { background: #64748b; }
.lg-avg { background: #f59e0b; height: 2px !important; }

/* Pending items */

.term-table {
    font-size: 0.72rem;
    margin: 0;
}

.term-table td {
    vertical-align: top;
}

.term-num-cell {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.term-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem;
    min-width: 110px;
}

.term-sub {
    font-size: 0.64rem;
    color: var(--app-muted);
}

.term-snippet {
    min-width: 200px;
    color: var(--app-muted);
}

.term-snippet > span {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.term-deadline {
    display: inline-block;
    padding: 0.05rem 0.4rem;
    border-radius: 0.25rem;
    font-weight: 600;
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.35);
    white-space: nowrap;
}

.term-deadline.is-small {
    font-size: 0.62rem;
    padding: 0 0.3rem;
}

.term-case {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.term-case.is-unmatched {
    color: var(--app-muted);
}

tr.is-new td,
.term-feed-item.is-new {
    animation: term-flash 2.5s ease-out;
}

@keyframes term-flash {
    0% { background: rgba(34, 197, 94, 0.28); }
    100% { background: transparent; }
}

/* Feed */

.term-feed-list {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    flex: 1;
}

.term-feed-item {
    padding: 0.4rem 0.3rem;
    border-bottom: 1px solid var(--app-border);
    border-left: 2px solid transparent;
    cursor: pointer;
    font-size: 0.72rem;
}

.term-feed-item.is-action {
    border-left-color: #f59e0b;
}

.term-feed-item:hover {
    background: var(--app-input-bg);
}

.term-feed-head {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
    margin-bottom: 0.15rem;
}

.term-feed-date {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.term-feed-journal {
    margin-left: auto;
    color: var(--app-muted);
    font-size: 0.64rem;
}

.term-feed-text {
    color: var(--app-muted);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    margin-top: 0.15rem;
}

.term-feed-item.is-open .term-feed-text {
    display: block;
    white-space: pre-wrap;
}

/* Typification badges and their colors */

.type-badge {
    --t: #6b7280;
    display: inline-block;
    padding: 0.05rem 0.4rem;
    border-radius: 0.25rem;
    font-size: 0.66rem;
    font-weight: 600;
    white-space: nowrap;
    color: var(--t);
    background: color-mix(in srgb, var(--t) 14%, transparent);
    border: 1px solid color-mix(in srgb, var(--t) 40%, transparent);
}

.type-badge.is-small {
    font-size: 0.6rem;
    padding: 0 0.3rem;
}

.type-CONSTRAINT { --t: #ef4444; }
.type-HEARING { --t: #a855f7; }
.type-JUDGMENT { --t: #f97316; }
.type-APPELLATE_DECISION { --t: #fb923c; }
.type-RES_JUDICATA { --t: #94a3b8; }
.type-DECISION { --t: #eab308; }
.type-SUMMONS { --t: #ec4899; }
.type-PAYMENT { --t: #06b6d4; }
.type-RESPONSE { --t: #3b82f6; }
.type-ORDER { --t: #14b8a6; }
.type-OTHER { --t: #6b7280; }

.term-book-bar[class*="tone-"] {
    background: var(--t);
}

.tone-CONSTRAINT { --t: #ef4444; }
.tone-HEARING { --t: #a855f7; }
.tone-JUDGMENT { --t: #f97316; }
.tone-APPELLATE_DECISION { --t: #fb923c; }
.tone-RES_JUDICATA { --t: #94a3b8; }
.tone-DECISION { --t: #eab308; }
.tone-SUMMONS { --t: #ec4899; }
.tone-PAYMENT { --t: #06b6d4; }
.tone-RESPONSE { --t: #3b82f6; }
.tone-ORDER { --t: #14b8a6; }
.tone-OTHER { --t: #6b7280; }

.type-dot {
    display: inline-block;
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 50%;
    margin-right: 0.35rem;
    background: var(--t);
}

/* Status bar */

.term-status {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.3rem 0.7rem;
    font-size: 0.66rem;
    color: var(--app-muted);
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 0.4rem;
    white-space: nowrap;
}

.term-status-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.term-marquee {
    flex: 1;
    overflow: hidden;
    min-width: 0;
    mask-image: linear-gradient(90deg, transparent, #000 5%, #000 95%, transparent);
}

.term-marquee-track {
    display: inline-flex;
    gap: 1.6rem;
    padding-left: 100%;
    animation: term-marquee 90s linear infinite;
}

.term-marquee:hover .term-marquee-track {
    animation-play-state: paused;
}

.term-marquee-item {
    display: inline-flex;
    align-items: center;
}

@keyframes term-marquee {
    from { transform: translateX(0); }
    to { transform: translateX(-100%); }
}

@media (prefers-reduced-motion: reduce) {
    .term-marquee-track,
    .term-live-dot.is-up,
    tr.is-new td,
    .term-feed-item.is-new {
        animation: none;
    }
}

/* 3D graph of a case (three.js), shown in place of the terminal grid */

.term-grid.is-behind {
    display: none;
}

.term-graph {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 205px);
    min-height: 480px;
}

.term-graph[hidden] {
    display: none;
}

.graph-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.9rem;
    font-size: 0.66rem;
    color: var(--app-muted);
    margin-bottom: 0.4rem;
}

.graph-legend-item i {
    display: inline-block;
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    margin-right: 0.3rem;
}

.graph-body {
    position: relative;
    flex: 1;
    min-height: 0;
    border: 1px solid var(--app-border);
    border-radius: 0.35rem;
    overflow: hidden;
    background: radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--app-accent) 7%, transparent), transparent 65%);
}

.graph-stage,
.graph-stage canvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: grab;
}

.graph-tooltip {
    position: absolute;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    max-width: 320px;
    padding: 0.35rem 0.5rem;
    font-size: 0.68rem;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 0.3rem;
}

.graph-tooltip span {
    color: var(--app-muted);
}

.graph-detail {
    position: absolute;
    top: 0.6rem;
    right: 0.6rem;
    bottom: 0.6rem;
    width: 300px;
    overflow-y: auto;
    padding: 0.7rem;
    font-size: 0.72rem;
    background: color-mix(in srgb, var(--app-surface) 92%, transparent);
    border: 1px solid var(--app-border);
    border-radius: 0.35rem;
}

.graph-type {
    --t: #6b7280;
    display: inline-block;
    padding: 0 0.35rem;
    border-radius: 0.25rem;
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--t);
    background: color-mix(in srgb, var(--t) 14%, transparent);
    border: 1px solid color-mix(in srgb, var(--t) 40%, transparent);
}

.graph-detail-title {
    margin: 0.4rem 0 0.3rem;
    font-size: 0.85rem;
    font-weight: 600;
}

.graph-detail-text {
    color: var(--app-muted);
    white-space: pre-wrap;
}

.graph-detail-sub {
    margin: 0.6rem 0 0.25rem;
    font-size: 0.64rem;
    color: var(--app-muted);
    text-transform: uppercase;
}

.graph-relations {
    list-style: none;
    margin: 0;
    padding: 0;
}

.graph-relations li {
    display: flex;
    flex-direction: column;
    padding: 0.25rem 0;
    border-bottom: 1px solid var(--app-border);
}

.graph-rel {
    font-size: 0.62rem;
    color: var(--app-accent);
}

.term-case-wrap {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    flex-wrap: wrap;
}

.term-klo {
    padding: 0 0.25rem;
    font-size: 0.56rem;
    font-weight: 700;
    border-radius: 0.2rem;
    color: var(--app-accent);
    border: 1px solid color-mix(in srgb, var(--app-accent) 50%, transparent);
}

.term-klo.is-link {
    color: var(--app-muted);
    border-color: var(--app-border);
    text-decoration: none;
}

/* Chat over the query agent */

.app-content.chat {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 0.5rem;
    padding: 0.75rem;
    height: calc(100vh - 56px);
}

@media (max-width: 900px) {
    .app-content.chat {
        grid-template-columns: minmax(0, 1fr);
        height: auto;
    }

    .chat-side {
        max-height: 220px;
    }
}

.chat-side {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-list {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    flex: 1;
}

.chat-list-item {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    padding: 0.45rem 0.5rem;
    border-radius: 0.3rem;
    cursor: pointer;
    font-size: 0.74rem;
}

.chat-list-item:hover,
.chat-list-item.active {
    background: var(--app-input-bg);
}

.chat-list-item.active {
    box-shadow: inset 2px 0 0 var(--app-accent);
}

.chat-list-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-list-date,
.chat-list-empty {
    font-size: 0.64rem;
    color: var(--app-muted);
}

.chat-main {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-head .term-title {
    font-size: 0.85rem;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chat-empty {
    margin: auto;
    max-width: 640px;
    text-align: center;
}

.chat-examples {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 0.5rem;
}

.chat-example {
    text-align: left;
    padding: 0.6rem 0.7rem;
    font: inherit;
    font-size: 0.74rem;
    color: var(--bs-body-color);
    background: var(--app-input-bg);
    border: 1px solid var(--app-border);
    border-radius: 0.4rem;
}

.chat-example:hover {
    border-color: var(--app-accent);
}

.chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 85%;
}

.chat-msg.is-user {
    align-self: flex-end;
    align-items: flex-end;
}

.chat-msg.is-assistant {
    align-self: flex-start;
}

.chat-bubble {
    padding: 0.55rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    line-height: 1.5;
    white-space: pre-wrap;
}

.chat-msg.is-user .chat-bubble {
    background: color-mix(in srgb, var(--app-accent) 18%, transparent);
    border: 1px solid color-mix(in srgb, var(--app-accent) 35%, transparent);
}

.chat-msg.is-assistant .chat-bubble {
    background: var(--app-input-bg);
    border: 1px solid var(--app-border);
    white-space: normal;
}

.chat-waiting {
    color: var(--app-muted);
    animation: chat-pulse 1.4s ease-in-out infinite;
}

@keyframes chat-pulse {
    0%, 100% { opacity: 0.45; }
    50% { opacity: 1; }
}

.chat-meta {
    margin-top: 0.2rem;
    font-size: 0.62rem;
    color: var(--app-muted);
}

.chat-md p,
.chat-md ul,
.chat-md ol {
    margin: 0 0 0.5rem;
}

.chat-md > :last-child {
    margin-bottom: 0;
}

.chat-md h3,
.chat-md h4,
.chat-md h5,
.chat-md h6 {
    font-size: 0.85rem;
    font-weight: 600;
    margin: 0.5rem 0 0.35rem;
}

.chat-md code {
    padding: 0 0.25rem;
    border-radius: 0.2rem;
    background: var(--app-surface);
    font-size: 0.75rem;
}

.chat-table {
    font-size: 0.74rem;
    margin: 0.25rem 0 0.5rem;
}

.chat-form {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    padding-top: 0.5rem;
    border-top: 1px solid var(--app-border);
}

.chat-form textarea {
    resize: vertical;
    min-height: 2.6rem;
    max-height: 12rem;
    font-size: 0.8rem;
}

@media (prefers-reduced-motion: reduce) {
    .chat-waiting {
        animation: none;
    }
}

.chat-case-link {
    color: var(--app-accent);
    text-decoration: underline dotted;
    text-underline-offset: 2px;
    white-space: nowrap;
}

.chat-case-link:hover {
    text-decoration-style: solid;
}

.graph-open {
    margin: 0.2rem 0 0.4rem;
    font-size: 0.68rem;
}

/* Map of the municipalities beside the KLO graph (MapLibre over the IBGE meshes) */

.graph-body {
    display: grid;
    grid-template-columns: minmax(280px, 34%) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    gap: 0;
}

@media (max-width: 1000px) {
    .graph-body {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: 320px minmax(420px, 1fr);
    }
}

.graph-map-wrap {
    position: relative;
    min-height: 0;
    border-right: 1px solid var(--app-border);
}

/* More specific than .maplibregl-map (position: relative), which the library stylesheet sets later */
.graph-map-wrap > .graph-map {
    position: absolute;
    inset: 0;
}

.graph-map.is-empty {
    background: var(--app-surface);
}

.graph-map-info {
    position: absolute;
    left: 0.5rem;
    bottom: 0.5rem;
    z-index: 2;
    padding: 0.2rem 0.45rem;
    font-size: 0.64rem;
    color: var(--app-muted);
    background: color-mix(in srgb, var(--app-surface) 88%, transparent);
    border: 1px solid var(--app-border);
    border-radius: 0.25rem;
    pointer-events: none;
}

.graph-stage-wrap {
    position: relative;
    min-height: 0;
}

.map-marker {
    min-width: 1.15rem;
    height: 1.15rem;
    padding: 0 0.25rem;
    font: inherit;
    font-size: 0.6rem;
    font-weight: 700;
    line-height: 1.15rem;
    color: var(--app-surface);
    background: var(--app-accent);
    border: 1px solid var(--app-surface);
    border-radius: 999px;
    cursor: pointer;
}

.map-marker.is-state {
    color: var(--bs-body-color);
    background: var(--app-surface);
    border: 1px dashed var(--app-accent);
}

.map-popup {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-family: var(--app-font);
    font-size: 0.68rem;
}

.maplibregl-popup-content {
    background: var(--app-surface);
    color: var(--bs-body-color);
    border: 1px solid var(--app-border);
    border-radius: 0.35rem;
}

.maplibregl-popup-tip {
    display: none;
}

.maplibregl-ctrl-group {
    background: var(--app-surface);
    border: 1px solid var(--app-border);
}

[data-bs-theme="dark"] .maplibregl-ctrl-group button .maplibregl-ctrl-icon {
    filter: invert(1);
}

.maplibregl-popup-close-button {
    color: var(--app-muted);
}
