:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #061c17;
  color: #f2fbf7;
  font-synthesis: none;
  --bg: #061c17;
  --surface: #0b2a22;
  --surface-strong: #10372d;
  --surface-soft: #123c31;
  --line: rgba(181, 225, 207, 0.14);
  --muted: #9bb8ad;
  --accent: #56e1a3;
  --accent-strong: #31cb8a;
  --accent-ink: #032318;
  --danger: #ff8c83;
  --warning: #ffd280;
  --shadow: 0 18px 46px rgba(0, 12, 9, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background:
    radial-gradient(circle at 85% -5%, rgba(57, 186, 131, 0.22), transparent 34%),
    linear-gradient(180deg, #08261f 0%, var(--bg) 38%);
  color: #f2fbf7;
  -webkit-font-smoothing: antialiased;
}

.auth-gate {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: calc(20px + env(safe-area-inset-top)) 18px calc(20px + env(safe-area-inset-bottom));
  overflow-y: auto;
  background: rgba(4, 25, 20, 0.96);
}

.auth-gate[hidden] {
  display: none;
}

.auth-card {
  width: min(100%, 430px);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(18, 60, 49, 0.98), rgba(9, 39, 32, 0.98));
  box-shadow: var(--shadow);
}

.auth-card h1 {
  margin: 5px 0 0;
  font-size: 25px;
}

.auth-copy,
.auth-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.auth-copy {
  margin: 7px 0 20px;
}

.auth-hint {
  margin: 13px 4px 0;
  text-align: center;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
  color: var(--muted);
  font-size: 11px;
}

.auth-divider::before,
.auth-divider::after {
  height: 1px;
  flex: 1;
  background: var(--line);
  content: "";
}

.passkey-button {
  width: 100%;
}

button,
input,
select {
  font: inherit;
}

button,
a,
select {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

.app-shell {
  width: min(100%, 620px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(18px + env(safe-area-inset-top)) 20px 14px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.topbar-button {
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 11px;
}

.topbar h1,
.section-heading h2,
.hero-card h2,
.confirm-dialog h2 {
  margin: 2px 0 0;
  letter-spacing: -0.025em;
}

.topbar h1 {
  font-size: 22px;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.mode-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 11px;
  border: 1px solid rgba(86, 225, 163, 0.3);
  border-radius: 999px;
  background: rgba(86, 225, 163, 0.12);
  color: var(--accent);
  font-size: 12px;
  font-weight: 750;
}

.mode-badge.is-loading {
  color: var(--muted);
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.mode-badge.is-demo {
  color: var(--warning);
  border-color: rgba(255, 210, 128, 0.3);
  background: rgba(255, 210, 128, 0.1);
}

.mode-badge.is-live {
  color: #ffaaa3;
  border-color: rgba(255, 140, 131, 0.42);
  background: rgba(255, 140, 131, 0.12);
}

.main-content {
  padding: 10px 16px calc(102px + env(safe-area-inset-bottom));
}

.page {
  animation: page-in 180ms ease-out;
}

.page[hidden] {
  display: none;
}

@keyframes page-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero-card,
.form-card,
.route-card,
.notice-card,
.tool-card,
.task-card {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(145deg, rgba(18, 60, 49, 0.96), rgba(9, 39, 32, 0.96));
  box-shadow: var(--shadow);
}

.security-card {
  display: flex;
  width: 100%;
  min-height: 64px;
  margin-top: 10px;
  padding: 13px 16px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid rgba(86, 225, 163, 0.22);
  border-radius: 17px;
  background: rgba(86, 225, 163, 0.08);
  text-align: left;
}

.security-card span {
  color: var(--muted);
  font-size: 11px;
}

.security-card strong {
  color: var(--accent);
  font-size: 13px;
}

.hero-card {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 20px;
}

.hero-icon {
  display: grid;
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 16px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 24px;
  font-weight: 900;
}

.hero-card h2 {
  font-size: 19px;
}

.hero-card p:last-child,
.notice-card p,
.install-tip p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.metric-grid,
.quick-grid,
.two-column,
.setting-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.metric-grid {
  margin-top: 10px;
}

.metric-card {
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgba(10, 43, 35, 0.74);
}

.metric-card span,
.setting-grid span,
.instrument-row span,
.route-card span,
.order-preview span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric-card strong {
  display: block;
  margin-top: 5px;
  font-size: 23px;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin: 24px 2px 12px;
}

.section-heading h2 {
  font-size: 24px;
}

.quick-card {
  min-height: 126px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(13, 49, 40, 0.86);
  text-align: left;
}

.quick-card:active,
.tool-card:active,
.nav-item:active {
  transform: scale(0.98);
}

.quick-symbol,
.tool-icon {
  display: grid;
  width: 38px;
  height: 38px;
  margin-bottom: 14px;
  place-items: center;
  border-radius: 12px;
  background: rgba(86, 225, 163, 0.14);
  color: var(--accent);
  font-size: 21px;
  font-weight: 800;
}

.quick-card strong,
.quick-card small {
  display: block;
}

.quick-card small {
  margin-top: 5px;
  color: var(--muted);
}

.notice-card {
  margin-top: 14px;
  padding: 16px 17px;
  box-shadow: none;
}

.notice-card strong {
  font-size: 14px;
}

.route-card {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  padding: 17px;
  box-shadow: none;
}

.route-card > div:last-child {
  text-align: right;
}

.route-card strong {
  display: block;
  margin-top: 5px;
  font-size: 13px;
}

.route-arrow {
  color: var(--accent) !important;
  font-size: 20px !important;
}

.form-card {
  padding: 18px;
}

.field {
  display: block;
  margin: 0 0 18px;
}

.field:last-of-type {
  margin-bottom: 14px;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: #dcebe5;
  font-size: 13px;
  font-weight: 700;
}

.field small,
.order-preview small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

input,
select {
  width: 100%;
  min-height: 52px;
  border: 1px solid rgba(190, 231, 214, 0.18);
  border-radius: 14px;
  outline: 0;
  background: rgba(3, 25, 20, 0.64);
  color: #f5fcf9;
  font-size: 16px;
}

input {
  padding: 12px 14px;
}

select {
  padding: 0 42px 0 14px;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(86, 225, 163, 0.12);
}

input[aria-invalid="true"],
select[aria-invalid="true"] {
  border-color: var(--danger);
}

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

.input-with-suffix {
  display: flex;
  align-items: center;
  border: 1px solid rgba(190, 231, 214, 0.18);
  border-radius: 14px;
  background: rgba(3, 25, 20, 0.64);
}

.input-with-suffix:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(86, 225, 163, 0.12);
}

.input-with-suffix input {
  min-width: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.input-with-suffix strong {
  padding-right: 14px;
  color: var(--accent);
  font-size: 13px;
}

.fieldset-reset {
  min-width: 0;
  padding: 0;
  border: 0;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 5px;
  border-radius: 14px;
  background: rgba(3, 25, 20, 0.64);
}

.segmented label {
  position: relative;
}

.segmented input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.segmented span {
  display: grid;
  min-height: 42px;
  place-items: center;
  border-radius: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.segmented input:checked + span {
  background: var(--surface-soft);
  color: var(--accent);
  box-shadow: 0 3px 13px rgba(0, 0, 0, 0.15);
}

.side-segmented label:first-child input:checked + span {
  color: var(--accent);
}

.side-segmented label:last-child input:checked + span {
  color: #ff9d96;
}

.instrument-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.instrument-row strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

.fixed-tag {
  padding: 6px 9px;
  border-radius: 9px;
  background: rgba(86, 225, 163, 0.12);
  color: var(--accent) !important;
  font-weight: 700;
}

.setting-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 18px;
}

.setting-grid div {
  padding: 11px 7px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(4, 30, 24, 0.46);
  text-align: center;
}

.setting-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 12px;
}

.two-column .field {
  min-width: 0;
}

.order-preview {
  margin: 2px 0 16px;
  padding: 14px;
  border: 1px dashed rgba(86, 225, 163, 0.28);
  border-radius: 14px;
  background: rgba(86, 225, 163, 0.06);
}

.order-preview strong {
  display: block;
  margin-top: 5px;
  color: var(--accent);
  font-size: 18px;
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 50px;
  border: 0;
  border-radius: 14px;
  font-weight: 800;
}

.primary-button {
  width: 100%;
  background: var(--accent);
  color: var(--accent-ink);
}

body[data-mode="demo"] .primary-button:not(.danger-confirm) {
  background: var(--warning);
  color: #382300;
}

.secondary-button {
  background: rgba(255, 255, 255, 0.07);
  color: #e4f1ec;
}

.ghost-button {
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--accent);
  font-size: 12px;
}

.form-error {
  margin: -4px 0 14px;
  padding: 11px 12px;
  border: 1px solid rgba(255, 140, 131, 0.25);
  border-radius: 11px;
  background: rgba(255, 140, 131, 0.08);
  color: #ffc1bc;
  font-size: 12px;
  line-height: 1.45;
}

.filter-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  overflow-x: auto;
}

.filter-chip {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.filter-chip.is-active {
  border-color: rgba(86, 225, 163, 0.35);
  background: rgba(86, 225, 163, 0.12);
  color: var(--accent);
}

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

.task-card {
  padding: 16px;
  box-shadow: none;
}

.task-card-head,
.task-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.task-kind {
  font-size: 14px;
  font-weight: 800;
}

.status-pill {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(255, 210, 128, 0.12);
  color: var(--warning);
  font-size: 10px;
  font-weight: 800;
}

.status-pill.is-done {
  background: rgba(86, 225, 163, 0.12);
  color: var(--accent);
}

.status-pill.is-failed {
  background: rgba(255, 140, 131, 0.11);
  color: var(--danger);
}

.task-detail {
  margin: 10px 0;
  color: #d8e9e2;
  font-size: 13px;
  line-height: 1.5;
}

.task-time {
  color: var(--muted);
  font-size: 11px;
}

.cancel-button {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid rgba(255, 140, 131, 0.22);
  border-radius: 10px;
  background: rgba(255, 140, 131, 0.07);
  color: #ffaaa3;
  font-size: 11px;
  font-weight: 750;
}

.task-actions {
  display: flex;
  gap: 6px;
}

.refresh-button {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid rgba(86, 225, 163, 0.22);
  border-radius: 10px;
  background: rgba(86, 225, 163, 0.07);
  color: var(--accent);
  font-size: 11px;
  font-weight: 750;
}

.empty-state {
  padding: 32px 18px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.tool-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 18px;
  color: inherit;
  text-decoration: none;
}

.tool-card .tool-icon {
  margin: 0;
}

.tool-card strong,
.tool-card small {
  display: block;
}

.tool-card small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.tool-arrow {
  color: var(--accent);
  font-size: 27px;
}

.bottom-nav {
  position: fixed;
  z-index: 20;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  max-width: 620px;
  margin: 0 auto;
  padding: 8px 8px calc(7px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(180, 224, 206, 0.13);
  background: rgba(5, 27, 22, 0.94);
  box-shadow: 0 -10px 30px rgba(0, 12, 9, 0.24);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

.nav-item {
  display: grid;
  min-height: 54px;
  padding: 5px 0;
  place-items: center;
  border: 0;
  border-radius: 13px;
  background: transparent;
  color: #769a8c;
}

.nav-item span {
  font-size: 20px;
  line-height: 1;
}

.nav-item small {
  margin-top: 3px;
  font-size: 10px;
  font-weight: 700;
}

.nav-item.is-active {
  background: rgba(86, 225, 163, 0.09);
  color: var(--accent);
}

.confirm-dialog {
  width: min(calc(100% - 24px), 520px);
  max-height: calc(100dvh - 24px);
  margin: auto auto 12px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: #0c2b23;
  color: #f2fbf7;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.55);
}

.confirm-dialog::backdrop {
  background: rgba(0, 12, 9, 0.72);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.confirm-dialog form {
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom));
}

.dialog-handle {
  width: 42px;
  height: 4px;
  margin: 2px auto 20px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.22);
}

.confirm-dialog h2 {
  font-size: 22px;
}

.confirm-summary {
  margin: 18px 0 12px;
  padding: 5px 14px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(3, 25, 20, 0.5);
}

.confirm-summary div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.confirm-summary div:last-child {
  border-bottom: 0;
}

.confirm-summary dt {
  color: var(--muted);
  font-size: 12px;
}

.confirm-summary dd {
  margin: 0;
  text-align: right;
  font-size: 13px;
  font-weight: 700;
}

.dialog-note {
  margin: 0 2px 16px;
  color: var(--warning);
  font-size: 12px;
  line-height: 1.5;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1.35fr;
  gap: 9px;
}

.toast {
  position: fixed;
  z-index: 40;
  right: 18px;
  bottom: calc(88px + env(safe-area-inset-bottom));
  left: 18px;
  max-width: 520px;
  margin: 0 auto;
  padding: 13px 15px;
  border: 1px solid rgba(86, 225, 163, 0.28);
  border-radius: 13px;
  background: #164837;
  color: #effbf6;
  box-shadow: var(--shadow);
  font-size: 13px;
  line-height: 1.45;
  text-align: center;
}

.toast.is-error {
  border-color: rgba(255, 140, 131, 0.3);
  background: #4a2624;
}

@media (min-width: 560px) {
  .main-content {
    padding-right: 24px;
    padding-left: 24px;
  }

  .topbar {
    padding-right: 28px;
    padding-left: 28px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
