:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #657083;
  --line: #dfe4ea;
  --panel: #ffffff;
  --soft: #f5f7fa;
  --brand: #d86016;
  --brand-dark: #9d3f0c;
  --nav: #16213a;
  --nav-active: #26395f;
  --blue: #3157d5;
  --green: #45b649;
  --yellow: #d99a00;
  --red: #ca3b35;
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--soft);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--nav);
  color: #fff;
  padding: 16px 12px;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 20px;
  letter-spacing: 0;
}

.brand span {
  color: #c7cfdd;
  font-size: 12px;
}

.main-nav {
  display: grid;
  gap: 6px;
  margin-top: 26px;
}

.nav-item {
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: #d9e2f2;
  padding: 12px 14px;
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  background: var(--nav-active);
  color: #fff;
}

.sidebar-foot {
  display: grid;
  gap: 8px;
  margin-top: auto;
  color: #c7cfdd;
  font-size: 13px;
}

.sidebar-foot a {
  color: #fff;
}

.workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(280px, 520px) auto;
  align-items: center;
  gap: 18px;
  min-height: 65px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.top-title strong,
.top-title span {
  display: block;
}

.top-title span {
  color: var(--muted);
  font-size: 12px;
}

.global-search {
  position: relative;
}

.global-search span {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 12px;
}

.global-search input {
  width: 100%;
  height: 40px;
  border: 1px solid #b9c2cf;
  border-radius: var(--radius);
  padding: 0 14px 0 66px;
}

.top-actions,
.toolbar,
.drawer-actions,
.modal-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.primary-button,
.ghost-button {
  min-height: 36px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 8px 14px;
  text-decoration: none;
}

.primary-button {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
  font-weight: 700;
}

.ghost-button {
  background: #fff;
  color: var(--ink);
}

.content-grid {
  display: grid;
  grid-template-columns: 280px minmax(480px, 1fr) 390px;
  min-height: 0;
}

.group-panel,
.main-panel,
.detail-panel {
  min-width: 0;
  overflow: auto;
}

.group-panel {
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 16px 12px;
}

.group-search {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px;
}

.group-list {
  display: grid;
  gap: 4px;
  margin-top: 14px;
}

.group-item {
  display: flex;
  justify-content: space-between;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  padding: 10px 12px;
  text-align: left;
  color: var(--ink);
}

.group-item.active,
.group-item:hover {
  background: #eef3ff;
  color: var(--blue);
}

.main-panel {
  background: #fbfcfe;
  padding: 26px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.view-heading h2,
.view-heading p {
  margin: 0;
}

.view-heading p,
.connect-card p,
.download-card p {
  color: var(--muted);
}

.support-layout {
  display: grid;
  gap: 18px;
}

.connect-card {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 360px;
  gap: 28px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 28px;
}

.eyebrow {
  color: var(--brand);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 12px;
}

.connect-card h1 {
  margin: 0;
  font-size: 32px;
}

.connect-form,
.device-modal {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

label input,
label select,
textarea {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 10px;
  color: var(--ink);
  background: #fff;
}

textarea {
  width: 100%;
  min-height: 82px;
  resize: vertical;
}

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

.metric,
.download-card,
.settings-panel,
.customer-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.metric {
  padding: 16px;
}

.metric span,
.metric strong {
  display: block;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  margin-top: 8px;
  font-size: 28px;
}

.device-table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: auto;
}

.device-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 840px;
}

.device-table th,
.device-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #eef1f5;
  text-align: left;
  font-size: 14px;
}

.device-table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.device-table tbody tr {
  background: #fff;
}

.device-table tbody tr:nth-child(2n) {
  background: #f7f9fc;
}

.device-table tbody tr.selected {
  background: #eef3ff;
}

.device-table td strong,
.device-table td span {
  display: block;
}

.device-table td span {
  color: var(--muted);
  font-size: 12px;
}

.status {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 7px;
  border-radius: 99px;
  background: #98a2b3;
}

.status.online {
  background: var(--green);
}

.status.idle {
  background: var(--yellow);
}

.status.offline {
  background: var(--red);
}

.copy-link,
.connect-link {
  border: 0;
  background: transparent;
  color: var(--blue);
  padding: 0;
}

.platform-pill {
  display: inline-grid;
  place-items: center;
  min-width: 70px;
  height: 24px;
  border-radius: 99px;
  background: #fff1e9;
  color: var(--brand-dark);
  font-weight: 700;
}

.detail-panel {
  border-left: 1px solid var(--line);
  background: var(--panel);
  padding: 22px;
}

.drawer-head {
  display: flex;
  gap: 12px;
  align-items: center;
}

.drawer-head h2,
.drawer-head p {
  margin: 0;
}

.drawer-head p {
  color: var(--muted);
}

.icon-device {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f1f4f8;
  color: var(--brand);
  font-weight: 900;
}

.drawer-actions {
  margin: 20px 0;
}

.drawer-section {
  border-top: 1px solid var(--line);
  padding: 18px 0;
}

.drawer-section.warning {
  border: 0;
  border-radius: var(--radius);
  background: #fff7df;
  padding: 14px;
}

.drawer-section h3 {
  margin: 0 0 12px;
}

.detail-row,
.settings-list div {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 10px;
  padding: 8px 0;
}

.detail-row span,
.settings-list span {
  color: var(--muted);
}

.mini-notes p {
  border-radius: var(--radius);
  background: var(--soft);
  padding: 10px;
}

.full {
  width: 100%;
  justify-content: center;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.download-card,
.customer-card,
.settings-panel {
  padding: 16px;
}

.download-card span {
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
}

.download-card strong,
.download-card code,
.customer-card strong,
.customer-card span {
  display: block;
  margin-top: 8px;
}

.customer-card {
  text-align: left;
}

.activity-list {
  display: grid;
  gap: 8px;
}

.activity-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 12px;
  text-align: left;
}

.activity-item strong,
.activity-item span {
  display: block;
}

.activity-item span {
  margin-top: 4px;
  color: var(--muted);
}

.settings-panel {
  max-width: 760px;
}

.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background: radial-gradient(circle at top left, #fff1e9, transparent 36%), var(--soft);
}

.login-card {
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 28px;
  box-shadow: 0 18px 50px rgba(23, 32, 42, 0.14);
}

.login-brand {
  margin-bottom: 22px;
}

.login-error {
  border-radius: var(--radius);
  background: #ffecea;
  color: #a5322d;
  padding: 10px 12px;
  margin: 12px 0;
}

.login-card form {
  display: grid;
  gap: 14px;
}

.client-download-page {
  min-height: 100vh;
  background: linear-gradient(180deg, #fff 0, #f5f7fa 100%);
  padding: 34px 18px;
}

.client-download-shell {
  width: min(840px, 100%);
  margin: 0 auto;
}

.client-download-brand {
  margin-bottom: 34px;
}

.client-download-brand span {
  color: var(--muted);
}

.client-download-heading {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.client-download-heading h1,
.client-download-heading p {
  margin: 0;
}

.client-download-heading h1 {
  font-size: 38px;
  line-height: 1.1;
}

.detected-label {
  display: inline-flex;
  width: fit-content;
  border: 1px solid #c9d7ff;
  border-radius: var(--radius);
  background: #eef3ff;
  color: var(--blue);
  padding: 8px 10px;
  font-size: 13px;
}

.download-code-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 14px;
  margin: 18px 0;
}

.client-download-list {
  display: grid;
  gap: 12px;
}

.client-download-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 18px;
}

.client-download-card.recommended {
  border-color: #efb68a;
  box-shadow: 0 10px 28px rgba(216, 96, 22, 0.12);
}

.client-download-card span {
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
}

.client-download-card h2,
.client-download-card p {
  margin: 6px 0 0;
}

.client-download-card p,
.client-download-note {
  color: var(--muted);
}

.client-download-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.client-download-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 138px;
  white-space: nowrap;
}

.client-download-button.disabled {
  cursor: default;
  opacity: 0.7;
}

.client-download-note {
  margin: 16px 0 0;
  font-size: 14px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(23, 32, 42, 0.36);
  padding: 18px;
}

.device-modal {
  width: min(520px, 100%);
  border-radius: var(--radius);
  background: #fff;
  padding: 22px;
}

.modal-actions {
  justify-content: flex-end;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  padding: 10px 14px;
  box-shadow: 0 12px 32px rgba(23, 32, 42, 0.24);
}

.empty-state,
.empty-detail {
  color: var(--muted);
  padding: 20px;
}

@media (max-width: 1180px) {
  .content-grid {
    grid-template-columns: 230px minmax(0, 1fr);
  }

  .detail-panel {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 820px) {
  .app-shell,
  .content-grid,
  .topbar,
  .connect-card,
  .metric-row {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  .main-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .client-download-card,
  .download-code-form {
    grid-template-columns: 1fr;
  }

  .client-download-actions {
    justify-content: stretch;
  }

  .client-download-button {
    width: 100%;
  }
}
