/* ─────────────────────────────────────────────────────────────────────────
   OpSignal Console — styles. Dark, Linear-like, tactical.
   ───────────────────────────────────────────────────────────────────────── */
:root {
  --bg:        #08090a;
  --panel:     #0d0e12;
  --panel-2:   #111318;
  --inset:     #0a0b0e;
  --border:    rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.14);
  --fg:        #f1f3f5;
  --muted:     #9aa3ad;
  --subtle:    #5d646e;
  --accent:    #7cb342;
  --accent-dim: rgba(124,179,66,0.14);
  --accent-line: rgba(124,179,66,0.40);
  --danger:    #e5484d;
  --danger-dim: rgba(229,72,77,0.13);
  --radius:    12px;
  --radius-sm: 8px;
  --ease:      cubic-bezier(0.16,1,0.3,1);
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
  --sans: "Inter", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--fg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* ambient green glow */
  background-image:
    radial-gradient(900px 520px at 75% -10%, rgba(124,179,66,0.06), transparent 60%),
    radial-gradient(700px 480px at 8% 110%, rgba(124,179,66,0.035), transparent 55%);
  background-attachment: fixed;
}
[hidden] { display: none !important; }
a { color: inherit; }
.mono { font-family: var(--mono); }
button { font-family: inherit; }

/* ── Brand ─────────────────────────────────────────────────────────────── */
.brand, .login-brand { display: flex; align-items: center; gap: 12px; }
.brand-text { display: flex; align-items: baseline; gap: 8px; }
.wordmark { font-weight: 700; letter-spacing: -0.02em; font-size: 16px; }
.tag {
  font-size: 10px; font-weight: 600; letter-spacing: 0.18em;
  color: var(--accent);
  border: 1px solid var(--accent-line);
  padding: 2px 6px; border-radius: 5px;
  background: var(--accent-dim);
  text-transform: uppercase;
}
.brand-logo, .login-logo { display: block; filter: drop-shadow(0 0 10px rgba(124,179,66,0.25)); }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--border-strong);
  background: var(--panel-2);
  color: var(--fg);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: background .15s var(--ease), border-color .15s var(--ease),
              transform .08s var(--ease), opacity .15s, box-shadow .15s var(--ease);
  white-space: nowrap; user-select: none;
}
.btn:hover { background: #16181e; border-color: var(--border-strong); }
.btn:active { transform: translateY(0.5px) scale(0.99); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn-block { width: 100%; }
.btn-primary {
  background: var(--accent); color: #0a1003; border-color: transparent; font-weight: 600;
  box-shadow: 0 1px 0 rgba(255,255,255,0.18) inset, 0 0 0 1px rgba(124,179,66,0.3);
}
.btn-primary:hover:not(:disabled) { background: #8bc34a; box-shadow: 0 0 22px -6px rgba(124,179,66,0.7), 0 1px 0 rgba(255,255,255,0.2) inset; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--muted); }
.btn-ghost:hover { background: rgba(255,255,255,0.04); color: var(--fg); }
.btn-danger { background: var(--danger-dim); border-color: rgba(229,72,77,0.4); color: #ff7a7e; }
.btn-danger:hover:not(:disabled) { background: var(--danger); color: #fff; border-color: transparent; }
.btn-icon { padding: 6px 9px; font-size: 12px; gap: 6px; }
.btn .spin { width: 13px; height: 13px; }

/* spinner */
.spin {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid currentColor; border-top-color: transparent;
  border-radius: 50%; animation: spin .6s linear infinite; opacity: 0.9;
}
@keyframes spin { to { transform: rotate(360deg); } }
.is-loading { pointer-events: none; }

/* ── Inputs ────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12px; font-weight: 500; color: var(--muted); }
.req { color: var(--accent); }
.input {
  width: 100%;
  background: var(--inset);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background .15s;
  outline: none;
}
.input::placeholder { color: var(--subtle); }
.input:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-dim); background: #0c0d11; }
.input.invalid { border-color: rgba(229,72,77,0.5); box-shadow: 0 0 0 3px var(--danger-dim); }
.hint { font-size: 11.5px; color: var(--subtle); min-height: 16px; transition: color .15s; }
.hint.error { color: #ff7a7e; }

/* ── Login ─────────────────────────────────────────────────────────────── */
.login-screen {
  min-height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 20px; padding: 24px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 24px 60px -20px rgba(0,0,0,0.8), 0 0 0 1px var(--border);
  animation: pop .35s var(--ease);
}
.login-card .login-brand { margin-bottom: 2px; }
.login-card .wordmark { font-size: 19px; }
.login-sub { margin: 0 0 6px; color: var(--muted); font-size: 12.5px; }
.login-error {
  background: var(--danger-dim); border: 1px solid rgba(229,72,77,0.35);
  color: #ff8b8e; padding: 8px 11px; border-radius: var(--radius-sm); font-size: 12.5px;
  animation: shake .35s var(--ease);
}
.login-card .btn-primary { margin-top: 4px; }
.login-foot { color: var(--subtle); font-size: 11px; letter-spacing: 0.08em; }
@keyframes shake { 0%,100%{transform:translateX(0)} 20%,60%{transform:translateX(-4px)} 40%,80%{transform:translateX(4px)} }
@keyframes pop { from { opacity: 0; transform: scale(0.97) translateY(6px); } to { opacity: 1; transform: none; } }

/* ── Topbar ────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(8,9,10,0.82);
  backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px;
}
.topbar-right { display: flex; align-items: center; gap: 12px; }
.who { color: var(--muted); font-size: 12px; }
.who::before { content: "● "; color: var(--accent); font-size: 9px; vertical-align: middle; }

/* tabs */
.tabs {
  max-width: 1080px; margin: 0 auto; padding: 0 24px;
  display: flex; gap: 4px;
}
.tab {
  background: none; border: none; color: var(--muted);
  padding: 10px 12px; font-size: 13px; font-weight: 500; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .15s, border-color .15s; display: inline-flex; align-items: center; gap: 7px;
}
.tab:hover { color: var(--fg); }
.tab.is-active { color: var(--fg); border-bottom-color: var(--accent); }
.tab-badge {
  background: var(--accent-dim); color: var(--accent); border: 1px solid var(--accent-line);
  font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 999px; font-family: var(--mono);
}

/* ── Layout ────────────────────────────────────────────────────────────── */
.container { max-width: 1080px; margin: 0 auto; padding: 28px 24px 64px; }
.tab-panel { animation: fade .2s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.section-title { font-size: 14px; font-weight: 600; margin: 0; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; }
.section-sub { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.count-pill {
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  border: 1px solid var(--border); padding: 1px 7px; border-radius: 999px; font-weight: 500;
}

/* ── Create card ───────────────────────────────────────────────────────── */
.create-card {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 32px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.create-head { margin-bottom: 16px; }
.create-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.create-foot {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  margin-top: 18px; flex-wrap: wrap;
}
.url-preview {
  display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1;
}
.url-preview-label { font-size: 11px; color: var(--subtle); text-transform: uppercase; letter-spacing: 0.1em; }
.url-preview-value {
  font-size: 13px; color: var(--accent);
  background: var(--inset); border: 1px solid var(--border);
  padding: 7px 11px; border-radius: var(--radius-sm);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: color .15s;
}
.url-preview-value.muted { color: var(--subtle); }

/* ── List head ─────────────────────────────────────────────────────────── */
.list-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }

/* ── Instances list ────────────────────────────────────────────────────── */
.inst { display: flex; flex-direction: column; gap: 10px; }
.inst-row {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px;
  display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center;
  transition: border-color .15s var(--ease), background .15s, transform .08s var(--ease);
}
.inst-row:hover { border-color: var(--border-strong); background: var(--panel-2); }
.inst-main { min-width: 0; }
.inst-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.inst-name { font-weight: 600; font-size: 14px; }
.inst-slug { font-family: var(--mono); font-size: 11.5px; color: var(--muted); background: var(--inset); border: 1px solid var(--border); padding: 1px 7px; border-radius: 5px; }
.inst-meta { display: flex; align-items: center; gap: 14px; margin-top: 7px; flex-wrap: wrap; }
.inst-url { font-family: var(--mono); font-size: 12px; color: var(--muted); text-decoration: none; transition: color .15s; }
.inst-url:hover { color: var(--accent); }
.inst-date { font-family: var(--mono); font-size: 11.5px; color: var(--subtle); }
.inst-actions { display: flex; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 999px;
  border: 1px solid; letter-spacing: 0.02em;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; }
.pill-running { color: var(--accent); border-color: var(--accent-line); background: var(--accent-dim); }
.pill-running .dot { background: var(--accent); box-shadow: 0 0 8px var(--accent); animation: pulse 2s infinite; }
.pill-stopped { color: var(--muted); border-color: var(--border); background: rgba(255,255,255,0.03); }
.pill-stopped .dot { background: var(--subtle); }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

/* ── Leads ─────────────────────────────────────────────────────────────── */
.lead {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 10px; transition: border-color .15s, background .15s;
}
.lead:hover { border-color: var(--border-strong); background: var(--panel-2); }
.lead-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.lead-name { font-weight: 600; }
.lead-date { font-family: var(--mono); font-size: 11.5px; color: var(--subtle); white-space: nowrap; }
.lead-fields { display: flex; gap: 6px 18px; flex-wrap: wrap; margin-top: 6px; font-size: 12.5px; }
.lead-fields span { color: var(--muted); }
.lead-fields a { color: var(--accent); text-decoration: none; }
.lead-fields a:hover { text-decoration: underline; }
.lead-msg { margin-top: 10px; color: var(--fg); font-size: 13px; background: var(--inset); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; white-space: pre-wrap; word-break: break-word; }
.lead-org { color: var(--subtle); font-weight: 400; font-size: 12px; }

/* ── Empty / skeleton ──────────────────────────────────────────────────── */
.empty {
  text-align: center; padding: 48px 24px; color: var(--muted);
  border: 1px dashed var(--border); border-radius: var(--radius); background: rgba(255,255,255,0.012);
}
.empty .empty-icon { font-size: 26px; opacity: 0.5; margin-bottom: 10px; }
.empty .empty-title { font-weight: 600; color: var(--fg); margin-bottom: 4px; }
.empty .empty-sub { font-size: 12.5px; }
.skel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); height: 64px; margin-bottom: 10px;
  background-image: linear-gradient(90deg, transparent, rgba(255,255,255,0.04), transparent);
  background-size: 200% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

/* ── Toasts ────────────────────────────────────────────────────────────── */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: flex; flex-direction: column; gap: 10px; max-width: min(360px, 92vw); }
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--panel-2); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 11px 13px; font-size: 13px;
  box-shadow: 0 12px 30px -10px rgba(0,0,0,0.7);
  animation: toast-in .28s var(--ease); border-left: 3px solid var(--muted);
}
.toast.out { animation: toast-out .25s var(--ease) forwards; }
.toast-ok { border-left-color: var(--accent); }
.toast-err { border-left-color: var(--danger); }
.toast-ico { font-size: 13px; line-height: 1.4; }
.toast-ok .toast-ico { color: var(--accent); }
.toast-err .toast-ico { color: var(--danger); }
.toast-body { color: var(--fg); }
@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(20px); } }

/* ── Modal / confirm ───────────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(4,5,6,0.66); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 24px;
  animation: fade .18s ease-out;
}
.modal {
  width: 100%; max-width: 440px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border-strong); border-radius: 16px;
  padding: 24px; box-shadow: 0 30px 70px -20px rgba(0,0,0,0.85);
  animation: pop .25s var(--ease);
}
.modal-title { font-size: 16px; font-weight: 700; margin: 0 0 6px; letter-spacing: -0.01em; }
.modal-sub { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.modal-warn {
  display: flex; gap: 9px; align-items: flex-start;
  background: var(--danger-dim); border: 1px solid rgba(229,72,77,0.3);
  color: #ffb3b5; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 12.5px; margin-bottom: 16px;
}
.modal-warn.accent { background: var(--accent-dim); border-color: var(--accent-line); color: #b8e08a; }

/* credentials block */
.cred-list { display: flex; flex-direction: column; gap: 12px; margin: 4px 0 0; }
.cred {
  display: flex; flex-direction: column; gap: 5px;
}
.cred-label { font-size: 11px; color: var(--subtle); text-transform: uppercase; letter-spacing: 0.08em; }
.cred-value {
  display: flex; align-items: center; gap: 8px;
  background: var(--inset); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 10px;
}
.cred-value code { font-family: var(--mono); font-size: 13px; color: var(--fg); flex: 1; overflow: hidden; text-overflow: ellipsis; word-break: break-all; }
.cred-value code.accent { color: var(--accent); }
.copy-btn {
  background: var(--panel-2); border: 1px solid var(--border); color: var(--muted);
  border-radius: 6px; padding: 4px 9px; font-size: 11px; cursor: pointer; white-space: nowrap;
  transition: all .15s; font-family: var(--mono);
}
.copy-btn:hover { color: var(--fg); border-color: var(--border-strong); }
.copy-btn.copied { color: var(--accent); border-color: var(--accent-line); background: var(--accent-dim); }

/* checkbox */
.checkbox { display: flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13px; color: var(--muted); margin-top: 14px; user-select: none; }
.checkbox input { appearance: none; width: 17px; height: 17px; border: 1px solid var(--border-strong); border-radius: 5px; background: var(--inset); cursor: pointer; position: relative; transition: all .15s; flex-shrink: 0; }
.checkbox input:checked { background: var(--danger); border-color: var(--danger); }
.checkbox input:checked::after { content: "✓"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 11px; font-weight: 700; }
.checkbox:hover { color: var(--fg); }

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .create-grid { grid-template-columns: 1fr; }
  .create-foot { flex-direction: column; align-items: stretch; }
  .create-foot .btn { width: 100%; }
  .inst-row { grid-template-columns: 1fr; }
  .inst-actions { justify-content: flex-start; }
  .topbar-inner { padding: 12px 16px; }
  .tabs { padding: 0 16px; }
  .container { padding: 20px 16px 56px; }
  .who { display: none; }
}
