@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap");

* {
  box-sizing: border-box;
}
*::selection {
  background: #5c63ff;
  color: #fff;
}
html {
  scroll-behavior: smooth;
}
body {
  margin: 0;
  background: #07071a;
  color: #f4f5ff;
  font-family: "Inter", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  line-height: 1.5;
}
/* slim, professional scrollbars (no color change — reuses existing palette) */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #25284a;
  border-radius: 8px;
}
::-webkit-scrollbar-thumb:hover {
  background: #25284a;
}
.app {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: 230px;
  background: #09091f;
  border-right: 1px solid #25284a;
  padding: 24px 18px;
  position: fixed;
  inset: 0 auto 0 0;
}
.brand {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 32px;
  color: #fff;
  letter-spacing: 0.3px;
  padding: 0 6px;
}
.nav-btn {
  width: 100%;
  display: block;
  margin: 8px 0;
  padding: 13px 16px;
  border: 1px solid #25284a;
  background: #111434;
  color: #c9cdfc;
  border-radius: 10px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease,
    transform 0.12s ease;
}
.nav-btn:hover {
  transform: translateX(2px);
}
.nav-btn.active,
.nav-btn:hover {
  background: #1a1f4b;
  color: #fff;
  border-color: #5c63ff;
}
.main {
  margin-left: 230px;
  width: calc(100% - 230px);
  padding: 26px 28px;
}
.topbar {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.topbar h1 {
  margin: 0;
  font-size: 23px;
  font-weight: 700;
  letter-spacing: 0.2px;
}
.connection {
  font-size: 13px;
  color: #cdd1ff;
  display: flex;
  align-items: center;
  background: #11132f;
  border: 1px solid #24284f;
  padding: 7px 14px;
  border-radius: 999px;
}
.connection span {
  display: inline-block;
  width: 9px;
  height: 9px;
  background: #11e6a4;
  border-radius: 50%;
  box-shadow: 0 0 8px #11e6a4;
  margin-right: 8px;
}
.page {
  display: none;
}
.page.active {
  display: block;
}
.stats-grid {
  display: grid;
  gap: 14px;
  margin: 16px 0 22px;
}
.four {
  grid-template-columns: repeat(4, 1fr);
}
.three {
  grid-template-columns: repeat(3, 1fr);
}
.two {
  grid-template-columns: repeat(2, 1fr);
}
.stat-card,
.panel,
.device-card,
.modal-box .detail-grid > div {
  background: #11132f;
  border: 1px solid #24284f;
  border-radius: 14px;
  box-shadow: 0 0 18px rgba(47, 48, 113, 0.25);
  transition:
    box-shadow 0.2s ease,
    border-color 0.2s ease;
}
.stat-card {
  padding: 20px 22px;
}
.stat-card:hover {
  border-color: #25284a;
  box-shadow: 0 0 22px rgba(47, 48, 113, 0.38);
}
.stat-card small,
.detail-grid small {
  display: block;
  color: #7d82aa;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 1px;
  margin-bottom: 9px;
}
.stat-card strong {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.blue {
  color: #26a7ff !important;
}
.green {
  color: #14e39a !important;
}
.yellow {
  color: #ffc443 !important;
}
.red {
  color: #ff4d7a !important;
}
.panel {
  padding: 22px;
  margin-bottom: 20px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 16px;
}
.panel h2 {
  margin: 0 0 10px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.2px;
}
.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.right {
  justify-content: flex-end;
}
button {
  border: 0;
  border-radius: 9px;
  background: #1b2148;
  color: #fff;
  padding: 10px 16px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.2px;
  transition:
    filter 0.15s ease,
    transform 0.1s ease,
    box-shadow 0.15s ease;
}
button:hover {
  filter: brightness(1.15);
}
button:active {
  transform: translateY(1px) scale(0.99);
}
button:focus-visible {
  outline: 2px solid #5c63ff;
  outline-offset: 2px;
}
.danger {
  background: linear-gradient(135deg, #ff3b78, #ff6b38) !important;
}
.purple {
  background: linear-gradient(135deg, #b34dff, #e166ff) !important;
}
.green-btn {
  background: #0ea66f;
}
.yellow-btn {
  background: #c48a00;
}
.search,
input,
textarea,
select {
  width: 100%;
  background: #171b43;
  border: 1px solid #272d63;
  color: #fff;
  border-radius: 10px;
  padding: 12px 14px;
  outline: none;
  font-family: inherit;
  font-size: 14px;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}
.search:focus,
input:focus,
textarea:focus,
select:focus {
  border-color: #5c63ff;
  box-shadow: 0 0 0 3px rgba(92, 99, 255, 0.18);
}
.search::placeholder,
input::placeholder {
  color: #7d82aa;
}
textarea {
  min-height: 90px;
  resize: vertical;
}
label {
  display: block;
  margin: 12px 0;
  color: #c9cdfc;
  font-size: 13.5px;
  font-weight: 500;
}
small {
  color: #8e93bd;
}
.filters {
  display: grid;
  grid-template-columns: 1.5fr repeat(6, auto);
  gap: 8px;
  align-items: center;
  margin-bottom: 15px;
}
.table-wrap {
  overflow: auto;
  border-radius: 10px;
}
table {
  width: 100%;
  border-collapse: collapse;
}
th,
td {
  padding: 14px;
  border-bottom: 1px solid #22264e;
  text-align: left;
  font-size: 13.5px;
}
th {
  color: #7d82aa;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.8px;
  position: sticky;
  top: 0;
  background: #11132f;
  z-index: 1;
}
tbody tr {
  transition: background 0.15s ease;
}
tbody tr:hover {
  background: rgba(92, 99, 255, 0.06);
}
.badge,
.status {
  padding: 5px 10px;
  border-radius: 12px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.2px;
  background: #073d35;
  color: #15e19b;
}
.paused {
  background: #3d2b07;
  color: #ffbd37;
}
h2,
h3 {
  font-weight: 700;
  letter-spacing: 0.1px;
}
h3 {
  font-size: 15.5px;
  margin: 22px 0 12px;
}
.action-set {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
}
.action-set button {
  font-size: 12.5px;
  padding: 8px 12px;
  white-space: nowrap;
}
.action-set .test {
  background: #9439d2;
}
.action-set .stats {
  background: #16a9ee;
}
.action-set .start {
  background: #19c77b;
}
.action-set .start.started {
  background: #0d804e;
  box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.4);
}
.action-set .pause {
  background: #ffa600;
}
.action-set .pause.paused {
  background: #b37400;
  box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.4);
}
.action-set .clone {
  background: #0fa6ef;
}
.action-set .delete {
  background: #ff336e;
}
.device-grid {
  width: 100%;
}
.device-card {
  padding: 22px;
}
.device-controls {
  display: grid;
  gap: 14px;
  margin-bottom: 20px;
}
.device-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.device-top-row h3 {
  margin: 0;
  color: #fff;
  font-size: 17px;
  font-weight: 700;
}
.device-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}
.device-filter-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.device-filter {
  background: #111434;
  border: 1px solid #25284a;
  color: #c9cdfc;
  padding: 9px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease;
}
.device-filter.active,
.device-filter:hover {
  background: #1a1f4b;
  color: #fff;
  border-color: #5c63ff;
}
.device-table-wrap {
  overflow: auto;
  border-radius: 10px;
}
.device-table {
  width: 100%;
  border-collapse: collapse;
}
.device-table th,
.device-table td {
  padding: 14px 12px;
  border-bottom: 1px solid #22264e;
  text-align: left;
  font-size: 13.5px;
}
.device-table th {
  color: #7d82aa;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.8px;
  position: sticky;
  top: 0;
  background: #11132f;
}
.device-table tbody tr {
  transition: background 0.15s ease;
}
.device-table tbody tr:hover {
  background: rgba(92, 99, 255, 0.08);
}
.device-table td span {
  display: inline-block;
  color: #c9cdfc;
}
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(3px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 35px;
  z-index: 10;
  overflow: auto;
}
.modal.show {
  display: flex;
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
.modal-box {
  width: 760px;
  background: #0b0c25;
  border: 1px solid #2b2e5b;
  border-radius: 16px;
  padding: 10px;
  position: relative;
  box-shadow: 0 0 45px rgba(0, 0, 0, 0.45);
}
.modal-box.large {
  width: min(1100px, 96vw);
}
.modal-box h2 {
  font-size: 19px;
  font-weight: 700;
  margin-top: 0;
}
.close {
  position: absolute;
  right: 18px;
  top: 16px;
  background: transparent;
  font-size: 26px;
  color: #8f94c0;
  padding: 4px 10px;
  border-radius: 8px;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}
.close:hover {
  background: #171b43;
  color: #fff;
  filter: none;
}
.success-msg {
  background: #0b423b;
  border: 1px solid #0e715f;
  color: #b8fff0;
  padding: 16px;
  border-radius: 10px;
  margin: 18px 0;
  font-size: 14px;
  line-height: 1.55;
}
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin: 16px 0;
}
.detail-grid > div {
  padding: 16px;
}
.detail-grid b {
  display: block;
  margin-bottom: 4px;
  font-size: 14.5px;
}
.detail-grid span {
  color: #8e93bd;
  font-size: 12.5px;
}
pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: #07081a;
  border: 1px solid #1c214c;
  color: #0eaaff;
  border-radius: 9px;
  padding: 14px;
  font-size: 13px;
  line-height: 1.5;
}
.green-box {
  border-color: #0e8d78;
  color: #12e69f;
}
.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.chips span {
  background: #0c315d;
  color: #68c8ff;
  padding: 8px 11px;
  border-radius: 7px;
  font-size: 12.5px;
}
.chain {
  background: #07081a;
  border-radius: 12px;
  padding: 16px;
}
.chain p {
  border-bottom: 1px solid #22264e;
  padding-bottom: 12px;
  font-size: 13.5px;
  word-break: break-all;
}
.chain em {
  background: #74540b;
  color: #ffd25f;
  font-style: normal;
  padding: 5px 8px;
  border-radius: 7px;
  margin: 0 10px;
  font-size: 12.5px;
}
.chain .ok {
  background: #024b37;
  color: #14e39a;
}
.form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  align-items: end;
}
.form-row:has(label:nth-child(3)),
.form-row:nth-of-type(1) {
  grid-template-columns: repeat(3, 1fr);
}
.link-row,
.random-row {
  display: grid;
  grid-template-columns: 40px 1fr 80px 140px 50px;
  gap: 8px;
  align-items: center;
  margin: 10px 0;
}
.random-row {
  grid-template-columns: 1.3fr 0.7fr 0.6fr 0.9fr 1fr auto;
}
.checks {
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.total {
  float: right;
  color: #14e39a;
  font-size: 14px;
}
.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 18px;
}
.modal-actions button {
  flex: 1;
}
.settings-box {
  max-width: 560px;
}
.settings-box h2 {
  margin-top: 0;
}
.settings-box input {
  margin-bottom: 10px;
}
.settings-box p {
  color: #8e93bd;
  font-size: 13.5px;
}
.toast {
  position: fixed;
  right: 26px;
  top: 74px;
  background: #0dc37e;
  color: #eafff6;
  padding: 14px 18px;
  border-radius: 10px;
  display: none;
  z-index: 20;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.toast.show {
  display: block;
  animation: slideIn 0.2s ease;
}
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@media (max-width: 900px) {
  .sidebar {
    position: static;
    width: 100%;
    display: flex;
    gap: 8px;
    overflow: auto;
  }
  .app {
    display: block;
  }
  .main {
    margin: 0;
    width: 100%;
  }
  .four,
  .three,
  .two,
  .detail-grid,
  .device-grid,
  .filters,
  .form-row {
    grid-template-columns: 1fr;
  }
  .panel-head {
    display: block;
  }
  .sidebar .brand {
    display: none;
  }
  .nav-btn {
    min-width: 120px;
  }
  .link-row,
  .random-row {
    grid-template-columns: 1fr;
  }
  .modal {
    padding: 12px;
  }
}

/* =========================
   RESPONSIVE FIXES
========================= */

@media (max-width: 1200px) {
  .form-row,
  .detail-grid {
    grid-template-columns: 1fr 1fr;
  }
  .action-set button {
    height: 20px;
  }
}

@media (max-width: 992px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    height: auto;
    margin-bottom: 15px;
  }
  .device-summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .stats-grid.four {
    grid-template-columns: repeat(2, 1fr);
  }

  .stats-grid.three {
    grid-template-columns: repeat(2, 1fr);
  }

  .device-grid {
    grid-template-columns: 1fr 1fr;
  }

  .filters {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .link-row {
    grid-template-columns: 1fr;
  }

  .random-row {
    grid-template-columns: 1fr;
  }

  .modal-box {
    width: 95%;
  }
}

@media (max-width: 768px) {
  .app {
    display: block;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    width: 100%;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    background: #09091f;
    border-bottom: 1px solid #25284a;
    height: 50px;
  }

  .brand {
    display: none;
  }

  .menu-toggle {
    background: none;
    border: none;
    color: #f4f5ff;
    font-size: 24px;
    cursor: pointer;
    padding: 5px 10px;
    margin-right: 10px;
    flex-shrink: 0;
  }

  .menu-toggle:hover {
    color: #26a7ff;
  }

  .nav-menu {
    display: none;
    position: absolute;
    position: fixed;
    top: 50px;
    left: 0;
    right: 0;
    background: #09091f;
    border-bottom: 1px solid #25284a;
    flex-direction: column;
    z-index: 101;
    max-height: calc(100vh - 50px);
    overflow-y: auto;
  }

  .nav-menu.active {
    display: flex;
  }

  .nav-btn {
    width: 100%;
    text-align: left;
    margin: 0;
    padding: 12px 20px;
    border: none;
    background: transparent;
    color: #a9aac9;
    font-size: 13px;
    cursor: pointer;
    border-bottom: 1px solid #25284a;
    flex-shrink: 0;
  }

  .nav-btn:hover {
    background: #0f0f2e;
    color: #f4f5ff;
  }

  .nav-btn.active {
    background: #1a1a3a;
    color: #26a7ff;
    border-left: 3px solid #26a7ff;
    padding-left: 17px;
  }

  .main {
    width: 100%;
    margin-left: 0;
    padding: 15px;
    padding-top: 60px;
  }

  .panel {
    padding: 15px;
  }

  .panel-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .actions {
    width: 100%;
  }

  .actions button {
    flex: 1;
    min-width: 120px;
  }

  .stats-grid.four,
  .stats-grid.three,
  .stats-grid.two {
    grid-template-columns: 1fr;
  }

  .device-grid {
    grid-template-columns: 1fr;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .checks {
    grid-template-columns: 1fr;
  }

  .table-wrap {
    overflow-x: auto;
  }

  table {
    min-width: 900px;
  }

  .modal {
    padding: 10px;
  }

  .modal-box,
  .modal-box.large {
    width: 100%;
    max-width: 100%;
    padding: 16px;
    margin-top: 20px;
  }

  .toast {
    right: 10px;
    left: 10px;
    width: auto;
    top: auto;
    bottom: 20px;
  }
}

/* Tablet and Desktop - Show nav menu as horizontal */
@media (min-width: 769px) {
  .menu-toggle {
    display: none;
  }

  .nav-menu {
    display: flex !important;
    position: static !important;
    flex-direction: column !important;
    background: transparent !important;
    border: none !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    z-index: auto !important;
  }

  .nav-btn {
    width: 100% !important;
    text-align: left !important;
    margin: 10px 0 !important;
    padding: 14px 16px !important;
    border: 1px solid #25284a !important;
    background: #111434 !important;
    color: #c9cdfc !important;
    font-size: auto !important;
    cursor: pointer !important;
    border-bottom: auto !important;
    flex-shrink: auto !important;
  }

  .nav-btn:hover {
    background: #1a1f4b !important;
    color: #fff !important;
    border-color: #5c63ff !important;
  }

  .nav-btn.active {
    background: #1a1f4b !important;
    color: #fff !important;
    border-color: #5c63ff !important;
    border-left: 1px solid #25284a !important;
    padding-left: 16px !important;
  }
}

@media (max-width: 480px) {
  .topbar h1 {
    font-size: 20px;
  }

  .stat-card {
    padding: 15px;
  }

  .stat-card strong {
    font-size: 22px;
  }

  th,
  td {
    padding: 10px;
    font-size: 12px;
  }

  button {
    width: 100%;
  }

  /* Mobile: keep action buttons horizontal and non-fixed so they don't push content */
  .action-set {
    flex-direction: row;
    overflow-x: auto;
    gap: 8px;
    padding: 6px 0;
    background: transparent;
    position: static;
  }

  .action-set button {
    min-width: 56px;
    height: 36px;
    padding: 0 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 12px;
  }

  .modal-actions {
    flex-direction: column;
  }
}

#actbar {
  display: flex !important;
}
