:root {
  color-scheme: light;
  --bg: #f7f8f8;
  --panel: #ffffff;
  --panel-soft: #f0f3f2;
  --text: #17201c;
  --muted: #69756f;
  --line: #dbe2df;
  --brand: #0f7b63;
  --brand-strong: #075c49;
  --danger: #b42318;
  --warning: #a15c07;
  --shadow: 0 18px 44px rgba(17, 24, 39, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

#app {
  min-height: 100vh;
}

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

button {
  border: 0;
  cursor: pointer;
}

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

.sidebar {
  background: #101714;
  color: #f8fbfa;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: grid;
  justify-items: start;
  gap: 12px;
}

.brand-logo {
  width: 50px;
  height: 50px;
  display: block;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.brand-name {
  color: #ffffff;
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
}

.brand-product {
  color: #aab8b2;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.02em;
}

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

.sidebar .muted {
  color: #aab8b2;
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav button {
  text-align: left;
  color: #dce6e2;
  background: transparent;
  border-radius: 8px;
  padding: 11px 12px;
}

.nav button.active,
.nav button:hover {
  background: #1b2723;
  color: #ffffff;
}

.main {
  padding: 28px;
  max-width: 1280px;
  width: 100%;
}

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

.topbar h2 {
  margin: 0 0 6px;
  font-size: 28px;
  letter-spacing: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: var(--panel);
  color: var(--muted);
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--warning);
}

.dot.on {
  background: var(--brand);
}

.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.span-4 {
  grid-column: span 4;
}

.span-5 {
  grid-column: span 5;
}

.span-7 {
  grid-column: span 7;
}

.span-8,
.span-12 {
  grid-column: span 12;
}

.panel h3 {
  margin: 0 0 14px;
  font-size: 16px;
}

.metric {
  font-size: 30px;
  font-weight: 750;
}

.actions,
.form-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  padding: 10px 14px;
  background: var(--brand);
  color: white;
  min-height: 42px;
}

.button.secondary {
  background: var(--panel-soft);
  color: var(--text);
}

.button.danger {
  background: #fff1f0;
  color: var(--danger);
}

.button.danger-solid {
  background: var(--danger);
  color: #ffffff;
}

.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 13px;
}

.field label {
  font-size: 13px;
  color: #52605a;
  font-weight: 650;
}

.input,
.textarea,
.select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: white;
  color: var(--text);
  outline: none;
}

.textarea {
  min-height: 120px;
  resize: vertical;
}

.textarea.compact {
  min-height: 86px;
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 123, 99, 0.12);
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(247, 248, 248, 0.96)),
    radial-gradient(circle at 50% 0%, rgba(15, 123, 99, 0.12), transparent 34%),
    var(--bg);
}

.login-card {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 22px 70px rgba(16, 23, 20, 0.12);
  padding: 34px;
  animation: loginEnter 420ms ease both;
}

.login-brand {
  display: grid;
  justify-items: center;
  gap: 18px;
  margin-bottom: 28px;
  text-align: center;
}

.login-logo {
  width: 86px;
  height: 86px;
  display: block;
}

.login-brand h1 {
  margin: 0 0 7px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  column-gap: 7px;
  row-gap: 2px;
  font-size: clamp(23px, 6vw, 27px);
  line-height: 1.15;
}

.login-brand p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.login-copy {
  display: grid;
  gap: 5px;
  justify-items: center;
  margin-bottom: 18px;
  text-align: center;
}

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

.login-copy strong {
  font-size: 17px;
}

.pin-group {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 22px;
}

.pin-input {
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfc;
  color: var(--text);
  font-size: 24px;
  font-weight: 750;
  text-align: center;
  outline: none;
}

.pin-input:focus {
  border-color: var(--brand);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(15, 123, 99, 0.12);
}

.login-button {
  width: 100%;
  min-height: 46px;
}

.login-card.is-submitting {
  pointer-events: none;
}

.login-card.is-submitting .login-button {
  opacity: 0.72;
}

.qr-wrap {
  display: grid;
  place-items: center;
  min-height: 280px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.qr-wrap img {
  width: min(320px, 100%);
  height: auto;
}

.list {
  display: grid;
  gap: 10px;
}

.list-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  background: #fff;
}

.list-item strong {
  display: block;
  margin-bottom: 4px;
}

.token {
  font-family: "SFMono-Regular", Consolas, monospace;
  overflow-wrap: anywhere;
  background: var(--panel-soft);
  border-radius: 8px;
  padding: 12px;
  font-size: 13px;
}

.param-list {
  display: grid;
  gap: 10px;
}

.param-list div {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.param-list div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.param-list strong {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
}

.param-list span {
  color: var(--muted);
  line-height: 1.45;
}

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

.doc-header h3 {
  margin: 0;
}

.code-block {
  margin: 0;
  overflow-x: auto;
  border-radius: 8px;
  background: #101714;
  color: #eef8f5;
  padding: 15px;
  font-size: 13px;
  line-height: 1.55;
}

.code-block code {
  font-family: "SFMono-Regular", Consolas, monospace;
  white-space: pre;
}

.notice {
  border-left: 3px solid var(--brand);
  background: #eef8f5;
  color: #23443b;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 14px;
}

.safe-mode {
  display: grid;
  gap: 4px;
  border: 1px solid #cfe9df;
  border-radius: 8px;
  background: #f2fbf7;
  color: #17493c;
  padding: 12px;
  margin-bottom: 14px;
}

.safe-mode strong {
  font-size: 14px;
}

.safe-mode span {
  color: #42685e;
  font-size: 13px;
  line-height: 1.45;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  background: #101714;
  color: white;
  padding: 12px 14px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-width: 360px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(16, 23, 20, 0.48);
  backdrop-filter: blur(5px);
  opacity: 0;
  transition: opacity 180ms ease;
}

.modal {
  width: min(420px, 100%);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 24px 80px rgba(16, 23, 20, 0.2);
  padding: 20px;
  opacity: 0;
  transform: translateY(10px) scale(0.98);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.modal-backdrop.is-open {
  opacity: 1;
}

.modal-backdrop.is-open .modal {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.modal-icon {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #eef8f5;
  color: var(--brand);
  font-weight: 800;
}

.modal-icon.danger {
  background: #fff1f0;
  color: var(--danger);
}

.modal-content h2 {
  margin: 2px 0 7px;
  font-size: 18px;
}

.modal-content p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.modal-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

.hidden {
  display: none;
}

@keyframes loginEnter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 16px;
  }

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

  .nav {
    grid-auto-flow: column;
    overflow-x: auto;
  }

  .main {
    padding: 18px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .span-4,
  .span-5,
  .span-7,
  .span-8,
  .span-12 {
    grid-column: span 12;
  }
}

@media (max-width: 560px) {
  .list-item,
  .actions,
  .form-row {
    align-items: stretch;
    flex-direction: column;
  }

  .login-card {
    padding: 26px 20px;
  }

  .pin-group {
    gap: 7px;
  }

  .pin-input {
    border-radius: 8px;
    font-size: 20px;
  }

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

  .modal-actions {
    flex-direction: column-reverse;
  }

  .param-list div {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .doc-header {
    align-items: stretch;
    flex-direction: column;
  }
}
