:root {
  --black: #050505;
  --panel: rgba(9, 11, 17, 0.78);
  --panel-strong: rgba(4, 5, 8, 0.92);
  --blue: #005dff;
  --blue-soft: #1f75ff;
  --text: #ffffff;
  --muted: #a7b0c0;
  --line: rgba(0, 93, 255, 0.24);
  --gray: #20242d;
  --good: #43e6a6;
  --warn: #fbbf24;
  --bad: #fb7185;
  --cyan: #38bdf8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: #000;
  overflow-x: hidden;
}

button, input, select { font: inherit; }
button { cursor: pointer; }

#plexus {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: none;
  opacity: 0;
}

.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  display: none;
}

.shell {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  padding: 24px;
}

.glass {
  background: linear-gradient(180deg, rgba(15, 17, 23, 0.82), rgba(0, 0, 0, 0.7));
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255,255,255,.08);
  backdrop-filter: blur(22px);
}

.hidden { display: none !important; }

.login-view {
  min-height: calc(100vh - 48px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 430px;
  gap: 44px;
  align-items: center;
  width: min(1180px, 100%);
  margin: 0 auto;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark strong {
  display: block;
  font-size: 20px;
  text-transform: uppercase;
  letter-spacing: 0;
  color: #fff;
  text-shadow: 0 0 18px rgba(255,255,255,.24);
}

.brand-mark small, .security-note, .panel p, .hero-copy p, .metric-card small {
  color: var(--muted);
}

.brand-logo {
  width: 58px;
  height: 58px;
  display: block;
  object-fit: contain;
  flex: 0 0 auto;
  filter: drop-shadow(0 0 18px rgba(255,255,255,.18)) drop-shadow(0 0 26px rgba(0,93,255,.28));
}

.brand-logo.small {
  width: 42px;
  height: 42px;
}

.hero-copy {
  margin-top: 120px;
  max-width: 780px;
}

.eyebrow {
  display: inline-flex;
  color: #e8edf8;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
  text-shadow: 0 0 18px rgba(0,93,255,.55);
}

.hero-copy h1 {
  margin: 18px 0 18px;
  font-size: clamp(42px, 6vw, 76px);
  line-height: .96;
  letter-spacing: 0;
  text-shadow: 0 0 28px rgba(255,255,255,.14);
}

.hero-copy p {
  max-width: 650px;
  font-size: 18px;
  line-height: 1.7;
}

.trust-strip {
  margin-top: 48px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.trust-strip span, .live-dot, .pill {
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(0, 93, 255, 0.13);
  color: #eef4ff;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
}

.login-card {
  border-radius: 8px;
  padding: 30px;
  border-top: 1px solid rgba(255,255,255,.2);
}

.form-head {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 26px;
}

.form-head h2, .panel h3, .topbar h2, .owner-hero h2, .empty-state h2 {
  margin: 0;
}

.form-head p {
  margin: 4px 0 0;
  color: var(--muted);
}

label {
  display: grid;
  gap: 8px;
  margin: 16px 0;
  color: #d6deeb;
  font-weight: 700;
  font-size: 13px;
}

input, select, textarea {
  width: 100%;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px;
  background: rgba(5, 5, 5, 0.72);
  color: var(--text);
  padding: 14px 15px;
  outline: none;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

input:focus, select:focus, textarea:focus {
  border-color: rgba(59,130,246,.8);
  box-shadow: 0 0 0 4px rgba(37,99,235,.18);
}

.field-hint {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.primary-btn, .outline-btn, .ghost-btn, .icon-btn, .table button, .link-btn {
  border: 0;
  border-radius: 8px;
  color: white;
  font-weight: 800;
}

.primary-btn {
  width: 100%;
  padding: 15px 18px;
  background: linear-gradient(135deg, #004ee8, #006dff 56%, #ffffff 180%);
  box-shadow: 0 14px 36px rgba(0,93,255,.36), inset 0 1px 0 rgba(255,255,255,.24);
}

.primary-btn:disabled,
button:disabled {
  cursor: wait;
  opacity: .62;
}

.support-btn {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin-top: 12px;
  padding: 14px 16px;
  border-radius: 8px;
  color: #dfffee;
  text-decoration: none;
  font-weight: 800;
  background: rgba(67, 230, 166, .11);
  border: 1px solid rgba(67, 230, 166, .28);
  box-shadow: 0 0 28px rgba(67,230,166,.08);
}

.support-btn::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 14px var(--good);
}

#loginForm:has(#roleSelect option[value="owner"]:checked) #supportLink {
  display: flex !important;
}

.primary-btn.slim, .outline-btn, .ghost-btn {
  width: auto;
  padding: 10px 14px;
}

.outline-btn, .ghost-btn, .table button, .link-btn {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.12);
}

.link-btn {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.ghost-btn {
  margin-top: auto;
}

.login-help {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  min-height: 42px;
  margin-top: 10px;
  padding: 10px 14px;
  text-align: center;
  text-decoration: none;
  background: rgba(255,255,255,.055);
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: none;
}

.app-view {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 20px;
  min-height: calc(100vh - 48px);
}

.sidebar {
  border-radius: 8px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  position: sticky;
  top: 24px;
  height: calc(100vh - 48px);
  min-width: 0;
}

.brand-mark.compact .brand-logo { width: 44px; height: 44px; }

nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #c7d2e5;
  text-align: left;
  padding: 12px;
  font-weight: 700;
}

.nav-item.active, .nav-item:hover {
  background: rgba(0,93,255,.18);
  border-color: rgba(0,93,255,.38);
  color: white;
}

.workspace {
  display: grid;
  gap: 20px;
  min-width: 0;
}

.topbar {
  border-radius: 8px;
  padding: 18px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
}

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

.live-dot::before {
  content: "";
  width: 7px;
  height: 7px;
  display: inline-block;
  border-radius: 50%;
  margin-right: 8px;
  background: var(--good);
  box-shadow: 0 0 16px var(--good);
}

.screen { display: none; }
.active-screen { display: grid; gap: 20px; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.metric-card, .panel, .table-panel, .owner-hero, .empty-state, .action-card {
  border-radius: 8px;
}

.metric-card {
  padding: 18px;
  min-height: 138px;
  display: grid;
  align-content: space-between;
}

.metric-card span, .action-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric-card strong {
  font-size: 40px;
  letter-spacing: 0;
}

.warning strong { color: var(--warn); }

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, .75fr);
  gap: 16px;
}

.panel, .table-panel, .owner-hero, .empty-state {
  padding: 20px;
  min-width: 0;
}

.table-panel {
  overflow: hidden;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.panel p, .owner-hero p {
  margin: 6px 0 0;
}

.icon-btn {
  width: 38px;
  height: 38px;
  background: rgba(0,93,255,.16);
  border: 1px solid rgba(0,93,255,.34);
}

.status-list {
  display: grid;
  gap: 10px;
}

.status-list div {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 13px;
  border-radius: 8px;
  background: rgba(255,255,255,.045);
  border: 1px solid rgba(255,255,255,.07);
}

.status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.connected { background: var(--good); box-shadow: 0 0 18px var(--good); }
.pending { background: var(--warn); box-shadow: 0 0 18px var(--warn); }
.offline { background: var(--bad); box-shadow: 0 0 18px var(--bad); }

.bar-chart {
  height: 260px;
  display: flex;
  align-items: end;
  gap: 12px;
  padding: 20px;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(0,93,255,.1), rgba(255,255,255,.03));
}

.bar-chart span {
  flex: 1;
  height: var(--h);
  min-height: 28px;
  border-radius: 8px 8px 3px 3px;
  background: linear-gradient(180deg, #ffffff, #006dff 34%, rgba(0,93,255,.24));
  box-shadow: 0 0 28px rgba(0,93,255,.32);
}

code {
  color: #cfe3ff;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.table {
  display: grid;
  gap: 8px;
  overflow-x: auto;
  max-width: 100%;
  min-width: 0;
  padding-bottom: 2px;
}

.table-row {
  min-width: 720px;
  display: grid;
  grid-template-columns: 1.2fr 1fr .8fr .8fr .7fr;
  align-items: center;
  gap: 14px;
  padding: 13px 14px;
  border-radius: 8px;
  background: rgba(255,255,255,.045);
  border: 1px solid rgba(255,255,255,.06);
}

.table-row span {
  min-width: 0;
}

.table-row small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.clients-row {
  grid-template-columns: 1.2fr 1.15fr .85fr .7fr 1fr;
}

.signup-row {
  grid-template-columns: 1.1fr 1fr 1.15fr .7fr 1fr;
}

.request-summary {
  display: grid;
  gap: 6px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid rgba(59,130,246,.22);
  background: rgba(59,130,246,.08);
}

.request-summary span,
.request-summary small {
  color: var(--muted);
}

.bots-row {
  grid-template-columns: 1fr 1fr 1fr .9fr 1.5fr;
}

.finance-table .table-row {
  min-width: 1180px;
}

.finance-row {
  grid-template-columns: 1.05fr .7fr .75fr .95fr .95fr .95fr .8fr 1.35fr;
}

.leads-admin-row .table-row {
  min-width: 900px;
  grid-template-columns: 1fr .9fr 1.2fr 1fr .75fr 1fr;
}

.owner-table .table-row {
  min-width: 760px;
  grid-template-columns: 1fr 1fr 1fr .8fr 1fr;
}

.table-head {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.pill { padding: 6px 10px; justify-self: start; }
.pill.ok { color: #b8ffe3; border-color: rgba(67,230,166,.35); background: rgba(67,230,166,.12); }
.pill.wait { color: #ffe7a3; border-color: rgba(251,191,36,.35); background: rgba(251,191,36,.12); }
.pill.bad { color: #ffd0d7; border-color: rgba(251,113,133,.35); background: rgba(251,113,133,.12); }

.row-actions, .inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.row-actions button {
  padding: 8px 10px;
  white-space: nowrap;
}

.filter-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0 16px;
}

.filter-row input,
.filter-row select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(5, 5, 5, .44);
  color: var(--text);
  padding: 11px 12px;
  outline: none;
}

.owner-hero {
  display: flex;
  justify-content: space-between;
  gap: 22px;
  align-items: center;
  background:
    linear-gradient(135deg, rgba(0,93,255,.18), rgba(5,5,5,.55)),
    var(--panel);
}

.owner-hero h2 {
  font-size: clamp(28px, 4vw, 46px);
  max-width: 760px;
  line-height: 1.05;
}

.connection-badge {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 8px;
  background: rgba(67,230,166,.1);
  border: 1px solid rgba(67,230,166,.25);
  font-weight: 800;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.action-card {
  border: 1px solid rgba(255,255,255,.1);
  color: white;
  padding: 18px;
  text-align: left;
  min-height: 112px;
  display: grid;
  align-content: space-between;
}

.action-card:hover {
  border-color: rgba(59,130,246,.55);
  transform: translateY(-2px);
}

.qr-panel {
  display: grid;
}

.qr-code {
  width: 190px;
  aspect-ratio: 1;
  border-radius: 8px;
  margin: 6px 0 16px;
  background:
    linear-gradient(90deg, #fff 10px, transparent 10px) 0 0 / 24px 24px,
    linear-gradient(#fff 10px, transparent 10px) 0 0 / 24px 24px,
    #050505;
  border: 12px solid white;
  box-shadow: 0 0 42px rgba(59,130,246,.3);
}

.qr-muted {
  opacity: .48;
  filter: saturate(.45);
}

ol {
  margin: 0;
  padding-left: 21px;
  color: #d6deeb;
  line-height: 1.8;
}

.simple-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.simple-metrics div {
  padding: 18px;
  border-radius: 8px;
  background: rgba(255,255,255,.045);
  border: 1px solid rgba(255,255,255,.07);
}

.simple-metrics strong {
  display: block;
  font-size: 32px;
}

.simple-metrics span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.empty-state {
  min-height: 560px;
  display: grid;
  place-items: center;
  text-align: center;
  align-content: center;
  gap: 14px;
}

.empty-state p {
  max-width: 560px;
  color: var(--muted);
  line-height: 1.7;
}

.empty-inline {
  display: grid;
  gap: 6px;
  padding: 22px;
  border-radius: 8px;
  background: rgba(255,255,255,.045);
  border: 1px solid rgba(255,255,255,.08);
}

.empty-inline b {
  font-size: 16px;
}

.empty-inline span {
  color: var(--muted);
  line-height: 1.6;
}

.empty-orbit {
  width: 130px;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.34);
  background: radial-gradient(circle, rgba(0,93,255,.38), transparent 56%);
  box-shadow: 0 0 60px rgba(0,93,255,.28);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.settings-card {
  display: grid;
  gap: 2px;
}

.settings-card .primary-btn {
  margin-top: 12px;
}

.whatsapp-guide {
  display: grid;
  gap: 16px;
}

.setup-steps {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.setup-steps div {
  min-height: 92px;
  display: grid;
  gap: 9px;
  align-content: start;
  padding: 14px;
  border-radius: 8px;
  background: rgba(255,255,255,.045);
  border: 1px solid rgba(255,255,255,.08);
}

.setup-steps b {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #dbeafe;
  background: rgba(37,99,235,.28);
  border: 1px solid rgba(59,130,246,.3);
}

.setup-steps span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.setup-steps .done {
  background: rgba(67,230,166,.08);
  border-color: rgba(67,230,166,.22);
}

.setup-steps .done b {
  color: #052e1d;
  background: var(--good);
  border-color: transparent;
}

.log-list {
  display: grid;
  gap: 10px;
}

.log-list div {
  display: grid;
  gap: 4px;
  padding: 13px;
  border-radius: 8px;
  background: rgba(255,255,255,.045);
  border: 1px solid rgba(255,255,255,.06);
}

.log-list span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.access-log div {
  gap: 5px;
}

.access-log small {
  color: var(--muted);
  line-height: 1.45;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 32px));
  padding: 14px 16px;
  border-radius: 8px;
  color: white;
  font-weight: 800;
  background: linear-gradient(135deg, rgba(0,93,255,.95), rgba(0,0,0,.96));
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: 0 18px 52px rgba(0,0,0,.42), 0 0 32px rgba(0,93,255,.3);
}

.toast.error {
  background: linear-gradient(135deg, rgba(220,38,38,.96), rgba(0,0,0,.96));
}

.auth-page {
  min-height: 100vh;
  place-items: center;
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.68);
  backdrop-filter: blur(8px);
}

.modal {
  position: relative;
  z-index: 1;
  width: min(620px, 100%);
  max-height: min(820px, calc(100vh - 40px));
  overflow: auto;
  border-radius: 8px;
  padding: 22px;
}

.modal form {
  display: grid;
  gap: 2px;
}

@media (max-width: 980px) {
  .shell { padding: 14px; }
  .login-view, .app-view { grid-template-columns: 1fr; }
  .hero-copy { margin-top: 64px; }
  .sidebar {
    position: static;
    height: auto;
  }
  nav {
    display: flex;
    overflow-x: auto;
    max-width: 100%;
  }
  .nav-item {
    flex: 0 0 138px;
  }
  .metric-grid, .quick-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid, .settings-grid, .setup-steps { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .login-view { gap: 24px; }
  .hero-copy h1 { font-size: 38px; }
  .login-card, .panel, .table-panel, .owner-hero, .empty-state { padding: 16px; }
  .topbar, .owner-hero { align-items: stretch; flex-direction: column; }
  .top-actions { justify-content: space-between; }
  .metric-grid, .quick-actions, .simple-metrics, .filter-row { grid-template-columns: 1fr; }
  .status-list div { grid-template-columns: 14px minmax(0, 1fr); }
  .status-list small { grid-column: 2; }
}

body[data-theme="light"] {
  --panel: rgba(255,255,255,.86);
  --panel-strong: rgba(255,255,255,.96);
  --text: #0f172a;
  --muted: #64748b;
  color: var(--text);
  background: #000;
}

body[data-theme="light"] .glass,
body[data-theme="light"] .panel,
body[data-theme="light"] .table-panel,
body[data-theme="light"] .metric-card,
body[data-theme="light"] .owner-hero,
body[data-theme="light"] .empty-state,
body[data-theme="light"] .action-card,
body[data-theme="light"] .modal {
  color: #0f172a;
  background: linear-gradient(180deg, rgba(255,255,255,.94), rgba(246,250,255,.88));
  border-color: rgba(148,163,184,.28);
  box-shadow: 0 18px 58px rgba(15,23,42,.12), inset 0 1px 0 rgba(255,255,255,.9);
}

body[data-theme="light"] .sidebar {
  background: linear-gradient(180deg, #07111f, #020617);
}

body[data-theme="light"] input,
body[data-theme="light"] select,
body[data-theme="light"] textarea {
  color: #0f172a;
  background: rgba(255,255,255,.9);
  border-color: rgba(148,163,184,.42);
}

body[data-theme="light"] .login-card {
  color: #fff;
  background: linear-gradient(180deg, rgba(7,17,31,.94), rgba(2,6,23,.9));
}

body[data-theme="light"] .login-card input,
body[data-theme="light"] .login-card select {
  color: #fff;
  background: rgba(2,6,23,.72);
}
