:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #21253a;
  --border: #2d3148;
  --text: #e2e5f0;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --success: #16a34a;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { background: var(--bg); color: var(--text); font-family: var(--font); min-height: 100vh; }

/* LOGIN */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 100%; max-width: 340px;
  text-align: center;
}
.login-logo { display: flex; align-items: center; justify-content: center; gap: .6rem;
  font-size: 1.3rem; font-weight: 700; margin-bottom: 1.5rem; }
.login-card h2 { margin-bottom: 1.2rem; font-size: 1.1rem; color: var(--muted); font-weight: 500; }
.pin-input {
  width: 100%; padding: .85rem 1rem; font-size: 1.6rem; letter-spacing: .4em;
  text-align: center; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); margin-bottom: 1rem;
}
.pin-input:focus { outline: none; border-color: var(--accent); }
.error { color: #f87171; margin-bottom: 1rem; font-size: .9rem; }

/* HEADER */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  padding: .75rem 1.5rem;
}
.header-inner { display: flex; align-items: center; justify-content: space-between; max-width: 900px; margin: 0 auto; }
.header-logo { display: flex; align-items: center; gap: .6rem; font-size: 1.1rem; font-weight: 700; }
.header-actions { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }

/* CONTAINER */
.container { max-width: 900px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }

/* SIG PREVIEW */
.sig-preview-bar {
  display: flex; align-items: center; gap: 1.2rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .85rem 1.2rem; margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.sig-label { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.sig-preview-img { height: 48px; border-radius: 4px; border: 1px solid var(--border); background: #fff; }

/* CARDS */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.2rem;
}
.section-title { font-size: 1rem; font-weight: 600; margin-bottom: 1.2rem; color: var(--text); }
.sub-heading { font-size: .85rem; font-weight: 600; color: var(--muted); margin-bottom: .75rem; }

/* FIELDS */
.field { display: flex; flex-direction: column; gap: .35rem; }
.field label { font-size: .82rem; color: var(--muted); font-weight: 500; }
.field input, .field select, .field textarea {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: .95rem;
  padding: .55rem .75rem; font-family: var(--font);
  transition: border-color .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent);
}
.field select { cursor: pointer; }
.field textarea { resize: vertical; }

.mt-2 { margin-top: 1.2rem; }
.mt-3 { margin-top: 1.8rem; }

/* GRIDS */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
.grid-med { display: grid; grid-template-columns: 2fr 1fr; gap: 1rem; }
@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-med { grid-template-columns: 1fr; }
}

/* CHECKBOXES */
.checkbox-grid { display: flex; flex-wrap: wrap; gap: .5rem .75rem; margin-top: .4rem; }
.checkbox-label {
  display: flex; align-items: center; gap: .45rem;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; padding: .35rem .75rem;
  cursor: pointer; font-size: .88rem; transition: border-color .15s;
}
.checkbox-label:hover { border-color: var(--accent); }
.checkbox-label input { accent-color: var(--accent); cursor: pointer; }

/* RADIO TABLE (Q8) */
.radio-table { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.radio-table-header, .radio-table-row {
  display: grid; grid-template-columns: 1fr 80px 80px 80px;
  align-items: center;
}
.radio-table-header {
  background: var(--surface2); padding: .5rem 1rem;
  font-size: .78rem; font-weight: 600; color: var(--muted); text-align: center;
}
.radio-table-header span:first-child { text-align: left; }
.radio-table-row {
  padding: .5rem 1rem; border-top: 1px solid var(--border);
  font-size: .9rem; transition: background .1s;
}
.radio-table-row:hover { background: var(--surface2); }
.radio-cell { display: flex; align-items: center; justify-content: center; }
.radio-cell input { accent-color: var(--accent); cursor: pointer; width: 16px; height: 16px; }

/* RADIO INLINE */
.radio-inline { display: flex; gap: 1.5rem; margin-top: .5rem; }
.radio-inline label { display: flex; align-items: center; gap: .4rem; cursor: pointer; }
.radio-inline input { accent-color: var(--accent); cursor: pointer; }

/* FIELD INLINE (side-by-side label + select) */
.field-inline {
  display: flex; align-items: center; justify-content: space-between;
  padding: .4rem 0; border-bottom: 1px solid var(--border);
}
.field-inline:last-child { border-bottom: none; }
.field-inline label { font-size: .88rem; color: var(--text); }
.field-inline select {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: .88rem;
  padding: .3rem .5rem; width: 80px; cursor: pointer;
}

/* BUTTONS */
.btn-primary, .btn-secondary, .btn-outline, .btn-danger, .btn-ghost {
  border: none; border-radius: 6px; cursor: pointer;
  font-size: .88rem; font-weight: 500; padding: .55rem 1.1rem;
  transition: background .15s, color .15s; font-family: var(--font);
  text-decoration: none; display: inline-block;
}
.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-outline   { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn-outline:hover { background: var(--accent); color: #fff; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-ghost     { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); }
.full-width { width: 100%; }

/* LOG */
.log-pre {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; padding: 1rem; font-size: .82rem;
  font-family: 'Courier New', monospace; white-space: pre-wrap;
  color: #a5f3a5; max-height: 300px; overflow-y: auto;
}

/* MODAL */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.65);
  display: flex; align-items: center; justify-content: center; z-index: 200;
}
.modal-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 2rem; max-width: 400px; width: 90%;
}
.modal-card h3 { margin-bottom: .75rem; }
.modal-card p { color: var(--muted); font-size: .9rem; margin-bottom: 1.5rem; }
.modal-actions { display: flex; gap: .75rem; justify-content: flex-end; }

/* TOAST */
.toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; padding: .65rem 1.2rem; font-size: .88rem;
  opacity: 0; transform: translateY(8px);
  transition: opacity .25s, transform .25s; pointer-events: none; z-index: 300;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.err { border-color: var(--danger); color: #f87171; }
.toast.ok { border-color: var(--success); color: #86efac; }

.muted { color: var(--muted); }
.small { font-size: .82rem; }
.ok-text { color: #86efac; }

/* VARIANTS */
.variant-card {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 1rem 1.2rem; margin-bottom: 1rem;
}
.variant-base { border-color: #2563eb44; background: #2563eb08; }
.variant-other { border-color: #fb923c44; background: #fb923c08; }
.variant-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.variant-meta { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.variant-hash { font-family: 'Courier New', monospace; font-size: .88rem; color: var(--text); }
.badge-base { background: #2563eb33; color: #93c5fd; border-radius: 4px; padding: .2rem .6rem; font-size: .75rem; font-weight: 600; }
.badge-warn { background: #fb923c33; color: #fdba74; border-radius: 4px; padding: .2rem .6rem; font-size: .75rem; font-weight: 600; }
.variant-label-row { display: flex; align-items: center; gap: .5rem; margin: .75rem 0 .5rem; }
.variant-label-input {
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); font-size: .88rem; padding: .35rem .65rem; flex: 1; max-width: 320px;
}
.variant-stats { font-size: .82rem; color: var(--muted); display: flex; gap: .5rem; }
.variant-diff { margin-top: .85rem; display: flex; flex-direction: column; gap: .5rem; }
.diff-section { border-radius: 6px; padding: .6rem .85rem; }
.diff-added { background: #16a34a15; border: 1px solid #16a34a33; }
.diff-removed { background: #dc262615; border: 1px solid #dc262633; }
.diff-label { font-size: .78rem; font-weight: 600; display: block; margin-bottom: .35rem; color: var(--muted); }
.diff-field { font-size: .82rem; margin-bottom: .2rem; }
.diff-field code { font-size: .78rem; background: var(--bg); padding: .1rem .35rem; border-radius: 3px; margin-right: .4rem; }

/* CHECK RESULT */
.check-output { padding: .5rem 0; }
.check-result { display: flex; flex-direction: column; gap: .4rem; font-size: .92rem; }
.check-result code { font-family: 'Courier New', monospace; font-size: .88rem; }
