:root {
  --bg: #f3f1ec;
  --bg-accent: #e7efe9;
  --surface: #ffffff;
  --surface-2: #f7f6f2;
  --ink: #14201a;
  --ink-soft: #4d5c54;
  --line: #d8ddd7;
  --brand: #0f6b4c;
  --brand-strong: #0a5239;
  --brand-soft: #d9efe5;
  --warn: #9a6b12;
  --warn-soft: #f5e6c4;
  --danger: #a33b32;
  --danger-soft: #f7d9d6;
  --ok: #1a7a4c;
  --ok-soft: #d5f0e2;
  --idle: #6b776f;
  --shadow: 0 18px 50px rgba(20, 32, 26, 0.08);
  --radius: 18px;
  --radius-sm: 12px;
  --font-display: "Sora", "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 0% 0%, rgba(15, 107, 76, 0.10), transparent 60%),
    radial-gradient(700px 380px at 100% 10%, rgba(154, 107, 18, 0.08), transparent 55%),
    var(--bg);
  line-height: 1.45;
}

h1, h2, h3, .brand-mark {
  font-family: var(--font-display);
  letter-spacing: -0.02em;
}

h1 { margin: 0 0 0.35rem; font-size: clamp(1.8rem, 3vw, 2.4rem); font-weight: 700; }
h2 { margin: 0; font-size: 1.15rem; font-weight: 650; }
h3 { margin: 0 0 0.65rem; font-size: 0.95rem; font-weight: 650; }

.eyebrow {
  margin: 0 0 0.45rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand);
}

.lede, .panel-hint, .status-detail, .fineprint {
  color: var(--ink-soft);
}

.lede { margin: 0 0 1.5rem; }
.panel-hint { margin: 0.25rem 0 0; font-size: 0.9rem; }
.fineprint { margin: 1.25rem 0 0; font-size: 0.8rem; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86em;
  background: var(--surface-2);
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
}

/* Buttons */
.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0.72rem 1.15rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  text-decoration: none;
  color: inherit;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-sm { padding: 0.45rem 0.85rem; font-size: 0.88rem; }
.btn-block { width: 100%; }

.btn-primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 10px 24px rgba(15, 107, 76, 0.22);
}
.btn-primary:hover { background: var(--brand-strong); }

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-soft);
}

.text-btn, .text-link {
  background: none;
  border: 0;
  color: var(--brand);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  text-decoration: none;
}
.text-link:hover { text-decoration: underline; }

/* Login */
.auth-page { min-height: 100vh; }
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
}
.auth-aside {
  background:
    linear-gradient(160deg, rgba(15, 107, 76, 0.92), rgba(10, 56, 40, 0.96)),
    url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  color: #f4faf7;
  display: grid;
  align-items: center;
  padding: 3rem;
}
.auth-aside-inner { max-width: 28rem; animation: rise 0.55s ease both; }
.auth-aside .brand-mark {
  display: inline-block;
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.12);
}
.auth-aside-title {
  margin: 0 0 0.85rem;
  font-size: clamp(1.8rem, 3vw, 2.5rem);
  line-height: 1.15;
  color: #fff;
}
.auth-aside-copy {
  margin: 0;
  color: rgba(244, 250, 247, 0.82);
  font-size: 1.05rem;
}
.auth-main {
  display: grid;
  place-items: center;
  padding: 2rem;
}
.auth-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  padding: 2rem;
  box-shadow: var(--shadow);
  animation: rise 0.55s ease 0.08s both;
}
.stack-form { display: grid; gap: 1rem; }
.field { display: grid; gap: 0.4rem; font-size: 0.92rem; font-weight: 500; }
.field input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.8rem 0.9rem;
  font: inherit;
  background: var(--surface-2);
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 107, 76, 0.15);
  background: #fff;
}
.password-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  align-items: center;
}

/* App shell */
.app-page { min-height: 100vh; }
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--line);
  background: rgba(243, 241, 236, 0.85);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-brand { display: flex; align-items: center; gap: 0.75rem; }
.brand-mark {
  font-size: 1rem;
  font-weight: 700;
  color: var(--brand);
}
.header-divider {
  width: 1px;
  height: 1.1rem;
  background: var(--line);
}
.header-sub { color: var(--ink-soft); font-size: 0.92rem; }
.header-actions { display: flex; align-items: center; gap: 0.5rem; }

.app-main {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.5rem 0 2.5rem;
  display: grid;
  gap: 1.25rem;
  animation: rise 0.45s ease both;
}

.hero-status {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  display: grid;
  gap: 1.25rem;
}
.status-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0.65rem 0 0.35rem;
}
.status-dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--idle);
  box-shadow: 0 0 0 4px rgba(107, 119, 111, 0.15);
}
.status-dot.ok { background: var(--ok); box-shadow: 0 0 0 4px rgba(26, 122, 76, 0.16); animation: pulse 2s ease infinite; }
.status-dot.warn { background: var(--warn); box-shadow: 0 0 0 4px rgba(154, 107, 18, 0.16); animation: pulse 1.4s ease infinite; }
.status-dot.err { background: var(--danger); box-shadow: 0 0 0 4px rgba(163, 59, 50, 0.16); }
.status-label {
  font-family: var(--font-display);
  font-weight: 650;
  font-size: 1.05rem;
}
.status-detail { margin: 0; max-width: 42rem; font-size: 0.95rem; }

.action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  padding-top: 0.25rem;
  border-top: 1px solid var(--line);
}

.toast {
  margin: 0.75rem 0 0;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: 0.92rem;
  font-weight: 500;
}
.toast.error {
  background: var(--danger-soft);
  color: var(--danger);
}

.workspace {
  display: grid;
  grid-template-columns: 1.35fr 0.85fr;
  gap: 1.25rem;
  align-items: start;
}

.qr-panel, .info-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.qr-panel { padding: 1.25rem; }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}
.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.chip.live { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip.ready { background: var(--ok-soft); color: var(--ok); border-color: transparent; }

.qr-stage {
  min-height: 340px;
  border-radius: calc(var(--radius) - 4px);
  background:
    linear-gradient(var(--surface-2), var(--surface-2)),
    repeating-linear-gradient(90deg, transparent, transparent 11px, rgba(15,107,76,0.04) 11px, rgba(15,107,76,0.04) 12px);
  border: 1px dashed #c9d2cb;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}
.qr-stage img {
  width: min(280px, 100%);
  background: #fff;
  padding: 0.9rem;
  border-radius: 16px;
  box-shadow: 0 12px 30px rgba(20, 32, 26, 0.12);
  animation: pop 0.35s ease both;
}
.qr-empty {
  text-align: center;
  max-width: 16rem;
  color: var(--ink);
}
.qr-empty p:first-of-type {
  margin: 0.75rem 0 0.35rem;
  font-family: var(--font-display);
  font-weight: 650;
}
.qr-empty-icon {
  width: 3rem;
  height: 3rem;
  margin: 0 auto;
  border-radius: 12px;
  border: 2px dashed #b7c4bc;
  background:
    linear-gradient(#b7c4bc, #b7c4bc) center/60% 2px no-repeat,
    linear-gradient(#b7c4bc, #b7c4bc) center/2px 60% no-repeat;
}

.side-panel { display: grid; gap: 1rem; }
.info-card { padding: 1.15rem 1.2rem; }
.muted-card { background: var(--surface-2); box-shadow: none; }
.steps, .legend {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.55rem;
  color: var(--ink-soft);
  font-size: 0.92rem;
}
.steps { counter-reset: step; }
.steps li {
  counter-increment: step;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.65rem;
  align-items: start;
}
.steps li::before {
  content: counter(step);
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-strong);
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 700;
}
.legend li { display: flex; align-items: center; gap: 0.55rem; }
.dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--idle);
  flex: 0 0 auto;
}
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.err { background: var(--danger); }
.dot.idle { background: var(--idle); }

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0.85rem 0 1rem;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  cursor: pointer;
}
.toggle-copy {
  display: grid;
  gap: 0.2rem;
}
.toggle-copy strong {
  font-size: 0.95rem;
}
.toggle-copy small {
  color: var(--ink-soft);
  font-size: 0.82rem;
  line-height: 1.35;
}
.toggle-row input[type="checkbox"] {
  appearance: none;
  width: 2.8rem;
  height: 1.55rem;
  border-radius: 999px;
  background: #c5cdc7;
  position: relative;
  flex: 0 0 auto;
  cursor: pointer;
  transition: background 0.18s ease;
}
.toggle-row input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 0.18rem;
  left: 0.18rem;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
  transition: transform 0.18s ease;
}
.toggle-row input[type="checkbox"]:checked {
  background: var(--brand);
}
.toggle-row input[type="checkbox"]:checked::after {
  transform: translateX(1.2rem);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pop {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

@media (max-width: 920px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-aside { min-height: 220px; padding: 2rem; }
  .workspace { grid-template-columns: 1fr; }
  .app-header { flex-wrap: wrap; }
}

@media (max-width: 560px) {
  .action-bar .btn { width: 100%; }
  .auth-aside-title { font-size: 1.55rem; }
}
