:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #6d7892;
  --line: #e4e8f1;
  --paper: #f7f9fc;
  --panel: #ffffff;
  --accent: #2f6df6;
  --accent-strong: #2358d6;
  --accent-soft: #e8f1ff;
  --sidebar: #ffffff;
  --sidebar-line: #edf1f7;
  --warning: #b74c27;
  --shadow: 0 18px 48px rgba(33, 46, 76, 0.1);
  font-family: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--paper);
  color: var(--ink);
}

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

button,
.button {
  min-height: 38px;
  border: 1px solid var(--accent);
  border-radius: 7px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: white;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

button:hover,
.button:hover {
  background: var(--accent-strong);
}

.secondary {
  background: white;
  color: var(--accent-strong);
}

.secondary:hover {
  background: var(--accent-soft);
}

.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.ghost:hover {
  background: rgba(47, 109, 246, 0.08);
  color: var(--ink);
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  background: white;
  color: var(--ink);
}

input:focus,
select:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(47, 109, 246, 0.14);
}

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

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.shell {
  width: 100%;
  min-height: 100vh;
  margin: 0;
  padding: 0;
}

.hidden {
  display: none !important;
}

.login-pane {
  min-height: calc(100vh - 82px);
  display: grid;
  align-content: center;
  grid-template-columns: minmax(360px, 560px) minmax(360px, 430px);
  justify-content: center;
  gap: 92px;
}

.login-brand {
  align-self: center;
  position: relative;
  display: grid;
  gap: 14px;
}

.login-brand::after {
  content: "";
  width: 168px;
  height: 8px;
  margin-top: 10px;
  background:
    linear-gradient(90deg, var(--accent-strong) 0 46px, transparent 46px 56px, var(--accent) 56px 116px, transparent 116px 126px, #9fc1ff 126px);
}

.brand-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border: 2px solid var(--accent-strong);
  border-radius: 12px;
  background: #f4f7ff;
  color: var(--accent-strong);
  font-size: 28px;
  font-weight: 900;
  line-height: 1;
  box-shadow: 8px 8px 0 rgba(47, 109, 246, 0.12);
}

.brand-mark.small {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  font-size: 20px;
  box-shadow: 5px 5px 0 rgba(47, 109, 246, 0.12);
}

.login-brand h1 {
  max-width: 620px;
  margin: 0;
  color: #111827;
  font-size: 56px;
  font-weight: 900;
  line-height: 1.04;
  letter-spacing: 0;
  text-wrap: balance;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.login-form {
  display: grid;
  gap: 16px;
  align-self: center;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(232, 241, 255, 0.62), transparent 120px),
    var(--panel);
  box-shadow: 0 30px 70px rgba(33, 46, 76, 0.12);
}

.login-form-head {
  margin-bottom: 2px;
  display: grid;
  gap: 4px;
}

.login-form-head strong {
  font-size: 22px;
  line-height: 1.2;
}

.login-form-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.login-form input {
  min-height: 44px;
}

.login-form button[type="submit"] {
  min-height: 46px;
  margin-top: 4px;
  font-weight: 800;
}

.error {
  min-height: 20px;
  margin: 0;
  color: var(--warning);
  font-size: 13px;
}

.dashboard {
  min-height: 100vh;
  display: block;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 10;
  width: 248px;
  height: 100dvh;
  overflow: hidden;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: var(--sidebar);
  color: var(--ink);
  border-right: 1px solid var(--line);
  box-shadow: 10px 0 32px rgba(33, 46, 76, 0.08);
}

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

.sidebar-brand .eyebrow {
  margin-bottom: 2px;
  color: var(--muted);
}

.sidebar-brand strong {
  font-size: 18px;
  color: var(--ink);
}

.side-nav {
  display: grid;
  align-content: start;
  gap: 8px;
}

.side-nav a {
  min-height: 42px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: #52607a;
  font-weight: 800;
  text-decoration: none;
}

.side-nav a::before {
  content: "";
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  background: currentColor;
  opacity: 0.9;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 5h6'/%3E%3Cpath d='M9 9h6'/%3E%3Cpath d='M9 13h3'/%3E%3Cpath d='M5 3h14a1 1 0 0 1 1 1v16l-3-2-3 2-3-2-3 2-3-2-3 2V4a1 1 0 0 1 1-1Z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.side-nav a:hover,
.side-nav a.active {
  border-color: transparent;
  background: #f0f5ff;
  color: #1d4fd8;
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

.sidebar-footer .ghost {
  border-color: var(--line);
  background: transparent;
  color: #52607a;
}

.sidebar-footer .ghost:hover {
  background: #f4f7fb;
  color: var(--ink);
}

.workspace {
  width: calc(100% - 248px);
  min-width: 0;
  min-height: 100vh;
  margin-left: 248px;
  overflow-y: visible;
  overflow-x: hidden;
  padding: 28px 32px 40px;
  display: grid;
  gap: 16px;
  align-content: start;
}

.topbar-actions,
.filter-actions,
.pager {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.app-selector {
  width: min(360px, 100%);
}

.sidebar .app-selector {
  width: 100%;
}

.sidebar .app-selector select {
  border-color: var(--line);
  background: #f8fafc;
}

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

.metric {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 8px 22px rgba(33, 46, 76, 0.04);
}

.metric {
  min-height: 96px;
  padding: 18px;
  display: grid;
  gap: 10px;
}

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

.metric strong {
  font-size: 30px;
  line-height: 1;
}

.filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-bottom: 8px;
}

.filter-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-left: auto;
}

.filter-actions .button {
  min-height: 32px;
  padding: 0 14px;
}

.search-field {
  width: min(280px, 100%);
}

.search-field input {
  min-height: 36px;
  border-color: #dbe2ef;
  border-radius: 7px;
  padding: 0 12px 0 36px;
  background-color: #ffffff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2379859d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
  background-size: 16px;
  color: #24304a;
  font-size: 14px;
  box-shadow: 0 1px 2px rgba(33, 46, 76, 0.04);
}

.search-field input::placeholder {
  color: #7b879d;
}

.range-field {
  width: min(390px, 100%);
}

.range-control {
  min-height: 36px;
  display: grid;
  grid-template-columns: minmax(145px, 1fr) auto minmax(145px, 1fr);
  align-items: center;
  gap: 6px;
  padding: 0 9px;
  border: 1px solid #dbe2ef;
  border-radius: 7px;
  background: white;
  box-shadow: 0 1px 2px rgba(33, 46, 76, 0.04);
}

.range-control:focus-within {
  border-color: var(--accent);
  outline: 3px solid rgba(47, 109, 246, 0.14);
}

.range-control input {
  min-height: 34px;
  border: 0;
  padding: 0;
  background: transparent;
  color: #24304a;
  font-size: 14px;
}

.range-control input:focus {
  outline: 0;
  border-color: transparent;
}

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

.table-zone {
  overflow: hidden;
  padding: 23px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 18px 46px rgba(33, 46, 76, 0.08);
}

.table-header {
  min-height: 58px;
  padding: 0 0 16px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  border-bottom: 1px solid var(--line);
}

#resultCount {
  color: #263249;
  font-size: 15px;
  font-weight: 700;
}

.table-actions,
.table-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}

.table-footer {
  min-height: 62px;
  padding: 16px 0 0;
  border-top: 1px solid var(--line);
  background: transparent;
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  table-layout: fixed;
}

th:nth-child(1),
td:nth-child(1) {
  width: 178px;
  white-space: nowrap;
}

th:nth-child(2),
td:nth-child(2) {
  width: 230px;
}

th:nth-child(3),
td:nth-child(3) {
  width: 140px;
}

th:nth-child(4),
td:nth-child(4) {
  width: 330px;
}

th:nth-child(5),
td:nth-child(5) {
  width: 220px;
}

th:nth-child(6),
td:nth-child(6) {
  width: 260px;
}

th,
td {
  padding: 15px 23px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  background: transparent;
}

td {
  color: #263249;
  font-size: 15px;
  overflow-wrap: anywhere;
}

td:nth-child(2),
td:nth-child(4),
td:nth-child(5),
td:nth-child(6) {
  word-break: break-word;
}

.app-cell {
  font-weight: 700;
}

.status-pill {
  min-height: 24px;
  padding: 3px 10px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #eef2f8;
  color: #263249;
  font-size: 13px;
  font-weight: 700;
}

.device-cell {
  color: #3d4960;
}

tr[data-row-id] {
  cursor: pointer;
}

tr[data-row-id]:hover {
  background: #f8fbff;
}

.empty {
  color: var(--muted);
  text-align: center;
}

dialog {
  width: min(760px, calc(100vw - 30px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(23, 32, 26, 0.35);
}

.dialog-head {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

pre {
  max-height: 62vh;
  margin: 0;
  padding: 16px;
  overflow: auto;
  color: #24342b;
  background: #fbfcf8;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
}

@media (max-width: 1100px) {
  .login-pane {
    grid-template-columns: 1fr;
    display: grid;
    align-items: start;
  }

  .dashboard {
    min-height: 0;
  }

  .sidebar {
    position: static;
    width: auto;
    height: auto;
    min-height: 0;
    overflow: visible;
    grid-template-rows: auto;
    gap: 16px;
  }

  .workspace {
    width: 100%;
    margin-left: 0;
    height: auto;
    overflow: visible;
    padding: 22px 16px 34px;
  }

  .login-pane {
    gap: 34px;
  }

  .login-brand h1 {
    max-width: 560px;
    font-size: 44px;
  }

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

  .filters {
    display: flex;
  }
}

@media (max-width: 560px) {
  .shell {
    width: 100%;
  }

  .login-pane {
    min-height: 100vh;
    padding: 20px;
  }

  .login-brand h1 {
    font-size: 34px;
  }

  .brand-mark {
    width: 46px;
    height: 46px;
    font-size: 24px;
  }

  .filters,
  .filter-actions,
  .metrics {
    grid-template-columns: 1fr;
    display: grid;
  }

  .search-field,
  .range-field {
    width: 100%;
  }

  .range-control {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 4px 10px;
  }

  .table-header,
  .table-actions,
  .table-footer,
  .pager {
    display: grid;
    justify-items: stretch;
  }

  .button,
  button {
    width: 100%;
  }
}
