:root {
  /* Apple / zyu.io Light Theme Tokens */
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-subtle: #f2f2f4;
  --surface-hover: #e8e8ed;
  --topbar-bg: rgba(255, 255, 255, 0.82);
  --topbar-line: rgba(0, 0, 0, 0.08);
  --border: rgba(0, 0, 0, 0.1);
  --border-strong: rgba(0, 0, 0, 0.18);
  --text: #1d1d1f;
  --text-secondary: #424245;
  --text-muted: #6e6e73;
  --text-soft: #86868b;
  --eyebrow: #bf4800;
  --primary: #0071e3;
  --primary-hover: #0067d2;
  --primary-link: #0066cc;
  --primary-soft: rgba(0, 113, 227, 0.12);
  --primary-border: rgba(0, 113, 227, 0.28);
  --focus-ring: 0 0 0 4px rgba(0, 113, 227, 0.25);
  --success: #248a3d;
  --success-soft: rgba(47, 143, 111, 0.13);
  --success-border: rgba(47, 143, 111, 0.3);
  --success-text: #1d6f32;
  --warning: #b06b00;
  --warning-soft: rgba(217, 119, 6, 0.13);
  --warning-border: rgba(217, 119, 6, 0.3);
  --warning-text: #92400e;
  --danger: #c9342f;
  --danger-soft: rgba(201, 52, 47, 0.12);
  --danger-border: rgba(201, 52, 47, 0.28);
  --danger-text: #a51e1a;
  --code-bg: #161617;
  --code-text: #f5f5f7;
  --radius: 18px;
  --radius-md: 12px;
  --radius-sm: 10px;
  --radius-pill: 980px;
  --shadow: 0 12px 32px -20px rgba(0, 0, 0, 0.22);
  --shadow-lg: 0 24px 56px -24px rgba(0, 0, 0, 0.35);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

[data-theme="dark"] {
  /* zyu.io Exact Dark Theme Tokens */
  --bg: #000000;
  --surface: #1d1d1f;
  --surface-subtle: #161617;
  --surface-hover: #2c2c2e;
  --topbar-bg: rgba(0, 0, 0, 0.8);
  --topbar-line: rgba(245, 245, 247, 0.08);
  --border: rgba(255, 255, 255, 0.11);
  --border-strong: rgba(255, 255, 255, 0.22);
  --text: #f5f5f7;
  --text-secondary: #d2d2d7;
  --text-muted: #a1a1a6;
  --text-soft: #86868b;
  --eyebrow: #ff9f45;
  --primary: #0071e3;
  --primary-hover: #0077ed;
  --primary-link: #2997ff;
  --primary-soft: rgba(10, 132, 255, 0.16);
  --primary-border: rgba(10, 132, 255, 0.36);
  --focus-ring: 0 0 0 4px rgba(0, 113, 227, 0.38);
  --success: #30d158;
  --success-soft: rgba(48, 209, 88, 0.15);
  --success-border: rgba(48, 209, 88, 0.32);
  --success-text: #5fe07f;
  --warning: #ffd60a;
  --warning-soft: rgba(255, 214, 10, 0.14);
  --warning-border: rgba(255, 214, 10, 0.32);
  --warning-text: #ffd60a;
  --danger: #ff453a;
  --danger-soft: rgba(255, 69, 58, 0.16);
  --danger-border: rgba(255, 69, 58, 0.34);
  --danger-text: #ff6961;
  --code-bg: #111112;
  --code-text: #f5f5f7;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.72);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.58;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--primary-link);
  text-decoration: none;
  transition: opacity 0.15s var(--ease);
}
a:hover { text-decoration: underline; }

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--surface-hover);
  padding: 2px 6px;
  border-radius: 6px;
  color: var(--text);
}

/* Slim Apple / zyu.io Global Nav (48px) */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 48px;
  background: var(--topbar-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 1px 0 0 var(--topbar-line);
}

.topbar-inner {
  max-width: 1024px;
  height: 100%;
  margin: 0 auto;
  padding: 0 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-inner-wide {
  max-width: 1120px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none !important;
}

.nav-center {
  display: flex;
  align-items: center;
  gap: 24px;
}

.nav-link {
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 400;
  text-decoration: none !important;
  transition: color 0.15s var(--ease);
}
.nav-link:hover { color: var(--text); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-icon-btn {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.nav-icon-btn:hover { background: var(--surface-hover); color: var(--text); }

/* Status Pill */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-soft);
}

.pill.ok { background: var(--success-soft); border-color: var(--success-border); color: var(--success-text); }
.pill.ok .pill-dot { background: var(--success); }
.pill.warn { background: var(--warning-soft); border-color: var(--warning-border); color: var(--warning-text); }
.pill.warn .pill-dot { background: var(--warning); }
.pill.err { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger-text); }
.pill.err .pill-dot { background: var(--danger); }
.pill.demo { background: var(--primary-soft); border-color: var(--primary-border); color: var(--primary-link); }

/* Containers */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 56px 22px 80px;
}

.container-wide {
  max-width: 1120px;
  margin: 0 auto;
  padding: 32px 22px 80px;
}

/* zyu.io Hero Typography */
.hero {
  text-align: center;
  margin-bottom: 40px;
}

.hero-eyebrow {
  font-size: 15px;
  font-weight: 500;
  color: var(--eyebrow);
  margin: 0 0 10px;
  letter-spacing: -0.005em;
}

.hero h1 {
  margin: 0 0 14px;
  font-family: var(--font-display);
  font-size: clamp(32px, 5vw, 48px);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--text);
}

.hero p {
  margin: 0 auto;
  max-width: 540px;
  color: var(--text-muted);
  font-size: 16.5px;
  line-height: 1.55;
}

.hero-actions {
  margin-top: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
}

/* Minimal Segmented Stepper */
.stepper {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 5px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  margin-bottom: 20px;
}

.step-item {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 12px;
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}

.step-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface-hover);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11.5px;
  font-weight: 600;
  flex-shrink: 0;
}

.step-item.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);
}
.step-item.active .step-num { background: var(--primary); color: #fff; }

.step-item.done { color: var(--success-text); }
.step-item.done .step-num { background: var(--success); color: #000; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  animation: fadeUp 0.24s var(--ease);
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.card + .card { margin-top: 18px; }

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

.card-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.muted { color: var(--text-muted); }
.small { font-size: 13px; }
.mono { font-family: var(--font-mono); }

/* Feature 3-column Strip (zyu.io signature band) */
.feature-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
  margin: 40px 0 28px;
  padding: 28px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.feature-item h3 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 15.5px;
  font-weight: 600;
  color: var(--text);
}

.feature-item p {
  margin: 0;
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.55;
}

/* Inputs & Form */
.field { margin-bottom: 18px; }

.field label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 500;
  margin-bottom: 8px;
  font-size: 13.5px;
  color: var(--text-secondary);
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrap .input { padding-right: 84px; }

.input-action {
  position: absolute;
  right: 8px;
  display: inline-flex;
  gap: 4px;
}

.input, .select, .textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  color: var(--text);
  font-family: inherit;
  font-size: 14.5px;
  outline: none;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease), background 0.15s var(--ease);
}

.input::placeholder, .textarea::placeholder { color: var(--text-soft); }

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
  background: var(--surface);
}

.input.valid { border-color: var(--success); }
.input.invalid { border-color: var(--danger); }

.input-lg {
  padding: 14px 16px;
  font-size: 16px;
  letter-spacing: 0.04em;
  font-family: var(--font-mono);
}

.textarea {
  min-height: 120px;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 13px;
}

.hint { margin-top: 7px; font-size: 12.5px; color: var(--text-muted); }
.hint.ok { color: var(--success-text); }
.hint.err { color: var(--danger-text); }

/* Pill Buttons (Apple / zyu.io signature) */
.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 20px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease), transform 0.1s var(--ease), opacity 0.15s;
  text-decoration: none !important;
  white-space: nowrap;
}

.btn:active:not(:disabled) { transform: scale(0.985); }
.btn:disabled { opacity: 0.48; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn-secondary { background: var(--surface-hover); border-color: var(--border); color: var(--text); }
.btn-secondary:hover:not(:disabled) { border-color: var(--border-strong); filter: brightness(1.08); }

.btn-ghost { background: transparent; color: var(--primary-link); padding-left: 8px; padding-right: 8px; }
.btn-ghost:hover:not(:disabled) { text-decoration: underline !important; }

.btn-danger { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger-text); }
.btn-danger:hover:not(:disabled) { filter: brightness(1.08); }

.btn-sm { padding: 6px 13px; font-size: 12.5px; }
.btn-icon { width: 34px; height: 34px; padding: 0; }
.btn-block { width: 100%; }

/* Alerts */
.alert {
  padding: 13px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  margin-bottom: 18px;
  font-size: 13.5px;
}

.alert-info { background: var(--primary-soft); border-color: var(--primary-border); color: var(--primary-link); }
.alert-success { background: var(--success-soft); border-color: var(--success-border); color: var(--success-text); }
.alert-warning { background: var(--warning-soft); border-color: var(--warning-border); color: var(--warning-text); }
.alert-danger { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger-text); }

/* Summary KV Box */
.summary-box {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: 18px;
}

.kv-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 18px;
}

.kv-item .kv-label { font-size: 12px; color: var(--text-muted); margin-bottom: 3px; }
.kv-item .kv-value { font-weight: 600; word-break: break-all; }

.progress-track {
  width: 100%;
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--surface-hover);
  overflow: hidden;
  margin: 12px 0 8px;
}

.progress-bar {
  height: 100%;
  width: 42%;
  border-radius: var(--radius-pill);
  background: var(--primary);
  animation: indeterminate 1.4s ease-in-out infinite;
}

@keyframes indeterminate {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(260%); }
}

.delivery-list { display: flex; flex-direction: column; gap: 10px; margin: 14px 0; }

.delivery-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 13px 16px;
  background: var(--surface-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.delivery-item-main { min-width: 0; flex: 1; }
.delivery-item-title { font-size: 12px; color: var(--text-muted); margin-bottom: 3px; }
.delivery-item-val { font-family: var(--font-mono); font-weight: 600; word-break: break-all; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-unused { background: var(--surface-hover); color: var(--text-secondary); }
.badge-processing, .badge-locked, .badge-submitted { background: var(--warning-soft); color: var(--warning-text); }
.badge-delivered { background: var(--success-soft); color: var(--success-text); }
.badge-disabled, .badge-failed, .badge-expired { background: var(--danger-soft); color: var(--danger-text); }

.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Recent chips (zyu.io category pill feel) */
.history-chips { display: flex; flex-wrap: wrap; gap: 8px; }

.history-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--text);
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}
.history-chip:hover { border-color: var(--primary); background: var(--primary-soft); }

/* FAQ Accordion */
.faq-list details { border-bottom: 1px solid var(--border); padding: 14px 0; }
.faq-list details:last-child { border-bottom: none; padding-bottom: 0; }
.faq-list details:first-child { padding-top: 0; }
.faq-list summary {
  cursor: pointer;
  font-weight: 500;
  font-size: 14.5px;
  color: var(--text);
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.faq-list summary::-webkit-details-marker { display: none; }
.faq-list summary::after { content: "+"; color: var(--text-soft); font-size: 18px; font-weight: 400; }
.faq-list details[open] summary::after { content: "−"; }
.faq-list details p { margin: 8px 0 0; color: var(--text-muted); font-size: 13.5px; line-height: 1.6; }

/* Admin Dashboard */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.kpi-label { font-size: 12.5px; color: var(--text-muted); margin-bottom: 6px; }
.kpi-val {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.kpi-sub { margin-top: 6px; font-size: 12px; color: var(--text-muted); }

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.tab-btn {
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.16s var(--ease), color 0.16s var(--ease);
}
.tab-btn:hover { color: var(--text); background: var(--surface-hover); }
.tab-btn.active { background: var(--surface); border-color: var(--border); color: var(--text); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { background: var(--surface-subtle); font-weight: 500; color: var(--text-muted); white-space: nowrap; font-size: 12.5px; }
tbody tr:hover { background: var(--surface-subtle); }
tr:last-child td { border-bottom: none; }

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
}

.toolbar .input, .toolbar .select { width: auto; min-width: 145px; }

.bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 16px;
  margin-bottom: 12px;
  border-radius: var(--radius-md);
  background: var(--primary-soft);
  border: 1px solid var(--primary-border);
  font-size: 13px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-card {
  width: 100%;
  max-width: 680px;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 24px;
}

.code-block {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  margin: 0;
}

.hidden { display: none !important; }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: var(--surface);
  color: var(--text);
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  font-size: 13.5px;
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  z-index: 120;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}
.toast.show { opacity: 1; transform: translateY(0); }

/* Minimal zyu.io Footer */
.site-footer {
  max-width: 1024px;
  margin: 0 auto;
  padding: 26px 22px 44px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--text-soft);
  font-size: 12.5px;
}

@media (max-width: 860px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: 1fr; }
  .nav-center { display: none; }
}

@media (max-width: 640px) {
  .feature-strip { grid-template-columns: 1fr; gap: 18px; }
  .stepper { grid-template-columns: 1fr; border-radius: var(--radius-md); }
  .kv-grid { grid-template-columns: 1fr; }
  .card { padding: 20px; }
  .container { padding-top: 34px; }
}
