:root {
  --bg: #070a13;
  --panel: #0f1524;
  --panel-2: #161f33;
  --border: #1e2942;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #3b82f6;
  --accent-glow: rgba(59, 130, 246, 0.15);
  --go: #10b981;
  --stop: #ef4444;
  --warn: #f59e0b;
  --pos: #10b981;
  --neg: #f87171;
  --radius: 14px;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* Custom Scrollbar Styles for Webkit */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ==========================================
   Topbar (Header Layout) - Mobile-First
   ========================================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
  background: rgba(7, 10, 19, 0.85);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}
.brand .logo {
  font-size: 20px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  border-radius: 10px;
  box-shadow: 0 0 15px var(--accent-glow);
  flex-shrink: 0;
  animation: logoFloat 4s ease-in-out infinite;
}

@keyframes logoFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.brand h1 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.active-profile-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  flex-wrap: wrap;
}
.active-profile-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
}
.active-profile {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 3px 24px 3px 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2.5' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 10px;
  transition: var(--transition);
}
.active-profile:hover {
  border-color: var(--accent);
}

.controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  width: 100%;
}

.controls > * {
  flex-grow: 1;
}

.controls select,
.controls button,
.controls .mode-toggle {
  height: 36px;
}

/* Buttons */
.btn {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 0 14px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 12.5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: var(--transition);
}
.btn:hover {
  border-color: var(--muted);
  background: var(--border);
}
.btn:active {
  transform: scale(0.97);
}
.btn.sm {
  height: 30px;
  padding: 0 10px;
  font-size: 11.5px;
  border-radius: 6px;
}
.btn.ghost {
  background: transparent;
}
.btn.ghost:hover {
  background: rgba(255, 255, 255, 0.05);
}

.btn-go {
  background: var(--go);
  border-color: var(--go);
  color: #022c22;
}
.btn-go:hover {
  background: #059669;
  border-color: #059669;
}
.btn-stop {
  background: var(--stop);
  border-color: var(--stop);
  color: #450a0a;
}
.btn-stop:hover {
  background: #dc2626;
  border-color: #dc2626;
}
.btn-warn {
  background: var(--warn);
  border-color: var(--warn);
  color: #451a03;
}
.btn-warn:hover {
  background: #d97706;
  border-color: #d97706;
}
.btn-warn.ghost {
  background: transparent;
  color: var(--warn);
  border-color: rgba(245, 158, 11, 0.3);
}
.btn-warn.ghost:hover {
  background: rgba(245, 158, 11, 0.08);
}
.btn:disabled {
  opacity: .35;
  cursor: not-allowed;
  transform: none !important;
}

.refresh {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  padding: 0 10px;
  border-radius: 8px;
}
.refresh select {
  border: none;
  background: transparent;
  padding: 0 16px 0 0;
  font-weight: 600;
  height: 100%;
}

.pill {
  padding: 0 12px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  border: 1px solid transparent;
}
.pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.pill-run {
  background: rgba(16, 185, 129, 0.08);
  color: var(--go);
  border-color: rgba(16, 185, 129, 0.15);
}
.pill-stop {
  background: rgba(239, 68, 68, 0.08);
  color: var(--stop);
  border-color: rgba(239, 68, 68, 0.15);
}
.pill-pause {
  background: rgba(245, 158, 11, 0.08);
  color: var(--warn);
  border-color: rgba(245, 158, 11, 0.15);
}
.pill-idle {
  background: rgba(148, 163, 184, 0.08);
  color: var(--muted);
  border-color: rgba(148, 163, 184, 0.15);
}

/* ==========================================
   Customize Drawer
   ========================================== */
.customize {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.customize.hidden {
  display: none;
}
.customize-title {
  font-weight: 700;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.widget-toggles {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.widget-toggles label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--panel-2);
  padding: 6px 10px;
  border-radius: 7px;
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 11.5px;
  transition: var(--transition);
}
.widget-toggles label:hover {
  border-color: var(--muted);
}
.widget-toggles input[type="checkbox"] {
  accent-color: var(--accent);
}

/* ==========================================
   Board & Responsive Layout (Mobile-First)
   ========================================== */
.board {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 12px;
  max-width: 1600px;
  margin: 0 auto;
}

.widget {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  min-width: 0;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
  box-shadow: 0 4px 18px -4px rgba(0, 0, 0, 0.5);
}
.widget:hover {
  border-color: rgba(59, 130, 246, 0.25);
  box-shadow: 0 8px 24px -6px rgba(59, 130, 246, 0.08);
}
.widget.hidden {
  display: none;
}

.w-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 8px;
  flex-wrap: wrap;
}
.w-head h2 {
  font-size: 11.5px;
  margin: 0;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
}
.w-sub {
  font-size: 10px;
  color: var(--muted);
  font-weight: 500;
}

/* ==========================================
   KPI Strip
   ========================================== */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.kpi {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
.kpi .label {
  font-size: 9.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 600;
}
.kpi .value {
  font-size: 18px;
  font-weight: 700;
  margin-top: 2px;
  font-family: var(--mono);
  word-break: break-all;
}
.kpi .value.pos { color: var(--pos); }
.kpi .value.neg { color: var(--neg); }
.kpi .foot {
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
}

/* ==========================================
   Charts & Tables
   ========================================== */
.chart-wrap {
  position: relative;
  height: 200px;
  width: 100%;
}
.table-wrap {
  overflow: auto;
  max-height: 300px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
th, td {
  text-align: right;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
th {
  position: sticky;
  top: 0;
  background: var(--panel-2);
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 9.5px;
  letter-spacing: 0.04em;
  z-index: 10;
}
th:first-child, td:first-child {
  text-align: left;
}
tr:hover td {
  background: var(--panel-2);
}
td.pos { color: var(--pos); }
td.neg { color: var(--neg); }
.badge {
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  display: inline-block;
}
.badge.win {
  background: rgba(16, 185, 129, 0.12);
  color: var(--pos);
}
.badge.loss {
  background: rgba(239, 68, 68, 0.12);
  color: var(--stop);
}
.badge.alert {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
}
.badge.other {
  background: rgba(148, 163, 184, 0.12);
  color: var(--muted);
}

/* ==========================================
   Forms & Controls
   ========================================== */
.params-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.params-form .field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.params-form label {
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
}
.params-form input,
select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 6px 8px;
  font-size: 12px;
  transition: var(--transition);
}
.params-form input {
  font-family: var(--mono);
  height: 32px;
}
.params-form input:focus,
select:focus {
  border-color: var(--accent);
  outline: none;
}
.params-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}
.params-msg {
  font-size: 11px;
  font-weight: 600;
}
.params-msg.ok { color: var(--pos); }
.params-msg.err { color: var(--neg); }

.raw-params {
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}
.raw-params summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  outline: none;
}
.raw-params pre {
  max-height: 180px;
  overflow: auto;
  background: var(--bg);
  padding: 8px;
  border-radius: 6px;
  font-size: 10px;
  border: 1px solid var(--border);
  margin-top: 6px;
}

/* ==========================================
   Logs & Feeds
   ========================================== */
.feed {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 240px;
  overflow: auto;
}
.feed .item {
  background: var(--panel-2);
  border-left: 3px solid var(--neg);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 11px;
}
.feed .item .t {
  color: var(--muted);
  font-size: 9.5px;
  font-family: var(--mono);
}
.feed .item .m {
  margin-top: 2px;
  word-break: break-all;
}
.feed .empty,
.log:empty::before {
  color: var(--muted);
  font-size: 11px;
}
.log:empty::before { content: "(empty)"; }
#jobOutput:empty::before { content: "Select a job to view output"; }
.log {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.55;
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

/* ==========================================
   Command Runner
   ========================================== */
.cmd-desc {
  color: var(--muted);
  font-size: 11.5px;
  margin-bottom: 12px;
}
.cmd-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.cmd-fields {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.fields-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  margin-bottom: 2px;
  font-weight: 700;
}
.cmd-fields .field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.cmd-fields .field.hidden,
.cmd-fields .field[hidden] {
  display: none;
}
.cmd-fields label {
  font-size: 10px;
  color: var(--muted);
}
.cmd-fields input {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 6px 8px;
  font-family: var(--mono);
  font-size: 12px;
  height: 32px;
}
.runner-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.runner-actions .btn {
  flex-grow: 1;
}
.cmd-preview {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  overflow-x: auto;
  white-space: nowrap;
}

/* ==========================================
   Jobs Panel
   ========================================== */
.jobs-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow: auto;
  margin-bottom: 8px;
}
.job {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 6px 8px;
  cursor: pointer;
  transition: var(--transition);
}
.job:hover {
  border-color: var(--accent);
}
.job.sel {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset;
}
.job-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.job-cmd {
  font-weight: 600;
  font-size: 12px;
}
.job-args {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.job-guidance {
  font-size: 10.5px;
  line-height: 1.3;
  white-space: normal;
}
.job-guidance.err { color: var(--neg); }
.job-guidance.ok { color: var(--pos); }
.job-guidance.warn { color: var(--warn); }
.job-side {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.job-status {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
}

/* ==========================================
   WhatsApp Panel
   ========================================== */
.wa-status {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 11px;
  margin-bottom: 10px;
}
.wa-status .wa-kv {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 6px;
  flex-grow: 1;
  text-align: center;
}
.wa-status .wa-kv b {
  color: var(--text);
  font-weight: 600;
}
.wa-status .wa-kv.ok {
  border-color: rgba(16, 185, 129, 0.35);
  background: rgba(16, 185, 129, 0.04);
}
.wa-status .wa-kv.bad {
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.04);
  color: var(--neg);
}
.wa-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}
.wa-actions input,
.wa-actions button {
  width: 100%;
}
.wa-actions button {
  height: 32px;
}
.wa-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  padding: 6px 10px;
  font-size: 12px;
}
.wa-cols {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.wa-h3 {
  margin-bottom: 6px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  font-weight: 700;
}
.wa-cmds {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 200px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
}
.wa-cmd {
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
  padding: 6px 8px;
}
.wa-cmd:last-child {
  border-bottom: none;
}
.wa-cmd.danger {
  border-left: 3px solid var(--stop);
}
.wa-cmd code {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
}
.wa-cmd .wa-cmd-desc {
  color: var(--muted);
  font-size: 10.5px;
  margin-top: 2px;
  line-height: 1.4;
}
.wa-cmd .wa-grp {
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: .05em;
}

/* ==========================================
   Profiles / sessions list
   ========================================== */
.prof-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.prof-empty {
  color: var(--muted);
  font-size: 12px;
}
.prof-card {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
}
.prof-card.is-running {
  border-color: rgba(16, 185, 129, 0.3);
}
.prof-card.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset;
}
.prof-card .prof-main {
  cursor: pointer;
  flex: 1;
  min-width: 0;
}
.prof-viewing {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: .05em;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent);
}
.prof-pick {
  padding-top: 2px;
}
.prof-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
}
.prof-title .prof-id {
  color: var(--muted);
  font-size: 10px;
  font-family: var(--mono);
}
.prof-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  display: inline-block;
  flex-shrink: 0;
}
.prof-dot.on {
  background: var(--pos);
  box-shadow: 0 0 6px var(--pos);
}
.prof-dot.off {
  background: #4b5563;
}
.prof-dot.warn {
  background: var(--warn);
}
.prof-meta {
  color: var(--muted);
  font-size: 10.5px;
  margin: 2px 0 6px;
  font-family: var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.prof-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 8px;
  font-size: 11.5px;
  color: var(--muted);
}
.prof-stats b {
  color: var(--text);
}
.prof-stats b.pos { color: var(--pos); }
.prof-stats b.neg { color: var(--neg); }
.prof-state {
  text-transform: uppercase;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .04em;
}
.prof-state.on { color: var(--pos); }
.prof-state.off { color: var(--muted); }
.prof-state.warn { color: var(--warn); }
.prof-btns {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.prof-btns .btn {
  height: 28px;
  font-size: 11px;
}
.prof-badge {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: .05em;
  padding: 1px 5px;
  border-radius: 4px;
  text-transform: uppercase;
}
.prof-badge.dry {
  background: rgba(148, 163, 184, 0.12);
  color: var(--muted);
}
.prof-badge.real {
  background: rgba(239, 68, 68, 0.12);
  color: var(--neg);
}

/* ==========================================
   Strategies
   ========================================== */
.strat-controls select {
  height: 28px;
  padding: 2px 6px;
}
.strat-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.strat-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.strat-card.risk-none { border-left-color: #475569; }
.strat-card.risk-low { border-left-color: var(--go); }
.strat-card.risk-medium { border-left-color: var(--warn); }
.strat-card.risk-high { border-left-color: #f43f5e; }
.strat-card.risk-danger { border-left-color: var(--stop); box-shadow: 0 0 0 1px rgba(239,68,68,.1) inset; }
.strat-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.strat-name {
  font-weight: 700;
  font-size: 13px;
}
.strat-tag {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}
.risk-badge {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 2px 6px;
  border-radius: 12px;
  white-space: nowrap;
}
.risk-badge.risk-none { background: #334155; color: #e2e8f0; }
.risk-badge.risk-low { background: rgba(16, 185, 129, 0.12); color: var(--pos); }
.risk-badge.risk-medium { background: rgba(245, 158, 11, 0.12); color: var(--warn); }
.risk-badge.risk-high { background: rgba(244, 63, 94, 0.12); color: #f43f5e; }
.risk-badge.risk-danger { background: rgba(239, 68, 68, 0.15); color: var(--neg); }
.strat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.chip {
  font-family: var(--mono);
  font-size: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--muted);
}
.chip b {
  color: var(--text);
  font-weight: 600;
}
.strat-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.strat-actions .btn {
  height: 28px;
  font-size: 11px;
  flex-grow: 1;
}
.mode-tag {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  text-transform: uppercase;
}
.mode-real {
  background: rgba(239, 68, 68, 0.12);
  color: var(--neg);
}
.mode-paper {
  background: rgba(59, 130, 246, 0.12);
  color: var(--accent);
}

/* ==========================================
   Modals & Popups
   ========================================== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(3, 6, 12, 0.8);
  display: grid;
  place-items: center;
  padding: 12px;
  backdrop-filter: blur(4px);
}
.modal.hidden {
  display: none;
}
.modal-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 580px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  border-radius: var(--radius) var(--radius) 0 0;
}
.modal-head h3 {
  margin: 0;
  font-size: 13.5px;
  font-weight: 700;
}
.modal-body {
  padding: 14px;
  font-size: 12.5px;
  line-height: 1.55;
  overflow-y: auto;
  flex: 1;
}
.modal-body h4 {
  margin: 12px 0 4px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  font-weight: 700;
}
.modal-body .warn-box {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 6px;
  padding: 8px 10px;
  color: #fca5a5;
  margin-top: 10px;
  font-weight: 500;
}
.modal-body pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  font-size: 10.5px;
  max-height: 200px;
  overflow: auto;
}
.modal-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  background: var(--panel-2);
  border-radius: 0 0 var(--radius) var(--radius);
}
.modal-actions .btn {
  height: 32px;
  font-size: 12px;
  flex-grow: 1;
}

/* ==========================================
   Custom Radio Layout for Modal Config
   ========================================== */
.pcfg-mode {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}
.pcfg-radio {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 10px;
  font-size: 12.5px;
  cursor: pointer;
  transition: var(--transition);
}
.pcfg-radio:hover {
  border-color: var(--muted);
}
.pcfg-radio em {
  color: var(--muted);
  font-style: normal;
  font-size: 10.5px;
  margin-left: auto;
}
.pcfg-radio.is-real {
  border-color: rgba(239, 68, 68, 0.25);
}
.pcfg-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.pcfg-file {
  margin-top: 12px;
  font-size: 10.5px;
  color: var(--muted);
  line-height: 1.4;
}
.pcfg-file code {
  color: var(--accent);
  font-family: var(--mono);
}

/* ==========================================
   Live Indicators & Micro-animations
   ========================================== */
.live-dot {
  font-size: 10.5px;
  font-weight: 700;
  padding: 0 8px;
  border-radius: 6px;
  letter-spacing: .04em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 1px solid transparent;
  height: 36px;
  text-transform: uppercase;
}
.live-dot.on {
  background: rgba(16, 185, 129, 0.08);
  color: var(--pos);
  border-color: rgba(16, 185, 129, 0.15);
}
.live-dot.off {
  background: rgba(148, 163, 184, 0.08);
  color: var(--muted);
  border-color: rgba(148, 163, 184, 0.15);
}
.live-dot.on::before {
  content: '●';
  animation: livePulse 1.4s infinite;
  margin-right: 1px;
}
@keyframes livePulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.3; }
  100% { transform: scale(1); opacity: 1; }
}

.mode-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg);
}
.mode-toggle .mode-btn {
  flex: 1;
  background: transparent;
  color: var(--muted);
  border: 0;
  cursor: pointer;
  font-size: 10.5px;
  font-weight: 700;
  padding: 0 10px;
  letter-spacing: .02em;
  text-transform: uppercase;
  transition: var(--transition);
}
.mode-toggle .mode-btn:hover {
  color: var(--text);
  background: rgba(255,255,255,0.03);
}
.mode-toggle .mode-btn.active {
  background: rgba(59, 130, 246, 0.18);
  color: #60a5fa;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.1) inset;
}
.mode-toggle .mode-btn + .mode-btn {
  border-left: 1px solid var(--border);
}


/* ==========================================
   MEDIA QUERIES (Up-scaling Responsiveness)
   ========================================== */

/* Small tablets / landscape phones (min-width: 600px) */
@media (min-width: 600px) {
  .params-form,
  .pcfg-form,
  .cmd-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Tablets (min-width: 768px) */
@media (min-width: 768px) {
  .topbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
  }
  .brand {
    width: auto;
  }
  .controls {
    width: auto;
    justify-content: flex-end;
    flex-grow: 0;
  }
  .controls > * {
    flex-grow: 0;
  }
  .refresh select {
    padding: 0 20px 0 0;
  }
  .customize {
    flex-direction: row;
    align-items: center;
    gap: 16px;
    padding: 10px 20px;
  }
  
  .board {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    padding: 16px;
  }
  
  .span-2,
  .span-all {
    grid-column: span 2;
  }

  .kpi-strip {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  }
  .kpi {
    padding: 12px 14px;
  }
  .kpi .value {
    font-size: 20px;
  }
  
  .wa-actions {
    flex-direction: row;
  }
  .wa-actions input {
    flex: 1;
  }
  .wa-actions button {
    width: auto;
  }
  .wa-cols {
    grid-template-columns: 1fr 1fr;
  }
  
  .pcfg-mode {
    flex-direction: row;
  }
  .pcfg-radio {
    flex: 1;
  }
  
  .modal-actions .btn {
    flex-grow: 0;
    min-width: 100px;
  }
}

/* Large Screens & Desktops (min-width: 1200px) */
@media (min-width: 1200px) {
  .board {
    grid-template-columns: repeat(3, 1fr);
    padding: 20px;
  }
  .span-2 {
    grid-column: span 2;
  }
  .span-all {
    grid-column: 1 / -1;
  }
  .kpi-strip {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }
  .kpi .value {
    font-size: 22px;
  }
  .prof-grid {
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  }
  .strat-grid {
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  }
}
.cmd-fields .toggle-field input[type="checkbox"] {
  appearance: none;
  width: 42px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  cursor: pointer;
  position: relative;
}
.cmd-fields .toggle-field input[type="checkbox"]::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 2px;
  top: 2px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform .15s ease, background .15s ease;
}
.cmd-fields .toggle-field input[type="checkbox"]:checked {
  background: var(--go);
}
.cmd-fields .toggle-field input[type="checkbox"]:checked::after {
  transform: translateX(20px);
  background: #fff;
}

.alert-banner {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 8px;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.alert-banner.hidden {
  display: none !important;
}
.alert-content {
  display: flex;
  align-items: center;
  gap: 12px;
}
.alert-icon {
  font-size: 24px;
}
.alert-text {
  color: var(--stop);
  font-weight: 500;
  font-size: 14px;
}

/* Reconciliation auto-fill: each prefilled field says where its value came
   from, colour-coded by how much the operator should trust it. */
.rec-source {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  line-height: 1.35;
  color: var(--muted);
}
.rec-source:empty { display: none; }
.rec-source-authoritative { color: var(--go); }
.rec-source-derived { color: var(--accent); }
.rec-source-inferred { color: var(--warn); }
.rec-autofill-ok {
  color: var(--go);
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
}
