:root {
  --bg: #0d1326;
  --bg-soft: #151d37;
  --card: linear-gradient(180deg, #131b34 0%, #0e1529 100%);
  --stroke: #324170;
  --text: #eef3ff;
  --muted: #a9b6dd;
  --accent: #5f8bff;
  --accent-2: #24d7a1;
  --danger: #ff6b81;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top, rgba(95,139,255,.16), transparent 28%),
    linear-gradient(180deg, #0a1020 0%, #0d1326 100%);
}

body {
  min-height: 100vh;
}

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-shell {
  width: 100%;
  max-width: 440px;
}

.auth-card,
.panel {
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: 22px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .28);
}

.auth-card {
  padding: 28px;
}

.auth-brand h1,
.topbar h1 {
  margin: 6px 0;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--accent-2);
  font-size: 12px;
}

.auth-form,
.stack-form {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

input,
textarea,
button,
select {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  padding: 12px 14px;
  font: inherit;
}

input,
textarea,
select {
  background: rgba(13, 19, 38, .9);
  color: var(--text);
  outline: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(95, 139, 255, .18);
}

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

button {
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent) 0%, #7b63ff 100%);
  color: white;
  font-weight: 700;
  transition: .18s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(95, 139, 255, .18);
}

button:active {
  transform: scale(.98);
}

.ghost-button {
  width: auto;
  background: transparent;
  color: var(--text);
  border: 1px solid rgba(95, 139, 255, .22);
}

.danger-button {
  width: auto;
  background: linear-gradient(135deg, #b12c47 0%, #7d1c31 100%);
  color: #fff;
  border: 1px solid rgba(255, 107, 129, .35);
}

.status-line {
  min-height: 20px;
  color: var(--muted);
  margin: 0;
}

.app-body {
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.topbar h1 {
  font-size: 2rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 20px;
  align-items: start;
}

.panel {
  padding: 22px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

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

.broker-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
  margin: 8px 0 4px;
}

.broker-grid label,
.inline {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 14px;
}

.inline input,
.broker-grid input {
  width: auto;
  transform: scale(1.08);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  border-radius: 16px;
}

table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid rgba(50, 65, 112, .5);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  color: var(--muted);
  font-weight: 600;
}

.sort-button {
  width: auto;
  padding: 0;
  background: transparent;
  border: none;
  color: inherit;
  font-weight: 700;
}

.sort-button.active-sort {
  color: var(--accent-2);
}

tbody tr:hover {
  background: rgba(95, 139, 255, .08);
}

.pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.pill.on {
  background: rgba(36, 215, 161, .14);
  color: #8ff0ce;
}

.pill.off {
  background: rgba(255, 107, 129, .14);
  color: #ffb3bf;
}

.action-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.action-row button {
  padding: 8px 10px;
  border-radius: 10px;
}

.form-divider {
  height: 1px;
  background: rgba(50, 65, 112, .4);
  margin: 10px 0 2px;
}

.modal-shell {
  position: fixed;
  inset: 0;
  background: rgba(6, 10, 22, .72);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 1000;
}

.modal-shell.hidden {
  display: none;
}

.hidden {
  display: none !important;
}

.product-panel {
  margin-bottom: 20px;
}

.product-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.product-card {
  padding: 18px;
  border-radius: 18px;
  border: 1px solid rgba(95, 139, 255, .22);
  background: rgba(13, 19, 38, .92);
  cursor: pointer;
  transition: .18s ease;
}

.product-card:hover,
.product-card.active-product {
  border-color: var(--accent-2);
  box-shadow: 0 10px 28px rgba(36, 215, 161, .12);
  transform: translateY(-1px);
}

.modal-card {
  width: min(1100px, 100%);
  max-height: 88vh;
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: 22px;
  padding: 22px;
}

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

.detail-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(13, 19, 38, .9);
  border: 1px solid rgba(50, 65, 112, .45);
}

.detail-card strong {
  color: var(--accent-2);
}

.detail-wide {
  grid-column: 1 / -1;
}

.detail-stack {
  display: grid;
  gap: 10px;
}

.detail-actions {
  grid-column: 1 / -1;
}

@media (max-width: 980px) {
  .app-body {
    padding: 16px;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .split-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 18px;
  }

  .topbar h1 {
    font-size: 1.5rem;
  }

  .panel {
    padding: 18px;
    border-radius: 18px;
  }

  .panel-head {
    flex-direction: column;
    align-items: stretch;
  }

  .action-row {
    flex-direction: column;
  }

  .action-row button,
  .ghost-button,
  .danger-button {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .auth-body {
    padding: 14px;
  }

  .auth-card {
    padding: 22px 16px;
    border-radius: 18px;
  }

  .app-body {
    padding: 12px;
  }

  .panel {
    padding: 14px;
    border-radius: 16px;
  }

  .topbar h1 {
    font-size: 1.25rem;
    line-height: 1.2;
  }

  .eyebrow {
    font-size: 11px;
  }

  input,
  textarea,
  button,
  select {
    min-height: 46px;
    font-size: 16px;
    padding: 12px 14px;
  }

  textarea {
    min-height: 100px;
  }

  .broker-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .broker-grid label,
  .inline {
    font-size: 13px;
  }

  .table-wrap {
    margin-top: 8px;
  }

  table {
    min-width: 780px;
  }

  th,
  td {
    padding: 10px;
    font-size: 13px;
  }

  .pill {
    font-size: 11px;
    padding: 4px 8px;
  }
}

@media (max-width: 420px) {
  .broker-grid {
    grid-template-columns: 1fr;
  }

  .auth-brand h1,
  .topbar h1 {
    font-size: 1.1rem;
  }

  .panel-head h2,
  .panel-head h3 {
    font-size: 1rem;
  }

  .table-wrap {
    border-radius: 12px;
  }

  table {
    min-width: 700px;
  }
}


.filters-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.filters-bar input {
  flex: 1;
  min-width: 220px;
}

.filters-bar select {
  width: 180px;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.pagination-bar span {
  color: var(--muted);
  font-size: 14px;
}

button:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

@media (max-width: 640px) {
  .filters-bar {
    flex-direction: column;
  }

  .filters-bar input,
  .filters-bar select {
    width: 100%;
  }

  .pagination-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .pagination-bar button {
    width: 100%;
  }
}
