:root {
    --bg: #080d19;
    --sidebar: #0a101d;
    --panel: #111a2b;
    --panel2: #0d1626;
    --border: #253149;
    --text: #f5f7fb;
    --secondary: #a1adc3;
    --muted: #69768d;
    --purple: #8067ff;
    --cyan: #22d3c5;
    --green: #32d583;
    --red: #ff6178;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family:
        Inter,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}

button,
textarea,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

.hidden {
    display: none !important;
}

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

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 246px;
    display: flex;
    flex-direction: column;
    padding: 24px 16px 18px;
    background:
        radial-gradient(
            circle at top left,
            rgba(128, 103, 255, 0.12),
            transparent 28%
        ),
        var(--sidebar);
    border-right: 1px solid #1d283c;
    z-index: 100;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 8px 24px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background:
        linear-gradient(
            145deg,
            var(--purple),
            #563cff
        );
    font-weight: 800;
}

.brand-name {
    font-size: 18px;
    font-weight: 800;
}

.brand-subtitle {
    margin-top: 3px;
    color: var(--muted);
    font-size: 9px;
    letter-spacing: .12em;
}

.sidebar-label {
    padding: 8px 12px 10px;
    color: #536078;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .16em;
}

.section-label {
    margin-top: 18px;
}

.navigation {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    padding: 0 12px;
    color: #9ca9bf;
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: 10px;
    transition: .15s ease;
}

.nav-item:hover {
    color: white;
    background: #111b2e;
}

.nav-item.active {
    color: white;
    background:
        linear-gradient(
            90deg,
            rgba(128,103,255,.20),
            rgba(128,103,255,.05)
        );
    border-color:
        rgba(128,103,255,.28);
}

.nav-icon {
    width: 20px;
    text-align: center;
}

.nav-count {
    margin-left: auto;
    min-width: 22px;
    padding: 3px 6px;
    border-radius: 20px;
    text-align: center;
    background:
        rgba(255,97,120,.12);
    color: #ff8193;
    font-size: 10px;
}

.sidebar-footer {
    margin-top: auto;
    padding: 18px 8px 0;
    border-top: 1px solid #1f2a3e;
}

.service-state {
    display: flex;
    gap: 10px;
    align-items: center;
}

.service-dot,
.pulse-dot,
.cluster-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
    box-shadow:
        0 0 12px rgba(50,213,131,.65);
}

.service-state strong {
    display: block;
    font-size: 10px;
}

.service-state span {
    color: var(--muted);
    font-size: 9px;
}

.logout-button {
    margin-top: 15px;
    width: 100%;
    height: 34px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #111a2b;
    color: #a8b3c7;
}

.main {
    margin-left: 246px;
    min-height: 100vh;
}

.topbar {
    height: 74px;
    display: grid;
    grid-template-columns:
        1fr auto 1fr;
    align-items: center;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 50;
    background:
        rgba(8,13,25,.90);
    backdrop-filter: blur(15px);
    border-bottom: 1px solid #1d283b;
}

.environment-block {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.eyebrow {
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 8px;
    letter-spacing: .16em;
}

.cluster-button {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
}

.cluster-indicator {
    background: var(--cyan);
}

.topbar-center {
    display: flex;
    gap: 10px;
}

.connection-status {
    display: flex;
    gap: 7px;
    align-items: center;
    padding: 7px 10px;
    border: 1px solid #202b40;
    border-radius: 20px;
    background: #0d1524;
    color: #8e9ab0;
    font-size: 8px;
    font-weight: 700;
}

.profile {
    justify-self: end;
    display: flex;
    gap: 10px;
    align-items: center;
}

.profile-avatar {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: var(--purple);
    font-size: 10px;
    font-weight: 800;
}

.profile-copy strong,
.profile-copy span {
    display: block;
}

.profile-copy strong {
    font-size: 11px;
}

.profile-copy span {
    color: var(--muted);
    font-size: 9px;
}

.content {
    max-width: 1650px;
    margin: auto;
    padding: 32px 30px 42px;
}

.page-panel {
    display: none;
}

.page-panel.active {
    display: block;
}

.hero,
.page-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 20px;
    margin-bottom: 28px;
}

.hero-kicker {
    margin-bottom: 7px;
    color: #9b88ff;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .18em;
}

.hero h1,
.page-heading h1 {
    margin: 0;
    font-size: clamp(30px,3vw,46px);
    letter-spacing: -.04em;
}

.hero h1 span {
    color: #8390a8;
    font-weight: 500;
}

.hero p,
.page-heading p {
    max-width: 700px;
    margin: 10px 0 0;
    color: var(--secondary);
    line-height: 1.6;
    font-size: 13px;
}

.pulse-grid {
    display: grid;
    grid-template-columns:
        repeat(4,minmax(0,1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.pulse-card,
.workspace-card {
    border: 1px solid var(--border);
    background:
        linear-gradient(
            145deg,
            rgba(255,255,255,.025),
            transparent
        ),
        var(--panel);
    box-shadow:
        0 12px 35px rgba(0,0,0,.18);
}

.pulse-card {
    min-height: 170px;
    padding: 18px;
    border-radius: 14px;
}

.metric-symbol {
    color: #9b88ff;
    font-size: 18px;
}

.metric-value {
    margin-top: 20px;
    font-size: 35px;
    font-weight: 800;
}

.metric-title {
    margin-top: 4px;
    font-size: 12px;
    font-weight: 700;
}

.metric-description {
    margin-top: 7px;
    color: var(--muted);
    font-size: 9px;
}

.workspace-grid {
    display: grid;
    grid-template-columns:
        minmax(0,1.5fr)
        minmax(300px,.6fr);
    gap: 14px;
}

.workspace-card {
    padding: 21px;
    border-radius: 15px;
}

.card-heading {
    margin-bottom: 20px;
}

.card-heading h2 {
    margin: 0;
    font-size: 17px;
}

.card-heading p {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 10px;
}

.quick-button {
    width: 100%;
    margin-bottom: 9px;
    padding: 13px;
    text-align: left;
    border: 1px solid #263249;
    border-radius: 10px;
    background: #0d1626;
    color: white;
}

.quick-button:hover {
    background: #151f34;
}

.alert-stream {
    max-height: 420px;
    overflow-y: auto;
}

.alert-stream.large {
    max-height:
        calc(100vh - 220px);
}

.alert-item {
    margin-bottom: 10px;
    padding: 14px;
    border: 1px solid #263249;
    border-radius: 10px;
    background: #0d1626;
}

.alert-item-header {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 8px;
}

.alert-source {
    color: #a795ff;
    font-size: 9px;
    font-weight: 800;
}

.alert-time {
    color: var(--muted);
    font-size: 9px;
}

.alert-text {
    white-space: pre-wrap;
    line-height: 1.5;
    font-size: 11px;
}

.alert-meta {
    margin-top: 9px;
    color: var(--muted);
    font-size: 9px;
}

.empty-state {
    padding: 50px 20px;
    color: var(--muted);
    text-align: center;
}

.terminal-page.active,
.assistant-page.active {
    display: flex;
    height:
        calc(100vh - 140px);
    flex-direction: column;
}

.terminal-heading {
    flex: 0 0 auto;
}

.terminal-status {
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--muted);
    font-size: 9px;
}

.terminal-status.connected {
    color: var(--green);
    border-color:
        rgba(50,213,131,.35);
}

.terminal-shell {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #050913;
}

.terminal-toolbar {
    height: 42px;
    flex: 0 0 42px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 13px;
    border-bottom: 1px solid #1c2637;
    color: #69768d;
    font-size: 10px;
}

.terminal-toolbar button {
    padding: 5px 9px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #111a2b;
    color: #a8b3c7;
    font-size: 9px;
}

#terminal {
    flex: 1;
    min-height: 0;
    padding: 8px;
}

.chat-workspace {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    max-width: 1050px;
    width: 100%;
    margin: 0 auto;
    border: 1px solid var(--border);
    border-radius: 15px;
    background: #0d1524;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    min-height: 0;
    padding: 28px;
    overflow-y: auto;
}

.chat-row {
    display: flex;
    gap: 12px;
    margin-bottom: 22px;
}

.chat-row.user {
    justify-content: flex-end;
}

.chat-avatar {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: var(--purple);
    font-size: 10px;
    font-weight: 800;
}

.chat-row.user .chat-avatar {
    display: none;
}

.chat-message {
    max-width: 78%;
    padding: 12px 14px;
    border: 1px solid #263249;
    border-radius: 12px;
    background: #151f32;
    white-space: pre-wrap;
    line-height: 1.65;
    font-size: 12px;
}

.chat-row.user .chat-message {
    border-color:
        rgba(128,103,255,.40);
    background:
        rgba(128,103,255,.18);
}

.chat-composer {
    display: flex;
    gap: 10px;
    padding: 13px;
    border-top: 1px solid var(--border);
    background: #0a111e;
}

.chat-composer textarea {
    flex: 1;
    min-height: 46px;
    max-height: 180px;
    resize: none;
    padding: 12px;
    outline: none;
    border: 1px solid #2a3650;
    border-radius: 10px;
    background: #111b2d;
    color: white;
}

.chat-composer textarea:focus {
    border-color: var(--purple);
}

.chat-composer button,
.secondary-button {
    border: 0;
    border-radius: 9px;
    background: var(--purple);
    color: white;
    font-weight: 700;
}

.chat-composer button {
    padding: 0 18px;
}

.secondary-button {
    padding: 10px 14px;
}

.login-overlay {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    z-index: 5000;
    background:
        radial-gradient(
            circle at center,
            rgba(128,103,255,.10),
            transparent 34%
        ),
        #080d19;
}

.login-card {
    width: 380px;
    padding: 35px;
    border: 1px solid var(--border);
    border-radius: 17px;
    background: #101827;
    box-shadow:
        0 30px 80px rgba(0,0,0,.45);
    text-align: center;
}

.login-mark {
    margin: 0 auto 15px;
}

.login-card h1 {
    margin: 0;
}

.login-card p {
    margin: 8px 0 22px;
    color: var(--muted);
    font-size: 11px;
}

.login-card input {
    width: 100%;
    height: 45px;
    padding: 0 12px;
    border: 1px solid #2a3650;
    border-radius: 9px;
    outline: none;
    background: #0a111e;
    color: white;
}

.login-card button {
    width: 100%;
    height: 43px;
    margin-top: 10px;
    border: 0;
    border-radius: 9px;
    background: var(--purple);
    color: white;
    font-weight: 700;
}

.login-error {
    min-height: 20px;
    margin-top: 10px;
    color: var(--red);
    font-size: 10px;
}

@media (max-width: 1000px) {
    .pulse-grid {
        grid-template-columns:
            repeat(2,1fr);
    }

    .workspace-grid {
        grid-template-columns: 1fr;
    }

    .topbar-center {
        display: none;
    }
}

@media (max-width: 700px) {
    .sidebar {
        width: 190px;
    }

    .main {
        margin-left: 190px;
    }

    .pulse-grid {
        grid-template-columns: 1fr;
    }
}

/* Consumer Tuning Table */

.consumer-table-wrap {
    width: 100%;
    overflow-x: auto;
    margin-top: 16px;
}

.consumer-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.consumer-table th,
.consumer-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid rgba(148, 163, 184, 0.15);
    vertical-align: middle;
}

.consumer-table thead th {
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}

.consumer-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.025);
}

.consumer-filter-row th {
    padding-top: 8px;
    padding-bottom: 12px;
    cursor: default;
}

.consumer-filter-row input {
    width: 100%;
    box-sizing: border-box;
    padding: 9px 11px;
    border-radius: 6px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    background: rgba(15, 23, 42, 0.65);
    color: inherit;
    outline: none;
}

.consumer-filter-row input:focus {
    border-color: rgba(124, 92, 255, 0.75);
}

.consumer-status-badge {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.status-running {
    background: rgba(34, 197, 94, 0.16);
    color: #4ade80;
}

.status-not-enabled {
    background: rgba(234, 179, 8, 0.16);
    color: #facc15;
}

.status-not-running {
    background: rgba(239, 68, 68, 0.16);
    color: #f87171;
}

.status-maintenance {
    background: rgba(59, 130, 246, 0.16);
    color: #60a5fa;
}

.consumer-empty {
    text-align: center;
    padding: 30px;
    opacity: 0.7;
}

/* =========================================================
   Consumer Tuning - Visual Table
   ========================================================= */

.consumer-table-wrap {
    width: 100%;
    overflow-x: auto;
    margin-top: 16px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 10px;
}

.consumer-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    background: rgba(8, 15, 30, 0.65);
}

.consumer-table th,
.consumer-table td {
    border-right: 1px solid rgba(148, 163, 184, 0.20);
    border-bottom: 1px solid rgba(148, 163, 184, 0.20);
    padding: 12px 14px;
    text-align: left;
    vertical-align: middle;
    word-break: break-word;
}

.consumer-table th:last-child,
.consumer-table td:last-child {
    border-right: none;
}

.consumer-table thead tr:first-child th {
    background: rgba(30, 41, 59, 0.95);
    font-weight: 700;
    font-size: 14px;
    color: #f8fafc;
}

.consumer-filter-row th {
    background: rgba(15, 23, 42, 0.95);
    padding: 8px;
}

.consumer-filter-row input {
    width: 100%;
    box-sizing: border-box;
    padding: 9px 10px;
    border-radius: 6px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: #ffffff;
    color: #111827;
    font-size: 13px;
    outline: none;
}

.consumer-filter-row input:focus {
    border-color: #7c5cff;
    box-shadow: 0 0 0 2px rgba(124, 92, 255, 0.18);
}

.consumer-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.025);
}

.consumer-table tbody tr:hover {
    background: rgba(124, 92, 255, 0.08);
}

.consumer-table th:nth-child(1),
.consumer-table td:nth-child(1) {
    width: 42%;
}

.consumer-table th:nth-child(2),
.consumer-table td:nth-child(2) {
    width: 18%;
}

.consumer-table th:nth-child(3),
.consumer-table td:nth-child(3) {
    width: 18%;
}

.consumer-table th:nth-child(4),
.consumer-table td:nth-child(4) {
    width: 22%;
}

/* Status badge */

.consumer-status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 120px;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
}

/* 0 = Running */
.status-running {
    background: rgba(34, 197, 94, 0.20);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.35);
}

/* 1 = Running - Not Enabled */
.status-not-enabled {
    background: rgba(234, 179, 8, 0.20);
    color: #facc15;
    border: 1px solid rgba(234, 179, 8, 0.35);
}

/* 2 = Not Running */
.status-not-running {
    background: rgba(239, 68, 68, 0.20);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.35);
}

/* 4 = Under Maintenance */
.status-maintenance {
    background: rgba(59, 130, 246, 0.20);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.35);
}

.consumer-empty {
    text-align: center;
    padding: 30px !important;
    opacity: 0.7;
}


/* ==========================================================
   MIRAI YARN QUEUE DASHBOARD
   ========================================================== */

.yarn-cluster-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 18px 0 22px 0;
}


.yarn-cluster-tab {
    display: flex;
    align-items: center;
    gap: 9px;

    border: 1px solid #273449;
    background: #0c1423;

    color: #cbd5e1;

    padding: 9px 14px;

    border-radius: 9px;

    cursor: pointer;

    font-size: 13px;
    font-weight: 650;

    transition:
        border-color .15s ease,
        background .15s ease,
        transform .15s ease;
}


.yarn-cluster-tab:hover {
    border-color: #64748b;
    transform: translateY(-1px);
}


.yarn-cluster-tab.active {
    background: #172036;
    border-color: #8b5cf6;
    box-shadow:
        0 0 0 1px
        rgba(139, 92, 246, .2);
}


.yarn-cluster-tab strong {
    font-size: 12px;
}


.yarn-cluster-heading {
    display: flex;
    align-items: baseline;
    gap: 12px;

    margin-bottom: 16px;
}


.yarn-cluster-heading span {
    font-size: 20px;
    font-weight: 750;
    color: #f8fafc;
}


.yarn-cluster-heading small {
    color: #94a3b8;
}


.yarn-main-metrics {
    display: grid;
    grid-template-columns:
        repeat(3, minmax(0, 1fr));

    gap: 16px;

    margin-bottom: 22px;
}


.yarn-metric-card {
    background: #0b1220;

    border: 1px solid #263347;

    border-radius: 12px;

    padding: 18px;

    min-height: 180px;
}


.yarn-metric-label {
    color: #94a3b8;

    font-size: 11px;

    letter-spacing: .10em;

    font-weight: 750;

    margin-bottom: 10px;
}


.yarn-metric-value {
    font-size: 32px;
    line-height: 1;

    font-weight: 800;

    margin-bottom: 18px;
}


.yarn-progress,
.yarn-mini-progress {
    overflow: hidden;

    background: #172033;

    border-radius: 999px;
}


.yarn-progress {
    height: 9px;
}


.yarn-mini-progress {
    height: 5px;
}


.yarn-progress-fill,
.yarn-mini-progress-fill {
    height: 100%;

    width: 0;

    border-radius: inherit;

    transition: width .3s ease;
}


.yarn-progress-fill.normal,
.yarn-mini-progress-fill.normal {
    background: #22c55e;
}


.yarn-progress-fill.warning,
.yarn-mini-progress-fill.warning {
    background: #eab308;
}


.yarn-progress-fill.critical,
.yarn-mini-progress-fill.critical {
    background: #ef4444;
}


.normal {
    color: #4ade80 !important;
}


.warning {
    color: #facc15 !important;
}


.critical {
    color: #f87171 !important;
}


.unknown {
    color: #94a3b8 !important;
}


.yarn-category-list {
    display: flex;

    flex-direction: column;

    gap: 12px;

    max-height: 330px;

    overflow-y: auto;
}


.yarn-all-queues-panel {
    margin-top: 4px;
}


.yarn-all-queues {
    display: grid;

    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 10px 18px;

    padding-top: 12px;
}


.yarn-queue-row {
    padding: 10px 0;

    border-bottom:
        1px solid rgba(
            51,
            65,
            85,
            .55
        );
}


.yarn-queue-row-top {
    display: flex;

    align-items: center;

    justify-content: space-between;

    gap: 15px;

    margin-bottom: 7px;
}


.yarn-queue-name {
    color: #cbd5e1;

    font-size: 12px;

    overflow: hidden;

    text-overflow: ellipsis;

    white-space: nowrap;
}


.yarn-queue-row strong {
    font-size: 12px;

    flex-shrink: 0;
}


.yarn-empty,
.yarn-error {
    color: #94a3b8;

    font-size: 13px;

    padding: 12px 0;
}


.yarn-error {
    color: #f87171;
}


@media (
    max-width: 1100px
) {

    .yarn-main-metrics {
        grid-template-columns:
            1fr;
    }

    .yarn-all-queues {
        grid-template-columns:
            1fr;
    }

}


/* MIRAI CONSUMER LAG */

.consumer-lag-badge {
    display: inline-block;
    min-width: 62px;

    padding: 4px 8px;

    border-radius: 6px;

    text-align: center;

    font-size: 12px;
    font-weight: 700;

    font-variant-numeric:
        tabular-nums;
}


.consumer-lag-badge.lag-normal {
    color: #4ade80;

    background:
        rgba(34, 197, 94, .12);

    border:
        1px solid
        rgba(34, 197, 94, .45);
}


.consumer-lag-badge.lag-warning {
    color: #facc15;

    background:
        rgba(234, 179, 8, .12);

    border:
        1px solid
        rgba(234, 179, 8, .50);
}


.consumer-lag-badge.lag-critical {
    color: #f87171;

    background:
        rgba(239, 68, 68, .13);

    border:
        1px solid
        rgba(239, 68, 68, .55);
}


.consumer-lag-badge.lag-unknown {
    color: #94a3b8;

    background:
        rgba(148, 163, 184, .08);

    border:
        1px solid
        rgba(148, 163, 184, .25);
}


.consumer-lag-na {
    color: #475569;
}


/* ============================================================
   MIRAI CONSUMER LAG COLUMN
   ============================================================ */

.consumer-table {
    min-width: 1250px;
}

.consumer-table th:nth-child(5),
.consumer-table td:nth-child(5) {
    width: 190px;
    min-width: 190px;
    max-width: 190px;
    text-align: center;
}

.consumer-lag-filter {
    width: 100%;
    min-width: 160px;
    height: 42px;
    padding: 0 12px;
    border: 1px solid #475569;
    border-radius: 8px;
    background: #ffffff;
    color: #111827;
    font-size: 14px;
    cursor: pointer;
}

.consumer-lag-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 105px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.consumer-table th:nth-child(5) {
    cursor: pointer;
    user-select: none;
}

.consumer-table th:nth-child(5):hover {
    background: rgba(148, 163, 184, 0.08);
}


/* ============================================================
   MIRAI CONSUMER LAG COLUMN
   ============================================================ */

.consumer-table {
    min-width: 1250px;
}

.consumer-table th:nth-child(5),
.consumer-table td:nth-child(5) {
    width: 190px;
    min-width: 190px;
    max-width: 190px;
    text-align: center;
}

.consumer-lag-filter {
    width: 100%;
    min-width: 160px;
    height: 42px;
    padding: 0 12px;
    border: 1px solid #475569;
    border-radius: 8px;
    background: #ffffff;
    color: #111827;
    font-size: 14px;
    cursor: pointer;
}

.consumer-lag-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 105px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.consumer-table th:nth-child(5) {
    cursor: pointer;
    user-select: none;
}

.consumer-table th:nth-child(5):hover {
    background: rgba(148, 163, 184, 0.08);
}


/* CONSUMER-YARN-SUMMARY */

#page-consumer-tuning .consumer-yarn-summary {
    margin-top: 16px;
    padding: 14px 16px;
    border: 1px solid #334155;
    border-radius: 9px;
    background: #0b1120;
}

#page-consumer-tuning .consumer-yarn-summary-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    color: #f8fafc;
    font-size: 13px;
    font-weight: 700;
}

#page-consumer-tuning #consumerYarnSummaryStatus {
    color: #64748b;
    font-size: 11px;
    font-weight: 500;
}

#page-consumer-tuning .consumer-yarn-summary-grid {
    display: grid;
    grid-template-columns:
        repeat(auto-fit, minmax(250px, 1fr));
    gap: 8px;
}

#page-consumer-tuning .consumer-yarn-row {
    display: grid;
    grid-template-columns: 82px 1fr 1fr;
    align-items: center;
    gap: 8px;

    padding: 8px 10px;

    border: 1px solid #334155;
    border-radius: 7px;

    background: #111827;
}

#page-consumer-tuning .consumer-yarn-cluster {
    color: #e2e8f0;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

#page-consumer-tuning .consumer-yarn-value {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 5px;

    padding: 4px 7px;

    border-radius: 5px;
    background: #0f172a;

    font-size: 11px;
}

#page-consumer-tuning .consumer-yarn-value span {
    color: #94a3b8;
}

#page-consumer-tuning .consumer-yarn-value strong {
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

#page-consumer-tuning .consumer-yarn-value strong.normal {
    color: #22c55e;
}

#page-consumer-tuning .consumer-yarn-value strong.warning {
    color: #f59e0b;
}

#page-consumer-tuning .consumer-yarn-value strong.critical {
    color: #ef4444;
}

#page-consumer-tuning .consumer-yarn-value strong.unknown {
    color: #64748b;
}


/* =========================================
   Consumer Tuning sticky YARN + sticky table
   ========================================= */

#page-consumer-tuning {
    height: calc(100vh - 90px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Keep YARN usage fixed */
#page-consumer-tuning .consumer-yarn-summary {
    flex: 0 0 auto;
    position: sticky;
    top: 0;
    z-index: 30;
    background: #0b1120;
}

/* Only the table area should use remaining space */
#page-consumer-tuning .consumer-table-wrap {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto !important;
    margin-top: 18px !important;
}

/* Main column names stay fixed */
#page-consumer-tuning table.consumer-table thead tr:first-child th {
    position: sticky !important;
    top: 0 !important;
    z-index: 20 !important;
    background: #1e293b !important;
}

/* Filter/search row stays fixed under main header */
#page-consumer-tuning table.consumer-table thead tr.consumer-filter-row th {
    position: sticky !important;
    top: 52px !important;
    z-index: 19 !important;
    background: #111827 !important;
}

/* Prevent sticky header transparency while rows scroll */
#page-consumer-tuning table.consumer-table thead th {
    background-clip: padding-box !important;
}

/* Keep body scrolling cleanly */
#page-consumer-tuning table.consumer-table tbody {
    position: relative;
}


/* =========================================
   FIX: only consumer rows/table area scroll
   ========================================= */

/* Undo page-level scroll locking */
#page-consumer-tuning {
    height: auto !important;
    min-height: 0 !important;
    display: block !important;
    overflow: visible !important;
}

/* YARN summary remains outside scrolling area */
#page-consumer-tuning .consumer-yarn-summary {
    position: relative !important;
    top: auto !important;
    z-index: 1 !important;
    flex: none !important;
}

/* This is the ONLY vertical scroll container */
#page-consumer-tuning .consumer-table-wrap {
    display: block !important;

    height: calc(100vh - 430px) !important;
    min-height: 300px !important;

    overflow-x: auto !important;
    overflow-y: auto !important;

    position: relative !important;
}

/* Column header */
#page-consumer-tuning table.consumer-table thead tr:first-child th {
    position: sticky !important;
    top: 0 !important;
    z-index: 30 !important;
    background: #1e293b !important;
}

/* Search/filter row */
#page-consumer-tuning table.consumer-table thead tr.consumer-filter-row th {
    position: sticky !important;
    top: 52px !important;
    z-index: 29 !important;
    background: #111827 !important;
}

/* Ensure rows don't interfere with sticky headers */
#page-consumer-tuning table.consumer-table tbody {
    position: static !important;
}



/* ==========================================================
   COMPACT CONSUMER TUNING V2
   ========================================================== */

/*
 * Consumer Tuning uses the viewport efficiently.
 * Only the table area scrolls vertically.
 */
#page-consumer-tuning {
    height: calc(100vh - 24px) !important;
    min-height: 0 !important;

    display: flex !important;
    flex-direction: column !important;

    padding-top: 12px !important;

    overflow: hidden !important;
}


/* ----------------------------------------------------------
   Compact top operations bar
   ---------------------------------------------------------- */

#page-consumer-tuning .consumer-ops-bar {
    flex: 0 0 auto;

    min-height: 64px;

    display: flex;
    align-items: center;
    gap: 14px;

    padding: 8px 10px;

    border: 1px solid #334155;
    border-radius: 9px;

    background: #0b1120;

    margin-bottom: 10px;
}


#page-consumer-tuning .consumer-refresh-btn {
    flex: 0 0 auto;

    height: 36px;

    padding: 0 14px;

    border: 1px solid #475569;
    border-radius: 7px;

    background: #1e293b;
    color: #f8fafc;

    font-size: 12px;
    font-weight: 700;

    cursor: pointer;
}


#page-consumer-tuning .consumer-refresh-btn:hover {
    background: #334155;
}


/* Consumer count metric */

#page-consumer-tuning .consumer-count-metric {
    flex: 0 0 auto;

    height: 38px;

    display: flex;
    align-items: center;
    gap: 10px;

    padding: 0 12px;

    border: 1px solid #334155;
    border-radius: 7px;

    background:
        linear-gradient(
            90deg,
            rgba(124,92,255,.16),
            rgba(124,92,255,.03)
        );
}


#page-consumer-tuning .consumer-count-label {
    color: #94a3b8;

    font-size: 11px;
    font-weight: 600;

    text-transform: uppercase;
    letter-spacing: .04em;
}


#page-consumer-tuning #consumerCount {
    color: #f8fafc;

    font-size: 16px;
    font-weight: 800;

    white-space: nowrap;
}


/* ----------------------------------------------------------
   Inline YARN queue utilization
   ---------------------------------------------------------- */

#page-consumer-tuning .consumer-yarn-inline {
    flex: 1 1 auto;
    min-width: 0;

    display: flex;
    align-items: center;
    gap: 10px;
}


#page-consumer-tuning .consumer-yarn-inline-label {
    flex: 0 0 auto;

    color: #94a3b8;

    font-size: 10px;
    font-weight: 700;

    text-transform: uppercase;
    letter-spacing: .05em;
}


#page-consumer-tuning .consumer-yarn-inline-grid {
    flex: 1 1 auto;

    min-width: 0;

    display: flex;
    align-items: center;
    gap: 6px;

    overflow-x: auto;
    overflow-y: hidden;

    scrollbar-width: thin;

    padding-bottom: 2px;
}


#page-consumer-tuning .consumer-yarn-cluster-mini {
    flex: 0 0 auto;

    height: 48px;

    display: flex;
    align-items: center;
    gap: 5px;

    padding: 3px 7px;

    border: 1px solid #334155;
    border-radius: 7px;

    background: #111827;
}


#page-consumer-tuning .consumer-yarn-cluster-name {
    min-width: 48px;

    color: #e2e8f0;

    font-size: 10px;
    font-weight: 800;

    text-transform: uppercase;
}


/* Circular gauges */

#page-consumer-tuning .consumer-yarn-gauge-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    gap: 1px;
}


#page-consumer-tuning .consumer-yarn-gauge-wrap small {
    color: #64748b;

    font-size: 7px;
    font-weight: 700;
}


#page-consumer-tuning .consumer-yarn-gauge {
    --usage: 0;

    width: 29px;
    height: 29px;

    position: relative;

    display: grid;
    place-items: center;

    border-radius: 50%;

    background:
        conic-gradient(
            currentColor
            calc(var(--usage) * 1%),
            #273449 0
        );
}


#page-consumer-tuning .consumer-yarn-gauge::before {
    content: "";

    position: absolute;
    inset: 4px;

    border-radius: 50%;

    background: #111827;
}


#page-consumer-tuning .consumer-yarn-gauge span {
    position: relative;
    z-index: 1;

    color: #e2e8f0;

    font-size: 8px;
    font-weight: 800;

    font-variant-numeric: tabular-nums;
}


#page-consumer-tuning .consumer-yarn-gauge.normal {
    color: #22c55e;
}


#page-consumer-tuning .consumer-yarn-gauge.warning {
    color: #facc15;
}


#page-consumer-tuning .consumer-yarn-gauge.critical {
    color: #ef4444;
}


#page-consumer-tuning .consumer-yarn-gauge.unknown {
    color: #475569;
}


#page-consumer-tuning .consumer-yarn-updated {
    flex: 0 0 auto;

    color: #64748b;

    font-size: 9px;

    white-space: nowrap;
}


/* ----------------------------------------------------------
   Maximize consumer table
   ---------------------------------------------------------- */

#page-consumer-tuning .consumer-table-wrap {
    flex: 1 1 auto !important;

    width: 100% !important;

    height: auto !important;
    min-height: 0 !important;

    margin-top: 0 !important;

    overflow-x: auto !important;
    overflow-y: auto !important;

    position: relative !important;

    border: 1px solid #334155 !important;
    border-radius: 8px !important;

    background: #0b1120;
}


/*
 * Separate borders are more reliable for sticky THEAD
 * than border-collapse: collapse.
 */
#page-consumer-tuning table.consumer-table {
    width: 100% !important;

    border-collapse: separate !important;
    border-spacing: 0 !important;

    table-layout: fixed !important;

    background: #0b1120 !important;
}


/* ----------------------------------------------------------
   Sticky column names
   ---------------------------------------------------------- */

#page-consumer-tuning table.consumer-table
thead tr:first-child th {

    position: sticky !important;

    top: 0 !important;

    height: 46px !important;
    box-sizing: border-box !important;

    z-index: 50 !important;

    padding: 10px 14px !important;

    background: #1e293b !important;

    box-shadow:
        0 1px 0 #334155;
}


/* ----------------------------------------------------------
   Sticky search/filter row
   ---------------------------------------------------------- */

#page-consumer-tuning table.consumer-table
thead tr.consumer-filter-row th {

    position: sticky !important;

    top: 46px !important;

    height: 56px !important;
    box-sizing: border-box !important;

    z-index: 49 !important;

    padding: 8px 10px !important;

    background: #111827 !important;

    box-shadow:
        0 2px 0 #334155;
}


/* Compact filter controls */

#page-consumer-tuning .consumer-filter-row input,
#page-consumer-tuning .consumer-filter-row select,
#page-consumer-tuning .consumer-lag-filter {

    height: 38px !important;

    width: 100% !important;

    box-sizing: border-box !important;

    margin: 0 !important;
}


/* Prevent body rows bleeding through sticky headers */

#page-consumer-tuning table.consumer-table thead {
    position: relative;
    z-index: 40;
}


#page-consumer-tuning table.consumer-table tbody {
    position: relative;
    z-index: 1;
}


/* Slightly tighter rows = more visible consumers */

#page-consumer-tuning table.consumer-table tbody td {
    padding-top: 10px !important;
    padding-bottom: 10px !important;
}


/* ==========================================================
   FIX: Consumer Tuning must only appear on its own page
   ========================================================== */

#page-consumer-tuning.page-panel {
    display: none !important;
}

#page-consumer-tuning.page-panel.active {
    display: flex !important;
    flex-direction: column !important;
}


/* ==========================================================
   FIX PAGE VISIBILITY - Consumer Tuning
   ========================================================== */

#page-consumer-tuning.page-panel {
    display: none !important;
}

#page-consumer-tuning.page-panel.active {
    display: flex !important;
    flex-direction: column !important;
}


/* ==========================================================
   RECORDS PAGE
   ========================================================== */

#page-records {
    padding-top: 12px;
}

#page-records .records-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;

    margin-bottom: 14px;
    padding: 12px 14px;

    border: 1px solid #334155;
    border-radius: 9px;

    background: #0b1120;
}

#page-records .records-title {
    color: #f8fafc;
    font-size: 16px;
    font-weight: 800;
}

#page-records .records-count {
    padding: 4px 9px;

    border: 1px solid #334155;
    border-radius: 999px;

    background: #111827;
    color: #94a3b8;

    font-size: 11px;
    font-weight: 700;
}

#page-records .records-grid {
    display: grid;
    grid-template-columns:
        repeat(auto-fit, minmax(260px, 1fr));

    gap: 10px;
}

#page-records .record-card {
    display: flex;
    align-items: center;
    gap: 10px;

    min-height: 54px;

    padding: 10px 14px;

    border: 1px solid #334155;
    border-radius: 8px;

    background: #111827;
}

#page-records .record-icon {
    width: 26px;
    height: 26px;

    display: grid;
    place-items: center;

    border-radius: 50%;

    background: rgba(34, 197, 94, .12);
    color: #4ade80;

    font-size: 11px;
    font-weight: 800;
}

#page-records .record-card-bad .record-icon {
    background: rgba(239, 68, 68, .14);
    color: #f87171;
}

#page-records .record-name {
    color: #e2e8f0;
    font-size: 14px;
    font-weight: 700;
}


#page-records .record-meta {
    margin-top: 3px;
    color: #64748b;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
}


/* RECORDS MANAGER V2 */

#page-records .records-add-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 18px 0 14px;
}

#page-records .records-add-bar input {
    width: 360px;
    max-width: 50vw;
    height: 40px;
    padding: 0 12px;
    border: 1px solid #334155;
    border-radius: 7px;
    background: #111827;
    color: #f8fafc;
    outline: none;
}

#page-records .records-add-bar button {
    height: 40px;
    padding: 0 16px;
    border: 0;
    border-radius: 7px;
    background: #7c5cff;
    color: white;
    font-weight: 700;
    cursor: pointer;
}

#page-records #recordsCount {
    color: #94a3b8;
    font-size: 12px;
}

#page-records .records-table-wrap {
    border: 1px solid #334155;
    border-radius: 9px;
    overflow: hidden;
}

#page-records .records-table {
    width: 100%;
    border-collapse: collapse;
    background: #0b1120;
}

#page-records .records-table th {
    padding: 12px 16px;
    background: #1e293b;
    color: #f8fafc;
    text-align: left;
    font-size: 12px;
}

#page-records .records-table td {
    padding: 13px 16px;
    border-top: 1px solid #1e293b;
    color: #cbd5e1;
}

#page-records .record-name-cell {
    color: #f8fafc;
    font-weight: 700;
}

#page-records .record-type {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 999px;
    background: #1e293b;
    font-size: 11px;
    font-weight: 700;
}

#page-records .record-type-dummy {
    color: #4ade80;
}

#page-records .record-type-bad {
    color: #f87171;
}

#page-records .record-delete-btn {
    padding: 5px 10px;
    border: 1px solid #7f1d1d;
    border-radius: 5px;
    background: transparent;
    color: #f87171;
    cursor: pointer;
}


/* REAL INFLUX RECORDS */

#page-records .records-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 14px 0;
}

#page-records .records-controls select,
#page-records .records-controls button {
    height: 38px;
    padding: 0 12px;
    border: 1px solid #334155;
    border-radius: 6px;
    background: #111827;
    color: #e2e8f0;
}

#page-records .records-controls button {
    cursor: pointer;
    font-weight: 700;
}

#page-records #recordsCount {
    margin-left: auto;
    color: #94a3b8;
    font-size: 12px;
}

#page-records .records-table-wrap {
    max-height: calc(100vh - 280px);
    overflow: auto;
    border: 1px solid #334155;
    border-radius: 8px;
}

#page-records .records-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: #0b1120;
}

#page-records .records-table thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 11px 14px;
    background: #1e293b;
    color: #f8fafc;
    text-align: left;
    font-size: 12px;
}

#page-records .records-table td {
    padding: 10px 14px;
    border-top: 1px solid #1e293b;
    color: #cbd5e1;
    font-size: 12px;
    white-space: nowrap;
}


/* RECORD SEARCH + COUNT STATUS */

#page-records .records-search {
    width: 320px;
    height: 38px;
    padding: 0 12px;
    border: 1px solid #334155;
    border-radius: 6px;
    background: #111827;
    color: #e2e8f0;
    font-size: 13px;
    outline: none;
}

#page-records .records-search::placeholder {
    color: #64748b;
}

#page-records .records-search:focus {
    border-color: #38bdf8;
}

#page-records .record-count {
    font-weight: 700;
}

#page-records .record-count-ok {
    color: #4ade80;
}

#page-records .record-count-bad {
    color: #fb7185;
}

#page-records .records-table th:nth-child(3),
#page-records .records-table td:nth-child(3) {
    text-align: right;
}


/* Records measurement tabs */

#page-records .records-tabs {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    border: 1px solid #334155;
    border-radius: 8px;
    background: #0f172a;
}

#page-records .records-tab {
    height: 32px;
    padding: 0 14px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
}

#page-records .records-tab:hover {
    background: #1e293b;
    color: #f8fafc;
}

#page-records .records-tab.active {
    background: #334155;
    color: #ffffff;
}

#page-records .records-search {
    min-width: 280px;
    height: 38px;
    padding: 0 12px;
    border: 1px solid #334155;
    border-radius: 6px;
    background: #111827;
    color: #e2e8f0;
    outline: none;
}

#page-records .records-search:focus {
    border-color: #38bdf8;
}

#page-records .record-count {
    display: inline-block;
    min-width: 42px;
    padding: 3px 9px;
    border-radius: 999px;
    text-align: center;
    font-weight: 800;
}

#page-records .record-count-ok {
    color: #4ade80;
    background: rgba(74, 222, 128, 0.12);
}

#page-records .record-count-bad {
    color: #fb7185;
    background: rgba(251, 113, 133, 0.12);
}



/* ==========================================================
   MIRAI CONSUMER CREATION / OPERATIONS
   ========================================================== */

#page-consumer-creation.page-panel {
    display: none !important;
}

#page-consumer-creation.page-panel.active {
    display: block !important;
}

.consumer-ops-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 18px;
}

.consumer-ops-toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.consumer-ops-toolbar input,
.consumer-ops-toolbar select {
    height: 38px;
    border: 1px solid #334155;
    border-radius: 7px;
    background: #111827;
    color: #e2e8f0;
    padding: 0 12px;
}

.consumer-ops-table-wrap {
    overflow-x: auto;
    border: 1px solid #334155;
    border-radius: 10px;
}

.consumer-ops-table {
    width: 100%;
    border-collapse: collapse;
}

.consumer-ops-table th,
.consumer-ops-table td {
    padding: 13px 14px;
    border-bottom: 1px solid #273449;
    text-align: left;
    vertical-align: middle;
}

.consumer-ops-table th {
    background: #1e293b;
    color: #f8fafc;
    position: sticky;
    top: 0;
    z-index: 2;
}

.consumer-ops-commands {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.consumer-ops-command,
.consumer-ops-manage,
.consumer-editor-header button,
.consumer-post-actions button {
    min-height: 32px;
    padding: 0 10px;
    border-radius: 6px;
    border: 1px solid #475569;
    background: #172033;
    color: #e2e8f0;
    font-weight: 700;
    cursor: pointer;
}

.consumer-ops-start {
    border-color: #15803d;
}

.consumer-ops-stop {
    border-color: #b91c1c;
}

.consumer-ops-restart {
    border-color: #a16207;
}

.consumer-ops-status {
    display: inline-flex;
    padding: 5px 10px;
    border-radius: 999px;
    background: #172033;
    color: #94a3b8;
    font-size: 12px;
    font-weight: 800;
}

.consumer-ops-status.running {
    color: #4ade80;
    border: 1px solid #16a34a;
}

.consumer-ops-status.stopped {
    color: #f87171;
    border: 1px solid #dc2626;
}

.consumer-ops-action-status {
    color: #94a3b8;
    font-size: 12px;
}

.consumer-ops-action-status.running {
    color: #60a5fa;
}

.consumer-ops-action-status.completed {
    color: #4ade80;
}

.consumer-ops-action-status.failed {
    color: #f87171;
}

.consumer-ops-drawer {
    margin-top: 18px;
    border: 1px solid #334155;
    border-radius: 12px;
    background: #0f172a;
    padding: 18px;
}

.consumer-ops-drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.consumer-ops-close {
    border: 0;
    background: transparent;
    color: #94a3b8;
    font-size: 20px;
    cursor: pointer;
}

.consumer-ops-meta {
    color: #94a3b8;
    margin: 6px 0 18px;
}

.consumer-editor-section {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid #273449;
}

.consumer-editor-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    margin-bottom: 10px;
}

.consumer-file-path {
    margin-top: 4px;
    font-family: monospace;
    font-size: 12px;
    color: #94a3b8;
    word-break: break-all;
}

#consumerOpsRunEditor,
#consumerOpsPropsEditor {
    width: 100%;
    min-height: 260px;
    resize: vertical;
    padding: 14px;
    border: 1px solid #334155;
    border-radius: 8px;
    background: #050913;
    color: #d7deea;
    font-family: Menlo, Monaco, "Courier New", monospace;
    font-size: 12px;
    line-height: 1.55;
}

.consumer-editor-note {
    margin-top: 8px;
    color: #94a3b8;
    font-size: 12px;
}

.consumer-post-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.consumer-post-actions button:disabled {
    opacity: .45;
    cursor: not-allowed;
}


/* ============================================================
   MIRAI PASSWORD VISIBILITY
   ============================================================ */

.mirai-password-field {
    position: relative;
    width: 100%;
}

.mirai-password-field input {
    width: 100%;
    box-sizing: border-box;
    padding-right: 58px !important;
}

.mirai-password-toggle {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);

    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;

    padding: 0 !important;
    margin: 0 !important;

    border: 0 !important;
    background: transparent !important;

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 20px;
    line-height: 1;

    cursor: pointer;
    opacity: .65;
}

.mirai-password-toggle:hover {
    opacity: 1;
    background: transparent !important;
}

/* MIRAI Consumer Lag explicit sort controls */
.consumer-lag-header {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.consumer-lag-sort-controls {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.consumer-lag-sort-button {
    border: 0;
    background: transparent;
    padding: 1px 3px;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    line-height: 1;
    opacity: 0.45;
}

.consumer-lag-sort-button:hover,
.consumer-lag-sort-button:focus-visible {
    opacity: 0.8;
}

.consumer-lag-sort-button.active {
    opacity: 1;
}

/* ==========================================================
   MIRAI consumer tuning compact action history
   ========================================================== */

.mirai-action-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 180px;
}

.mirai-action-header .mirai-action-status {
    min-width: 0;
}

.mirai-history-button {
    border: 0;
    background: transparent;
    padding: 0;
    font: inherit;
    font-size: 11px;
    line-height: 1.3;
    cursor: pointer;
    text-decoration: underline;
    white-space: nowrap;
    opacity: .85;
}

.mirai-history-button:hover {
    opacity: 1;
}

.mirai-latest-action {
    margin-top: 2px;
    font-size: 11px;
    line-height: 1.35;
    white-space: nowrap;
}

.mirai-latest-action.success {
    opacity: .9;
}

.mirai-latest-action.failed {
    opacity: .95;
}

.mirai-latest-action.running {
    opacity: .9;
}

#consumerTuningBody td:nth-child(8) {
    position: relative;
}

.mirai-history-popover {
    position: absolute;
    z-index: 1000;
    top: calc(100% - 4px);
    right: 8px;
    width: 310px;
    max-width: min(310px, 80vw);
    padding: 10px 12px;
    border: 1px solid rgba(148, 163, 184, .28);
    border-radius: 8px;
    background: var(--card-bg, #111827);
    box-shadow: 0 12px 30px rgba(0, 0, 0, .32);
    text-align: left;
}

.mirai-history-popover[hidden] {
    display: none;
}

.mirai-history-title {
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 7px;
}

.mirai-history-item {
    padding: 7px 0;
    border-top: 1px solid rgba(148, 163, 184, .16);
}

.mirai-history-item:first-of-type {
    border-top: 0;
}

.mirai-history-item-top {
    font-size: 11px;
    font-weight: 600;
}

.mirai-history-change {
    margin-top: 2px;
    font-size: 11px;
    line-height: 1.35;
}

.mirai-history-error {
    margin-top: 3px;
    font-size: 10px;
    line-height: 1.35;
    opacity: .8;
    white-space: normal;
    overflow-wrap: anywhere;
}

.mirai-history-empty {
    padding: 6px 0;
    font-size: 11px;
    opacity: .75;
}

/* MIRAI Consumer Tuning controlled live inventory scan */
#page-consumer-tuning .consumer-refresh-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;

    height: 36px;
    padding: 0 12px;

    border: 1px solid #d97706;
    border-radius: 7px;

    background: rgba(217, 119, 6, .12);
    color: #f8fafc;

    font-size: 12px;
    font-weight: 700;

    cursor: pointer;
}

#page-consumer-tuning .consumer-refresh-btn:hover {
    background: rgba(217, 119, 6, .22);
    border-color: #f59e0b;
}

#page-consumer-tuning .consumer-refresh-btn:disabled {
    opacity: .65;
    cursor: wait;
}

#page-consumer-tuning .consumer-refresh-icon {
    color: #f59e0b;
    font-size: 15px;
    line-height: 1;
}

#page-consumer-tuning .consumer-refresh-main {
    color: #f8fafc;
    font-weight: 800;
    letter-spacing: .03em;
}

#page-consumer-tuning .consumer-refresh-live {
    padding-left: 7px;
    border-left: 1px solid rgba(245, 158, 11, .45);

    color: #fbbf24;

    font-size: 9px;
    font-weight: 800;
    letter-spacing: .08em;
    white-space: nowrap;
}
