/* ============================================================
   TixMetric — Modern Redesign Layer
   Loaded AFTER main.css. Overrides shell + adds components.
   Keeps view-specific styles (mv-*, tm-collector-*, etc.) intact.
   ============================================================ */

:root {
    /* Brand */
    --tm-bg:        #07090A;
    --tm-bg-2:      #0C0F11;
    --tm-surface:   #11161A;
    --tm-surface-2: #161C21;
    --tm-surface-3: #1C242A;

    --tm-border:    rgba(255,255,255,0.06);
    --tm-border-2:  rgba(255,255,255,0.10);
    --tm-divider:   rgba(255,255,255,0.04);

    --tm-text:      #E8ECEF;
    --tm-text-2:    #B6BFC7;
    --tm-text-3:    #7E8893;
    --tm-text-4:    #56616B;

    --tm-accent:        #46D369;
    --tm-accent-soft:   rgba(70,211,105,0.12);
    --tm-accent-strong: #58E380;
    --tm-accent-ring:   rgba(70,211,105,0.35);
    --tm-warn:          #F4B740;
    --tm-danger:        #F45B69;
    --tm-info:          #5DA9FF;

    --tm-radius:    10px;
    --tm-radius-lg: 14px;
    --tm-radius-sm: 6px;

    --tm-shadow-sm: 0 1px 2px rgba(0,0,0,0.30);
    --tm-shadow:    0 4px 14px rgba(0,0,0,0.30);
    --tm-shadow-lg: 0 18px 50px rgba(0,0,0,0.50);

    --tm-font: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* --- Reset font-size hack from old CSS ---------------------------- */
html, body { font-size: 14px; }
body {
    font-family: var(--tm-font);
    background: var(--tm-bg);
    color: var(--tm-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Sidebar -------------------------------------------------------- */
.sidebar {
    width: 240px;
    background: var(--tm-bg-2);
    border-right: 1px solid var(--tm-border);
    padding: 14px 10px 10px;
    gap: 4px;
}
.sidebar-header {
    padding: 6px 8px 18px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--tm-divider);
    display: flex;
    justify-content: center;
}
.logo-icon {
    width: 32px; height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, #58E380 0%, #2BA84D 60%, #0E5C28 100%);
    box-shadow: 0 0 0 1px rgba(70,211,105,0.35), 0 6px 16px rgba(70,211,105,0.20);
    color: #07120A;
    font-weight: 800; font-size: 13px;
    letter-spacing: -.02em;
}
.logo-text { font-size: 15px; font-weight: 600; letter-spacing: 0.01em; }
.logo-img {
    display: block;
    width: 180px; height: auto;
    max-width: 100%;
    border-radius: 6px;
}
/* Login-page auth-brand + logo-img-auth styles live in the
   "--- Auth pages (login)" section near the bottom of this file. */

.sidebar-nav { gap: 2px; display: flex; flex-direction: column; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 10px;
    font-size: 13px; font-weight: 500;
    color: var(--tm-text-3);
    border-radius: var(--tm-radius-sm);
    cursor: pointer;
    transition: background .15s, color .15s;
    position: relative;
}
.sidebar-nav a:hover { background: var(--tm-surface); color: var(--tm-text); }
.sidebar-nav a.active {
    background: var(--tm-accent-soft);
    color: var(--tm-accent-strong);
}
.sidebar-nav a.active::before {
    content: '';
    position: absolute; left: -10px; top: 8px; bottom: 8px;
    width: 3px; border-radius: 0 3px 3px 0;
    background: var(--tm-accent);
}
.sidebar-nav a span.icon {
    width: 18px; height: 18px;
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    color: currentColor;
}
.sidebar-nav a span.icon svg { width: 16px; height: 16px; }

/* --- Main / Topbar ------------------------------------------------- */
.main { background: var(--tm-bg); }

.topbar {
    height: 56px;
    padding: 0 22px;
    background: var(--tm-bg);
    border-bottom: 1px solid var(--tm-border);
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px;
}

.topbar-search {
    display: flex; align-items: center; gap: 8px;
    background: var(--tm-surface);
    border: 1px solid var(--tm-border);
    border-radius: var(--tm-radius);
    padding: 7px 12px;
    color: var(--tm-text-3);
    width: 380px; max-width: 40vw;
    transition: border-color .15s, background .15s;
}
.topbar-search:focus-within {
    border-color: var(--tm-border-2);
    background: var(--tm-surface-2);
}
.topbar-search .search-box,
.topbar .search-box {
    background: transparent; border: 0; outline: 0;
    color: var(--tm-text);
    font: 500 13px/1 var(--tm-font);
    width: 100%;
}
.topbar .search-box::placeholder { color: var(--tm-text-4); }

.topbar-right { display: flex; align-items: center; gap: 8px; }

/* Live FX ticker (next to currency selector) */
.topbar-fx {
    display: inline-flex; align-items: center; gap: 10px;
    padding: 4px 10px;
    background: var(--tm-surface);
    border: 1px solid var(--tm-border);
    border-radius: 999px;
    font-size: 11px; color: var(--tm-text-3);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.topbar-fx .fx-pair em {
    font-style: normal; font-weight: 600; color: var(--tm-text);
    margin-left: 4px;
}
.topbar-fx .fx-pair + .fx-pair {
    border-left: 1px solid var(--tm-border);
    padding-left: 10px;
}
@media (max-width: 1100px) { .topbar-fx { display: none; } }

/* Display-currency selector */
.topbar-ccy { position: relative; }
.topbar-ccy-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 10px;
    background: var(--tm-surface);
    border: 1px solid var(--tm-border);
    border-radius: 999px;
    color: var(--tm-text); font-size: 12px; font-weight: 600;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}
.topbar-ccy-btn:hover { background: var(--tm-surface-2); border-color: var(--tm-border-2); }
.topbar-ccy-menu {
    position: absolute; right: 0; top: calc(100% + 6px);
    min-width: 220px;
    background: var(--tm-surface);
    border: 1px solid var(--tm-border);
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0,0,0,.32);
    padding: 6px;
    z-index: 30;
    display: flex; flex-direction: column;
}
.topbar-ccy-menu[hidden] { display: none; }
.topbar-ccy-menu .ccy-opt {
    text-align: left; padding: 8px 10px;
    background: transparent; border: 0; border-radius: 8px;
    color: var(--tm-text); font-size: 13px; cursor: pointer;
}
.topbar-ccy-menu .ccy-opt:hover { background: var(--tm-surface-2); }
.topbar-ccy-menu .ccy-opt.is-active {
    background: var(--tm-surface-2); color: var(--tm-accent, #58E380);
}

.topbar-icon-btn {
    width: 34px; height: 34px;
    display: inline-flex; align-items: center; justify-content: center;
    background: transparent; color: var(--tm-text-3);
    border: 1px solid transparent; border-radius: 8px;
    cursor: pointer; transition: background .15s, color .15s, border-color .15s;
}
.topbar-icon-btn:hover {
    background: var(--tm-surface); color: var(--tm-text);
    border-color: var(--tm-border);
}

/* User pill + dropdown */
.user-pill {
    display: flex; align-items: center; gap: 10px;
    padding: 5px 10px 5px 5px;
    background: var(--tm-surface);
    border: 1px solid var(--tm-border);
    border-radius: 999px;
    cursor: pointer;
    color: var(--tm-text);
    font-size: 13px;
    position: relative;
    transition: background .15s, border-color .15s;
}
.user-pill:hover { background: var(--tm-surface-2); border-color: var(--tm-border-2); }

.user-avatar {
    width: 26px; height: 26px;
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #58E380, #2BA84D);
    color: #07120A;
    font-weight: 700; font-size: 12px;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.15; }
.user-name { font-weight: 600; font-size: 12.5px; }
.user-role { font-size: 10.5px; color: var(--tm-text-3); text-transform: uppercase; letter-spacing: .04em; }

.user-menu {
    position: absolute; top: calc(100% + 8px); right: 0;
    min-width: 220px;
    background: var(--tm-surface-2);
    border: 1px solid var(--tm-border-2);
    border-radius: var(--tm-radius);
    box-shadow: var(--tm-shadow-lg);
    padding: 6px;
    z-index: 60;
}
.user-menu[hidden] { display: none; }
.user-menu-header {
    padding: 10px 10px 12px;
    border-bottom: 1px solid var(--tm-divider);
    margin-bottom: 6px;
}
.user-menu-name  { font-weight: 600; font-size: 13px; color: var(--tm-text); }
.user-menu-email { font-size: 11.5px; color: var(--tm-text-3); margin-top: 2px; }
.user-menu-item {
    display: block;
    padding: 8px 10px;
    font-size: 13px;
    color: var(--tm-text-2);
    border-radius: var(--tm-radius-sm);
    text-decoration: none;
}
.user-menu-item:hover { background: var(--tm-surface-3); color: var(--tm-text); }

/* --- Content ------------------------------------------------------- */
.content {
    padding: 16px 24px 24px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.view { flex: 1; min-height: 0; }
.view.active { display: flex; flex-direction: column; }

.page-header {
    display: flex; justify-content: space-between; align-items: flex-end;
    gap: 16px; margin-bottom: 14px;
}
.page-header h1 {
    font-size: 20px; font-weight: 700; letter-spacing: -.01em;
    color: var(--tm-text); margin: 0 0 2px;
}
.page-sub { color: var(--tm-text-3); font-size: 12.5px; }

/* --- Buttons ------------------------------------------------------- */
.btn-primary, .btn-ghost, .btn-icon {
    display: inline-flex; align-items: center; gap: 8px;
    border: 1px solid transparent; border-radius: var(--tm-radius-sm);
    font: 600 13px/1 var(--tm-font);
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s, transform .05s;
}
.btn-primary {
    background: var(--tm-accent); color: #07120A;
    padding: 9px 14px;
    box-shadow: 0 1px 0 rgba(0,0,0,.25), inset 0 -1px 0 rgba(0,0,0,.10);
}
.btn-primary:hover { background: var(--tm-accent-strong); }
.btn-primary:active { transform: translateY(1px); }

.btn-ghost {
    background: transparent; color: var(--tm-text-2);
    padding: 9px 14px;
    border-color: var(--tm-border);
}
.btn-ghost:hover { background: var(--tm-surface); color: var(--tm-text); border-color: var(--tm-border-2); }

.btn-icon {
    width: 30px; height: 30px;
    padding: 0; justify-content: center;
    background: transparent; color: var(--tm-text-3);
    border-color: var(--tm-border);
}
.btn-icon:hover { background: var(--tm-surface); color: var(--tm-text); }
.btn-icon-danger:hover { background: rgba(244,91,105,0.10); color: var(--tm-danger); border-color: rgba(244,91,105,0.30); }

/* --- Data card + table -------------------------------------------- */
.data-card {
    background: var(--tm-surface);
    border: 1px solid var(--tm-border);
    border-radius: var(--tm-radius-lg);
    overflow: hidden;
}

.data-table {
    width: 100%; border-collapse: separate; border-spacing: 0;
    font-size: 13px;
}
.data-table thead th {
    text-align: left; font-weight: 600; font-size: 11.5px;
    letter-spacing: .05em; text-transform: uppercase;
    color: var(--tm-text-3);
    background: var(--tm-bg-2);
    padding: 11px 16px;
    border-bottom: 1px solid var(--tm-border);
}
.data-table tbody td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--tm-divider);
    color: var(--tm-text-2);
    vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: var(--tm-surface-2); }
.data-table .cell-strong { color: var(--tm-text); font-weight: 600; }
.data-table .cell-muted { color: var(--tm-text-3); font-size: 12px; }
.data-table .empty { color: var(--tm-text-3); text-align: center; padding: 32px; font-style: italic; }
.data-table .th-actions, .data-table .td-actions { text-align: right; white-space: nowrap; }
.data-table .td-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* --- Badges + status ---------------------------------------------- */
.role-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .04em;
    border: 1px solid transparent;
}
.role-admin   { background: rgba(244,91,105,0.10); color: #FF8C97; border-color: rgba(244,91,105,0.25); }
.role-analyst { background: var(--tm-accent-soft); color: var(--tm-accent-strong); border-color: rgba(70,211,105,0.25); }
.role-viewer  { background: rgba(93,169,255,0.10); color: #91C2FF; border-color: rgba(93,169,255,0.25); }

.status-dot {
    display: inline-block;
    width: 7px; height: 7px;
    border-radius: 50%;
    margin-right: 7px; vertical-align: middle;
}
.status-ok  { background: var(--tm-accent); box-shadow: 0 0 0 3px var(--tm-accent-soft); }
.status-off { background: var(--tm-text-4); }

/* --- Generic Modal (tm-modal) ------------------------------------- */
.tm-modal {
    position: fixed; inset: 0;
    display: flex; align-items: center; justify-content: center;
    z-index: 80;
}
.tm-modal[hidden] { display: none; }
.tm-modal-backdrop {
    position: absolute; inset: 0;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(2px);
}
.tm-modal-card {
    position: relative;
    width: min(480px, calc(100vw - 32px));
    background: var(--tm-surface-2);
    border: 1px solid var(--tm-border-2);
    border-radius: var(--tm-radius-lg);
    box-shadow: var(--tm-shadow-lg);
    overflow: hidden;
}
.tm-modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid var(--tm-divider);
}
.tm-modal-head h2 { font-size: 15px; font-weight: 600; color: var(--tm-text); margin: 0; }
.tm-modal-x {
    background: transparent; border: 0; cursor: pointer;
    color: var(--tm-text-3); font-size: 22px; line-height: 1;
    padding: 0 4px;
}
.tm-modal-x:hover { color: var(--tm-text); }

/* --- Generic Form ------------------------------------------------- */
.tm-form { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.tm-form label {
    display: flex; flex-direction: column; gap: 6px;
    font-size: 12px; font-weight: 600; color: var(--tm-text-2);
}
.tm-form input[type="text"],
.tm-form input[type="email"],
.tm-form input[type="password"],
.tm-form input[type="number"],
.tm-form select,
.tm-form textarea {
    background: var(--tm-bg-2);
    border: 1px solid var(--tm-border);
    border-radius: var(--tm-radius-sm);
    color: var(--tm-text);
    padding: 9px 11px;
    font: 500 13px/1.2 var(--tm-font);
    transition: border-color .15s, box-shadow .15s, background .15s;
    font-family: var(--tm-font);
    resize: vertical;
}
.tm-form input:focus, .tm-form select:focus, .tm-form textarea:focus {
    outline: 0;
    border-color: var(--tm-accent);
    box-shadow: 0 0 0 3px var(--tm-accent-ring);
    background: var(--tm-bg);
}
.tm-checkbox { flex-direction: row !important; align-items: center; gap: 8px !important; }
.tm-checkbox input { accent-color: var(--tm-accent); width: 16px; height: 16px; }
.tm-form-foot {
    display: flex; justify-content: flex-end; gap: 8px;
    padding-top: 6px; border-top: 1px solid var(--tm-divider); margin-top: 4px;
}
.tm-form-foot { padding-top: 14px; }

/* --- Toast (modernize the existing toast container) --------------- */
#tm-toast-container {
    position: fixed;
    /* Explicitly undo main.css's top/width so the container doesn't stretch
       across the viewport and swallow clicks on elements behind it. */
    top: auto; left: auto; width: auto;
    bottom: 20px; right: 20px;
    display: flex; flex-direction: column; gap: 8px;
    z-index: 100;
    pointer-events: none;   /* let clicks pass through empty space */
}
.tm-toast {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 14px;
    border-radius: var(--tm-radius);
    background: var(--tm-surface-2);
    border: 1px solid var(--tm-border-2);
    box-shadow: var(--tm-shadow);
    font-size: 13px; color: var(--tm-text);
    min-width: 240px; max-width: 360px;
    pointer-events: auto;   /* but the toasts themselves are interactive */
}
.tm-toast button {
    background: transparent; border: 0; color: inherit;
    cursor: pointer; font-size: 18px; line-height: 1;
    margin-left: auto; opacity: .7;
}
.tm-toast button:hover { opacity: 1; }
.tm-toast-success { border-left: 3px solid var(--tm-accent); }
.tm-toast-error   { border-left: 3px solid var(--tm-danger); }
.tm-toast-warning { border-left: 3px solid var(--tm-warn); }
.tm-toast-info    { border-left: 3px solid var(--tm-info); }

/* --- Auth pages (login) ------------------------------------------- */
.auth-body {
    background:
        radial-gradient(circle at 12% -10%, rgba(70,211,105,0.12), transparent 40%),
        radial-gradient(circle at 90% 110%, rgba(93,169,255,0.08), transparent 40%),
        var(--tm-bg);
    color: var(--tm-text);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    min-height: 100vh;
    padding: 32px 20px;
    font-family: var(--tm-font);
}
/* Outer wrapper holds: logo (floating, transparent), card (surface), footer.
   Each is a flex item with its own background — the .auth-card retains the
   original surface card chrome; the logo sits above it without any box. */
.auth-card {
    width: min(520px, 100%);
    background: transparent;
    border: 0;
    box-shadow: none;
    padding: 0;
    display: flex; flex-direction: column;
    align-items: center;
    gap: 26px;
}
.auth-brand {
    display: flex; justify-content: center; align-items: center;
    margin: 0;
}
.logo-img-auth {
    display: block;
    width: 480px; max-width: 100%;
    height: auto;
}
.auth-form-wrap {
    width: min(400px, 100%);
    background: var(--tm-surface);
    border: 1px solid var(--tm-border-2);
    border-radius: var(--tm-radius-lg);
    box-shadow: var(--tm-shadow-lg);
    padding: 28px 28px 24px;
    text-align: left;
}
.auth-h1 {
    font-size: 19px; font-weight: 600;
    margin: 0; text-align: center;
    color: var(--tm-text);
}
.auth-tagline {
    text-align: center;
    color: var(--tm-text-3);
    font-size: 11.5px; font-weight: 500;
    letter-spacing: .05em;
    margin: 4px 0 20px;
    text-transform: uppercase;
}
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form label {
    display: flex; flex-direction: column; gap: 6px;
    font-size: 12px; font-weight: 600; color: var(--tm-text-2);
}
.auth-form input {
    background: var(--tm-bg-2);
    border: 1px solid var(--tm-border);
    border-radius: var(--tm-radius-sm);
    color: var(--tm-text);
    padding: 11px 12px;
    font: 500 14px/1.2 var(--tm-font);
    transition: border-color .12s ease, box-shadow .12s ease;
}
.auth-form input:focus {
    outline: 0;
    border-color: var(--tm-accent);
    box-shadow: 0 0 0 3px var(--tm-accent-ring);
}
.auth-form .btn-primary {
    justify-content: center;
    padding: 11px; margin-top: 4px;
}
.auth-error {
    background: rgba(244,91,105,0.10);
    border: 1px solid rgba(244,91,105,0.30);
    color: #FF8C97;
    padding: 10px 12px; border-radius: var(--tm-radius-sm);
    font-size: 12.5px; margin: 0 0 14px;
}
.auth-foot {
    text-align: center;
    margin-top: 0;
    font-size: 11.5px;
    color: var(--tm-text-4);
}

/* --- Polish for old views (subtle, non-breaking) ------------------ */
.view-title    { font-size: 22px; font-weight: 700; color: var(--tm-text); margin-bottom: 4px; }
.view-subtitle { color: var(--tm-text-3); font-size: 13px; }
.card {
    background: var(--tm-surface);
    border: 1px solid var(--tm-border);
    border-radius: var(--tm-radius-lg);
}
.tm-card  { background: var(--tm-surface); border-color: var(--tm-border); border-radius: var(--tm-radius-lg); }
.mv-card  { background: var(--tm-surface) !important; border: 1px solid var(--tm-border) !important; border-radius: var(--tm-radius-lg) !important; }
.mv-table-wrapper, .table-wrapper {
    background: var(--tm-surface); border: 1px solid var(--tm-border);
    border-radius: var(--tm-radius-lg); overflow: hidden;
}

/* ============================================================
   COLLECTOR CONFIG MODULE
   ============================================================ */
/* Viewport-fit layout — header / KPIs / filters fixed; table scrolls inside */
.cc-view {
    display: flex; flex-direction: column;
    gap: 12px; flex: 1; min-height: 0;
}
.cc-view > .page-header,
.cc-view > .cc-kpis,
.cc-view > .cc-filters,
.cc-view > .cc-bulk-actions { flex-shrink: 0; }
.cc-view > .cc-card {
    flex: 1; min-height: 0;
    display: flex; flex-direction: column;
    overflow: hidden;
}
.cc-table-scroll {
    flex: 1; min-height: 0;
    overflow: auto;
}
.cc-table-scroll thead th {
    position: sticky; top: 0; z-index: 1;
}

.cc-header-actions { display: flex; gap: 8px; }

/* KPI strip — total + active + page/pager all on one row */
.cc-kpis {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 12px;
}
.cc-kpi {
    display: flex; flex-direction: column; gap: 2px;
    padding: 10px 14px;
    background: var(--tm-surface);
    border: 1px solid var(--tm-border);
    border-radius: var(--tm-radius-lg);
}
.cc-kpi-label {
    font-size: 11px; font-weight: 600;
    color: var(--tm-text-3);
    text-transform: uppercase; letter-spacing: .04em;
}
.cc-kpi-value {
    font: 700 20px var(--tm-font);
    color: var(--tm-text);
    font-variant-numeric: tabular-nums;
}
.cc-kpi-meta {
    flex-direction: row; align-items: center; gap: 12px;
    min-width: 220px;
}
.cc-kpi-meta .cc-kpi-label { white-space: nowrap; }

/* Filter strip — extends mk-filters, adds compact toggles */
.cc-filters .cc-filter-toggle {
    align-self: flex-end;
    padding: 8px 0;
    margin-bottom: 1px;
    white-space: nowrap;
}

/* Search input mounts inside an mk-filter — match its sizing */
.cc-search {
    display: flex; align-items: center; gap: 7px;
    background: var(--tm-bg-2);
    border: 1px solid var(--tm-border);
    border-radius: var(--tm-radius-sm);
    padding: 7px 10px; color: var(--tm-text-3);
}
.cc-search input {
    background: transparent; border: 0; outline: 0;
    color: var(--tm-text); font: 500 13px var(--tm-font); width: 100%;
}
.cc-search input::placeholder { color: var(--tm-text-4); }

.cc-checkbox {
    display: flex; align-items: center; gap: 7px;
    color: var(--tm-text-2); font-size: 12.5px;
    cursor: pointer; user-select: none;
}
.cc-checkbox input { accent-color: var(--tm-accent); width: 14px; height: 14px; }

.cc-bulk-actions {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 12px;
    background: var(--tm-accent-soft);
    border: 1px solid rgba(70,211,105,0.30);
    border-radius: var(--tm-radius-sm);
}
.cc-bulk-actions[hidden] { display: none; }
.cc-selected-count {
    font-size: 11.5px; color: var(--tm-accent-strong);
    font-weight: 600; padding: 0 6px;
}

.cc-pager { display: flex; align-items: center; gap: 8px; }

/* Compact rows — 2 lines max */
.cc-table tbody td {
    padding: 7px 14px; vertical-align: middle;
    line-height: 1.3;
}
.cc-table thead th { padding: 8px 14px; }
.cc-table tr.inactive td:not(:last-child) { opacity: 0.55; }
.cc-table .cell-strong { font-size: 13px; line-height: 1.25; }
.cc-table .cell-muted  { font-size: 11px; line-height: 1.2; margin-top: 1px; }

.cc-event-cell { max-width: 360px; }
.cc-event-cell .cell-strong,
.cc-event-cell .cell-muted {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cc-date-cell { white-space: nowrap; }

/* Marketplace pills — single row, horizontal-scroll if too many */
.cc-pills-cell {
    max-width: 360px;
    min-width: 200px;
}
.cc-pills {
    display: flex; flex-wrap: nowrap; gap: 4px;
    overflow-x: auto; overflow-y: hidden;
    scrollbar-width: thin;
    padding-bottom: 1px;
}
.cc-pills::-webkit-scrollbar { height: 3px; }
.cc-pills::-webkit-scrollbar-thumb { background: var(--tm-border-2); border-radius: 2px; }
.cc-pill {
    flex-shrink: 0;
    padding: 2px 8px;
    background: var(--tm-bg-2);
    border: 1px solid var(--tm-border);
    color: var(--tm-text-3);
    border-radius: 999px;
    font: 600 10.5px var(--tm-font);
    cursor: pointer;
    transition: all .15s;
    letter-spacing: .01em;
    line-height: 1.4;
}
.cc-pill:hover:not(:disabled) {
    border-color: var(--tm-border-2); color: var(--tm-text);
}
.cc-pill.on {
    background: var(--tm-accent-soft);
    border-color: rgba(70,211,105,0.45);
    color: var(--tm-accent-strong);
}
.cc-pill:disabled { cursor: not-allowed; opacity: 0.5; }

.cc-th-interval { width: 110px; }
.cc-th-master   { width: 80px;  text-align: center; }
.cc-th-date     { width: 160px; }
.cc-table td.cc-th-master,
.cc-table td:last-child { text-align: center; }

.cc-interval { display: inline-flex; align-items: center; gap: 6px; justify-content: flex-end; }
.cc-interval-input {
    width: 52px; padding: 4px 6px;
    background: var(--tm-bg-2);
    border: 1px solid var(--tm-border);
    color: var(--tm-text);
    border-radius: var(--tm-radius-sm);
    font: 500 12px var(--tm-font);
    text-align: right;
}
.cc-interval-input:focus {
    outline: 0; border-color: var(--tm-accent);
    box-shadow: 0 0 0 2px var(--tm-accent-ring);
}
.cc-interval-input:disabled { opacity: 0.5; }
.cc-unit { font-size: 11px; color: var(--tm-text-3); }

.cc-master {
    width: 38px; height: 20px;
    background: var(--tm-surface-3);
    border: 1px solid var(--tm-border);
    border-radius: 999px;
    position: relative; cursor: pointer;
    padding: 0; transition: background .15s, border-color .15s;
}
.cc-master-knob {
    position: absolute; top: 2px; left: 2px;
    width: 14px; height: 14px;
    border-radius: 50%; background: var(--tm-text-3);
    transition: transform .15s, background .15s;
}
.cc-master.on { background: var(--tm-accent); border-color: var(--tm-accent-strong); }
.cc-master.on .cc-master-knob { transform: translateX(18px); background: #07120A; }
.cc-master:disabled { cursor: not-allowed; opacity: 0.5; }

.cc-rowcheck { accent-color: var(--tm-accent); width: 15px; height: 15px; cursor: pointer; }

.cc-table .empty .error { color: var(--tm-danger); font-style: normal; font-weight: 500; }

/* ============================================================
   DASHBOARD VIEW
   ============================================================ */
.dash-view {
    flex: 1;
    min-height: 0;
    display: flex; flex-direction: column;
    gap: 12px;
}
.dash-view > .page-header,
.dash-view > .dash-kpis { flex-shrink: 0; }

.dash-header-actions { display: flex; align-items: center; gap: 12px; }
.dash-updated { color: var(--tm-text-3); font-size: 12px; }

.dash-kpis {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}
@media (max-width: 1100px) { .dash-kpis { grid-template-columns: repeat(2, 1fr); } }

.dash-kpi {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 12px 16px;
    background: var(--tm-surface);
    border: 1px solid var(--tm-border);
    border-radius: var(--tm-radius-lg);
    transition: border-color .15s, background .15s;
}
.dash-kpi:hover { border-color: var(--tm-border-2); }
.dash-kpi-icon {
    width: 32px; height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--tm-accent-soft);
    color: var(--tm-accent-strong);
    border-radius: 8px;
    flex-shrink: 0;
}
.dash-kpi-bad .dash-kpi-icon { background: rgba(244,91,105,0.10); color: var(--tm-danger); }
.dash-kpi-warn .dash-kpi-icon { background: rgba(244,183,64,0.10); color: var(--tm-warn); }

.dash-kpi-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.dash-kpi-label {
    font-size: 11px; font-weight: 600;
    color: var(--tm-text-3);
    text-transform: uppercase; letter-spacing: .06em;
}
.dash-kpi-value {
    font-size: 20px; font-weight: 700;
    color: var(--tm-text);
    letter-spacing: -.01em;
    line-height: 1.1;
    margin: 1px 0 2px;
}
.dash-kpi-sub { font-size: 12px; color: var(--tm-text-3); }

.dash-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    grid-auto-rows: 1fr;
    gap: 12px;
    flex: 1;
    min-height: 0;
}
@media (max-width: 1100px) { .dash-grid { grid-template-columns: 1fr; } }

.dash-card {
    padding: 0; overflow: hidden;
    display: flex; flex-direction: column;
    min-height: 0;
}
.dash-card-wide { grid-column: span 1; }

.dash-card-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid var(--tm-divider);
    flex-shrink: 0;
}

/* Scroll container wrapping tables inside dash cards */
.dash-card-body { flex: 1; min-height: 0; overflow-y: auto; }
.dash-card-body .data-table thead th {
    position: sticky; top: 0; z-index: 1;
    background: var(--tm-bg-2);
}
.dash-card-head h2 {
    font-size: 13px; font-weight: 600;
    color: var(--tm-text);
    letter-spacing: .01em;
    margin: 0;
    text-transform: uppercase; letter-spacing: .04em;
}
.dash-card-meta { font-size: 12px; color: var(--tm-text-3); }
.dash-card-link {
    font-size: 12px; font-weight: 500;
    color: var(--tm-accent-strong); text-decoration: none;
}
.dash-card-link:hover { color: var(--tm-accent); text-decoration: underline; }

.dash-spark-wrap { padding: 10px 14px 0; height: 110px; flex-shrink: 0; }
.dash-mp-table { margin-top: 6px; }
.dash-mp-table thead th { background: transparent; border-top: 1px solid var(--tm-divider); }
.dash-mp-table .num, .data-table .num { text-align: right; }

/* Tighten table rows inside dashboard cards only */
.dash-view .data-table thead th { padding: 8px 14px; }
.dash-view .data-table tbody td { padding: 8px 14px; }

.rate-pill {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 11px; font-weight: 600;
    border: 1px solid transparent;
}
.rate-ok   { background: var(--tm-accent-soft); color: var(--tm-accent-strong); border-color: rgba(70,211,105,0.25); }
.rate-warn { background: rgba(244,183,64,0.10); color: var(--tm-warn);          border-color: rgba(244,183,64,0.25); }
.rate-bad  { background: rgba(244,91,105,0.10); color: var(--tm-danger);        border-color: rgba(244,91,105,0.25); }

/* Opportunities list */
.dash-opps-list { list-style: none; padding: 6px 0; margin: 0; flex: 1; min-height: 0; overflow-y: auto; }
.dash-opp {
    display: grid;
    grid-template-columns: 64px 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 9px 16px;
    border-bottom: 1px solid var(--tm-divider);
}
.dash-opps-list li:last-child { border-bottom: 0; }
.dash-opp-edge {
    font-size: 16px; font-weight: 700;
    color: var(--tm-accent-strong);
    text-align: center;
}
.dash-opp-event { font-weight: 600; font-size: 13px; color: var(--tm-text); }
.dash-opp-meta {
    display: flex; gap: 6px;
    font-size: 12px; color: var(--tm-text-2);
    margin-top: 2px;
}
.dash-opp-time { font-size: 11px; color: var(--tm-text-3); white-space: nowrap; }
.dash-opps-list .empty,
.dash-activity .empty { padding: 20px 18px; color: var(--tm-text-3); font-style: italic; text-align: center; }

/* Activity list */
.dash-activity { list-style: none; margin: 0; padding: 6px 0; flex: 1; min-height: 0; overflow-y: auto; }
.dash-activity-item {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 8px 16px;
    border-bottom: 1px solid var(--tm-divider);
}
.dash-activity-item:last-child { border-bottom: 0; }
.dash-activity-body { display: flex; flex-direction: column; gap: 2px; }
.dash-activity-line { font-size: 12.5px; }
.status-warn { background: var(--tm-warn); }
.status-bad  { background: var(--tm-danger); }

.dash-add-btn { padding: 4px 10px; font-size: 11px; }

/* ============================================================
   MARKETS VIEW
   ============================================================ */
/* Viewport-fit: fixed header / KPIs / filters; only the table body scrolls */
.mk-view {
    display: flex; flex-direction: column;
    gap: 12px; flex: 1; min-height: 0;
}
.mk-view > .page-header,
.mk-view > .mk-kpis,
.mk-view > .mk-filters { flex-shrink: 0; }
.mk-view > .mk-card {
    flex: 1; min-height: 0;
    display: flex; flex-direction: column;
    overflow: hidden;
}
.mk-table-scroll {
    flex: 1; min-height: 0;
    overflow: auto;
}
.mk-table-scroll thead th {
    position: sticky; top: 0; z-index: 1;
}

.mk-header-actions { display: flex; align-items: center; gap: 12px; }

/* Compact mk-kpis with optional 4th cell (mk-kpi-meta) for pager */
.mk-kpi-meta {
    flex-direction: row !important; align-items: center; gap: 16px;
}
.mk-kpi-meta .dash-kpi-body { flex: 1; min-width: 0; }

/* "With data only" inline toggle on the filter bar */
.mk-filters .mk-filter-toggle {
    align-self: flex-end; padding: 8px 0; margin-bottom: 1px;
    white-space: nowrap;
}

.mk-filters {
    display: flex; flex-wrap: wrap;
    gap: 12px; align-items: flex-end;
    padding: 14px 16px;
    background: var(--tm-surface);
    border: 1px solid var(--tm-border);
    border-radius: var(--tm-radius-lg);
}

/* ===================================================================
   Alerts view — rules + inbox
   =================================================================== */
.al-view {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.al-view > .page-header { flex-shrink: 0; }
.al-header-actions { display: flex; align-items: center; gap: 10px; }

.al-inbox, .al-rules { display: flex; flex-direction: column; gap: 8px; }

.al-inbox-head, .al-rules-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0 2px;
}
.al-inbox-head h2, .al-rules-head h2 {
    font-size: 14px; font-weight: 600; letter-spacing: .01em;
    color: var(--tm-text); margin: 0;
}
.al-inbox-count {
    display: inline-block;
    margin-left: 8px;
    padding: 1px 8px;
    background: var(--tm-surface-2);
    color: var(--tm-text-3);
    border-radius: 999px;
    font-size: 11px; font-weight: 600;
}

.al-pill-toggle {
    display: inline-flex; align-items: center; gap: 6px;
    color: var(--tm-text-3); font-size: 12px;
    cursor: pointer;
}
.al-pill-toggle input { accent-color: var(--tm-accent); }

.al-inbox-scroll { max-height: 40vh; overflow-y: auto; }
.al-inbox-scroll .data-table thead th {
    position: sticky; top: 0; z-index: 1;
    background: var(--tm-bg-2);
}

.al-inbox-row.al-unacked td { background: rgba(93,169,255,0.04); }
.al-inbox-row.al-acked   td { opacity: 0.55; }
.al-extlink {
    color: var(--tm-accent-strong); text-decoration: none; font-weight: 600; font-size: 12px;
}
.al-extlink:hover { text-decoration: underline; }

.al-rule-card { width: min(720px, calc(100vw - 32px)); }
.al-rule-form {
    display: flex; flex-direction: column; gap: 14px;
    padding: 4px 20px 18px;
}
.al-field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--tm-text-3); }
.al-field input, .al-field select {
    background: var(--tm-bg-2);
    border: 1px solid var(--tm-border);
    color: var(--tm-text);
    border-radius: var(--tm-radius-sm);
    padding: 8px 10px;
    font: 500 13px/1.2 var(--tm-font);
}
.al-field input:focus, .al-field select:focus {
    outline: none; border-color: var(--tm-border-2);
}
.al-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
@media (max-width: 680px) { .al-row { grid-template-columns: 1fr; } }
.al-modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.al-field-checkbox {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    color: var(--tm-text);
    font-size: 13px;
}
.al-field-checkbox input { accent-color: var(--tm-accent); width: 16px; height: 16px; }

/* Topbar bell badge (unack count) */
.topbar-alerts {
    position: relative;
}
.topbar-alerts-badge {
    position: absolute;
    top: 3px; right: 3px;
    min-width: 16px; height: 16px;
    padding: 0 4px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--tm-danger);
    color: #fff;
    border-radius: 999px;
    font-size: 10px; font-weight: 700;
    line-height: 1;
    border: 2px solid var(--tm-bg);
}
.topbar-alerts-badge:empty,
.topbar-alerts-badge[data-count="0"] { display: none; }

/* Historical view — Mean/Median price summary toggle */
.hist-mode-toggle {
    display: inline-flex;
    background: var(--tm-bg-2);
    border: 1px solid var(--tm-border);
    border-radius: var(--tm-radius-sm);
    overflow: hidden;
    height: 32px;
}
.hist-mode-toggle button {
    appearance: none;
    background: transparent;
    border: 0;
    color: var(--tm-text-3);
    font: 600 12px/1 var(--tm-font);
    padding: 0 12px;
    cursor: pointer;
}
.hist-mode-toggle button + button { border-left: 1px solid var(--tm-border); }
.hist-mode-toggle button.active {
    background: var(--tm-accent-soft);
    color: var(--tm-accent-strong);
}
.hist-mode-toggle button:hover:not(.active) { color: var(--tm-text); }
.mk-filter {
    display: flex; flex-direction: column; gap: 5px;
    min-width: 150px;
}
.mk-filter > span {
    font-size: 11px; font-weight: 600;
    color: var(--tm-text-3);
    text-transform: uppercase; letter-spacing: .04em;
}
.mk-filter select {
    background: var(--tm-bg-2);
    border: 1px solid var(--tm-border);
    color: var(--tm-text);
    padding: 8px 10px;
    border-radius: var(--tm-radius-sm);
    font: 500 13px var(--tm-font);
    cursor: pointer;
}
.mk-filter select:focus { outline: 0; border-color: var(--tm-accent); box-shadow: 0 0 0 2px var(--tm-accent-ring); }
.mk-filter-grow { flex: 1; min-width: 220px; }
.mk-filter-grow .cc-search { max-width: none; padding: 7px 10px; }

.mk-kpis {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}
@media (max-width: 1100px) { .mk-kpis { grid-template-columns: repeat(2, 1fr); } }

/* Tight, single-line rows */
.mk-table tbody td { padding: 7px 14px; vertical-align: middle; line-height: 1.3; }
.mk-table thead th  { padding: 8px 14px; }
.mk-table .num { text-align: right; white-space: nowrap; }
.mk-table .mk-th-spark { text-align: center; width: 140px; }
.mk-table .mk-th-date  { width: 170px; }
.mk-table .cell-strong { font-size: 13px; line-height: 1.25; }
.mk-table .cell-muted  { font-size: 11px; line-height: 1.2; margin-top: 1px; }
.mk-table tbody tr.mk-row { cursor: pointer; }
.mk-table tbody tr.mk-row:hover { background: var(--tm-surface-2); }
.mk-table .mk-spark-cell { padding: 4px 14px; text-align: center; }
.mk-spark { display: inline-block; vertical-align: middle; }
.mk-cell-nowrap { white-space: nowrap; }
/* Numeric columns: number then inline delta on the same line */
.mk-table td.num .cell-strong { display: inline-block; font-variant-numeric: tabular-nums; margin-right: 6px; }
.mk-table td.num .mk-delta { display: inline-block; font-size: 11px; }
/* Event cell — name (line 1) + venue/country (line 2), each ellipsised */
.mk-event-cell { max-width: 360px; }
.mk-event-cell .cell-strong,
.mk-event-cell .cell-muted {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.mk-delta {
    display: inline-flex; align-items: center; gap: 3px;
    font-size: 11.5px; font-weight: 600;
    padding: 1px 5px; border-radius: 4px;
}
.mk-delta-up   { color: var(--tm-accent-strong); background: var(--tm-accent-soft); }
.mk-delta-down { color: var(--tm-danger);        background: rgba(244,91,105,0.10); }
.mk-delta-flat { color: var(--tm-text-4); }

/* ============================================================
   COLLECTOR MONITOR
   ============================================================ */
.cm-view { display: flex; flex-direction: column; gap: 18px; }
.cm-header-actions { display: flex; align-items: center; gap: 12px; }

.cm-grid > .dash-card { padding: 0; }
.cm-grid .data-table .num { text-align: right; white-space: nowrap; }
.cm-runs-table tbody tr.cm-run-row { cursor: pointer; }
.cm-runs-table tbody tr.cm-run-row:hover { background: var(--tm-surface-2); }
.cm-error-cell { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cm-status-running {
    background: rgba(93,169,255,0.10);
    color: var(--tm-info);
    border: 1px solid rgba(93,169,255,0.25);
}

.cm-running-list { list-style: none; margin: 0; padding: 6px 0; max-height: 360px; overflow-y: auto; }
.cm-running-list .empty { padding: 20px 18px; color: var(--tm-text-3); font-style: italic; text-align: center; }
.cm-running-item {
    display: flex; gap: 10px; align-items: center;
    padding: 11px 16px;
    border-bottom: 1px solid var(--tm-divider);
}
.cm-running-item:last-child { border-bottom: 0; }
.cm-running-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cm-running-body .cell-strong { font-size: 12.5px; }
.cm-running-body .cell-muted  { font-size: 11px; }
.cm-pulse {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--tm-info);
    box-shadow: 0 0 0 0 rgba(93,169,255,0.7);
    animation: cm-pulse 1.4s infinite;
    flex-shrink: 0;
}
.cm-stuck .cm-pulse { background: var(--tm-warn); animation: none; }
@keyframes cm-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(93,169,255,0.7); }
    70%  { box-shadow: 0 0 0 8px rgba(93,169,255,0); }
    100% { box-shadow: 0 0 0 0 rgba(93,169,255,0); }
}

.cm-fail-list { list-style: none; margin: 0; padding: 6px 0; }
.cm-fail-list .empty { padding: 20px 18px; color: var(--tm-text-3); font-style: italic; text-align: center; }
.cm-fail-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--tm-divider);
    display: flex; flex-direction: column; gap: 6px;
}
.cm-fail-item:last-child { border-bottom: 0; }
.cm-fail-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.cm-fail-error {
    background: var(--tm-bg-2);
    border-radius: var(--tm-radius-sm);
    padding: 6px 8px;
    font-family: ui-monospace, 'JetBrains Mono', Menlo, Consolas, monospace;
    font-size: 11px;
    color: var(--tm-text-2);
    word-break: break-word;
}

.cm-filters { display: flex; gap: 8px; }
.cm-filters select {
    background: var(--tm-bg-2);
    border: 1px solid var(--tm-border);
    color: var(--tm-text);
    padding: 5px 8px;
    border-radius: var(--tm-radius-sm);
    font: 500 12px var(--tm-font);
    cursor: pointer;
}

/* ============================================================
   MAPPING
   ============================================================ */
.mp-view {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.mp-view > .page-header,
.mp-view > .mk-filters { flex-shrink: 0; }
.mp-view > .data-card {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.mp-view > .data-card > .cc-toolbar { flex-shrink: 0; }
.mp-header-actions { display: flex; align-items: center; gap: 12px; }

.mp-table-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}
.mp-table-scroll .data-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
}

.mp-table tbody tr.mp-row { cursor: pointer; }
.mp-table tbody tr.mp-row:hover { background: var(--tm-surface-2); }

.mp-pills-cell { max-width: 480px; }
.mp-pills-cell .mp-pill {
    display: inline-block;
    padding: 2px 7px;
    margin: 2px 3px 2px 0;
    border-radius: 4px;
    font-size: 10.5px; font-weight: 600;
    border: 1px solid transparent;
}
.mp-pill.mp-mapped {
    background: var(--tm-accent-soft);
    color: var(--tm-accent-strong);
    border-color: rgba(70,211,105,0.25);
}
.mp-pill.mp-locked {
    background: rgba(93,169,255,0.10);
    color: var(--tm-info);
    border-color: rgba(93,169,255,0.30);
}
.mp-pill.mp-missing {
    background: var(--tm-surface);
    color: var(--tm-text-4);
    border-color: var(--tm-border);
}

.mp-unknown {
    display: inline-block;
    margin-top: 4px;
    padding: 2px 6px;
    background: rgba(244,183,64,0.10);
    color: var(--tm-warn);
    border: 1px solid rgba(244,183,64,0.25);
    border-radius: 4px;
    font-size: 11px;
}

/* Editor drawer */
.mp-editor-card { width: min(880px, calc(100vw - 32px)); }
.mp-editor-body { padding: 6px 0 18px; max-height: 70vh; overflow-y: auto; }
.mp-editor-rows { display: flex; flex-direction: column; }
.mp-edit-row {
    display: grid;
    grid-template-columns: 200px 1fr auto;
    gap: 14px;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid var(--tm-divider);
}
.mp-edit-row:last-child { border-bottom: 0; }
.mp-row-locked { background: rgba(93,169,255,0.04); }
.mp-row-unknown { background: rgba(244,183,64,0.04); }
.mp-row-pending { background: rgba(240,180,40,0.07); }
.mp-row-pending .mp-edit-label .cell-strong::before { content: '⏵ '; color: #e8b73a; }
.mp-edit-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 11px; }
.mp-edit-label { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mp-edit-fields { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.mp-input {
    background: var(--tm-bg-2);
    border: 1px solid var(--tm-border);
    color: var(--tm-text);
    border-radius: var(--tm-radius-sm);
    padding: 7px 9px;
    font: 500 12.5px var(--tm-font);
    min-width: 0;
}
.mp-input:focus { outline: 0; border-color: var(--tm-accent); box-shadow: 0 0 0 2px var(--tm-accent-ring); }
.mp-input:disabled { opacity: 0.5; cursor: not-allowed; }
.mp-edit-actions { display: flex; gap: 6px; align-items: center; }
.mp-btn-save { padding: 6px 12px; font-size: 12px; }
.mp-verified { font-size: 10.5px; color: var(--tm-text-3); }

.mp-editor-section {
    padding: 10px 20px 6px;
    color: var(--tm-warn);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-top: 1px solid var(--tm-divider);
    margin-top: 8px;
    background: rgba(244,183,64,0.04);
}

.mp-readonly-note {
    padding: 12px 20px;
    color: var(--tm-text-3);
    font-size: 12px;
    text-align: center;
    background: var(--tm-bg-2);
    border-top: 1px solid var(--tm-divider);
}

/* ============================================================
   HISTORICAL / EVENT STATS
   ============================================================ */
.hist-view { display: flex; flex-direction: column; gap: 18px; }

.hist-chart-card .dash-card-head { padding-bottom: 12px; }
.hist-chart-wrap { padding: 4px 18px 18px; height: 280px; position: relative; }

.hist-tables {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}
@media (max-width: 1100px) { .hist-tables { grid-template-columns: 1fr; } }

.hist-table-scroll {
    max-height: 280px;
    overflow-y: auto;
}
.hist-table tbody tr.hist-row { cursor: pointer; }
.hist-table tbody tr.hist-row:hover { background: var(--tm-surface-2); }
.hist-table .num { text-align: right; white-space: nowrap; }
.hist-table .empty { padding: 24px; color: var(--tm-text-3); font-style: italic; text-align: center; }

.mk-modal-card { width: min(720px, calc(100vw - 32px)); max-height: 85vh; display: flex; flex-direction: column; }
.mk-modal-body { padding: 16px 20px 20px; overflow: auto; flex: 1; min-height: 0; }
/* Chart.js with responsive:true needs a fixed-height parent or it loops infinitely */
.mk-modal-chart-wrap { position: relative; height: 280px; margin-top: 16px; }
.mk-modal-chart-wrap canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; }
.mk-modal-metrics {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 18px;
    padding: 14px 16px;
    background: var(--tm-bg-2);
    border-radius: var(--tm-radius-sm);
}
.mk-modal-metrics > div { display: flex; flex-direction: column; gap: 4px; }
.mk-modal-metrics .cell-muted {
    font-size: 11px; text-transform: uppercase; letter-spacing: .04em; font-weight: 600;
}
@media (max-width: 720px) {
    .mk-modal-metrics { grid-template-columns: repeat(2, 1fr); }
}

/* ===================================================================
   Shared additions for opportunities / alerts / proxies / settings
   =================================================================== */

/* Small button + danger ghost */
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-ghost.danger { color: var(--tm-danger); border-color: rgba(220,80,80,0.4); }
.btn-ghost.danger:hover { background: rgba(220,80,80,0.08); border-color: var(--tm-danger); color: var(--tm-danger); }

/* Filter bar inputs (text/number/search) — match the existing select styling */
.mk-filter input[type="number"],
.mk-filter input[type="text"],
.mk-filter input[type="search"] {
    background: var(--tm-bg-2);
    border: 1px solid var(--tm-border);
    color: var(--tm-text);
    padding: 8px 10px;
    border-radius: var(--tm-radius-sm);
    font: 500 13px var(--tm-font);
    min-width: 0;
}
.mk-filter input:focus { outline: 0; border-color: var(--tm-accent); box-shadow: 0 0 0 2px var(--tm-accent-ring); }

/* Modal form: two-column row + grow helper + number input parity */
.tm-form-row { display: flex; gap: 12px; align-items: flex-end; }
.tm-form-row > label { flex: 0 0 auto; }
.tm-form-row > label.grow { flex: 1 1 auto; min-width: 0; }
.tm-form input[type="number"] {
    background: var(--tm-bg-2);
    border: 1px solid var(--tm-border);
    color: var(--tm-text);
    padding: 8px 10px;
    border-radius: var(--tm-radius-sm);
    font: 500 13px var(--tm-font);
}
.tm-form input[type="number"]:focus { outline: 0; border-color: var(--tm-accent); box-shadow: 0 0 0 2px var(--tm-accent-ring); }

/* Severity badge variants (default badge stays green/accent for "success") */
.badge.success { border-color: rgba(70,211,105,0.6); background: var(--accent-soft); color: var(--accent); }
.badge.warning { border-color: rgba(240,180,40,0.55); background: rgba(240,180,40,0.10); color: #e8b73a; }
.badge.error,
.badge.failed { border-color: rgba(220,80,80,0.55); background: rgba(220,80,80,0.10); color: #f08585; }
.badge.stale   { border-color: rgba(160,160,170,0.4); background: rgba(160,160,170,0.10); color: #aaaab2; }

/* Right-aligned numeric cells (used by op-/st- tables) */
.data-table .num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Realized-vs-edge delta colouring */
.delta-pos { color: var(--tm-accent-strong); }
.delta-neg { color: var(--tm-danger); }

/* --- Zones ----------------------------------------------------------- */
.zones-view { display: flex; flex-direction: column; gap: 12px; flex: 1; min-height: 0; }
.zones-view > .page-header,
.zones-view > .mk-filters { flex-shrink: 0; }

.zones-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 12px;
    flex: 1;
    min-height: 0;
}
@media (max-width: 1100px) { .zones-grid { grid-template-columns: 1fr; } }

.zones-card {
    display: flex; flex-direction: column;
    min-height: 0;
    padding: 0; overflow: hidden;
}
.zones-card-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--tm-divider);
    flex-shrink: 0;
    gap: 12px;
}
.zones-card-head h2 {
    font-size: 13px; font-weight: 600;
    color: var(--tm-text);
    margin: 0;
    text-transform: uppercase; letter-spacing: .04em;
}
.zones-card-actions { display: flex; gap: 8px; align-items: center; }
.zones-select-all {
    display: flex; gap: 6px; align-items: center;
    font-size: 12px; color: var(--tm-text-2);
    cursor: pointer;
}
.zones-bulk-select {
    background: var(--tm-bg-2);
    border: 1px solid var(--tm-border);
    border-radius: var(--tm-radius-sm);
    color: var(--tm-text);
    padding: 5px 8px;
    font: 500 12px var(--tm-font);
}

.zones-alias-list, .zones-zone-list {
    list-style: none; padding: 4px 0; margin: 0;
}

.zones-alias-item {
    display: grid;
    grid-template-columns: auto 70px 1fr auto auto;
    gap: 10px; align-items: center;
    padding: 8px 14px;
    border-bottom: 1px solid var(--tm-divider);
    font-size: 13px;
    cursor: grab;
    user-select: none;
}
.zones-alias-item:last-child { border-bottom: 0; }
.zones-alias-item:hover { background: var(--tm-surface-2); }
.zones-alias-item.dragging { opacity: 0.5; cursor: grabbing; }
.zones-alias-item.mapped { color: var(--tm-text-3); cursor: default; }
.zones-alias-item.mapped .zones-alias-name { text-decoration: line-through; }

.zones-alias-mp {
    font-size: 11px; font-weight: 600;
    color: var(--tm-text-3);
    text-transform: uppercase; letter-spacing: .04em;
    text-align: right;
}
.zones-alias-name { color: var(--tm-text); }
.zones-alias-count {
    font-variant-numeric: tabular-nums;
    color: var(--tm-text-3); font-size: 11px;
    min-width: 40px; text-align: right;
}
.zones-mapped-tag {
    color: var(--tm-accent-strong);
    font-size: 11px; font-weight: 500;
}

.zones-zone-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--tm-divider);
    font-size: 13px;
    transition: background .15s, border-color .15s;
}
.zones-zone-item:last-child { border-bottom: 0; }
.zones-zone-item:hover { background: var(--tm-surface-2); }
.zones-zone-item.drop-hover {
    background: var(--tm-accent-soft);
    outline: 2px dashed var(--tm-accent);
    outline-offset: -2px;
}
.zones-zone-count {
    background: var(--tm-surface-2);
    color: var(--tm-text-2);
    border-radius: 999px;
    padding: 1px 9px;
    font-size: 11px; font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.zones-alias-list .empty,
.zones-zone-list  .empty { padding: 24px 16px; color: var(--tm-text-3); font-style: italic; text-align: center; }
.zones-alias-list .empty.error,
.zones-zone-list  .empty.error { color: var(--tm-danger); }

/* --- Market Spread --------------------------------------------------- */
.ms-view { display: flex; flex-direction: column; gap: 12px; flex: 1; min-height: 0; }
.ms-view > .page-header, .ms-view > .mk-filters { flex-shrink: 0; }
.ms-view .ms-card { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.ms-view .cc-toolbar { flex-shrink: 0; }

.ms-table th.sortable { cursor: pointer; user-select: none; }
.ms-table th.sortable:hover { color: var(--tm-text); }
.ms-table .sort-arrow { font-size: 9px; color: var(--tm-text-3); }

.ms-table td.ms-cheapest {
    color: var(--tm-accent-strong);
    font-weight: 600;
    background: var(--tm-accent-soft);
}
.ms-table th.ms-mp-col { font-size: 11px; }
.ms-table td.spread-pct { color: var(--tm-warn); font-weight: 600; }
.ms-table td.spread-abs { color: var(--tm-text); font-weight: 500; }

/* Small marketplace pill in opportunities table */
/* Opportunities view — viewport-bounded table with sticky header + h-scroll */
.op-view {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.op-view > .page-header,
.op-view > .mk-filters { flex-shrink: 0; }
.op-view > .data-card {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.op-view > .data-card > .cc-toolbar { flex-shrink: 0; }
.op-header-actions { display: flex; align-items: center; gap: 12px; }

.op-table-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: auto;
}
.op-table-scroll .data-table {
    min-width: 1280px;    /* 13 columns — don't crush on narrower viewports */
}
.op-table-scroll .data-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
}

.op-mp {
    display: inline-flex; align-items: center;
    padding: 3px 8px; border-radius: 999px;
    background: var(--tm-bg-2); border: 1px solid var(--tm-border);
    font-size: 11.5px; font-weight: 500; color: var(--tm-text-2);
}

/* Inactive / closed row dimming (matches collector_config pattern) */
.data-table tr.inactive { opacity: 0.55; }

/* Sortable header indicator (markup uses th[data-sort]) */
.data-table th[data-sort] { cursor: pointer; user-select: none; }
.data-table th[data-sort]:hover { color: var(--tm-text); }

/* Mono cell for script names / IDs */
.data-table .mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
}

/* ===================================================================
   Events browser (views/events.php)
   =================================================================== */

/* Make the events view fill the viewport and scroll the table only */
.ev-view {
    display: flex; flex-direction: column;
    gap: 12px;
    flex: 1; min-height: 0;
}
.ev-view > .page-header,
.ev-view > .ev-kpis,
.ev-view > .mk-filters,
.ev-view > .ev-source-bar { flex-shrink: 0; }
.ev-view > .data-card {
    flex: 1; min-height: 0;
    display: flex; flex-direction: column;
    overflow: hidden;
}
.ev-view > .data-card > .cc-toolbar { flex-shrink: 0; }
.ev-table-scroll {
    flex: 1; min-height: 0;
    overflow: auto;
}
.ev-table-scroll .data-table thead th {
    position: sticky; top: 0; z-index: 1;
}

/* Tight, single-line rows */
.ev-table tbody td { padding: 8px 14px; line-height: 1.35; }
.ev-table thead th { padding: 8px 14px; }
.ev-cell-nowrap { white-space: nowrap; }

/* Pending count cell becomes a clickable link to Mapping */
.ev-pending-link { text-decoration: none; cursor: pointer; }
.ev-pending-link:hover { filter: brightness(1.15); }

/* ===================================================================
   On Sales view + dashboard widget
   =================================================================== */
.os-view {
    display: flex; flex-direction: column;
    gap: 12px; flex: 1; min-height: 0;
}
.os-view > .page-header,
.os-view > .os-kpis,
.os-view > .mk-filters { flex-shrink: 0; }
.os-view > .os-card {
    flex: 1; min-height: 0;
    display: flex; flex-direction: column;
    overflow: hidden;
}
.os-table-scroll {
    flex: 1; min-height: 0;
    overflow: auto;
}
.os-table-scroll thead th {
    position: sticky; top: 0; z-index: 1;
}

.os-header-actions { display: flex; align-items: center; gap: 12px; }

.os-kpis {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 12px;
}
.os-kpi {
    display: flex; flex-direction: column; gap: 2px;
    padding: 10px 14px;
    background: var(--tm-surface);
    border: 1px solid var(--tm-border);
    border-radius: var(--tm-radius-lg);
}
.os-kpi-label {
    font-size: 11px; font-weight: 600;
    color: var(--tm-text-3);
    text-transform: uppercase; letter-spacing: .04em;
}
.os-kpi-value {
    font: 700 20px var(--tm-font);
    color: var(--tm-text);
    font-variant-numeric: tabular-nums;
}
.os-kpi-meta {
    flex-direction: row; align-items: center; gap: 12px;
    min-width: 220px;
}
.os-kpi-meta .os-kpi-label { white-space: nowrap; }

/* Tight rows */
.os-table tbody td { padding: 7px 14px; vertical-align: middle; line-height: 1.3; }
.os-table thead th  { padding: 8px 14px; }
.os-table .os-cell-nowrap { white-space: nowrap; }
.os-th-countdown { width: 90px; }
.os-event-cell { max-width: 320px; }
.os-event-cell .cell-strong,
.os-event-cell .cell-muted {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.os-event-link { color: var(--tm-text); text-decoration: none; }
.os-event-link:hover { color: var(--tm-accent); text-decoration: underline; }
.os-row-presale td:first-child { box-shadow: inset 3px 0 0 rgba(240,180,40,0.55); }
.os-row-public  td:first-child { box-shadow: inset 3px 0 0 rgba(70,211,105,0.55); }

/* Countdown chip */
.os-cd {
    display: inline-block;
    padding: 2px 8px; border-radius: 999px;
    font: 700 11px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    background: var(--tm-bg-2); color: var(--tm-text-2);
    border: 1px solid var(--tm-border);
    font-variant-numeric: tabular-nums;
}
.os-cd-soon { background: rgba(240,180,40,0.15); color: #e8b73a; border-color: rgba(240,180,40,0.45); }
.os-cd-now  { background: rgba(220,80,80,0.18); color: #f08585; border-color: rgba(220,80,80,0.55); }
.os-cd-far  { color: var(--tm-text-3); }

/* Dashboard widget */
.dash-onsales-list {
    list-style: none; margin: 0; padding: 6px 0;
    flex: 1; min-height: 0; overflow-y: auto;
}
.dash-onsale-item {
    display: flex; gap: 10px; align-items: center;
    padding: 8px 18px;
    border-bottom: 1px solid var(--tm-divider);
}
.dash-onsale-item:last-child { border-bottom: 0; }
.dash-onsale-body { flex: 1; min-width: 0; }
.dash-onsale-body .cell-strong {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-size: 13px;
}
.dash-onsale-body .cell-muted {
    font-size: 11px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    margin-top: 2px;
}
.dash-onsale-body a { color: var(--tm-text); text-decoration: none; }
.dash-onsale-body a:hover { color: var(--tm-accent); text-decoration: underline; }

.ev-header-actions { display: flex; align-items: center; gap: 12px; }

/* 3-column KPI grid (vs the 4-col mk-kpis default) */
.ev-kpis {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}
@media (max-width: 720px) {
    .ev-kpis { grid-template-columns: 1fr; }
}

/* Filter strip — keep "include past" inline at the right */
.ev-filters .ev-past-toggle {
    margin-left: auto;
    align-self: center;
    white-space: nowrap;
}

/* Source chip toggle bar (replaces the broken multi-select) */
.ev-source-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--tm-surface);
    border: 1px solid var(--tm-border);
    border-radius: var(--tm-radius-lg);
}
.ev-source-label {
    font-size: 11px; font-weight: 600;
    color: var(--tm-text-3);
    text-transform: uppercase; letter-spacing: .04em;
    margin-right: 4px;
}
.ev-source-chips {
    display: flex; flex-wrap: wrap; gap: 6px;
    flex: 1;
    min-width: 0;
}
.ev-chip {
    display: inline-flex; align-items: center;
    padding: 4px 10px; border-radius: 999px;
    background: var(--tm-bg-2);
    border: 1px solid var(--tm-border);
    color: var(--tm-text-2);
    font: 500 12px var(--tm-font);
    cursor: pointer;
    transition: background .12s, border-color .12s, color .12s;
}
.ev-chip:hover { color: var(--tm-text); border-color: var(--tm-border-2); }
.ev-chip.on {
    background: rgba(70, 211, 105, 0.18);
    border-color: rgba(70, 211, 105, 0.55);
    color: var(--tm-accent);
}
.ev-chip.primary { font-weight: 600; }
.ev-chip.primary::before {
    content: '★'; margin-right: 4px; font-size: 10px;
}
.ev-source-match {
    display: flex; gap: 8px; align-items: center;
    padding: 0 6px;
    border-left: 1px solid var(--tm-border);
    color: var(--tm-text-3);
    font-size: 12px;
}
.ev-source-match label {
    display: inline-flex; align-items: center; gap: 4px;
    cursor: pointer;
}
.ev-source-match input[type="radio"] { accent-color: var(--tm-accent); }
.ev-source-clear {
    background: transparent;
    border: 1px solid var(--tm-border);
    color: var(--tm-text-3);
    padding: 3px 10px;
    border-radius: var(--tm-radius-sm);
    font-size: 11.5px;
    cursor: pointer;
}
.ev-source-clear:hover { color: var(--tm-text); border-color: var(--tm-border-2); }

/* Event row clickability */
.ev-table tr.ev-row { cursor: pointer; }
.ev-table tr.ev-row:hover { background: rgba(255,255,255,0.03); }

/* Source badges (shown in table cell + detail modal) */
.src-badges {
    display: flex; flex-wrap: wrap; gap: 4px;
}
.src-badge {
    display: inline-flex; align-items: center;
    padding: 2px 8px; border-radius: 999px;
    font-size: 11px; font-weight: 500;
    background: var(--tm-bg-2);
    border: 1px solid var(--tm-border);
    color: var(--tm-text-2);
}
.src-badge.primary {
    background: rgba(70, 211, 105, 0.10);
    border-color: rgba(70, 211, 105, 0.45);
    color: var(--tm-accent);
}

/* Detail modal */
.ev-detail-card { width: min(720px, 92vw); max-height: 80vh; display: flex; flex-direction: column; }
.ev-detail-body { padding: 18px; overflow: auto; }
.ev-mapping-list { display: flex; flex-direction: column; gap: 12px; }
.ev-mapping {
    background: var(--tm-bg-2);
    border: 1px solid var(--tm-border);
    border-radius: var(--tm-radius-sm);
    padding: 10px 12px;
    display: flex; flex-direction: column; gap: 4px;
}
.ev-mapping-head {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.ev-mapping-link a, .ev-extlink {
    color: var(--tm-accent);
    text-decoration: none;
    word-break: break-all;
    font-size: 12.5px;
}
.ev-mapping-link a:hover, .ev-extlink:hover { text-decoration: underline; }

/* ===================================================================
   Event Stats — typeahead event picker (replaces the old dropdown)
   =================================================================== */
.hist-event-search { position: relative; min-width: 280px; }
.hist-event-search .cc-search { position: relative; }
.hist-event-clear {
    position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
    background: transparent; border: 0; color: var(--tm-text-3);
    font-size: 18px; line-height: 1; cursor: pointer; padding: 0 6px;
}
.hist-event-clear:hover { color: var(--tm-text); }
.hist-event-results {
    position: absolute; left: 0; right: 0; top: calc(100% + 4px);
    background: var(--tm-surface);
    border: 1px solid var(--tm-border);
    border-radius: var(--tm-radius-sm);
    box-shadow: 0 12px 32px rgba(0,0,0,.32);
    max-height: 360px; overflow-y: auto;
    z-index: 30;
    padding: 4px;
}
.hist-event-results[hidden] { display: none; }
.hist-event-row {
    display: flex; flex-direction: column; gap: 2px;
    width: 100%; text-align: left;
    background: transparent; border: 0;
    padding: 8px 10px; border-radius: 6px;
    cursor: pointer; color: var(--tm-text);
}
.hist-event-row:hover { background: var(--tm-surface-2); }
.hist-event-name { font-weight: 600; font-size: 13px; }
.hist-event-meta { font-size: 11.5px; color: var(--tm-text-3); }
.hist-event-loading,
.hist-event-empty {
    padding: 14px; text-align: center;
    font-size: 12.5px; color: var(--tm-text-3);
    font-style: italic;
}

