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

:root {
    --bg:        #f0f4f8;
    --surface:   #ffffff;
    --surface2:  #f5f7fa;
    --border:    #dde3ec;
    --accent:    #2563eb;
    --accent2:   #6c63ff;
    --green:     #16a34a;
    --red:       #dc2626;
    --yellow:    #b45309;
    --text:      #1e2535;
    --muted:     #6b7280;
    --radius:    10px;
    --shadow:    0 2px 12px rgba(0,0,0,0.08);
}

html { font-size: 15px; }
body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    line-height: 1.6;
    min-height: 100vh;
}

/* ─── Navbar ──────────────────────────────────────────────── */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 6px rgba(0,0,0,0.07);
    padding: 0 32px;
    height: 60px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-icon {
    font-size: 0.9rem;
    background: var(--accent);
    color: #fff;
    border-radius: 6px;
    padding: 3px 7px;
}

.nav-links {
    list-style: none;
    display: flex;
    gap: 4px;
}

.nav-links a {
    display: block;
    padding: 6px 16px;
    border-radius: 6px;
    color: var(--muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.18s, background 0.18s;
}

.nav-links a:hover { color: var(--text); background: var(--surface2); }
.nav-links a.active { color: var(--accent); background: rgba(79,142,247,0.1); }

/* ─── Layout ──────────────────────────────────────────────── */
.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 36px 24px 80px;
}

.page-header {
    margin-bottom: 32px;
}
.page-header h1 {
    font-size: 1.9rem;
    font-weight: 700;
    color: var(--text);
}
.page-header p {
    color: var(--muted);
    margin-top: 4px;
    font-size: 0.92rem;
}
.page-header code {
    font-family: 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.83rem;
    background: var(--surface2);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--accent);
}

/* ─── Cards Grid ──────────────────────────────────────────── */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 22px;
}

.card-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 6px;
}
.card-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}
.card-sub {
    font-size: 0.78rem;
    color: var(--muted);
    margin-top: 4px;
}

/* ─── Badges ──────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 5px;
    font-size: 1rem;
    font-weight: 600;
}
.badge.red   { background: rgba(239,68,68,0.15); color: var(--red); }
.badge.green { background: rgba(34,197,94,0.15);  color: var(--green); }

/* ─── Status pills ────────────────────────────────────────── */
.status {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
}
.status.on  { background: rgba(34,197,94,0.12);  color: var(--green); }
.status.off { background: rgba(239,68,68,0.1);   color: var(--red); }

/* ─── Section grid (2-col) ────────────────────────────────── */
.section-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
@media (max-width: 640px) { .section-grid { grid-template-columns: 1fr; } }

.info-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}
.info-box h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text);
}

.info-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.info-table tr { border-bottom: 1px solid var(--border); }
.info-table tr:last-child { border-bottom: none; }
.info-table td { padding: 9px 0; vertical-align: middle; }
.info-table td:first-child { color: var(--muted); width: 55%; }
.info-table td.mono {
    font-family: 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.78rem;
    word-break: break-all;
}

/* ─── Alerts ──────────────────────────────────────────────── */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius);
    margin-bottom: 24px;
    font-size: 0.92rem;
    line-height: 1.5;
}
.alert.success {
    background: rgba(34,197,94,0.08);
    border: 1px solid rgba(34,197,94,0.3);
    color: var(--green);
}
.alert.error {
    background: rgba(239,68,68,0.08);
    border: 1px solid rgba(239,68,68,0.3);
    color: #b91c1c;
}
.alert a { color: inherit; font-weight: 600; }

/* ─── Buttons ─────────────────────────────────────────────── */
.btn {
    display: inline-block;
    padding: 9px 20px;
    border-radius: 7px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    border: none;
    transition: opacity 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { opacity: 0.88; }
.btn.secondary {
    background: var(--surface2);
    color: var(--muted);
    border: 1px solid var(--border);
}
.btn.secondary:hover { color: var(--text); }
.btn:not(.primary):not(.secondary) {
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn:not(.primary):not(.secondary):hover { border-color: var(--accent); }

/* ─── Step Size Selector ──────────────────────────────────── */
.step-group {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 7px;
    overflow: hidden;
}
.step-btn {
    background: var(--surface2);
    border: none;
    border-right: 1px solid var(--border);
    color: var(--muted);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 5px 13px;
    transition: background 0.15s, color 0.15s;
}
.step-btn:last-child { border-right: none; }
.step-btn:hover { background: var(--surface); color: var(--text); }
.step-btn.active { background: var(--accent); color: #fff; }
.trend-btn.trend-up.active   { background: var(--green); color: #fff; border-color: var(--green); }
.trend-btn.trend-down.active { background: var(--red);   color: #fff; border-color: var(--red); }

/* ─── Form Sections ───────────────────────────────────────── */
.form-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 28px 24px;
    margin-bottom: 20px;
}
.form-section h2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}
.section-icon { font-size: 1.1rem; }
.section-desc {
    color: var(--muted);
    font-size: 0.85rem;
    margin-bottom: 22px;
}

/* ─── Form Rows & Groups ──────────────────────────────────── */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 18px;
    margin-bottom: 16px;
}
.form-row:last-child { margin-bottom: 0; }

.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full-width { grid-column: 1 / -1; }

label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

input[type="text"],
input[type="password"],
input[type="number"],
select {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 7px;
    color: var(--text);
    font-size: 0.92rem;
    padding: 9px 12px;
    outline: none;
    transition: border-color 0.18s, box-shadow 0.18s;
    width: 100%;
    font-family: inherit;
}

input:focus, select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79,142,247,0.15);
}

input::placeholder { color: var(--muted); opacity: 0.6; }

select option { background: var(--surface2); }

.hint {
    font-size: 0.78rem;
    color: var(--muted);
    line-height: 1.4;
}

/* ─── Password eye toggle ─────────────────────────────────── */
.input-eye-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}
.input-eye-wrapper input { padding-right: 40px; }
.eye-btn {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--muted);
    opacity: 0.5;
    padding: 0;
    line-height: 1;
    transition: opacity 0.15s;
}
.eye-btn:hover { opacity: 0.9; }

/* ─── Toggle checkbox ─────────────────────────────────────── */
.toggle-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--text);
    text-transform: none;
    letter-spacing: 0;
}
.toggle-label input[type="checkbox"] { display: none; }
.toggle-box {
    display: inline-block;
    width: 40px;
    height: 22px;
    background: #c5ccd8;
    border-radius: 11px;
    position: relative;
    flex-shrink: 0;
    transition: background 0.2s;
}
.toggle-box::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    transition: left 0.2s, background 0.2s;
}
.toggle-label input:checked + .toggle-box {
    background: var(--green);
}
.toggle-label input:checked + .toggle-box::after {
    left: 21px;
    background: #fff;
}

/* ─── Rule Builder ────────────────────────────────────────── */
.rule-builder-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.rule-builder-header h2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.rules-empty {
    text-align: center;
    color: var(--muted);
    font-size: 0.88rem;
    padding: 36px 0;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

.rule-card {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 14px;
    overflow: hidden;
    transition: border-color 0.2s;
}
.rule-card:hover { border-color: rgba(79,142,247,0.4); }
.rule-card.rule-triggered { border-color: rgba(234,179,8,0.4); }
.rule-card.rule-disabled  { opacity: 0.55; }

.rule-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.rule-name-input {
    flex: 1;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 5px;
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    outline: none;
    padding: 3px 7px;
    transition: background 0.15s, border-color 0.15s;
}
.rule-name-input:focus {
    background: var(--surface2);
    border-color: var(--border);
}

.rule-badge {
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    white-space: nowrap;
    flex-shrink: 0;
}
.rule-badge.badge-active     { background: rgba(34,197,94,0.12);  color: var(--green); }
.rule-badge.badge-triggered  { background: rgba(234,179,8,0.12);  color: var(--yellow); }
.rule-badge.badge-disabled   { background: rgba(136,146,164,0.1); color: var(--muted); }

.rule-card-body { padding: 18px 18px 14px; }

.rule-section { margin-bottom: 18px; }
.rule-section:last-child { margin-bottom: 0; }

.rule-section-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    color: var(--accent);
    text-transform: uppercase;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.rule-section-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.rule-triggered-info {
    margin-top: 10px;
    font-size: 0.78rem;
    color: var(--yellow);
}

.btn-icon {
    background: none;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--muted);
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 4px 9px;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
}
.btn-icon:hover         { color: var(--red);   background: rgba(239,68,68,0.08); border-color: rgba(239,68,68,0.2); }
.btn-icon.btn-rearm:hover { color: var(--green); background: rgba(34,197,94,0.08); border-color: rgba(34,197,94,0.2); }

/* Demo mode toggle */
.demo-toggle-label { cursor: pointer; user-select: none; }
.demo-toggle-box {
    width: 32px !important;
    height: 18px !important;
    background: #c5ccd8;
}
.demo-toggle-box::after {
    width: 12px !important;
    height: 12px !important;
    top: 3px !important;
    left: 3px !important;
}
.demo-toggle-label input:checked + .demo-toggle-box {
    background: var(--yellow);
}
.demo-toggle-label input:checked + .demo-toggle-box::after {
    left: 17px !important;
}
.demo-toggle-text {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--muted);
    letter-spacing: 0.04em;
}
.demo-toggle-label:has(input:checked) .demo-toggle-text {
    color: var(--yellow);
}

.rules-save-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 14px;
    margin-top: 16px;
}
.rules-msg {
    font-size: 0.85rem;
    flex: 1;
}
.rules-msg.ok  { color: var(--green); }
.rules-msg.err { color: var(--red); }

/* ─── Settings Tabs ───────────────────────────────────────── */
.tab-bar {
    display: flex;
    gap: 2px;
    border-bottom: 2px solid var(--border);
    margin-bottom: 24px;
}

.tab-btn {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    padding: 9px 22px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    border-radius: 6px 6px 0 0;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.tab-btn:hover { color: var(--text); background: var(--surface2); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); background: rgba(79,142,247,0.06); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ─── Form actions ────────────────────────────────────────── */
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 8px;
}

/* ─── Footer ──────────────────────────────────────────────── */
footer {
    text-align: center;
    color: var(--muted);
    font-size: 0.8rem;
    padding: 24px;
    border-top: 1px solid var(--border);
}

/* ─── Dashboard two-column layout ────────────────────────── */
body.has-dash-layout {
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.dash-layout {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 580px;
    overflow: hidden;
    min-height: 0;
}

/* ─── Log panel (left) ────────────────────────────────────── */
.log-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: 1px solid var(--border);
    min-height: 0;
}

.log-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 18px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.log-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text);
}

.bot-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-block;
    transition: background 0.3s;
}
.bot-dot.stopped    { background: var(--muted); }
.bot-dot.restarting { background: var(--yellow); animation: botPulse 0.6s ease-in-out infinite; }
.bot-dot.running {
    background: var(--green);
    box-shadow: 0 0 7px rgba(34,197,94,0.7);
    animation: botPulse 1.8s ease-in-out infinite;
}
@keyframes botPulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.45; }
}

.bot-status-label {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--muted);
}

.log-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px 18px;
    margin: 0;
    font-family: 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.77rem;
    line-height: 1.65;
    color: #4b5563;
    white-space: pre-wrap;
    word-break: break-word;
    min-height: 0;
    background: var(--bg);
}

.log-empty {
    color: var(--muted);
    font-style: italic;
}

/* ─── Dashboard side (right) ──────────────────────────────── */
.dash-side {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    min-height: 0;
}

.dash-inner {
    flex: 1;
    padding: 24px 20px 20px;
}

/* ─── Inline Option Chain Panel ──────────────────────────── */
.r-chain-panel {
    margin-top: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.r-chain-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    background: var(--surface2);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.r-chain-title {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--muted);
    text-transform: uppercase;
    white-space: nowrap;
    margin-right: 4px;
}

.r-chain-expiry {
    flex: 1;
    min-width: 140px;
    max-width: 220px;
    font-size: 0.84rem;
    padding: 5px 10px;
}

.r-chain-placeholder,
.r-chain-loading,
.r-chain-error {
    padding: 18px 16px;
    font-size: 0.83rem;
    text-align: center;
    color: var(--muted);
}
.r-chain-error { color: var(--red); }

.chain-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    table-layout: fixed;
}

.chain-table thead th {
    padding: 7px 10px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    background: var(--surface2);
    border-bottom: 1px solid var(--border);
}
.chain-ce-head  { text-align: right; color: var(--green); width: 42%; }
.chain-strike-head { text-align: center; color: var(--muted);  width: 16%; }
.chain-pe-head  { text-align: left;  color: var(--red);   width: 42%; }

.chain-table tbody tr { border-bottom: 1px solid var(--border); }
.chain-table tbody tr:last-child { border-bottom: none; }
.chain-table tbody tr:hover td { background: rgba(37,99,235,0.04); }

.chain-atm-row td { background: rgba(37,99,235,0.06) !important; }

.chain-ce-td  { text-align: right;  padding: 5px 10px; }
.chain-pe-td  { text-align: left;   padding: 5px 10px; }
.chain-strike-td {
    text-align: center;
    padding: 5px 6px;
    font-weight: 700;
    font-size: 0.84rem;
    color: var(--text);
    white-space: nowrap;
}
.chain-atm-badge {
    font-size: 0.62rem;
    font-weight: 700;
    background: var(--accent);
    color: #fff;
    border-radius: 3px;
    padding: 1px 4px;
    margin-left: 4px;
    vertical-align: middle;
}
.chain-level-badge {
    font-size: 0.62rem;
    font-weight: 700;
    background: var(--yellow);
    color: #fff;
    border-radius: 3px;
    padding: 1px 4px;
    margin-left: 4px;
    vertical-align: middle;
}
.chain-empty { color: var(--muted); }

.chain-pick-btn {
    padding: 3px 8px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.74rem;
    font-family: 'Cascadia Code', 'Consolas', monospace;
    white-space: nowrap;
    transition: background 0.13s, color 0.13s, border-color 0.13s;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
}
.chain-ce-btn:hover,
.chain-ce-btn.chain-selected {
    background: rgba(22,163,74,0.12);
    color: var(--green);
    border-color: rgba(22,163,74,0.4);
}
.chain-pe-btn:hover,
.chain-pe-btn.chain-selected {
    background: rgba(220,38,38,0.1);
    color: var(--red);
    border-color: rgba(220,38,38,0.35);
}

.chain-ltp-note {
    padding: 6px 14px;
    font-size: 0.75rem;
    color: var(--muted);
    background: var(--surface2);
    border-top: 1px solid var(--border);
    text-align: right;
}
.chain-ltp-note strong { color: var(--text); }

/* ─── Start / Stop buttons ────────────────────────────────── */
.btn-start {
    background: rgba(34,197,94,0.12);
    color: var(--green);
    border: 1px solid rgba(34,197,94,0.28);
    padding: 6px 14px;
    font-size: 0.83rem;
}
.btn-start:hover:not(:disabled) { background: rgba(34,197,94,0.22); }

.btn-stop {
    background: rgba(239,68,68,0.1);
    color: var(--red);
    border: 1px solid rgba(239,68,68,0.25);
    padding: 6px 14px;
    font-size: 0.83rem;
}
.btn-stop:hover:not(:disabled) { background: rgba(239,68,68,0.18); }

.btn-start:disabled,
.btn-stop:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* ─── Rules Monitor (dashboard) ───────────────────────────── */
.rs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    line-height: 1.5;
}
.rs-table th {
    text-align: left;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    padding: 6px 8px;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
.rs-table td {
    padding: 7px 8px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.rs-table tr:last-child td { border-bottom: none; }

.rs-name  { font-weight: 600; white-space: nowrap; }
.rs-status { white-space: nowrap; font-weight: 600; }
.rs-action { font-size: 0.75rem; color: var(--muted); max-width: 200px; word-break: break-word; }

/* status row colours */
.rs-watching .rs-status  { color: var(--accent); }
.rs-fired .rs-status     { color: var(--green); }
.rs-demo .rs-status      { color: var(--yellow); }
.rs-disabled             { opacity: 0.45; }
.rs-disabled .rs-status  { color: var(--muted); }
.rs-triggered .rs-status { color: #8b5cf6; }
.rs-error .rs-status     { color: var(--red); }

/* condition met / not met */
.rs-met    { color: var(--green); font-weight: 600; }
.rs-notmet { color: var(--muted); }

/* demo badge */
.rs-demo-tag {
    display: inline-block;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    background: rgba(180,83,9,0.12);
    color: var(--yellow);
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 5px;
    vertical-align: middle;
}

/* fired-row highlight */
.rs-fired td, .rs-demo td {
    background: rgba(34,197,94,0.04);
}

/* dashboard level editor in trigger settings */
.ts-level-cell {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
}
.ts-level-input {
    width: 110px;
    padding: 2px 6px;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 0.78rem;
    font-family: 'Cascadia Code', 'Consolas', monospace;
    background: var(--surface2);
    color: var(--text);
    outline: none;
}
.ts-level-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(37,99,235,0.15);
}
button.ts-level-save {
    padding: 1px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    appearance: none;
    background: #1e40af;
    color: #bfdbfe;
    font-family: inherit;
    white-space: nowrap;
}
button.ts-level-save:hover:not(:disabled) { opacity: 0.8; }
button.ts-level-save:disabled { opacity: 0.5; cursor: not-allowed; }

/* dashboard toggle button (enabled/disabled) */
button.btn-toggle-dash {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    border: none;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    font-family: inherit;
    line-height: 1.5;
}
button.btn-toggle-dash.is-on   { background: #166534; color: #bbf7d0; }
button.btn-toggle-dash.is-off  { background: #991b1b; color: #fecaca; }
button.btn-toggle-dash.is-live { background: #1e40af; color: #bfdbfe; }
button.btn-toggle-dash.is-demo { background: #92400e; color: #fde68a; }
button.btn-toggle-dash:hover:not(:disabled) { opacity: 0.75; }
button.btn-toggle-dash:disabled { opacity: 0.5; cursor: not-allowed; }

/* dashboard re-arm button */
.btn-rearm-dash {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 5px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid rgba(139,92,246,0.35);
    background: rgba(139,92,246,0.1);
    color: #8b5cf6;
    transition: background 0.15s, color 0.15s;
}
.btn-rearm-dash:hover:not(:disabled) {
    background: rgba(139,92,246,0.22);
    color: #7c3aed;
}
.btn-rearm-dash:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ─── Responsive: Tablet (iPad) ──────────────────────────────── */
@media (max-width: 1024px) {
    .dash-layout {
        grid-template-columns: 1fr;
        overflow-y: auto;
    }
    body.has-dash-layout {
        height: auto;
        overflow: auto;
    }
    .log-panel {
        border-right: none;
        border-bottom: 1px solid var(--border);
        max-height: 40vh;
    }
    .dash-side { overflow-y: visible; }
    .dash-inner { padding: 16px 14px; }
    .navbar { padding: 0 16px; }
}

/* ─── Responsive: Mobile (iPhone) ────────────────────────────── */
@media (max-width: 640px) {
    html { font-size: 14px; }
    .navbar {
        flex-wrap: wrap;
        height: auto;
        padding: 8px 12px;
        gap: 6px;
    }
    .nav-links { gap: 2px; flex-wrap: wrap; }
    .nav-links a { padding: 5px 10px; font-size: 0.8rem; }
    .nav-brand { font-size: 1.1rem; }

    .dash-layout { grid-template-columns: 1fr; }
    .log-panel { max-height: 35vh; }
    .dash-inner { padding: 12px 10px; }

    .page-header h1 { font-size: 1.4rem; }
    .cards-grid { grid-template-columns: 1fr !important; gap: 10px !important; }

    /* Trigger settings table */
    .info-table { font-size: 0.8rem; }
    .info-table td { padding: 6px 2px; }
    .ts-level-input { width: 85px; min-width: 85px; font-size: 0.72rem; }

    /* Rules monitor table — horizontal scroll */
    .rs-table { font-size: 0.72rem; }
    .rs-table th, .rs-table td { padding: 5px 4px; }
    #rulesMonitorBox { overflow-x: auto; }

    /* Buttons */
    button.btn-toggle-dash { font-size: 0.7rem; padding: 2px 7px; }
    .btn-rearm-dash { font-size: 0.68rem; padding: 2px 7px; }

    /* Log toolbar */
    .log-toolbar { padding: 8px 12px; flex-wrap: wrap; gap: 8px; }
    .btn-start, .btn-stop { padding: 5px 10px; font-size: 0.78rem; }

    /* Form sections (rules, settings pages) */
    .form-section { padding: 16px 14px 14px; }
    .form-row { grid-template-columns: 1fr !important; }
    .container { padding: 20px 12px 60px; }
    .form-actions { flex-direction: column; gap: 8px; }
    .form-actions .btn { width: 100%; text-align: center; }

    /* Rule cards */
    .rule-card-header { flex-wrap: wrap; gap: 6px; padding: 8px 12px; }
    .rule-card-body { padding: 12px 12px 10px; }
    .rule-name-input { min-width: 0; width: 100%; }

    /* Settings tabs */
    .tab-bar { flex-wrap: wrap; }
    .tab-btn { padding: 7px 14px; font-size: 0.8rem; }

    /* Info boxes */
    .info-box { padding: 16px; }
    .info-box h2 { font-size: 0.9rem; margin-bottom: 12px; }

    /* Login page */
    .login-card { padding: 28px 20px 24px; margin: 0 12px; }
}
