:root {
  --paper: #f3fcfb;
  --surface: #ffffff;
  --ink: #083834;
  --muted: #1b6f68;
  --line: #c5ebe6;
  --line-strong: #98d8d0;
  --action: #0f766e;
  --action-hover: #0d9488;
  --action-soft: #e6f8f5;
  --ok: #0f7a5a;
  --danger: #c2413b;
  --focus: #0f766e;
  --code: #083834;
  --code-text: #e7fffb;
  --shadow: 0 10px 30px rgba(15, 118, 110, 0.12);
  --radius: 16px;
  --radius-sm: 10px;
}

html[data-theme="dark"] {
  --paper: #042724;
  --surface: #0a3532;
  --ink: #e7fffb;
  --muted: #8ed9d0;
  --line: #1a5c56;
  --line-strong: #24756e;
  --action: #2dd4bf;
  --action-hover: #5eead4;
  --action-soft: #0e4a45;
  --ok: #5ee0b5;
  --danger: #f08078;
  --focus: #2dd4bf;
  --code: #021c1a;
  --code-text: #e7fffb;
  --shadow: 0 12px 32px rgba(2, 28, 26, 0.45);
}

html {
  color-scheme: light;
}

html[data-theme="dark"] {
  color-scheme: dark;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
}

body {
  font-family: "Plus Jakarta Sans", "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.5;
  font-size: 16px;
}

html[data-theme="dark"] body {
  background: var(--paper);
}

a {
  color: inherit;
}

.site-header {
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner,
.page {
  width: min(1140px, calc(100% - 32px));
  margin: 0 auto;
}

.header-inner {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mark {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(160deg, #134e4a, #0f766e);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: 0 8px 18px rgba(15, 118, 110, 0.28);
}

.company {
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.division {
  font-size: 0.78rem;
  color: var(--muted);
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 10px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 12px 6px 7px;
  cursor: pointer;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
}

.switch-track {
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: var(--line-strong);
  position: relative;
  display: block;
  transition: background 0.18s ease;
}

.switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.18s ease;
}

html[data-theme="dark"] .switch-track {
  background: var(--action);
}

html[data-theme="dark"] .switch-knob {
  transform: translateX(16px);
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.btn:hover:not(:disabled) {
  border-color: var(--line-strong);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn:focus-visible,
.switch:focus-visible,
.icon-btn:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--action);
  border-color: var(--action);
  color: #fff;
}

html[data-theme="dark"] .btn-primary {
  color: #042724;
}

.btn-primary:hover:not(:disabled) {
  background: var(--action-hover);
  border-color: var(--action-hover);
}

.btn-ghost {
  background: var(--surface);
}

.btn-wide {
  width: 100%;
}

.btn-small {
  padding: 6px 10px;
  font-size: 0.8rem;
}

.icon-btn {
  border: 0;
  background: var(--paper);
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
}

.page {
  padding: 32px 0 72px;
}

.page-head {
  margin-bottom: 22px;
  max-width: 42rem;
}

.kicker {
  color: var(--action);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.page-head h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.15;
}

.page-head p {
  margin-top: 10px;
  color: var(--muted);
  font-size: 1.02rem;
}

.worksheet {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.sheet-head,
.sheet-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
}

.sheet-head {
  background: color-mix(in srgb, var(--action-soft) 70%, var(--surface));
  border-bottom: 1px solid var(--line);
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--muted);
}

#formMeta {
  color: var(--action);
}

.sheet-foot {
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 55%, var(--surface));
}

.sheet-foot p {
  color: var(--muted);
  font-size: 0.92rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  padding: 16px;
}

.card {
  padding: 16px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: color-mix(in srgb, var(--paper) 65%, var(--surface));
  border: 1px solid var(--line);
  border-radius: 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.card.ready {
  border-color: color-mix(in srgb, var(--action) 45%, var(--line));
  box-shadow: 0 0 0 3px var(--action-soft);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 16px;
}

.badge {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--action);
  background: var(--action-soft);
}

.hint {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
}

.card.ready .hint {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 35%, var(--line));
}

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.field {
  margin-bottom: 12px;
}

input[type="text"],
input[type="password"],
input[type="tel"],
textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="text"],
input[type="password"],
input[type="tel"] {
  height: 44px;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="tel"]:focus {
  border-color: var(--action);
  box-shadow: 0 0 0 4px var(--action-soft);
}

.phone-input {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  letter-spacing: 0.04em;
  background: var(--action-soft);
  border-color: color-mix(in srgb, var(--action) 28%, var(--line));
}

.phone-input:focus {
  background: var(--surface);
}

.phone-input::placeholder {
  color: color-mix(in srgb, var(--muted) 70%, var(--surface));
  font-weight: 500;
  letter-spacing: 0.03em;
}

.card .btn {
  margin-top: auto;
}

.admin-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 16px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100% - 32px));
  background: var(--ink);
  color: var(--paper);
  padding: 12px 14px;
  font-size: 0.92rem;
  border-radius: 12px;
  box-shadow: var(--shadow);
  transform: translateY(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 40;
}

.toast.show {
  opacity: 1;
  transform: none;
}

.toast.error {
  background: var(--danger);
  color: #fff;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 39, 36, 0.55);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 16px;
  overflow: auto;
  z-index: 30;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  width: min(640px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.modal-sm {
  width: min(420px, 100%);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.modal h2 {
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}

.modal-lede {
  color: var(--muted);
  margin-bottom: 14px;
}

.steps {
  margin: 0 0 16px 18px;
  display: grid;
  gap: 7px;
}

.codebox {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 14px;
}

.codebox-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 0.75rem;
  color: var(--muted);
  background: var(--paper);
}

.codebox textarea {
  min-height: 140px;
  border: 0;
  border-radius: 0;
  padding: 12px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.75rem;
  line-height: 1.4;
  background: var(--code);
  color: var(--code-text);
  resize: vertical;
}

.setup-row {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.setup-row input {
  flex: 1;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
  }
}

@media (max-width: 980px) {
  .grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .grid {
    grid-template-columns: 1fr;
  }

  .sheet-head,
  .sheet-foot,
  .setup-row,
  .header-inner {
    flex-direction: column;
    align-items: stretch;
  }

  .page-head h1 {
    font-size: 1.55rem;
  }
}
