/* ---------- Questionnaire ---------- */

.form-wrap {
    max-width: 1040px;
    margin: 0 auto;
    padding-bottom: 96px;
}

.form-intro {
    margin-bottom: 20px;
    color: var(--text-gray);
    font-size: 0.95rem;
}

.form-intro .req {
    margin: 0 2px;
}

.section-head {
    display: flex;
    align-items: baseline;
    gap: 14px;
    margin-bottom: 6px;
}

.section-head__num {
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

.section-head h2 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.section-note {
    color: var(--text-gray);
    font-size: 0.88rem;
    margin-bottom: 24px;
}

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

.form-group--wide {
    grid-column: 1 / -1;
}

.form-group label.form-label {
    display: block;
    font-weight: 700;
    font-size: 0.92rem;
    letter-spacing: -0.01em;
    margin-bottom: 4px;
}

.req {
    color: var(--accent);
    font-weight: 800;
}

.field-note {
    display: block;
    font-weight: 400;
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--text-gray);
    margin-bottom: 8px;
}

.form-group.invalid .ac-select,
.form-group.invalid .ac-input {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

.field-error {
    display: none;
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--accent-dark);
}

.form-group.invalid .field-error {
    display: block;
}

.checks {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ---------- Fields: one field, the same everywhere (fields.js, 2026-10-01) ----------
 * label row → control → hint UNDER the control (the same slot turns into the error).
 * A hint never sits between the label and the control; long explanations go into the "i".
 * In a form grid (.fgrid) every field spans three grid rows — label / control / hint — as a
 * subgrid, so the controls of one row share a top even when a label wraps or a hint is longer. */
.fld { display: flex; flex-direction: column; min-width: 0; }
.fld__head { display: flex; align-items: flex-end; gap: 8px; min-width: 0; margin-bottom: 6px; }
.fld__head .form-label,
.form-group .fld__head label.form-label { margin-bottom: 0; }
.fld__head .fld__label { min-width: 0; }
.fld__head > :not(.fld__label) { margin-left: auto; flex: none; }
.fld__ctl { min-width: 0; }
.fld--bare > .fld__head { display: none; }
.fld__ctl > .ac-input,
.fld__ctl > .ac-select { width: 100%; }
.fld__ctl > .tabs { margin-bottom: 0; }
.fld__hint {
    min-width: 0;
    font-size: 0.8rem;
    line-height: 1.45;
    color: var(--text-gray);
}
.fld--hinted .fld__hint,
.fld--ruled .fld__hint,
.fld.invalid .fld__hint { margin-top: 5px; }
/* A field with a format rule keeps a line for its message, so typing never moves what is below. */
.fld--ruled .fld__hint { min-height: 1.45em; }
.fld__err { display: none; color: var(--accent-dark); font-weight: 600; }
.fld.invalid .fld__note { display: none; }
.fld.invalid .fld__err { display: block; }
.fld.invalid .ac-input,
.fld.invalid .ac-select { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.fld .field-error { display: none !important; }
.fld--action .fld__ctl { display: flex; align-items: center; gap: 10px; min-height: var(--ac-control-h); }
/* The button of an action field is as tall as the controls beside it (top and bottom level, ui:check-forms). */
.fld--action .fld__ctl > .btn { height: var(--ac-control-h); padding-top: 0; padding-bottom: 0; }
/* In a row it follows a field sideways — no column gap above it. */
.fld + .fld.fld--action { margin-top: 0; }
/* The compact look of toolbars, panels and dialogs (was .mkt-field): a small uppercase label. */
.fld--compact .fld__head { margin-bottom: 6px; }
.form-group.fld--compact .fld__head label.fld__label,
.fld--compact .fld__label { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-gray); }
.fld--action .fld__label { visibility: hidden; }
/* Fields one under another (a dialog, a column). */
.fld + .fld,
.fld + .fgrid,
.fgrid + .fld,
.fgrid + .fgrid { margin-top: 16px; }
/* …unless the column already spaces them with its own gap. */
:is(.hyp__form, .profile-form, .seg-form) > :is(.fld, .fgrid) { margin-top: 0; }

.fgrid {
    --fgap: 18px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 24px;
    row-gap: 0;
    margin-bottom: calc(-1 * var(--fgap));
}
.fgrid--1 { grid-template-columns: minmax(0, 1fr); }
.fgrid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fgrid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.fgrid > * { margin-bottom: var(--fgap); }
.fgrid > .fld { grid-row: span 3; }
.fgrid > .fld + .fld { margin-top: 0; }
.fgrid > .fld--wide,
.fgrid > .form-group--wide,
.fgrid > :not(.fld) { grid-column: 1 / -1; }
@supports (grid-template-rows: subgrid) {
    .fgrid > .fld { display: grid; grid-template-rows: subgrid; row-gap: 0; }
    .fgrid > .fld > .fld__head { align-self: end; }
}
@media (max-width: 860px) {
    .fgrid, .fgrid--3 { grid-template-columns: minmax(0, 1fr); }
    .fgrid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
    .fgrid--4 { grid-template-columns: minmax(0, 1fr); }
}


/* The bar that follows the form: how much is left, and the one action. */
.form-bar {
    position: sticky;
    bottom: 0;
    margin-top: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 20px;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(6px);
    border: 1px solid var(--border-gray);
    border-radius: var(--radius);
    box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.06);
}

.form-bar__left {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.progress {
    width: 140px;
    height: 6px;
    border-radius: 3px;
    background: var(--light-gray);
    overflow: hidden;
    flex: 0 0 auto;
}

.progress__fill {
    height: 100%;
    width: 0;
    background: var(--primary);
    transition: width 0.25s;
}

.progress.done .progress__fill {
    background: var(--accent);
}

.form-bar__count {
    font-size: 0.85rem;
    color: var(--text-gray);
    white-space: nowrap;
}

.form-bar__right {
    display: flex;
    gap: 10px;
}

.form-bar .btn-primary {
    padding: 10px 22px;
    font-size: 0.95rem;
}

/* ---------- Result ---------- */

.result-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.result-head h2 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.result-head p {
    color: var(--text-gray);
    font-size: 0.88rem;
}

.result-acts {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.tabs {
    display: inline-flex;
    padding: 3px;
    margin-bottom: 12px;
    border: 1px solid var(--border-gray);
    border-radius: 8px;
    background: var(--light-gray);
}

.tabs button {
    padding: 6px 14px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text-gray);
    font: inherit;
    font-size: 0.85rem;
    cursor: pointer;
}

.tabs button.on {
    background: var(--white);
    color: var(--primary);
    font-weight: 600;
    box-shadow: var(--shadow);
}

.prompt-box {
    width: 100%;
    min-height: 60vh;
    padding: 20px 22px;
    border: 1px solid var(--border-gray);
    border-radius: 10px;
    background: #FAFAFA;
    font-family: 'SF Mono', ui-monospace, Menlo, Consolas, monospace;
    font-size: 0.82rem;
    line-height: 1.6;
    color: var(--primary);
    resize: vertical;
}

.prompt-box:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

.next-step {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.next-step h3 {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-gray);
    margin-bottom: 4px;
}

.next-step p {
    font-size: 0.9rem;
    color: var(--text-gray);
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    transform: translateX(-50%);
    padding: 10px 18px;
    border-radius: 10px;
    background: var(--primary);
    color: var(--white);
    font-size: 0.88rem;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
    z-index: 1000;
}

/* ---------- Table, toolbar, badges (from book-forms admin.css) ---------- */

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.table-panel {
    padding: 0;
    overflow: hidden;
}

.table-scroll {
    overflow: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th,
.data-table td {
    padding: 13px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-gray);
    white-space: nowrap;
}

.data-table th {
    background: var(--light-gray);
    font-weight: 600;
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--text-gray);
    position: sticky;
    top: 0;
    z-index: 1;
    border-bottom: 0;
    box-shadow: inset 0 -1px 0 var(--border-gray);
}

.data-table tbody tr {
    cursor: pointer;
    transition: background 0.15s ease;
}

.data-table tbody tr:hover {
    background: var(--light-gray);
}

.data-table tbody tr:last-child td {
    border-bottom: 0;
}

.cell-strong { font-weight: 600; }
.cell-muted { color: var(--text-gray); }

.cell-clip {
    max-width: 420px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.table-empty {
    padding: 48px;
    text-align: center;
    color: var(--text-gray);
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: calc(6ch + 20px);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.badge--pending   { background: #F1F1F1; color: #6B6B6B; }
.badge--running   { background: var(--accent-wash); color: var(--accent-dark); }
.badge--questions { background: #FFF4D6; color: #8A5A00; }
.badge--done      { background: var(--primary); color: var(--white); }
.badge--error     { background: #FDE8E8; color: #B42318; }

