:root {
  color-scheme:light dark;
  --bg:#f4f6fb;
  --card:#fff;
  --rail:#151b2f;
  --text:#172039;
  --muted:#51617c;
  --line:#dce3ef;
  --accent:#4056d6;
  --on-accent:#fff;
  --active:#e9edff;
  --green:#15634b;
  --red:#a12d3e
}
@media(prefers-color-scheme:dark) {
  :root {
    --bg:#101522;
    --card:#181f31;
    --rail:#12182a;
    --text:#ecf0fd;
    --muted:#aab7d1;
    --line:#333e56;
    --accent:#a9b4ff;
    --on-accent:#132253;
    --active:#252f57;
    --green:#91dfbd;
    --red:#ffafba
  }
}
* {
  box-sizing:border-box
}
body {
  margin:0;
  background:var(--bg);
  color:var(--text);
  font:15px/1.55 system-ui,sans-serif
}
button,input,select {
  font:inherit
}
button {
  cursor:pointer;
  color:var(--text);
  border:1px solid var(--line);
  background:var(--card);
  border-radius:8px;
  padding:8px 13px;
  font-weight:600
}
button:hover {
  border-color:var(--accent)
}
button:disabled {
  opacity:.55;
  cursor:wait
}
.primary {
  background:var(--accent);
  color:var(--on-accent);
  border-color:var(--accent)
}
.quiet {
  background:transparent
}
.muted {
  color:var(--muted)
}
.error,.danger {
  color:var(--red)
}
.connected {
  color:var(--green)
}
[hidden] {
  display:none!important
}
#app {
  display:grid;
  min-height:100vh;
  grid-template-columns:230px minmax(0,1fr)
}
aside {
  background:var(--rail);
  color:#f1f4ff;
  padding:24px;
  display:flex;
  align-items:stretch;
  flex-direction:column;
  gap:18px
}
aside button {
  color:#e7edff;
  background:transparent;
  border-color:#3a4564;
  text-align:left
}
aside .quiet {
  margin-top:auto
}
.brand {
  display:flex;
  align-items:center;
  gap:10px;
  font-size:20px;
  font-weight:750;
  letter-spacing:-.02em
}
.brand b {
  display:grid;
  place-items:center;
  width:34px;
  height:34px;
  color:#fff;
  background:#5368e9;
  border-radius:10px
}
.aside-label {
  color:#aebbd7;
  font-size:13px;
  margin-top:14px
}
nav {
  display:grid;
  gap:8px
}
nav button[aria-current=page] {
  background:#2b3763;
  border-color:#5466a9
}
.dashboard {
  padding:clamp(24px,4vw,54px);
  max-width:1440px;
  width:100%;
  margin:0 auto 0 0
}
.heading,.toolbar,.modal-head,.modal-actions {
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px
}
.heading {
  margin-bottom:26px
}
.heading p {
  margin:4px 0 0
}
h1,h2 {
  margin:0;
  line-height:1.2;
  letter-spacing:-.035em
}
h1 {
  font-size:clamp(26px,4vw,38px)
}
h2 {
  font-size:22px
}
.toolbar {
  margin-bottom:16px
}
.card,dialog {
  background:var(--card);
  border:1px solid var(--line);
  border-radius:14px
}
.records {
  overflow:auto
}
.records p {
  margin:20px
}
.table {
  width:100%;
  border-collapse:collapse;
  text-align:left
}
.table th,.table td {
  padding:13px 16px;
  border-bottom:1px solid var(--line);
  vertical-align:middle
}
.table th {
  font-size:13px;
  color:var(--muted);
  background:var(--bg)
}
.table tr:last-child td {
  border-bottom:0
}
.actions {
  display:flex;
  flex-wrap:wrap;
  gap:6px
}
.actions button {
  font-size:13px;
  padding:5px 9px
}
.status {
  font-weight:650
}
.detail {
  display:block;
  font-size:13px;
  color:var(--muted);
  overflow-wrap:anywhere
}
.details-col {
  max-width:270px
}
.search {
  width:min(290px,100%)
}
label {
  display:grid;
  gap:5px;
  font-weight:600
}
input,select {
  width:100%;
  padding:8px 11px;
  border-radius:8px;
  background:var(--bg);
  color:var(--text);
  border:1px solid var(--line)
}
input[type=checkbox] {
  width:auto
}
.login {
  width:min(390px,calc(100% - 32px));
  margin:14vh auto 24px;
  padding:26px;
  display:grid;
  gap:15px
}
.login h1 {
  font-size:28px
}
#notice {
  margin-bottom:14px;
  color:var(--muted)
}
.sr {
  position:absolute;
  width:1px;
  height:1px;
  overflow:hidden;
  clip-path:inset(50%)
}
dialog {
  color:var(--text);
  width:min(560px,calc(100% - 24px));
  max-height:90vh;
  padding:22px
}
dialog::backdrop {
  background:#071124a6
}
#fields {
  display:grid;
  gap:12px;
  margin:16px 0
}
#fields p {
  margin:0
}
.modal-actions {
  justify-content:flex-end
}
.transport {
  display:grid;
  grid-template-columns:120px minmax(0,1fr) auto;
  gap:7px;
  margin-bottom:7px
}
.qr {
  width:min(230px,100%);
  height:auto;
  border-radius:8px
}
.log {
  max-height:320px;
  overflow:auto;
  white-space:pre-wrap;
  overflow-wrap:anywhere;
  background:var(--bg);
  padding:10px;
  border-radius:8px
}
.check {
  display:flex;
  gap:7px;
  align-items:center
}
.mobile-field-label {
  display: none;
}

@media (max-width: 730px) {
  :root {
    --bg: #f2f2f7;
    --card: #fff;
    --text: #17171a;
    --muted: #595960;
    --line: #dddde5;
    --accent: #0065d9;
    --on-accent: #fff;
    --active: #eaf3ff;
    --green: #176538;
    --red: #b3232b;
    --track: #e9e9ef;
    --selected: #fff;
    --shadow: #17171a15;
  }

  body {
    font-family: -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    -webkit-text-size-adjust: 100%;
  }

  #app {
    display: block;
    min-height: 100dvh;
  }

  aside {
    color: var(--text);
    background: var(--bg);
    padding: calc(12px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
      8px max(16px, env(safe-area-inset-left));
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
  }

  aside .brand {
    font-size: 19px;
  }

  .brand b {
    background: var(--accent);
    color: var(--on-accent);
  }

  .aside-label {
    display: none;
  }

  aside .quiet {
    grid-column: 2;
    grid-row: 1;
    margin: 0;
  }

  aside button {
    color: var(--accent);
    text-align: center;
    border-color: transparent;
  }

  nav {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 3px;
    padding: 3px;
    background: var(--track);
    border-radius: 13px;
  }

  nav button {
    min-width: 0;
    color: var(--text);
    padding: 6px;
    border-radius: 10px;
    font-size: 14px;
    overflow-wrap: anywhere;
  }

  nav button[aria-current=page] {
    background: var(--selected);
    border-color: transparent;
    box-shadow: 0 1px 4px var(--shadow);
  }

  button, input, select {
    min-height: 44px;
    min-width: 0;
    border-radius: 12px;
  }

  input, select {
    font-size: 16px;
  }

  button:focus-visible, input:focus-visible, select:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }

  .dashboard {
    min-width: 0;
    padding: 20px max(16px, env(safe-area-inset-right))
      calc(24px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  }

  .heading {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    margin-bottom: 14px;
  }

  h1 {
    font-size: clamp(30px, 8vw, 38px);
    font-weight: 750;
  }

  .heading .primary {
    width: 100%;
  }

  .toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }

  .search {
    width: 100%;
  }

  .search input, #refresh {
    background: var(--card);
  }

  .records {
    overflow: visible;
    border: 0;
    background: transparent;
  }

  .records p {
    margin: 0;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--card);
  }

  .table, .table td {
    display: block;
  }

  .table thead {
    display: none;
  }

  .table tbody {
    display: grid;
    gap: 10px;
  }

  .table tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    gap: 12px 10px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--card);
    box-shadow: 0 2px 4px var(--shadow);
  }

  .table td {
    min-width: 0;
    padding: 0;
    border: 0;
    overflow-wrap: anywhere;
  }

  .record-name {
    font-size: 17px;
    font-weight: 700;
  }

  .record-status {
    text-align: right;
  }

  .record-status .status {
    display: inline-block;
    max-width: 100%;
    padding: 3px 8px;
    border-radius: 10px;
    background: var(--track);
    font-size: 13px;
  }

  .record-status .status.connected {
    background: var(--active);
  }

  .record-status .detail {
    margin-top: 3px;
  }

  .mobile-field-label {
    display: block;
    margin-bottom: 2px;
    color: var(--muted);
    font-size: 13px;
  }

  .record-value {
    display: block;
    font-weight: 550;
  }

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

  .record-actions .actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
  }

  .actions button {
    background: var(--bg);
    color: var(--accent);
    font-size: 14px;
    overflow-wrap: anywhere;
  }

  .actions .danger {
    color: var(--red);
  }

  .login {
    border-radius: 20px;
    margin-top: max(28px, calc(14svh + env(safe-area-inset-top)));
  }

  dialog {
    position: fixed;
    inset: auto 0 0;
    width: 100%;
    max-width: none;
    max-height: 90vh;
    max-height: 90dvh;
    margin: 0;
    padding: 18px max(18px, env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom))
      max(18px, env(safe-area-inset-left));
    border-radius: 22px 22px 0 0;
    overscroll-behavior: contain;
  }

  .modal-head h2 {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  #close {
    flex: 0 0 44px;
    padding: 0;
    background: var(--bg);
    font-size: 22px;
  }

  #fields, .transport {
    grid-template-columns: minmax(0, 1fr);
  }

  #fields > *, .transport > * {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .transport {
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 14px;
  }

  .modal-actions {
    flex-wrap: wrap;
  }

  .modal-actions button {
    flex: 1 1 105px;
    overflow-wrap: anywhere;
  }
}

@media (max-width: 730px) and (prefers-color-scheme: dark) {
  :root {
    --bg: #101012;
    --card: #1c1c1e;
    --text: #f5f5f7;
    --muted: #b0b0b8;
    --line: #3c3c43;
    --accent: #80b7ff;
    --on-accent: #09203c;
    --active: #203229;
    --green: #9fe6b8;
    --red: #ff9ca1;
    --track: #2c2c2e;
    --selected: #46464b;
    --shadow: #0004;
  }
}
