/* ═══════════════════════════════════════════════════════
   Ignis Dashboard — Dark Terminal Theme
   ═══════════════════════════════════════════════════════ */

:root {
    /* Core palette */
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-tertiary: #1a2234;
    --bg-hover: #1e293b;
    --bg-surface: #0f172a;

    /* Borders */
    --border-primary: #1e293b;
    --border-subtle: #1a2234;
    --border-accent: #334155;

    /* Text */
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-dim: #475569;

    /* Accents */
    --accent-blue: #3b82f6;
    --accent-cyan: #06b6d4;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    --accent-yellow: #f59e0b;
    --accent-orange: #f97316;
    --accent-purple: #8b5cf6;

    /* Trading */
    --color-buy: #10b981;
    --color-sell: #ef4444;
    --color-buy-bg: rgba(16, 185, 129, 0.08);
    --color-sell-bg: rgba(239, 68, 68, 0.08);

    /* Sizing */
    --sidebar-w: 220px;
    --radius: 6px;
    --radius-sm: 4px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
    font-family: 'JetBrains Mono', 'Cascadia Code', 'SF Mono', monospace;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
}

/* ═══════════════════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════════════════ */

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

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-primary);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 16px;
    border-bottom: 1px solid var(--border-primary);
}

.brand-icon {
    font-size: 22px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
    border-radius: var(--radius);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font-weight: 700; font-size: 14px; color: var(--text-primary); }
.brand-sub { font-size: 11px; color: var(--text-muted); }

/* Status indicators in sidebar */
.sidebar-status {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-primary);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.status-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dot-online {
    background: var(--accent-green);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
    animation: pulse-green 2s infinite;
}

.dot-offline {
    background: var(--accent-red);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
}

@keyframes pulse-green {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.status-label { color: var(--text-muted); min-width: 28px; }
.status-value { color: var(--text-secondary); }

/* Nav */
.sidebar-nav {
    list-style: none;
    padding: 8px 0;
    flex: 1;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}

.sidebar-nav li a:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-nav li a.active {
    background: rgba(59, 130, 246, 0.08);
    color: var(--accent-blue);
    border-left-color: var(--accent-blue);
}

.nav-icon { font-size: 14px; width: 18px; text-align: center; }

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-primary);
}

.queue-badge {
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}

/* ── Main column (top-bar + content) ── */
.main-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

/* ── Top bar (timezone toggle) ── */
.top-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 16px;
    padding: 8px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.06));
    min-height: 40px;
}

.top-bar-label {
    font-size: 12px;
    color: var(--text-muted);
}

.top-bar-label strong {
    color: var(--text-secondary);
    font-weight: 500;
}

.tz-toggle {
    display: inline-flex;
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-tertiary);
}

.tz-toggle-btn {
    appearance: none;
    border: none;
    background: transparent;
    color: var(--text-muted);
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 120ms ease, color 120ms ease;
}

.tz-toggle-btn:hover {
    color: var(--text-primary);
}

.tz-toggle-btn.active {
    background: var(--accent-color, #3b82f6);
    color: #fff;
}

/* ── Main content ── */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: var(--bg-primary);
}

/* ═══════════════════════════════════════════════════════
   PAGE HEADER
   ═══════════════════════════════════════════════════════ */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h1 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.header-time {
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
}

.header-stat {
    font-size: 12px;
    color: var(--text-secondary);
}

.header-stats-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

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

/* ═══════════════════════════════════════════════════════
   KPI CARDS
   ═══════════════════════════════════════════════════════ */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.kpi-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
}

.kpi-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 4px;
}

.kpi-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.kpi-active .kpi-value { color: var(--accent-cyan); }
.kpi-success .kpi-value { color: var(--accent-green); }
.kpi-danger .kpi-value { color: var(--accent-red); }

/* ═══════════════════════════════════════════════════════
   PANELS
   ═══════════════════════════════════════════════════════ */

.panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius);
    margin-bottom: 16px;
    overflow: hidden;
}

.panel-header {
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-badge {
    font-size: 10px;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg-secondary);
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: auto;
}

.panel-body {
    padding: 0;
    overflow-x: auto;
}

.panel-scroll {
    max-height: 280px;
    overflow-y: auto;
    padding: 8px 0;
}

.panel-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

@media (max-width: 1100px) {
    .panel-grid { grid-template-columns: 1fr; }
}

.health-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 700px) {
    .health-grid { grid-template-columns: 1fr; }
}

.health-block-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted, #94a3b8);
    margin-bottom: 8px;
}

.health-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* ═══════════════════════════════════════════════════════
   DATA TABLES
   ═══════════════════════════════════════════════════════ */

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.data-table th {
    padding: 8px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-primary);
    position: sticky;
    top: 0;
    z-index: 1;
    white-space: nowrap;
}

.data-table td {
    padding: 7px 12px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    white-space: nowrap;
}

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

.data-table-full { min-width: 900px; }

.mono { font-family: 'JetBrains Mono', monospace; }
.num { text-align: right; }
.small { font-size: 11px; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--accent-green); }
.text-danger { color: var(--accent-red); }
.text-outbound { color: var(--accent-cyan); }
.text-inbound { color: var(--accent-purple); }

.row-danger td { background: rgba(239, 68, 68, 0.04); }
.row-success td { background: rgba(16, 185, 129, 0.04); }
.row-outbound td { border-left: 2px solid var(--accent-cyan); }
.row-inbound td { border-left: 2px solid var(--accent-purple); }

.empty-state {
    padding: 32px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

/* ═══════════════════════════════════════════════════════
   BADGES
   ═══════════════════════════════════════════════════════ */

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.badge-default { background: var(--bg-tertiary); color: var(--text-secondary); }
.badge-info { background: rgba(59, 130, 246, 0.12); color: var(--accent-blue); }
.badge-success { background: rgba(16, 185, 129, 0.12); color: var(--accent-green); }
.badge-warning { background: rgba(245, 158, 11, 0.12); color: var(--accent-yellow); }
.badge-danger { background: rgba(239, 68, 68, 0.12); color: var(--accent-red); }
.badge-muted { background: var(--bg-tertiary); color: var(--text-muted); }
.badge-buy { background: var(--color-buy-bg); color: var(--color-buy); border: 1px solid rgba(16, 185, 129, 0.2); }
.badge-sell { background: var(--color-sell-bg); color: var(--color-sell); border: 1px solid rgba(239, 68, 68, 0.2); }
.badge-outbound { background: rgba(6, 182, 212, 0.1); color: var(--accent-cyan); }
.badge-inbound { background: rgba(139, 92, 246, 0.1); color: var(--accent-purple); }

/* ═══════════════════════════════════════════════════════
   CONNECTION BLOCK
   ═══════════════════════════════════════════════════════ */

.connection-block { padding: 16px; }

.conn-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
}

.conn-row + .conn-row { border-top: 1px solid var(--border-subtle); }

.conn-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.ci-online {
    background: var(--accent-green);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}

.ci-offline {
    background: var(--accent-red);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.3);
}

.conn-info { display: flex; flex-direction: column; gap: 2px; }
.conn-info strong { font-size: 13px; color: var(--text-primary); }
.conn-detail { font-size: 11px; color: var(--text-muted); }

/* ═══════════════════════════════════════════════════════
   LOG ENTRIES
   ═══════════════════════════════════════════════════════ */

.log-line {
    display: flex;
    gap: 10px;
    padding: 3px 16px;
    font-size: 12px;
    align-items: baseline;
}

.log-line:hover { background: var(--bg-hover); }

.log-time { color: var(--text-dim); min-width: 90px; flex-shrink: 0; }
.log-level {
    min-width: 44px;
    font-weight: 600;
    font-size: 10px;
    text-transform: uppercase;
}

.log-info { color: var(--accent-blue); }
.log-warn { color: var(--accent-yellow); }
.log-error { color: var(--accent-red); }
.log-msg { color: var(--text-secondary); }

/* ═══════════════════════════════════════════════════════
   FILTER BAR
   ═══════════════════════════════════════════════════════ */

.filter-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 12px;
    flex-wrap: wrap;
}

.filter-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius);
    padding: 3px;
}

.tab {
    background: transparent;
    border: none;
    padding: 6px 14px;
    color: var(--text-muted);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tab:hover { color: var(--text-secondary); background: var(--bg-hover); }

.tab-active {
    background: var(--accent-blue) !important;
    color: #fff !important;
}

.tab-count {
    font-size: 10px;
    background: rgba(255,255,255,0.15);
    padding: 1px 6px;
    border-radius: 8px;
}

.search-input {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
    padding: 8px 14px;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 12px;
    width: 280px;
    outline: none;
    transition: border-color 0.15s;
}

.search-input:focus { border-color: var(--accent-blue); }
.search-input::placeholder { color: var(--text-dim); }

/* Date picker (dark theme) */
.date-picker {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 12px;
    outline: none;
    transition: border-color 0.15s;
    color-scheme: dark;
}
.date-picker:focus { border-color: var(--accent-blue); }
.date-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-right: 6px;
}

/* ── Filter bar labels + inline selects/inputs (Signals/Connections) ── */
.filter-bar label {
    display: inline-flex;
    flex-direction: column;
    gap: 4px;
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.filter-bar select,
.filter-bar input[type="text"],
.input-inline {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 12px;
    outline: none;
    transition: border-color 0.15s;
    color-scheme: dark;
    min-width: 140px;
    text-transform: none;
    letter-spacing: normal;
}

.filter-bar select:focus,
.filter-bar input[type="text"]:focus,
.input-inline:focus { border-color: var(--accent-blue); }

.filter-bar select option {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.filter-bar input[type="text"]::placeholder,
.input-inline::placeholder { color: var(--text-dim); }

/* Filter bar com múltiplos filtros: usa flex-start em vez de space-between */
.filter-bar.filter-bar-left {
    justify-content: flex-start;
}

/* Quando o filter-bar fica dentro do panel-body (padding: 0), damos padding próprio */
.panel-body > .filter-bar {
    padding: 14px 16px;
    margin-bottom: 0;
    border-bottom: 1px solid var(--border-primary);
}

/* ═══════════════════════════════════════════════════════
   CONFIG PAGE
   ═══════════════════════════════════════════════════════ */

.config-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

@media (max-width: 1100px) {
    .config-grid { grid-template-columns: 1fr; }
}

.config-field {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-subtle);
}

.config-field label {
    font-size: 12px;
    color: var(--text-muted);
    min-width: 140px;
}

.config-value {
    font-size: 13px;
    color: var(--text-primary);
    text-align: right;
}

.config-subsection {
    padding: 10px 16px 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-primary);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
}

.stat-label { font-size: 12px; color: var(--text-muted); }
.stat-value { font-size: 14px; font-weight: 600; color: var(--text-primary); }

/* ═══════════════════════════════════════════════════════
   404
   ═══════════════════════════════════════════════════════ */

.not-found {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 60vh;
    color: var(--text-muted);
}

.not-found h2 { font-size: 64px; font-weight: 700; color: var(--text-dim); }

/* ═══════════════════════════════════════════════════════
   SCROLLBAR
   ═══════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════
   TRADING TICKET
   ═══════════════════════════════════════════════════════ */

.trading-form { display: flex; flex-direction: column; gap: 12px; }

.side-toggle { display: flex; gap: 8px; }

.side-btn {
    flex: 1;
    padding: 10px;
    border: 1px solid;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    font-family: inherit;
    text-align: center;
    transition: all 0.15s;
    user-select: none;
}

.side-btn.buy { border-color: var(--color-buy); color: var(--color-buy); }
.side-btn.buy.active { background: var(--color-buy); color: var(--bg-primary); }
.side-btn.sell { border-color: var(--color-sell); color: var(--color-sell); }
.side-btn.sell.active { background: var(--color-sell); color: var(--bg-primary); }

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

.form-group label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input {
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
}

.form-input:focus { border-color: var(--accent-blue); outline: none; }

.submit-btn {
    padding: 12px;
    border: none;
    border-radius: var(--radius);
    font-weight: 700;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    text-transform: uppercase;
    transition: opacity 0.15s;
}

.submit-btn:hover { opacity: 0.9; }
.submit-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.submit-btn.buy { background: var(--color-buy); color: #000; }
.submit-btn.sell { background: var(--color-sell); color: #fff; }

/* Emergency buttons */
.emergency-btn {
    display: inline-block;
    padding: 6px 16px;
    font-family: inherit;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    text-align: center;
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
    border: 1px solid rgba(239, 68, 68, 0.4);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
    -webkit-appearance: none;
    appearance: none;
}
.emergency-btn:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.3);
    border-color: var(--accent-red);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.3);
}
.emergency-btn:active:not(:disabled) { transform: scale(0.96); }
.emergency-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Action buttons (cancel order, close position) */
.action-btn {
    display: inline-block;
    padding: 5px 12px;
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: 0.3px;
    text-align: center;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-accent);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
    white-space: nowrap;
    -webkit-appearance: none;
    appearance: none;
}
.action-btn:active { transform: scale(0.96); }
.action-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.action-btn.cancel {
    background: rgba(239, 68, 68, 0.12);
    color: var(--accent-red);
    border: 1px solid rgba(239, 68, 68, 0.25);
}
.action-btn.cancel:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.25);
    border-color: rgba(239, 68, 68, 0.5);
}

.action-btn.close-pos {
    background: rgba(245, 158, 11, 0.12);
    color: var(--accent-yellow);
    border: 1px solid rgba(245, 158, 11, 0.25);
}
.action-btn.close-pos:hover:not(:disabled) {
    background: rgba(245, 158, 11, 0.25);
    border-color: rgba(245, 158, 11, 0.5);
}

.action-btn.query-pos {
    padding: 6px 16px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    background: rgba(59, 130, 246, 0.12);
    color: var(--accent-blue);
    border: 1px solid rgba(59, 130, 246, 0.25);
}
.action-btn.query-pos:hover:not(:disabled) {
    background: rgba(59, 130, 246, 0.25);
    border-color: rgba(59, 130, 246, 0.5);
}

/* ── Generic buttons (Routing page) ── */
.btn {
    display: inline-block;
    padding: 6px 14px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    text-align: center;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-accent);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
    white-space: nowrap;
    appearance: none;
}
.btn:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--text-muted); }
.btn:active:not(:disabled) { transform: scale(0.96); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
    background: rgba(59, 130, 246, 0.2);
    color: var(--accent-blue);
    border-color: rgba(59, 130, 246, 0.4);
}
.btn-primary:hover:not(:disabled) {
    background: rgba(59, 130, 246, 0.35);
    border-color: var(--accent-blue);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    border-color: var(--border-primary);
}
.btn-secondary:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.12);
    color: var(--accent-red);
    border-color: rgba(239, 68, 68, 0.3);
}
.btn-danger:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.25);
    border-color: rgba(239, 68, 68, 0.5);
}

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

/* Toggle button */
.btn-toggle {
    display: inline-block;
    padding: 3px 10px;
    font-family: inherit;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 1px solid;
    transition: all 0.15s;
    appearance: none;
}
.toggle-on {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-green);
    border-color: rgba(16, 185, 129, 0.4);
}
.toggle-on:hover {
    background: rgba(16, 185, 129, 0.3);
}
.toggle-off {
    background: rgba(100, 116, 139, 0.1);
    color: var(--text-muted);
    border-color: var(--border-primary);
}
.toggle-off:hover {
    background: rgba(100, 116, 139, 0.2);
}

/* Muted row (disabled rules) */
.row-muted td { opacity: 0.45; }

/* ── Routing page ── */
.routing-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.routing-form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

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

.routing-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.routing-hint {
    font-size: 10px;
    color: var(--text-dim);
    line-height: 1.3;
}

.routing-error {
    padding: 8px 12px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-sm);
    color: var(--accent-red);
    font-size: 12px;
}

.routing-form-actions {
    display: flex;
    gap: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-subtle);
}

.routing-actions {
    display: flex;
    gap: 4px;
}

.routing-toggle {
    display: inline-block;
    padding: 3px 10px;
    font-family: inherit;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 1px solid;
    transition: all 0.15s;
    appearance: none;
    min-width: 60px;
    text-align: center;
}

.routing-toggle-on {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-green);
    border-color: rgba(16, 185, 129, 0.4);
}
.routing-toggle-on:hover {
    background: rgba(16, 185, 129, 0.3);
    border-color: rgba(16, 185, 129, 0.6);
}

.routing-toggle-off {
    background: rgba(100, 116, 139, 0.1);
    color: var(--text-muted);
    border-color: var(--border-primary);
}
.routing-toggle-off:hover {
    background: rgba(100, 116, 139, 0.2);
    border-color: var(--border-accent);
}

/* Account chips */
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-accent);
    border-radius: 20px;
    font-size: 12px;
    color: var(--text-primary);
    white-space: nowrap;
}

.chip-remove {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1;
    transition: color 0.15s;
}

.chip-remove:hover { color: var(--accent-red); }

.chip-add {
    cursor: pointer;
    background: transparent;
    border: 1px dashed var(--border-accent);
    color: var(--text-muted);
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 20px;
    transition: all 0.15s;
}

.chip-add:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

/* ═══════════════════════════════════════════════════════
   MODAL
   ═══════════════════════════════════════════════════════ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: modal-fade-in 0.15s ease-out;
}

@keyframes modal-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modal-slide-in {
    from { opacity: 0; transform: translateY(-12px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-accent);
    border-radius: var(--radius);
    width: 520px;
    max-width: 92vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: modal-slide-in 0.2s ease-out;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-primary);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
    font-family: inherit;
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.modal-body .form-input {
    width: 100%;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-primary);
}

.modal-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 500px) {
    .modal-form-row { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════════════
   FIX LOG — details modal + raw viewer
   ═══════════════════════════════════════════════════════ */

.btn-icon {
    background: transparent;
    border: 1px solid var(--border-primary);
    color: var(--text-secondary);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s ease;
}
.btn-icon:hover {
    background: var(--bg-hover);
    border-color: var(--border-accent);
    color: var(--text-primary);
}

.fixlog-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 8px 16px;
    margin-bottom: 16px;
    padding: 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
}
.fixlog-details-grid > div {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.fixlog-details-grid label {
    font-size: 10px;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.04em;
    margin-bottom: 2px;
}
.fixlog-details-grid span {
    font-size: 13px;
    color: var(--text-primary);
    word-break: break-all;
}
.fixlog-details-full { grid-column: 1 / -1; }

.fixlog-raw-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}
.fixlog-raw {
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    padding: 10px 12px;
    margin: 0;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 12px;
    color: var(--accent-cyan);
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 260px;
    overflow-y: auto;
}

/* ═══════════════════════════════════════════════════════
   SCROLLBAR
   ═══════════════════════════════════════════════════════ */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-accent); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }
