:root {
  --bg-primary:    #0f0f0f;
  --bg-secondary:  #1a1a1a;
  --bg-tertiary:   #242424;
  --bg-hover:      #2a2a2a;
  --accent:        #8B1A2B;
  --accent-hover:  #A52238;
  --text-primary:  #E8E8E8;
  --text-secondary:#9a9a9a;
  --text-muted:    #666;
  --border:        #2a2a2a;
  --success:       #2ECC71;
  --danger:        #E74C3C;
  --warning:       #F39C12;
  --info:          #3498DB;
  --radius:        6px;
}

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

html, body {
  height: 100%;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  overflow: hidden;
}

/* ── Layout ── */
.container { display: flex; flex-direction: column; height: 100vh; padding: 16px; gap: 12px; }

.page-header { padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.page-header h1 { font-size: 20px; font-weight: 700; }
.subtitle { color: var(--text-secondary); font-size: 12px; margin-top: 2px; }

.layout { display: flex; flex: 1; gap: 16px; overflow: hidden; }

/* ── Panels ── */
.panel { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden; }
.panel-left  { width: 260px; flex-shrink: 0; }
.panel-right { flex: 1; }

.panel-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.panel-header h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-secondary); }

/* ── Instance list ── */
.instance-list { flex: 1; overflow-y: auto; list-style: none; padding: 6px; }
.instance-list li.item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 10px; border-radius: var(--radius);
  cursor: pointer; transition: background 0.1s;
}
.instance-list li.item:hover { background: var(--bg-hover); }
.instance-list li.item.active { background: var(--bg-tertiary); border-left: 3px solid var(--accent); }
.instance-list li.item .inst-name { flex: 1; font-weight: 500; }
.instance-list li.item .inst-id  { font-size: 11px; color: var(--text-muted); }
.instance-list li.item .inst-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); flex-shrink: 0; }
.instance-list li.item .inst-dot.connected { background: var(--success); }

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

/* ── Add form ── */
.add-form { padding: 12px; border-top: 1px solid var(--border); background: var(--bg-tertiary); }
.add-form h3 { font-size: 12px; font-weight: 600; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 10px; }
.form-group { margin-bottom: 8px; }
.form-group label { display: block; font-size: 11px; color: var(--text-secondary); margin-bottom: 4px; }
.form-group .hint { color: var(--text-muted); font-size: 10px; }
.form-group input, .form-group select {
  width: 100%; background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-primary); padding: 6px 8px;
  font-size: 13px; outline: none;
}
.form-group input:focus, .form-group select:focus { border-color: var(--accent); }
.form-actions { display: flex; gap: 6px; margin-top: 10px; }

/* ── Detail panel ── */
.empty-state-center { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--text-muted); }
#instance-detail { display: flex; flex-direction: column; height: 100%; overflow: hidden; }

.detail-header { display: flex; justify-content: space-between; align-items: flex-start; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.detail-header h2 { font-size: 16px; font-weight: 600; }
.vmix-link-row { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.vmix-link-row .label { color: var(--text-secondary); font-size: 11px; }
.link-pill {
  background: var(--bg-tertiary); color: var(--info); text-decoration: none;
  padding: 2px 8px; border-radius: 20px; font-size: 11px; font-family: monospace;
  border: 1px solid var(--border);
}
.link-pill:hover { border-color: var(--info); }

.host-status-row { display: flex; align-items: center; gap: 8px; padding: 8px 16px; border-bottom: 1px solid var(--border); font-size: 12px; color: var(--text-secondary); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }
.status-dot.online { background: var(--success); }
.status-dot.offline { background: var(--danger); }

.section-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.section-header h3 { font-size: 12px; font-weight: 600; text-transform: uppercase; color: var(--text-secondary); }
.legend { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-muted); }

.table-wrapper { flex: 1; overflow-y: auto; }
.input-table { width: 100%; border-collapse: collapse; }
.input-table th { padding: 8px 12px; text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; color: var(--text-muted); background: var(--bg-tertiary); position: sticky; top: 0; z-index: 1; border-bottom: 1px solid var(--border); }
.input-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.input-table tr:hover td { background: var(--bg-hover); }
.input-table tr.missing td { opacity: 0.5; }
.col-name { min-width: 160px; }
.col-type, .col-state { width: 90px; }
.col-check { width: 70px; text-align: center; }
.col-check td { text-align: center; }

.state-badge { display: inline-block; padding: 1px 6px; border-radius: 20px; font-size: 11px; }
.state-badge.running { background: rgba(46,204,113,0.15); color: var(--success); }
.state-badge.paused  { background: rgba(243,156,18,0.15); color: var(--warning); }
.state-badge.stopped { background: rgba(102,102,102,0.15); color: var(--text-muted); }

.save-bar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); background: var(--bg-secondary); }
.save-hint { font-size: 12px; color: var(--text-muted); }

/* ── Badges ── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-layout { background: rgba(139,26,43,0.2); color: #e86a7a; border: 1px solid rgba(139,26,43,0.4); }
.badge-pip    { background: rgba(52,152,219,0.2); color: #5dade2; border: 1px solid rgba(52,152,219,0.4); }
.badge-hint   { font-size: 11px; color: var(--text-muted); }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 4px; border: none; border-radius: var(--radius); cursor: pointer; font-size: 13px; font-weight: 500; padding: 6px 14px; transition: background 0.1s, opacity 0.1s; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-sm  { padding: 4px 10px; font-size: 12px; }
.btn-xs  { padding: 2px 6px; font-size: 11px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { filter: brightness(1.1); }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(1.1); }
.btn-ghost   { background: var(--bg-hover); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-tertiary); color: var(--text-primary); }

/* Checkbox styling */
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 20px; right: 20px; padding: 10px 18px;
  background: var(--bg-tertiary); color: var(--text-primary);
  border-radius: var(--radius); border: 1px solid var(--border);
  font-size: 13px; opacity: 0; transition: opacity 0.2s;
  z-index: 9999; pointer-events: none;
}
.toast.show { opacity: 1; }
.toast.success { border-color: var(--success); color: var(--success); }
.toast.error   { border-color: var(--danger);  color: var(--danger); }

/* ── Modals ── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal-box {
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius); width: 100%; max-width: 440px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.modal-header { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 15px; font-weight: 600; }
.modal-body { padding: 16px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }

/* Instance list items (dynamic, generated by JS) */
.instance-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 10px; border-radius: var(--radius);
  cursor: pointer; transition: background 0.1s;
}
.instance-item:hover { background: var(--bg-hover); }
.instance-item.active { background: var(--bg-tertiary); border-left: 3px solid var(--accent); }
.instance-item .inst-name { flex: 1; font-size: 13px; font-weight: 500; }
.instance-item .inst-id  { font-size: 11px; color: var(--text-muted); }
.instance-item .inst-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); flex-shrink: 0; }
.instance-item .inst-dot.connected { background: var(--success); }
.delete-btn {
  opacity: 0; background: none; border: none; color: var(--text-muted);
  cursor: pointer; padding: 3px; border-radius: 4px; transition: color 0.1s, opacity 0.1s;
}
.instance-item:hover .delete-btn { opacity: 1; }
.delete-btn:hover { color: var(--danger); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #444; }
