/* =========================================================
   App pages (post-payment portal, coach admin) — builds on styles.css tokens
   ========================================================= */
.app-main { flex: 1; padding: 28px 0 64px; }
.app-main > * { margin-left: auto; margin-right: auto; }
.app-footer { border-top: 1px solid var(--line); background: #fff; padding: 20px 0; font-size: .8rem; color: var(--muted); }
.app-footer p { margin: 0 0 6px; max-width: 900px; }
.app-footer a { color: var(--muted); }
.app-link { font-size: .88rem; font-weight: 600; color: var(--ink-2); text-decoration: none; }
.app-link:hover { color: var(--navy-900); text-decoration: underline; }
.app-loading { text-align: center; color: var(--muted); padding: 60px 0; }
.app-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 28px 22px; margin-bottom: 20px; }
@media (min-width: 640px) { .app-card { padding: 34px 36px; } }
.app-narrow { max-width: 560px; }
.app-card h1 { font-size: clamp(1.5rem, 4vw, 2rem); margin-bottom: 10px; }
.app-card h2 { font-size: 1.35rem; margin-bottom: 8px; }
.app-card h3 { font-size: 1.08rem; margin-bottom: 6px; }
.app-form { display: grid; gap: 4px; margin-top: 12px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .95rem; color: var(--ink-2); margin: 10px 0 16px; line-height: 1.45; }
.check input { width: 20px; height: 20px; margin-top: 2px; flex: none; accent-color: var(--blue-600); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .06em; font-size: 1rem; background: var(--cream); padding: 10px 12px; border-radius: 10px; }
.test-banner { background: #fff4de; color: #9a5b00; border-radius: 10px; padding: 10px 14px; font-weight: 700; font-size: .85rem; margin-bottom: 16px; }
.field select, .field textarea { min-height: 54px; padding: 12px 16px; border: 1.5px solid var(--line); border-radius: 12px; font: inherit; font-size: 1.02rem; background: #fff; width: 100%; }
.field textarea { min-height: 96px; resize: vertical; }
.field select:focus, .field textarea:focus { outline: none; border-color: var(--blue-600); box-shadow: 0 0 0 4px var(--blue-50); }
.field .help { font-size: .85rem; color: var(--muted); margin: -2px 0 2px; }
.field-row { display: grid; gap: 0 14px; }
@media (min-width: 560px) { .field-row { grid-template-columns: 1fr 1fr; } }
.money { position: relative; }
.money::before { content: "$"; position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 600; }
.money input { padding-left: 30px; width: 100%; }
.field input { width: 100%; }

/* Portal */
.portal { max-width: 720px; }
.welcome { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; }
.welcome img { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; object-position: 50% 15%; border: 3px solid #fff; box-shadow: var(--shadow-sm); flex: none; }
.welcome h1 { font-size: clamp(1.4rem, 4vw, 1.9rem); margin: 0 0 2px; }
.welcome p { margin: 0; color: var(--muted); font-size: .95rem; }
.tracker { display: flex; gap: 6px; list-style: none; padding: 0; margin: 0 0 22px; flex-wrap: wrap; }
.tracker li { flex: 1 1 120px; display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 12px; background: #fff; border: 1px solid var(--line); font-size: .84rem; font-weight: 600; color: var(--muted); }
.tracker li::before { content: ""; width: 18px; height: 18px; border-radius: 50%; border: 2px solid #c5ccda; flex: none; box-sizing: border-box; }
.tracker li.is-done { color: var(--green-700); }
.tracker li.is-done::before { background: var(--green-600) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5'%3E%3Cpath d='M5 12l5 5L20 7'/%3E%3C/svg%3E") center/12px no-repeat; border-color: var(--green-600); }
.tracker li.is-current { color: var(--navy-900); border-color: var(--blue-600); box-shadow: inset 0 0 0 1px var(--blue-600); }
.tracker li.is-current::before { border-color: var(--blue-600); border-width: 5px; }
.wizard-top { display: flex; justify-content: space-between; align-items: center; font-size: .82rem; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.saved { font-size: .8rem; color: var(--green-700); font-weight: 600; min-height: 1em; }
.step-title { font-size: clamp(1.35rem, 3.6vw, 1.7rem); margin-bottom: 6px; }
.step-help { color: var(--muted); margin-bottom: 20px; }
.issues { background: var(--red-50); color: var(--red-600); border-radius: 12px; padding: 12px 16px; margin-bottom: 16px; font-weight: 600; font-size: .92rem; }
.issues ul { margin: 6px 0 0; padding-left: 18px; font-weight: 500; }
.dropzone { border: 2px dashed #c5ccda; border-radius: 16px; padding: 22px; text-align: center; background: #fbfcff; transition: border-color .15s, background-color .15s; cursor: pointer; }
.dropzone:hover, .dropzone.is-over { border-color: var(--blue-600); background: var(--blue-50); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone strong { display: block; color: var(--navy-900); margin-bottom: 4px; }
.dropzone span { color: var(--muted); font-size: .88rem; }
.file-ok { display: flex; gap: 12px; align-items: flex-start; background: var(--green-50); border-radius: 14px; padding: 14px 16px; margin: 12px 0; }
.file-ok b { color: var(--green-700); }
.file-ok p { margin: 2px 0 0; color: var(--ink-2); font-size: .92rem; }
.file-ok button, .linkish { background: none; border: 0; padding: 0; color: var(--blue-600); font-weight: 600; cursor: pointer; text-decoration: underline; font: inherit; font-size: .88rem; }
.file-warn { background: #fff4de; color: #7a4a00; border-radius: 12px; padding: 10px 14px; font-size: .88rem; margin: 8px 0; }
.howto { background: var(--cream); border-radius: 14px; padding: 14px 16px; margin: 0 0 14px; font-size: .92rem; color: var(--ink-2); }
.howto summary { cursor: pointer; font-weight: 700; color: var(--navy-900); }
.howto ol { margin: 10px 0 4px; padding-left: 20px; display: grid; gap: 6px; }
.review-list { display: grid; gap: 2px; margin: 0 0 18px; }
.review-list div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: .95rem; }
.review-list dt { color: var(--muted); }
.review-list dd { margin: 0; font-weight: 600; text-align: right; color: var(--navy-900); }
.status-card { text-align: center; }
.status-card .big { width: 72px; height: 72px; border-radius: 50%; background: var(--green-50); color: var(--green-600); display: grid; place-items: center; margin: 0 auto 16px; font-size: 2rem; }
.upsell { background: var(--navy-800); color: #dfe7f5; border-radius: var(--radius-lg); padding: 24px; display: grid; gap: 10px; }
.upsell h3 { color: #fff; margin: 0; font-size: 1.15rem; }
.upsell p { margin: 0; font-size: .95rem; }
.upsell .btn { justify-self: start; }
.embed-wrap--tall iframe { height: 760px; }

/* Admin */
.admin { max-width: 1240px; padding: 0 var(--gutter); }
.admin-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); font-size: .92rem; }
.admin-table th, .admin-table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.admin-table th { background: var(--navy-800); color: #fff; font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.admin-table tr:hover td { background: #f8faff; }
.admin-table a { font-weight: 700; color: var(--navy-900); }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 800; letter-spacing: .03em; text-transform: uppercase; background: var(--blue-50); color: var(--blue-600); white-space: nowrap; }
.pill--in_review { background: #fff4de; color: #9a5b00; }
.pill--delivered { background: var(--green-50); color: var(--green-700); }
.pill--generation_failed, .pill--refunded { background: var(--red-50); color: var(--red-600); }
.review-grid { display: grid; gap: 20px; }
@media (min-width: 1040px) { .review-grid { grid-template-columns: minmax(0, 1.5fr) minmax(360px, 1fr); align-items: start; } }
.preview { width: 100%; height: 72vh; min-height: 520px; border: 1px solid var(--line); border-radius: 14px; background: #f3f4f7; }
.preview-empty { display: grid; place-items: center; text-align: center; color: var(--muted); }
.chat { display: flex; flex-direction: column; height: 72vh; min-height: 520px; }
.chat-log { flex: 1; overflow-y: auto; display: grid; gap: 10px; align-content: start; padding: 4px 2px 12px; }
.msg { padding: 10px 14px; border-radius: 14px; font-size: .93rem; line-height: 1.45; max-width: 92%; white-space: pre-wrap; }
.msg--coach { background: var(--navy-800); color: #fff; justify-self: end; border-bottom-right-radius: 4px; }
.msg--assistant { background: #fff; border: 1px solid var(--line); justify-self: start; border-bottom-left-radius: 4px; }
.msg--system { background: var(--green-50); color: var(--green-700); justify-self: center; font-size: .85rem; font-weight: 600; text-align: center; }
.msg table { width: 100%; margin: 8px 0; border-collapse: collapse; font-size: .85rem; }
.msg td { padding: 4px 6px; border-top: 1px solid var(--line); }
.msg .actions { display: flex; gap: 8px; margin-top: 8px; }
.msg .actions button { min-height: 38px; padding: 8px 16px; font-size: .9rem; }
.chat-form { display: flex; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; }
.chat-form textarea { flex: 1; min-height: 56px; max-height: 160px; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px; font: inherit; resize: vertical; }
.chat-form button { min-height: 56px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: .9rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }
.opts-table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.opts-table th, .opts-table td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: right; }
.opts-table th:first-child, .opts-table td:first-child { text-align: left; }
.opts-table tr.is-featured td { background: #e8f6ef; font-weight: 700; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar .btn { min-height: 44px; padding: 10px 20px; font-size: .95rem; }
.alert { border-radius: 12px; padding: 12px 16px; margin-bottom: 14px; font-weight: 600; font-size: .92rem; }
.alert--warn { background: #fff4de; color: #7a4a00; }
.alert--err { background: var(--red-50); color: var(--red-600); }
.alert--ok { background: var(--green-50); color: var(--green-700); }
.edit-grid { display: grid; gap: 0 12px; grid-template-columns: 1fr 1fr; }
.edit-grid .field input, .edit-grid .field select { min-height: 44px; font-size: .92rem; }
dialog.confirm { border: 0; border-radius: var(--radius-lg); padding: 28px; max-width: 480px; box-shadow: var(--shadow-lg); }
dialog.confirm::backdrop { background: rgba(11,29,56,.55); }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }
#totp-qr { margin: 12px 0; }
#totp-qr img, #totp-qr canvas { margin: 0 auto; }
