/* SaferResident app UI (landlord app, resident course, owner console). Builds on /assets/site.css tokens. */

body.app { background: var(--bg-soft); min-height: 100vh; }
.app-shell { display: grid; min-height: 100vh; grid-template-columns: 1fr; }
@media (min-width: 960px) { .app-shell { grid-template-columns: 248px 1fr; } }

.sidebar { background: #fff; border-right: 1px solid var(--line); padding: 18px 14px; display: none; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
@media (min-width: 960px) { .sidebar { display: flex; } }
.sidebar .brand { padding: 6px 10px 18px; }
.side-link { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: var(--ink-2); text-decoration: none; font-weight: 560; font-size: 0.95rem; }
.side-link:hover { background: var(--bg-soft); color: var(--ink); }
.side-link[aria-current="page"] { background: var(--blue-50); color: var(--blue-700); }
.side-link svg { width: 18px; height: 18px; flex: none; }
.side-foot { margin-top: auto; padding: 12px; border-top: 1px solid var(--line); font-size: 0.85rem; color: var(--ink-3); }
.side-foot button { margin-top: 8px; }

.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
@media (min-width: 960px) { .topbar { display: none; } }
.mobile-nav { display: flex; gap: 6px; overflow-x: auto; padding: 8px 16px; background: #fff; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.mobile-nav::-webkit-scrollbar { display: none; }
.mobile-nav .side-link { white-space: nowrap; padding: 8px 12px; }
@media (min-width: 960px) { .mobile-nav { display: none; } }

.main { padding: clamp(16px, 3vw, 36px); max-width: 1180px; width: 100%; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 20px; margin-bottom: 22px; }
.page-head h1 { font-size: clamp(1.6rem, 2.6vw, 2.1rem); margin: 0; letter-spacing: -0.025em; }
.page-head p { margin: 6px 0 0; color: var(--ink-3); }
.crumbs { font-size: 0.88rem; color: var(--ink-3); margin-bottom: 6px; }
.crumbs a { color: var(--ink-3); text-decoration: none; }
.crumbs a:hover { color: var(--blue-600); }

.panel { background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-sm); }
.panel + .panel { margin-top: 16px; }
.panel-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.panel-h h2 { font-size: 1.05rem; margin: 0; letter-spacing: -0.01em; }
.panel-b { padding: 18px 20px; }
.panel-b > :last-child { margin-bottom: 0; }

.stats { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); margin-bottom: 16px; }
@media (min-width: 900px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; }
.stat b { display: block; font-size: 1.8rem; letter-spacing: -0.03em; line-height: 1.1; }
.stat span { color: var(--ink-3); font-size: 0.9rem; }
.meter { height: 8px; border-radius: 99px; background: var(--blue-50); overflow: hidden; margin-top: 10px; }
.meter > i { display: block; height: 100%; background: var(--blue); border-radius: inherit; }

.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 0.94rem; }
.t th { text-align: left; font-weight: 600; font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); padding: 10px 20px; background: var(--bg-soft); white-space: nowrap; }
.t td { padding: 12px 20px; border-top: 1px solid var(--line); vertical-align: middle; }
.t tr:hover td { background: #fbfcfe; }
.t .muted { color: var(--ink-3); }
.t input[type="checkbox"] { width: 18px; height: 18px; }

.badge--muted { background: #eef1f6; color: var(--ink-2); }
.badge--danger { background: #fdecec; color: #b3261e; }

.empty { text-align: center; padding: 40px 20px; color: var(--ink-3); }
.empty h3 { color: var(--ink); margin-bottom: 6px; }
.empty .btn { margin-top: 14px; }

.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn--danger { background: #fff; color: #b3261e; border-color: #f2c4c2; }
.btn--danger:hover { background: #fdecec; color: #b3261e; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn[aria-busy="true"] { cursor: progress; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--blue-600); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

.form-grid { display: grid; gap: 14px; }
@media (min-width: 640px) { .form-grid.two { grid-template-columns: 1fr 1fr; } }
.field { display: grid; gap: 6px; font-weight: 600; font-size: 0.9rem; }
.field small { font-weight: 450; color: var(--ink-3); font-size: 0.84rem; }
.row-actions > input:not([type]), .row-actions > input[type="text"], .row-actions > input[type="email"] { flex: 1 1 200px; min-width: 0; }
.field input, .field select, .field textarea, .row-actions > input:not([type]), .row-actions > input[type="text"], .row-actions > input[type="email"] { font: inherit; font-size: 1rem; font-weight: 450; padding: 11px 13px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); width: 100%; }
.field textarea { min-height: 88px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .row-actions > input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px rgba(10, 102, 255, 0.14); }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; font-size: 0.95rem; }
.check input { width: 18px; height: 18px; margin-top: 3px; }
.form-foot { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; align-items: center; }
.error-text { color: #b3261e; font-weight: 600; font-size: 0.92rem; }

.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.checklist li { display: flex; gap: 12px; align-items: center; }
.checklist .dot { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; flex: none; }
.checklist .done .dot { background: var(--green); border-color: var(--green); color: #fff; }
.checklist .done span { color: var(--ink-3); text-decoration: line-through; }
.checklist a { font-weight: 600; }

.slot { display: grid; gap: 10px; padding: 16px 0; border-top: 1px solid var(--line); }
.slot:first-child { border-top: 0; padding-top: 0; }
.slot h3 { font-size: 1rem; margin: 0; }
.slot p { margin: 0; color: var(--ink-3); font-size: 0.9rem; }
.slot .thumb { width: 120px; height: 90px; border-radius: 12px; object-fit: cover; border: 1px solid var(--line); background: var(--bg-soft); }
.slot-row { display: grid; gap: 10px; }
@media (min-width: 760px) { .slot-row { grid-template-columns: 1fr 150px; align-items: start; } }
.pill-tabs { display: inline-flex; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; }
.pill-tabs button { font: inherit; font-size: 0.88rem; font-weight: 600; border: 0; background: transparent; color: var(--ink-2); padding: 7px 14px; border-radius: 999px; cursor: pointer; }
.pill-tabs button[aria-selected="true"] { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }

.dialog { border: 0; border-radius: 20px; padding: 24px; max-width: min(520px, calc(100vw - 32px)); width: 100%; box-shadow: var(--shadow-lg); }
.dialog::backdrop { background: rgba(11, 27, 52, 0.45); }
.dialog-title { font-size: 1.2rem; margin: 0 0 10px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 560; box-shadow: var(--shadow-lg); transition: all 0.25s ease; z-index: 100; max-width: calc(100vw - 32px); }
.toast.is-shown { opacity: 1; transform: translate(-50%, 0); }
.toast--err { background: #b3261e; }

/* Sign in and centered pages */
.center-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background:
  radial-gradient(600px 300px at 15% 10%, rgba(10, 102, 255, 0.08), transparent 70%), radial-gradient(520px 320px at 90% 0%, rgba(255, 122, 47, 0.08), transparent 70%), var(--bg-soft); }
.auth-card { width: 100%; max-width: 440px; background: #fff; border: 1px solid var(--line); border-radius: 24px; padding: clamp(22px, 5vw, 34px); box-shadow: var(--shadow); }
.auth-card .brand { margin-bottom: 22px; }
.auth-card h1 { font-size: 1.6rem; margin-bottom: 8px; }
.auth-card p { color: var(--ink-2); }
.auth-card .btn { width: 100%; }
.code-input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace !important; font-size: 1.6rem !important; letter-spacing: 0.4em; text-align: center; }
.fine { font-size: 0.84rem; color: var(--ink-3); margin-top: 16px; }

/* Resident course player */
.player { max-width: 560px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; background: #fff; }
@media (min-width: 600px) { .player { margin: 24px auto; min-height: auto; border: 1px solid var(--line); border-radius: 28px; box-shadow: var(--shadow); overflow: hidden; } }
.player-top { padding: 16px 18px 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 5; }
.player-meta { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 0.85rem; color: var(--ink-3); font-weight: 600; }
.player-meta .tools { display: flex; gap: 6px; }
.icon-btn { font: inherit; border: 1px solid var(--line); background: #fff; color: var(--ink-2); border-radius: 10px; min-width: 40px; min-height: 36px; padding: 4px 10px; cursor: pointer; font-weight: 650; font-size: 0.85rem; display: inline-flex; align-items: center; gap: 6px; }
.icon-btn[aria-pressed="true"] { background: var(--blue-50); color: var(--blue-700); border-color: #cfe0ff; }
.player .progress { margin-top: 10px; }
.player-body { flex: 1; padding: 20px 18px 8px; }
.player-body:focus, .main:focus { outline: none; }
.player-card .tag { display: inline-block; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--blue-600); background: var(--blue-50); padding: 4px 9px; border-radius: 6px; margin-bottom: 12px; }
.player-card h2 { font-size: clamp(1.35rem, 5vw, 1.7rem); line-height: 1.2; margin: 0 0 10px; }
.player-card .body p { margin: 0 0 10px; font-size: var(--fs, 1.05rem); color: var(--ink-2); line-height: 1.55; }
/* Every illustration is drawn at 4:3 (800 x 600), so hotspots line up even before the image loads. */
.player-card .art { border-radius: 18px; background: var(--bg-blue); overflow: hidden; margin: 4px 0 16px; position: relative; aspect-ratio: 4 / 3; }
.player-card .art img { width: 100%; height: 100%; display: block; object-fit: contain; }
.player-card .art[hidden] { display: none; }
.alt-list { margin: 0 0 12px; }
.alt-list summary { cursor: pointer; color: var(--blue-700); font-weight: 600; padding: 6px 0; }
.alt-list .options { margin-top: 6px; }
.player-card .photo { border-radius: 16px; overflow: hidden; border: 1px solid var(--line); margin: 4px 0 14px; }
.player-card .photo img { width: 100%; height: auto; display: block; }
.player-card .note { display: flex; gap: 8px; align-items: center; font-size: 0.85rem; color: var(--ink-3); margin-top: 6px; }
.hot { position: absolute; transform: translate(-50%, -50%); border-radius: 50%; border: 3px solid var(--orange); background: rgba(255, 122, 47, 0.18); cursor: pointer; padding: 0; }
.hot:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.hot.is-right { border-color: var(--green); background: rgba(14, 159, 110, 0.22); }
.hot.is-wrong { border-color: #b3261e; background: rgba(179, 38, 30, 0.14); }
@media (prefers-reduced-motion: no-preference) { .hot:not(.is-right):not(.is-wrong) { animation: pulse 1.8s ease-in-out infinite; } }
.options { display: grid; gap: 10px; margin-top: 8px; }
.option { font: inherit; text-align: left; padding: 14px 16px; border-radius: 14px; border: 1.5px solid var(--line); background: #fff; color: var(--ink); font-weight: 560; font-size: var(--fs, 1.02rem); cursor: pointer; }
.option:hover { border-color: #c8d2e1; }
.option.is-right { border-color: var(--green); background: var(--green-50); }
.option.is-wrong { border-color: #e5484d; background: #fdecec; }
.option.is-picked { border-color: var(--blue); background: var(--blue-50); }
.option .n { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--blue); color: #fff; font-size: 0.8rem; margin-right: 10px; }
.feedback-box { margin-top: 12px; padding: 12px 14px; border-radius: 12px; font-weight: 560; font-size: 0.97rem; }
.feedback-box.ok { background: var(--green-50); color: #0a6a49; }
.feedback-box.no { background: #fdecec; color: #9b1c16; }
.player-foot { padding: 12px 18px 18px; display: flex; gap: 10px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: #fff; }
.player-foot .btn { flex: 1; }
.wait-note { font-size: 0.9rem; color: var(--ink-3); text-align: center; margin: 4px 18px 0; min-height: 1.2em; }
.big-cert { text-align: center; padding: 12px 0; }
.big-cert .seal { width: 72px; height: 72px; margin: 0 auto 10px; }
.big-cert dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; text-align: left; margin: 18px auto 0; max-width: 360px; font-size: 0.95rem; }
.big-cert dt { color: var(--ink-3); }
.big-cert dd { margin: 0; font-weight: 650; }
.big-cert .code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.06em; }
.tutor { margin-top: 18px; border-top: 1px dashed var(--line); padding-top: 12px; }
.tutor summary { cursor: pointer; font-weight: 650; color: var(--blue-600); }
.tutor .answer { margin-top: 10px; padding: 12px 14px; background: var(--bg-soft); border-radius: 12px; white-space: pre-wrap; font-size: 0.95rem; }
.tutor .ai-note { font-size: 0.78rem; color: var(--ink-3); margin-top: 6px; }

@media print {
  .player-top, .player-foot, .tutor, .no-print { display: none !important; }
  .player { border: 0; box-shadow: none; }
}
.code-small { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .82rem; margin-top: 4px; letter-spacing: .04em; }

/* Course details: grouped rows that open an editor */
.slot-group { margin-top: 8px; }
.slot-group + .slot-group { margin-top: 22px; }
.group-title { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); margin: 0 0 4px; }
.slot-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px 16px; }
.slot-head > div:first-child { flex: 1 1 280px; min-width: 0; }
.slot-head p { overflow-wrap: anywhere; }
.slot-editor { display: grid; gap: 12px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.slot-editor textarea, .slot-editor input[type="tel"] { font: inherit; font-size: 1rem; padding: 11px 13px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); width: 100%; }
.slot-editor textarea { min-height: 88px; resize: vertical; }
.slot-editor textarea:focus, .slot-editor input[type="tel"]:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px rgba(10, 102, 255, 0.14); }
.photo-pick { display: grid; gap: 6px; justify-items: start; align-content: start; }

/* AI assistant (tutor) */
.tutor { border: 0; padding: 0; width: min(560px, calc(100vw - 16px)); max-height: min(78vh, 720px); border-radius: 22px; box-shadow: var(--shadow-lg); display: none; flex-direction: column; }
.tutor[open] { display: flex; }
.tutor::backdrop { background: rgba(11, 27, 52, 0.45); }
@media (max-width: 600px) { .tutor { margin: auto 8px 8px; width: calc(100vw - 16px); } }
.tutor-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; padding: 18px 18px 12px; border-bottom: 1px solid var(--line); }
.tutor-head h2 { margin: 0; font-size: 1.1rem; }
.tutor-head p { margin: 4px 0 0; font-size: 0.86rem; color: var(--ink-3); }
.tutor-log { flex: 1; overflow-y: auto; padding: 14px 18px; display: grid; gap: 10px; align-content: start; min-height: 120px; }
.bubble { max-width: 88%; padding: 10px 12px; border-radius: 14px; background: var(--bg-soft); border: 1px solid var(--line); }
.bubble p { margin: 2px 0 0; font-size: var(--fs, 1rem); line-height: 1.5; color: var(--ink); white-space: pre-line; }
.bubble .who { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-3); }
.bubble--me { justify-self: end; background: var(--blue-50); border-color: #cfe0ff; }
.bubble .call { margin-top: 8px; }
.bubble .left { display: block; margin-top: 6px; font-size: 0.8rem; color: var(--ink-3); }
.tutor-form { display: flex; gap: 8px; padding: 12px 18px 16px; border-top: 1px solid var(--line); align-items: flex-end; }
.tutor-form textarea { flex: 1; font: inherit; font-size: 1rem; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 12px; resize: none; min-height: 46px; }
.tutor-form textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px rgba(10, 102, 255, 0.14); }
.bubble .call { background: #b3261e; color: #fff; border-color: #b3261e; }

/* Property Course Builder results in the course details tab */
.review-note { margin: 0; font-size: 0.9rem; border-radius: 12px; padding: 10px 12px; }
.review-note.muted { padding: 0; color: var(--ink-3); }
.review-note.bad { background: #fdecec; color: #8c1d18; border: 1px solid #f2c4c2; }
.review-note.tip { background: var(--blue-50); color: var(--ink-2); border: 1px solid #cfe0ff; }
.review-note.es { background: var(--bg-soft); border: 1px solid var(--line); display: grid; gap: 6px; justify-items: start; }
.review-note.es p { margin: 0; color: var(--ink); }
.pill-tabs .tab-link { font-size: 0.88rem; font-weight: 600; color: var(--ink-2); padding: 7px 14px; border-radius: 999px; text-decoration: none; }
.pill-tabs .tab-link[aria-selected="true"] { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }

/* Sales demo page */
.demo-page { max-width: 760px; margin: 0 auto; padding: 32px 16px 64px; }
.demo-head .brand { margin-bottom: 24px; display: inline-flex; }
.demo-head h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); letter-spacing: -0.02em; margin: 0 0 10px; }
.demo-cards { display: grid; gap: 18px; margin-top: 24px; }
.demo-card { background: #fff; border: 1px solid var(--line); border-radius: 22px; padding: 20px; }
.demo-body { margin: 0 0 8px; color: var(--ink-2); line-height: 1.55; }
.demo-cta { margin-top: 32px; padding: 24px; border-radius: 22px; background: var(--bg-blue); text-align: center; }
.demo-cta h2 { margin: 0 0 8px; }

/* Landlord terms: preview in settings, the line residents read */
.terms-preview { margin: 0; padding: 12px 14px; border-radius: 12px; background: var(--bg-blue); color: var(--ink-2); font-size: 0.92rem; }
.notice { margin: 0; padding: 10px 14px; border-radius: 12px; background: #fff7e6; color: #7a4b00; font-size: 0.92rem; }
.player-card .terms { margin-top: 14px; padding: 12px 14px; border-radius: 12px; background: var(--green-50); color: #0b5d42; font-weight: 600; }
.referral { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.referral .row-actions { flex-wrap: wrap; gap: 8px; align-items: center; }
.referral code { word-break: break-all; }

/* Property page sharing */
.share-grid { display: grid; gap: 18px; align-items: start; }
@media (min-width: 760px) { .share-grid { grid-template-columns: 1fr 200px; } }
.share-link code { word-break: break-all; }
.share-text { margin: 6px 0 10px; padding: 12px 14px; border-radius: 12px; background: var(--bg-soft); border: 1px solid var(--line); }
.share-qr { width: 180px; height: 180px; border: 1px solid var(--line); border-radius: 12px; padding: 8px; background: #fff; }
.panel h3 { font-size: 1rem; margin: 18px 0 0; }
.terms-note { display: block; margin-top: 6px; color: var(--ink-3); font-size: 0.86rem; }
/* Fields stack inside dialogs so choices are never cut off */
.dialog .form-grid.two { grid-template-columns: 1fr; }
