/* Question-state colour tokens — needed on both /inputs and /questions pages. */
:root {
  --q-gate:        #16a34a;   --q-gate-soft:   rgba(22,163,74,0.08);
  --q-parent:      #b45309;   --q-parent-soft: rgba(202,138,4,0.08);
  --q-exit:        #16a34a;   --q-exit-soft:   rgba(22,163,74,0.08);
  --q-detail:      #1565C0;   --q-detail-soft: rgba(21,101,192,0.08);
}
html.dark-mode {
  --q-gate:        #86efac;   --q-gate-soft:   rgba(134,239,172,0.08);
  --q-parent:      #fcd34d;   --q-parent-soft: rgba(252,211,77,0.08);
  --q-exit:        #86efac;   --q-exit-soft:   rgba(134,239,172,0.08);
  --q-detail:      #60a5fa;   --q-detail-soft: rgba(96,165,250,0.08);
}

    body { min-height: 100vh; background: #fff !important; }
    .app-section {
      min-height: calc(100vh - 120px);
      display: flex;
      align-items: flex-start;
      justify-content: center;
      padding: 56px 24px 84px;
    }
    .shell,
    .shell-wide {
      width: 100%;
      margin: 0 auto;
    }
    .shell { max-width: 640px; }
    .shell-wide { max-width: 960px; }
    .app-header {
      max-width: 760px;
      margin: 0 auto 24px;
      text-align: left;
    }
    .app-header h1,
    .dash-header h1 {
      color: var(--heading, #0d1a3a);
    }
    .app-header h1 {
      margin-bottom: 12px;
      font-size: clamp(1.9rem, 4vw, 2.65rem);
      line-height: 1.1;
      letter-spacing: -0.02em;
    }
    .app-header .sub {
      margin: 0;
      max-width: 42rem;
      font-size: 1rem;
      color: #556;
      line-height: 1.7;
    }
    .steps {
      display: flex;
      gap: 8px;
      margin: 0 0 26px;
    }
    .step-dot {
      width: 30px;
      height: 30px;
      border-radius: 50%;
      background: var(--line);
      display: inline-flex;
      align-items: center;
      justify-content: center;
      font-size: 0.78rem;
      font-weight: 700;
      color: rgba(100,110,140,0.7);
      text-decoration: none;
      flex-shrink: 0;
      border: none;
    }
    .step-dot.active {
      background: var(--accent, #2f6bff);
      color: #fff;
    }
    .step-dot.done {
      background: rgba(47,107,255,0.28);
      color: rgba(47,107,255,0.9);
      cursor: pointer;
    }
    .step-dot.done:hover {
      background: rgba(47,107,255,0.45);
    }
    .card {
      border: 1px solid #C2C2C2;
      border-radius: var(--radius-lg);
      background: #fff;
      backdrop-filter: none;
      box-shadow: var(--shadow-card);
      padding: var(--card-padding, 32px);
      margin-bottom: 22px;
    }
    .card h1,
    .card h2 {
      color: var(--heading, #0d1a3a);
      letter-spacing: -0.02em;
    }
    .card h1 {
      margin: 0 0 8px;
      font-size: clamp(1.55rem, 3vw, 2rem);
      line-height: 1.15;
    }
    .card h2 {
      margin: 0 0 14px;
      font-size: 1.18rem;
    }
    .sub {
      margin: 0 0 26px;
      color: #556;
      line-height: 1.65;
    }
    .field,
    .form-group {
      margin-bottom: 18px;
    }
    .field-row {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 14px;
    }
    .field label,
    .form-group label {
      display: block;
      margin-bottom: 6px;
      font-size: 0.9rem;
      font-weight: 600;
      color: var(--ink-soft);
    }
    .field-hint {
      margin: 6px 0 0;
      font-size: 0.83rem;
      color: var(--ink-soft);
      line-height: 1.55;
    }
    .field-hint kbd {
      font-size: 0.95rem;
      padding: 3px 7px;
      background: rgba(47,107,255,0.07);
      border: 1px solid rgba(47,107,255,0.18);
      border-radius: 6px;
      font-family: inherit;
      font-weight: 600;
      color: var(--heading, #0d1a3a);
    }
    .btn-row {
      display: flex;
      flex-wrap: wrap;
      gap: 12px;
      margin-top: 24px;
      justify-content: flex-end;
    }
    .btn-danger {
      background: transparent;
      color: #b42318;
      border: 1px solid rgba(180, 35, 24, 0.18);
      box-shadow: none;
    }
    .btn-danger:hover {
      background: rgba(180, 35, 24, 0.06);
      color: #8e1c13;
    }
    .btn-sm {
      padding: 10px 16px;
      font-size: 0.88rem;
    }

/* Override external .btn — compact, square-cornered, same shape as .btn-round-add */
.btn {
  padding: 5px 14px !important;
  border-radius: 8px !important;
  font-size: 0.82rem !important;
  font-weight: 600 !important;
  line-height: 1.4 !important;
  border: 1.5px solid var(--line, #dde3f0) !important;
  background: transparent !important;
  color: var(--ink-soft, #67789e) !important;
  box-shadow: none !important;
  transition: background 0.13s, color 0.13s, border-color 0.13s !important;
}
.btn:hover {
  background: rgba(47,107,255,0.05) !important;
  border-color: rgba(47,107,255,0.25) !important;
  color: var(--accent, #2f6bff) !important;
}
.btn.btn-primary {
  border-radius: 999px !important;
  padding: 8px 20px !important;
  font-size: 0.9rem !important;
  background: var(--accent, #2f6bff) !important;
  border-color: var(--accent, #2f6bff) !important;
  color: #fff !important;
}
.btn.btn-primary:hover {
  background: #1a57f0 !important;
  border-color: #1a57f0 !important;
  color: #fff !important;
}
.btn.btn-danger {
  color: #b42318 !important;
  border-color: rgba(180,35,24,0.25) !important;
  background: transparent !important;
}
.btn.btn-danger:hover {
  background: rgba(180,35,24,0.06) !important;
  color: #8e1c13 !important;
}
.btn.btn-sm {
  padding: 4px 12px !important;
  font-size: 0.78rem !important;
}
    .flash {
      margin-bottom: 18px;
      padding: 13px 16px;
      border-radius: 16px;
      border: 1px solid rgba(180, 35, 24, 0.16);
      background: rgba(180, 35, 24, 0.08);
      color: #8e1c13;
      font-size: 0.94rem;
    }
    .eng-row {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 11px 0;
      border-bottom: 1px solid var(--line);
    }
    .eng-row:last-child { border-bottom: none; }
    .eng-name {
      flex: 1;
      font-weight: 600;
      color: var(--heading, #0d1a3a);
    }
    .eng-phone {
      color: var(--ink-soft);
      font-size: 0.92rem;
    }
    .notice {
      margin-bottom: 24px;
      padding: 14px 16px;
      border-left: 3px solid var(--highlight);
      border-radius: 0 16px 16px 0;
      background: rgba(244, 63, 140, 0.05);
      color: #556;
      line-height: 1.6;
    }
    .badge {
      display: inline-block;
      padding: 4px 10px;
      border-radius: 999px;
      font-size: 0.68rem;
      font-weight: 700;
      letter-spacing: 0.05em;
      text-transform: uppercase;
    }
    .badge-paid { background: rgba(47,107,255,0.07); color: #5070b0; }
    .badge-free { background: var(--surface-alt); color: var(--ink-soft); }
    .badge-voucher { background: rgba(168,85,247,0.07); color: #8555b0; }
    .dash-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 20px;
    }
    .or-divider {
      display: flex;
      align-items: center;
      gap: 12px;
      margin: 20px 0;
      color: var(--ink-soft);
      font-size: 0.85rem;
    }
    .or-divider::before,
    .or-divider::after {
      content: "";
      flex: 1;
      height: 1px;
      background: var(--line);
    }
    .upload-zone {
      display: block;
      border: 2px dashed var(--line);
      border-radius: 18px;
      padding: 24px;
      background: rgba(255, 255, 255, 0.72);
      color: #556;
      text-align: center;
      cursor: pointer;
      transition: border-color 0.2s ease, transform 0.2s ease, background-color 0.2s ease;
    }
    .upload-zone:hover {
      border-color: rgba(47, 107, 255, 0.28);
      transform: translateY(-2px);
      background: rgba(255, 255, 255, 0.88);
    }
    .tier-card,
    .tier-highlight {
      border: 1px solid var(--line);
      border-radius: 18px;
      padding: 22px 24px;
      margin-bottom: 24px;
      background: linear-gradient(135deg, rgba(47, 107, 255, 0.07) 0%, rgba(244, 63, 140, 0.06) 100%);
    }
    .tier-price {
      font-size: clamp(2rem, 4vw, 2.35rem);
      font-weight: 700;
      color: var(--heading, #0d1a3a);
      line-height: 1.1;
    }
    .tier-price span,
    .tier-label {
      font-size: 0.95rem;
      color: var(--ink-soft);
    }
    .inputs-table {
      width: 100%;
      border-collapse: collapse;
    }
    .inputs-table th {
      padding: 0 8px 10px 0;
      text-align: left;
      font-size: 0.72rem;
      font-weight: 700;
      letter-spacing: 0.05em;
      text-transform: uppercase;
      color: var(--ink-soft);
      border-bottom: 1.5px solid var(--line);
    }
    .inputs-table td {
      padding: 8px 8px 8px 0;
      vertical-align: middle;
      border-bottom: 1px solid var(--line);
    }
    .inputs-table tr:last-child td {
      border-bottom: none;
    }

    /* ── Unified form controls ───────────────────────────────────────────── */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="number"],
    input[type="password"],
    textarea,
    select {
      width: 100%;
      box-sizing: border-box;
      font-family: inherit;
      font-size: 0.97rem;
      font-weight: 400;
      color: var(--ink, #0d1a3a);
      background: rgba(255, 255, 255, 0.86);
      border: 1.5px solid var(--line, #dde3f0);
      border-radius: 12px;
      padding: 11px 14px;
      line-height: 1.5;
      outline: none;
      transition: border-color 0.17s ease, box-shadow 0.17s ease;
      -webkit-appearance: none;
      appearance: none;
    }
    input[type="text"]:focus,
    input[type="email"]:focus,
    input[type="tel"]:focus,
    input[type="number"]:focus,
    input[type="password"]:focus,
    textarea:focus,
    select:focus {
      border-color: var(--accent, #2f6bff);
      box-shadow: 0 0 0 3px rgba(47, 107, 255, 0.13);
    }
    input::placeholder,
    textarea::placeholder {
      color: #a8b0c4;
      font-weight: 400;
    }
    textarea {
      resize: vertical;
      line-height: 1.65;
    }
    select {
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23556' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
      background-repeat: no-repeat;
      background-position: right 13px center;
      padding-right: 36px;
      cursor: pointer;
    }
    input[type="checkbox"] {
      width: 17px;
      height: 17px;
      border-radius: 5px;
      padding: 0;
      cursor: pointer;
      accent-color: var(--accent, #2f6bff);
    }

    /* Table inputs (inputs_confirm) — fit within cells */
    .inputs-table input[type="text"],
    .inputs-table select {
      font-size: 0.88rem;
      padding: 8px 10px;
      border-radius: 8px;
    }
    .inputs-table select {
      padding-right: 30px;
      background-position: right 9px center;
    }

    kbd {
      display: inline-block;
      padding: 1px 6px;
      font-family: inherit;
      font-size: 0.8em;
      font-weight: 600;
      color: var(--ink, #0d1a3a);
      background: rgba(255,255,255,0.9);
      border: 1.5px solid var(--line, #dde3f0);
      border-radius: 5px;
      box-shadow: 0 1px 2px rgba(0,0,0,0.07);
    }

    /* ── Shared phone picker (see static/phone_picker.js) ────────────────── */
    .pp-wrap { width: 100%; }
    .pp-row { display: flex; gap: 8px; position: relative; }
    .pp-national { flex: 1; min-width: 0; }
    .pp-combo-wrap { position: relative; flex-shrink: 0; }
    .pp-combo {
      display: flex; align-items: center; gap: 5px;
      width: 130px; padding: 0 8px 0 10px;
      background: rgba(255,255,255,0.86);
      border: 1.5px solid var(--line, #dde3f0);
      border-radius: 12px;
      transition: border-color 0.17s, box-shadow 0.17s;
      cursor: text; box-sizing: border-box; height: 46px;
    }
    .pp-combo:focus-within, .pp-combo.open {
      border-color: var(--accent, #2f6bff);
      box-shadow: 0 0 0 3px rgba(47,107,255,0.13);
    }
    .pp-flag { font-size: 1.1rem; flex-shrink: 0; line-height: 1; }
    .pp-dial-input {
      flex: 1; min-width: 0;
      border: none !important; background: transparent !important;
      box-shadow: none !important; padding: 0 !important; margin: 0 !important;
      font-family: inherit !important;
      font-size: 0.93rem !important; font-weight: 500 !important;
      color: var(--ink, #0d1a3a) !important; width: 100% !important;
      outline: none !important;
    }
    .pp-chevron { opacity: 0.4; flex-shrink: 0; transition: transform 0.18s; }
    .pp-combo.open .pp-chevron { transform: rotate(180deg); }
    .pp-panel {
      display: none; position: absolute; top: calc(100% + 6px); left: 0;
      z-index: 2000; width: 260px; background: #fff;
      border: 1.5px solid var(--line, #dde3f0); border-radius: 14px;
      box-shadow: 0 8px 32px rgba(13,26,58,0.18); overflow: hidden;
    }
    .pp-panel.open { display: block; }
    .pp-list { max-height: 240px; overflow-y: auto; overscroll-behavior: contain; }
    .pp-opt {
      display: flex; align-items: center; gap: 9px; padding: 9px 14px;
      font-size: 0.9rem; color: var(--ink, #0d1a3a);
      cursor: pointer; transition: background 0.1s;
    }
    .pp-opt:hover, .pp-opt.focused { background: rgba(47,107,255,0.07); }
    .pp-opt.selected { font-weight: 600; color: var(--accent, #2f6bff); }
    .pp-code { color: var(--ink-soft); font-size: 0.85rem; margin-left: auto; flex-shrink: 0; }
    .pp-divider { height: 1px; background: var(--line, #dde3f0); margin: 4px 0; }
    .pp-group-label {
      padding: 6px 14px 2px; font-size: 0.72rem; font-weight: 700;
      letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-soft);
    }

    .nav-settings-btn {
      display: inline-flex; align-items: center; justify-content: center;
      background: transparent; border: none; cursor: pointer;
      padding: 10px 12px; border-radius: 999px;
      color: var(--ink-soft, #556); opacity: 1;
      transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
      line-height: 1;
    }
    .nav-settings-btn:hover {
      background: rgba(47, 107, 255, 0.08); color: var(--accent, #2f6bff);
      transform: translateY(-1px);
    }

    .nav-brand {
      display: flex; align-items: center; gap: 10px;
    }
    .nav-firm-sep {
      color: var(--line, #dde3f0); font-size: 1.4rem; line-height: 1; font-weight: 300;
      user-select: none;
    }
    .nav-firm-name {
      font-size: 1.05rem; font-weight: 700; color: #000;
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px;
      text-decoration: none;
    }
    a.nav-firm-name:hover { color: var(--accent, #2f6bff); }

    @media (max-width: 760px) {
      .dash-grid,
      .field-row {
        grid-template-columns: 1fr;
      }
      .app-section {
        padding: 40px 18px 64px;
      }
      .card {
        padding: 24px 20px;
      }
      nav .nav-menu {
        gap: 14px;
      }
      .inputs-table thead {
        display: none;
      }
      .inputs-table tr {
        display: block;
        margin-bottom: 18px;
        border-bottom: 1.5px solid var(--line, #dde3f0);
        padding-bottom: 18px;
      }
      .inputs-table td {
        display: block;
        border-bottom: none;
        padding: 4px 0;
      }
    }

/* ── Dark mode — neutral dark, applied via html.dark-mode ───────────────────
   Script in base.html <head> adds the class from localStorage before render,
   so there is no flash. All colours are neutral dark (no blue tint).        */

/* Dark palette — two levels, borders do the separation work:
   page #000000  →  surface #000000  →  elevated #000000             */

html.dark-mode body {
  background: #000000 !important;
  background-image: none !important;
  color: #e0e0e0;
  --dm-base:     #000000;
  --dm-raised:   #000000;
  --dm-elevated: #000000;
  --dm-border:   rgba(255,255,255,0.18);
  --ink: #e0e0e0;
  --ink-soft: #e0e0e0;
  --ink-strong: #e0e0e0;
  --heading: #e0e0e0;
  --line: rgba(255,255,255,0.18);
  --surface: #000000;
  --surface-2: #000000;
  --surface-alt: #000000;
  --accent-soft: rgba(47,107,255,0.2);
  --shadow-card: none;
}
html.dark-mode body::before,
html.dark-mode body::after { display: none !important; background: none !important; }
html.dark-mode .app-section { background: #000000; }

/* Nav — same as body, seamless */
nav { border-color: rgba(0,0,0,0.08) !important; transition: border-color 0.25s ease !important; }
nav:hover { border-color: rgba(0,0,0,0.22) !important; }
html.dark-mode nav { background: #181818 !important; border-color: transparent !important; }
html.dark-mode .nav-firm-name { color: #e0e0e0; }
html.dark-mode a.nav-firm-name:hover { color: #ffffff; }
html.dark-mode nav a, html.dark-mode .nav-action-btn { color: #e0e0e0; }
html.dark-mode nav a:hover { color: #ffffff; }
html.dark-mode #signout-link { color: #e0e0e0; }
html.dark-mode #signout-link.signout-armed { background: rgba(255,69,58,0.15); color: #ff453a; border-radius: 999px; }

/* Cards — one step up */
html.dark-mode .card {
  background: #181818 !important;
  border-color: #797979 !important;
  border-width: 3px !important;
  box-shadow: none;
}
html.dark-mode .card h1,
html.dark-mode .card h2 { color: #e0e0e0; }
html.dark-mode .sub { color: #e0e0e0; }

/* Buttons (base) — elevated */
html.dark-mode .btn {
  background: #000000 !important;
  border-color: rgba(255,255,255,0.12) !important;
  color: #e0e0e0 !important;
}
html.dark-mode .btn:hover {
  background: rgba(255,255,255,0.06) !important;
  border-color: rgba(255,255,255,0.22) !important;
  color: #ffffff !important;
}
html.dark-mode .btn-primary {
  background: var(--accent, #2f6bff) !important;
  border-color: var(--accent, #2f6bff) !important;
  color: #fff !important;
}
html.dark-mode .btn-danger {
  background: rgba(255,69,58,0.1) !important;
  border-color: rgba(255,69,58,0.3) !important;
  color: #ff6b6b !important;
}
html.dark-mode .btn-danger:hover { border-color: rgba(255,69,58,0.55) !important; }

/* Form inputs — elevated */
html.dark-mode input[type="text"],
html.dark-mode input[type="email"],
html.dark-mode input[type="tel"],
html.dark-mode input[type="number"],
html.dark-mode input[type="password"],
html.dark-mode textarea,
html.dark-mode select {
  background: #1e1e1e;
  border-color: rgba(255,255,255,0.12);
  color: #e0e0e0;
}
html.dark-mode input::placeholder,
html.dark-mode textarea::placeholder { color: #555555; }

/* Tables */
html.dark-mode th { color: #e0e0e0; border-bottom-color: rgba(255,255,255,0.1); }
html.dark-mode td { border-bottom-color: rgba(255,255,255,0.07); }

/* Badges */
html.dark-mode .badge-paid { background: rgba(74,222,128,0.12); color: #4ade80; }
html.dark-mode .badge-free { background: #000000; color: #e0e0e0; }
html.dark-mode .badge-voucher { background: rgba(167,139,250,0.12); color: #a78bfa; }

/* Phone picker */
html.dark-mode .pp-combo { background: #000000; border-color: rgba(255,255,255,0.12); }
html.dark-mode .pp-panel { background: #000000; border-color: rgba(255,255,255,0.12); box-shadow: 0 8px 32px rgba(0,0,0,0.8); }
html.dark-mode .pp-opt { color: #e0e0e0; }
html.dark-mode .pp-opt:hover, html.dark-mode .pp-opt.focused { background: rgba(255,255,255,0.06); }
html.dark-mode .pp-opt.selected { color: var(--accent, #2f6bff); }
html.dark-mode .pp-code { color: #e0e0e0; }
html.dark-mode .pp-divider { background: rgba(255,255,255,0.18); }
html.dark-mode .pp-dial-input { color: #e0e0e0 !important; }

/* Footer */
html.dark-mode footer { background: #000000; color: #e0e0e0; border-top-color: rgba(255,255,255,0.06); }
html.dark-mode footer a { color: #e0e0e0; }

/* No gradients */
html.dark-mode .tier-card,
html.dark-mode .tier-highlight { background: #000000; }

/* ── Custom tooltip ─────────────────────────────────────────────────────── */
.custom-tip {
  position: fixed !important;
  z-index: 2147483647;
  background: #111 !important;
  color: #fff !important;
  font-size: 11px;
  line-height: 1.4;
  padding: 5px 9px;
  border-radius: 6px;
  border: none !important;
  box-shadow: none !important;
  pointer-events: none;
  white-space: pre-wrap;
  max-width: 260px;
  margin: 0;
  inset: unset;
}

/* ── Sign-out armed state ───────────────────────────────────────────────── */
#signout-link {
  padding: 3px 10px;
  border-radius: 999px;
  outline: 2px solid transparent;
  outline-offset: 2px;
  transition: background 0.15s, color 0.15s;
}
#signout-link.signout-armed {
  color: #1d4ed8 !important;
  font-weight: 600 !important;
  outline-color: transparent;
  background: rgba(29,78,216,0.10);
  border-radius: 999px;
}
