/* ============================================================
   一人一码 · 基础样式
   ============================================================ */
:root {
  --brand: #0f766e;
  --brand-deep: #0b4f4a;
  --brand-dark: #0b2420;
  --brand-soft: #e9f5f1;
  --ink: #15201e;
  --ink-2: #263632;
  --muted: #6a7a74;
  --muted-2: #8a9a94;
  --line: #e4eae7;
  --line-strong: #d3ddd8;
  --bg: #f4f6f4;
  --surface: #ffffff;
  --surface-soft: #f8faf9;
  --danger: #d92d20;
  --danger-soft: #fef3f2;
  --warn: #b45309;
  --warn-soft: #fffaeb;
  --ok: #067647;
  --ok-soft: #ecfdf3;
  --info: #175cd3;
  --info-soft: #eff8ff;
  --shadow-xs: 0 1px 2px rgba(15, 35, 30, 0.04);
  --shadow-sm: 0 1px 2px rgba(15, 35, 30, 0.04), 0 4px 12px rgba(15, 35, 30, 0.04);
  --shadow-md: 0 8px 30px rgba(15, 35, 30, 0.08);
  --shadow-lg: 0 24px 70px rgba(8, 30, 25, 0.16);
  --radius-xs: 8px;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --sidebar-w: 248px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, p, ul, ol, figure {
  margin: 0;
}

ul, ol {
  padding: 0;
}

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  text-decoration: none;
}

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

button {
  cursor: pointer;
}

img, svg {
  display: block;
  max-width: 100%;
}

code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  background: #eef3f1;
  color: #24534b;
  padding: 0.15em 0.42em;
  border-radius: 5px;
}

::selection {
  background: #bfe8dd;
  color: #073b35;
}

/* Scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: #c4d2cc transparent;
}
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-thumb {
  background: #c4d2cc;
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: 99px;
}
::-webkit-scrollbar-track {
  background: transparent;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  --btn-bg: var(--surface);
  --btn-color: var(--ink);
  --btn-border: var(--line-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--btn-border);
  border-radius: 10px;
  background: var(--btn-bg);
  color: var(--btn-color);
  font-weight: 600;
  font-size: 13.5px;
  line-height: 1;
  white-space: nowrap;
  transition: background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, transform 0.12s ease;
  user-select: none;
}
.btn:hover {
  background: #f7faf8;
  border-color: #bfcec7;
}
.btn:active {
  transform: translateY(1px);
}
.btn:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.22);
  outline-offset: 1px;
}
.btn:disabled,
.btn.is-disabled {
  opacity: 0.5;
  pointer-events: none;
}
.btn svg {
  flex: none;
}
.btn-primary {
  --btn-bg: var(--brand);
  --btn-color: #fff;
  --btn-border: var(--brand);
  box-shadow: 0 1px 2px rgba(11, 79, 74, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}
.btn-primary:hover {
  background: #0d6a63;
  border-color: #0d6a63;
}
.btn-dark {
  --btn-bg: #162a26;
  --btn-color: #fff;
  --btn-border: #162a26;
}
.btn-dark:hover {
  background: #213b36;
  border-color: #213b36;
}
.btn-soft {
  --btn-bg: var(--brand-soft);
  --btn-color: #0b5f57;
  --btn-border: transparent;
}
.btn-soft:hover {
  background: #dcf0ea;
  border-color: transparent;
}
.btn-ghost {
  --btn-bg: transparent;
  --btn-border: transparent;
  --btn-color: var(--muted);
}
.btn-ghost:hover {
  background: #eef2f0;
  border-color: transparent;
  color: var(--ink);
}
.btn-danger {
  --btn-bg: #fff;
  --btn-color: var(--danger);
  --btn-border: #f3c7c2;
}
.btn-danger:hover {
  background: var(--danger-soft);
  border-color: #eaa8a0;
}
.btn-danger-solid {
  --btn-bg: var(--danger);
  --btn-color: #fff;
  --btn-border: var(--danger);
}
.btn-danger-solid:hover {
  background: #b42318;
  border-color: #b42318;
}
.btn-sm {
  height: 32px;
  padding: 0 11px;
  font-size: 12.5px;
  border-radius: 8px;
  gap: 6px;
}
.btn-lg {
  height: 48px;
  padding: 0 22px;
  font-size: 15px;
  border-radius: 12px;
}
.btn-block {
  width: 100%;
}
.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 9px;
  color: var(--muted);
  border-color: transparent;
  background: transparent;
}
.btn-icon:hover {
  color: var(--ink);
  background: #eef2f0;
  border-color: transparent;
}
.btn-icon.danger:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

/* ============================================================
   Forms
   ============================================================ */
.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}
.field-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12.8px;
  font-weight: 600;
  color: #3d4c47;
  letter-spacing: 0.01em;
}
.field-label i {
  font-style: normal;
  color: var(--danger);
}
.field-hint {
  font-size: 11.8px;
  color: var(--muted-2);
  line-height: 1.55;
}
.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input-wrap:focus-within {
  border-color: #65a99f;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.11);
}
.input-wrap > svg {
  margin-left: 12px;
  color: #8b9a95;
  flex: none;
}
.input-wrap input {
  flex: 1;
  min-width: 0;
  height: 42px;
  border: 0;
  background: transparent;
  padding: 0 12px;
  outline: none;
  font-size: 14px;
}
.input-wrap > svg + input {
  padding-left: 9px;
}
.input-wrap input::placeholder {
  color: #a3b0ab;
}
.input-wrap .pw-toggle {
  border: 0;
  background: transparent;
  color: #8b9a95;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  margin-right: 2px;
}
.input-wrap .pw-toggle:hover {
  color: var(--ink);
  background: #f2f5f3;
}

.input,
.select,
.textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  outline: none;
  font-size: 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input,
.select {
  height: 42px;
  padding: 0 12px;
}
.textarea {
  padding: 10px 12px;
  min-height: 92px;
  resize: vertical;
  line-height: 1.65;
}
.input:focus,
.select:focus,
.textarea:focus {
  border-color: #65a99f;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.11);
}
.input::placeholder,
.textarea::placeholder {
  color: #a3b0ab;
}
.select {
  appearance: none;
  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='%236a7a74' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 34px;
}
.form-grid {
  display: grid;
  gap: 16px;
}
.form-grid.two {
  grid-template-columns: 1fr 1fr;
}
.form-grid.three {
  grid-template-columns: repeat(3, 1fr);
}
.form-error {
  padding: 9px 12px;
  border-radius: 9px;
  background: var(--danger-soft);
  border: 1px solid #f5c6c0;
  color: #a5251b;
  font-size: 12.8px;
  line-height: 1.5;
}

/* Switch */
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.switch .track {
  width: 40px;
  height: 23px;
  border-radius: 99px;
  background: #d5ded9;
  transition: background 0.18s ease;
  flex: none;
  position: relative;
}
.switch .track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.3, 1.2);
}
.switch input:checked + .track {
  background: var(--brand);
}
.switch input:checked + .track::after {
  transform: translateX(17px);
}
.switch input:focus-visible + .track {
  outline: 3px solid rgba(15, 118, 110, 0.22);
  outline-offset: 2px;
}
.switch .switch-text {
  font-size: 13px;
  color: #3d4c47;
}

/* ============================================================
   Badges / chips
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 23px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}
.badge-ok {
  color: var(--ok);
  background: var(--ok-soft);
}
.badge-off {
  color: #667085;
  background: #f2f4f7;
}
.badge-warn {
  color: var(--warn);
  background: var(--warn-soft);
}
.badge-info {
  color: var(--info);
  background: var(--info-soft);
}
.badge-plain {
  color: #4b5a55;
  background: #eef2f0;
  font-weight: 500;
}
.badge-plain::before {
  display: none;
}
.chip {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 9px;
  border-radius: 99px;
  background: #f0f5f3;
  color: #3f5750;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}

/* ============================================================
   Avatar
   ============================================================ */
.avatar {
  --avatar-size: 40px;
  width: var(--avatar-size);
  height: var(--avatar-size);
  border-radius: 50%;
  overflow: hidden;
  flex: none;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #d9eee7, #b9ded5);
  color: #11655d;
  font-weight: 700;
  font-size: calc(var(--avatar-size) * 0.38);
  letter-spacing: -0.02em;
  border: 1px solid rgba(15, 118, 110, 0.1);
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ============================================================
   Toast
   ============================================================ */
.toast-root {
  position: fixed;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: min(92vw, 440px);
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 100%;
  padding: 11px 15px;
  background: #142622;
  color: #f2f7f5;
  border-radius: 11px;
  box-shadow: 0 12px 40px rgba(8, 30, 25, 0.26);
  font-size: 13px;
  line-height: 1.5;
  pointer-events: auto;
  animation: toast-in 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}
.toast svg {
  flex: none;
  margin-top: 1px;
}
.toast.ok svg {
  color: #6ee7b7;
}
.toast.error {
  background: #3b1412;
}
.toast.error svg {
  color: #fda29b;
}
.toast.warn svg {
  color: #fcd34d;
}
.toast.is-out {
  animation: toast-out 0.2s ease forwards;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(-6px) scale(0.98); }
}

/* ============================================================
   Modal / dialog
   ============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(9, 26, 22, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fade-in 0.18s ease;
  overflow-y: auto;
}
.modal {
  width: min(520px, 100%);
  background: #fff;
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.24s cubic-bezier(0.16, 1, 0.3, 1);
  max-height: calc(100dvh - 48px);
  display: flex;
  flex-direction: column;
}
.modal.modal-lg {
  width: min(760px, 100%);
}
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px 0;
}
.modal-head h3 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.modal-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12.8px;
}
.modal-body {
  padding: 18px 24px 22px;
  overflow-y: auto;
}
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding: 14px 24px 20px;
  border-top: 1px solid var(--line);
}
.modal-close {
  border: 0;
  background: transparent;
  color: #93a19c;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  flex: none;
}
.modal-close:hover {
  background: #f1f4f2;
  color: var(--ink);
}
.confirm-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--danger-soft);
  color: var(--danger);
  margin-bottom: 14px;
}
.confirm-icon.warn {
  background: var(--warn-soft);
  color: var(--warn);
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============================================================
   Skeleton / spinner / empty
   ============================================================ */
.skeleton {
  background: linear-gradient(90deg, #edf1ef 25%, #f6f8f7 37%, #edf1ef 63%);
  background-size: 400% 100%;
  animation: skeleton 1.3s ease infinite;
  border-radius: 8px;
}
@keyframes skeleton {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}
.spinner {
  width: 17px;
  height: 17px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex: none;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 56px 24px;
  color: var(--muted);
}
.empty-icon {
  width: 62px;
  height: 62px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: #eef4f1;
  color: #86a29a;
  margin-bottom: 16px;
}
.empty h4 {
  color: var(--ink);
  font-size: 15px;
  font-weight: 650;
  margin-bottom: 5px;
}
.empty p {
  font-size: 12.8px;
  max-width: 340px;
  line-height: 1.65;
}
.empty .btn {
  margin-top: 18px;
}

/* ============================================================
   Boot screen
   ============================================================ */
.boot-screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  color: var(--muted);
  font-size: 13px;
}
.boot-screen img {
  border-radius: 14px;
  box-shadow: var(--shadow-md);
}
.boot-spinner {
  width: 26px;
  height: 26px;
  border: 2.5px solid #cfe1db;
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ============================================================
   Utilities
   ============================================================ */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
  letter-spacing: -0.02em;
}
.muted {
  color: var(--muted);
}
.nowrap {
  white-space: nowrap;
}
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 720px) {
  .form-grid.two,
  .form-grid.three {
    grid-template-columns: 1fr;
  }
  .modal-backdrop {
    padding: 12px;
    align-items: flex-end;
  }
  .modal {
    width: 100%;
    max-height: calc(100dvh - 24px);
    border-radius: 20px;
  }
  .modal-head {
    padding: 20px 18px 0;
  }
  .modal-body {
    padding: 16px 18px 20px;
  }
  .modal-foot {
    padding: 13px 18px 18px;
  }
  .toast-root {
    top: 12px;
  }
}
[hidden] {
  display: none !important;
}
