:root {
  --brand: #a3102a;
  --brand-2: #7a0b1f;
  --brand-soft: #fbeef0;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --surface: #ffffff;
  --page: #f6f5f2;
  --line: #e6e4dd;
  --grid: #e1e0d9;
  --series-1: #2a78d6;
  --good: #0ca30c;
  --good-text: #006300;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --radius: 14px;
  --bs-body-font-family: "Tajawal", system-ui, -apple-system, "Segoe UI", sans-serif;
  --bs-primary: var(--brand);
  --bs-primary-rgb: 163, 16, 42;
  --bs-link-color: var(--brand);
  --bs-link-color-rgb: 163, 16, 42;
  --bs-link-hover-color: var(--brand-2);
}

html, body { background: var(--page); }
body { font-family: var(--bs-body-font-family); color: var(--ink); font-size: 15.5px; min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1 0 auto; }
.num, .tabular { font-variant-numeric: tabular-nums; }
[dir="ltr"], .ltr { direction: ltr; unicode-bidi: isolate; }

/* ---------- top bar ---------- */
.topbar { background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%); color: #fff; position: sticky; top: 0; z-index: 1020; box-shadow: 0 2px 10px rgba(0,0,0,.12); }
.topbar > .container-xl { padding-top: .6rem; padding-bottom: .6rem; }
.brand { display: flex; align-items: center; gap: .6rem; color: #fff; text-decoration: none; min-width: 0; }
.brand:hover { color: #fff; }
.brand-mark { width: 40px; height: 40px; border-radius: 12px; background: rgba(255,255,255,.16); display: grid; place-items: center; font-size: 1.2rem; flex: 0 0 auto; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-text strong { font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text small { opacity: .8; font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-light-ghost { color: #fff; border: 1px solid rgba(255,255,255,.35); background: rgba(255,255,255,.08); }
.btn-light-ghost:hover { color: var(--brand); background: #fff; }
.subnav { background: rgba(0,0,0,.14); }
.subnav .container-xl { display: flex; gap: .25rem; overflow-x: auto; scrollbar-width: none; }
.subnav .container-xl::-webkit-scrollbar { display: none; }
.subnav a { color: rgba(255,255,255,.82); text-decoration: none; padding: .6rem .85rem; white-space: nowrap; border-bottom: 3px solid transparent; font-weight: 500; font-size: .95rem; }
.subnav a:hover { color: #fff; }
.subnav a.active { color: #fff; border-bottom-color: #fff; }

.site-footer { color: var(--muted); font-size: .85rem; padding: 1.25rem 0 1.75rem; text-align: center; }

/* ---------- cards & panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.panel + .panel { margin-top: 1rem; }
.panel-title { font-size: 1.05rem; font-weight: 700; margin: 0 0 1rem; display: flex; align-items: center; gap: .5rem; }
.panel-title .bi { color: var(--brand); }
.panel-title .actions { margin-inline-start: auto; display: flex; gap: .4rem; }
.page-title { font-weight: 800; font-size: 1.5rem; margin: 0; }
.page-sub { color: var(--ink-2); margin: .25rem 0 0; }
.section-label { font-size: .8rem; font-weight: 700; color: var(--muted); letter-spacing: .02em; margin: 1.25rem 0 .5rem; }

.form-label { font-weight: 600; font-size: .92rem; margin-bottom: .3rem; }
.form-label .opt { color: var(--muted); font-weight: 400; font-size: .82rem; }
.form-label .req { color: var(--critical); }
.form-control, .form-select { border-radius: 10px; padding: .6rem .8rem; border-color: #d9d7cf; }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 .2rem rgba(163,16,42,.15); }
.btn { border-radius: 10px; font-weight: 600; }
.btn-primary { --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand-2); --bs-btn-hover-border-color: var(--brand-2); --bs-btn-active-bg: var(--brand-2); --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand); }
.btn-outline-primary { --bs-btn-color: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand); --bs-btn-active-bg: var(--brand-2); }
.nav-pills .nav-link.active { background: var(--brand); }
.nav-pills .nav-link { color: var(--ink-2); border-radius: 10px; }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }

.choice-group { display: flex; flex-wrap: wrap; gap: .5rem; }
.choice-group .btn-check + .btn { border: 1px solid #d9d7cf; background: #fff; color: var(--ink-2); font-weight: 500; }
.choice-group .btn-check:checked + .btn { background: var(--brand-soft); color: var(--brand); border-color: var(--brand); font-weight: 700; }

/* ---------- auth ---------- */
.auth-wrap { max-width: 460px; margin: 2rem auto; }
.auth-hero { text-align: center; margin-bottom: 1.25rem; }
.auth-hero .logo { width: 72px; height: 72px; border-radius: 20px; display: grid; place-items: center; margin: 0 auto .75rem; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; font-size: 2rem; box-shadow: 0 10px 25px rgba(163,16,42,.25); }
.auth-hero h1 { font-size: 1.45rem; font-weight: 800; margin: 0; }
.auth-hero p { color: var(--ink-2); margin: .35rem 0 0; }

/* ---------- participant home ---------- */
.hero-card { background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%); color: #fff; border-radius: 18px; padding: 1.4rem 1.5rem; position: relative; overflow: hidden; }
.hero-card::after { content: ""; position: absolute; inset-inline-end: -40px; top: -40px; width: 180px; height: 180px; border-radius: 50%; background: rgba(255,255,255,.07); }
.hero-card h2 { font-weight: 800; font-size: 1.35rem; margin: 0 0 .25rem; }
.hero-card .countdown { display: flex; align-items: baseline; gap: .4rem; margin-top: .75rem; }
.hero-card .countdown strong { font-size: 2.4rem; font-weight: 800; line-height: 1; }
.progress-ring { --p: 0; width: 86px; height: 86px; border-radius: 50%; background: conic-gradient(#fff calc(var(--p) * 1%), rgba(255,255,255,.2) 0); display: grid; place-items: center; flex: 0 0 auto; }
.progress-ring span { width: 70px; height: 70px; border-radius: 50%; background: var(--brand-2); display: grid; place-items: center; font-weight: 800; font-size: 1.15rem; }

.step-card { display: flex; gap: .9rem; align-items: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; height: 100%; text-decoration: none; color: inherit; transition: border-color .15s, box-shadow .15s, transform .15s; }
@media (hover: hover) {
  .step-card:hover { border-color: var(--brand); box-shadow: 0 6px 18px rgba(0,0,0,.06); color: inherit; transform: translateY(-1px); }
}
.step-card:active { transform: scale(.985); background: #fcfbf9; }
.step-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.35rem; flex: 0 0 auto; background: #f1f0ec; color: var(--ink-2); }
.step-card.is-done .step-icon { background: #e6f5e6; color: var(--good-text); }
.step-card.is-partial .step-icon { background: #fff5dc; color: #8a5a00; }
.step-card.is-todo .step-icon { background: var(--brand-soft); color: var(--brand); }
.step-card h3 { font-size: 1rem; font-weight: 700; margin: 0 0 .2rem; }
.step-card p { margin: 0; color: var(--ink-2); font-size: .9rem; }
.step-state { font-size: .8rem; font-weight: 700; display: inline-flex; align-items: center; gap: .3rem; margin-top: .45rem; }
.step-state.done { color: var(--good-text); }
.step-state.partial { color: #8a5a00; }
.step-state.todo { color: var(--brand); }

/* ---------- badges ---------- */
.badge-status { display: inline-flex; align-items: center; gap: .35rem; padding: .28rem .6rem; border-radius: 999px; font-size: .82rem; font-weight: 700; white-space: nowrap; }
.badge-status.is-empty { background: #f1f0ec; color: var(--ink-2); }
.chip { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 600; background: #f1f0ec; color: var(--ink-2); white-space: nowrap; }
.chip.good { background: #e6f5e6; color: var(--good-text); }
.chip.warn { background: #fff5dc; color: #7a5000; }
.chip.bad { background: #fde8e8; color: #9b1c1c; }
.chip.info { background: #e7f0fb; color: #1c5cab; }

/* ---------- timeline (visa history) ---------- */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline li { position: relative; padding: 0 1.75rem 1.1rem 0; }
.timeline li::before { content: ""; position: absolute; right: 7px; top: 18px; bottom: -2px; width: 2px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.timeline .dot { position: absolute; right: 0; top: 4px; width: 16px; height: 16px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px var(--line); }
.timeline .when { color: var(--muted); font-size: .82rem; }
.timeline .note { color: var(--ink-2); font-size: .9rem; margin-top: .2rem; }

/* ---------- admin: stat tiles ---------- */
.stat-tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; height: 100%; }
.stat-tile .label { color: var(--ink-2); font-size: .88rem; font-weight: 600; display: flex; align-items: center; gap: .4rem; }
.stat-tile .label .bi { color: var(--brand); }
.stat-tile .value { font-size: 2rem; font-weight: 800; line-height: 1.15; margin-top: .35rem; }
.stat-tile .value small { font-size: 1rem; color: var(--muted); font-weight: 600; }
.stat-tile .meta { color: var(--muted); font-size: .82rem; margin-top: .2rem; }
.meter { height: 6px; border-radius: 999px; background: #efede7; overflow: hidden; margin-top: .6rem; }
.meter > span { display: block; height: 100%; border-radius: 999px; background: var(--series-1); }

/* HTML bar list (labels always visible, no colour-only meaning) */
.barlist { list-style: none; margin: 0; padding: 0; }
.barlist li { display: grid; grid-template-columns: minmax(90px, 38%) 1fr auto; align-items: center; gap: .6rem; padding: .32rem 0; font-size: .9rem; }
.barlist .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.barlist .track { height: 12px; border-radius: 0 4px 4px 0; background: transparent; position: relative; }
.barlist .fill { display: block; height: 100%; min-width: 3px; border-radius: 4px 0 0 4px; background: var(--series-1); }
[dir="rtl"] .barlist .fill { border-radius: 4px 0 0 4px; }
.barlist .val { font-variant-numeric: tabular-nums; color: var(--ink-2); font-weight: 700; min-width: 3.2em; text-align: left; }
.barlist .val small { color: var(--muted); font-weight: 500; }
.barlist .swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-inline-end: .35rem; vertical-align: middle; }
.barlist a { color: inherit; text-decoration: none; }
.barlist a:hover .lbl { color: var(--brand); text-decoration: underline; }

.segbar { display: flex; height: 18px; border-radius: 6px; overflow: hidden; gap: 2px; background: var(--surface); }
.segbar span { display: block; height: 100%; }
.legend-inline { display: flex; flex-wrap: wrap; gap: .4rem 1rem; margin-top: .6rem; font-size: .85rem; color: var(--ink-2); }
.legend-inline i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-inline-end: .3rem; vertical-align: -1px; }

.alert-list { list-style: none; margin: 0; padding: 0; }
.alert-list li { display: flex; gap: .7rem; align-items: center; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.alert-list li:last-child { border-bottom: 0; }
.alert-list .ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: 0 0 auto; }
.alert-list .ico.warn { background: #fff5dc; color: #8a5a00; }
.alert-list .ico.bad { background: #fde8e8; color: #9b1c1c; }
.alert-list .ico.info { background: #e7f0fb; color: #1c5cab; }
.alert-list .txt { flex: 1; min-width: 0; }
.alert-list .count { font-weight: 800; font-size: 1.2rem; font-variant-numeric: tabular-nums; }

.chart-box { position: relative; height: 240px; }

/* ---------- tables ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; }
.table-wrap table { margin: 0; }
.table thead th { background: #faf9f6; color: var(--ink-2); font-size: .82rem; font-weight: 700; white-space: nowrap; border-bottom-color: var(--line); position: sticky; top: 0; z-index: 1; }
.table td { vertical-align: middle; border-color: #efede7; }
.table tbody tr:hover { background: #fcfbf9; }
.table .name-cell a { font-weight: 700; color: var(--ink); text-decoration: none; }
.table .name-cell a:hover { color: var(--brand); }
.table .name-cell small { display: block; color: var(--muted); font-size: .78rem; }

.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: end; }
.filters .form-control, .filters .form-select { padding: .45rem .7rem; font-size: .92rem; }

/* ---------- technical card ---------- */
.tech-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.tech-head { display: flex; gap: 1rem; align-items: center; padding: 1.25rem 1.4rem; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; }
.tech-avatar { width: 64px; height: 64px; border-radius: 16px; background: rgba(255,255,255,.18); display: grid; place-items: center; font-size: 1.6rem; font-weight: 800; flex: 0 0 auto; }
.tech-head h2 { margin: 0; font-weight: 800; font-size: 1.35rem; }
.tech-head .lat { opacity: .85; letter-spacing: .03em; }
.tech-body { padding: 1.25rem 1.4rem; }
.tech-section { margin-bottom: 1.4rem; }
.tech-section h3 { font-size: .95rem; font-weight: 800; color: var(--brand); border-bottom: 2px solid var(--brand-soft); padding-bottom: .4rem; margin-bottom: .75rem; display: flex; align-items: center; gap: .45rem; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .65rem 1.25rem; }
.kv div { min-width: 0; }
.kv dt { font-size: .78rem; color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

.admin-edit-banner { background: #fff5dc; border: 1px solid #f3dca0; color: #6b4600; border-radius: 12px; padding: .7rem 1rem; margin-bottom: 1rem; font-size: .92rem; }

.empty-state { text-align: center; padding: 2rem 1rem; color: var(--muted); }
.empty-state .bi { font-size: 2.2rem; display: block; margin-bottom: .5rem; color: #c3c2b7; }

.hint-box { background: #e7f0fb; border: 1px solid #cde2fb; color: #184f95; border-radius: 12px; padding: .75rem 1rem; font-size: .92rem; }
.warn-box { background: #fff5dc; border: 1px solid #f3dca0; color: #6b4600; border-radius: 12px; padding: .75rem 1rem; font-size: .92rem; }

.leg-box { border: 1px dashed #d9d7cf; border-radius: 12px; padding: 1rem; }
.leg-box h4 { font-size: .95rem; font-weight: 700; margin-bottom: .75rem; display: flex; align-items: center; gap: .4rem; }

.sticky-actions { position: sticky; bottom: 0; background: linear-gradient(to top, var(--page) 70%, transparent); padding: .9rem 0 .4rem; margin-top: 1rem; z-index: 5; }

/* =====================================================================
   App feel on phones
   ===================================================================== */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
a, button, .btn, label, input, select, textarea, .step-card { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
body { overscroll-behavior-y: none; }

/* top loading bar between pages */
#navProgress { position: fixed; top: 0; inset-inline: 0; height: 3px; z-index: 2000; pointer-events: none; transform-origin: right center; transform: scaleX(0); background: linear-gradient(90deg, #ffd166, #fff); opacity: 0; }
#navProgress.run { opacity: 1; animation: navRun 8s cubic-bezier(.1,.7,.2,1) forwards; }
@keyframes navRun { 0% { transform: scaleX(0); } 20% { transform: scaleX(.45); } 100% { transform: scaleX(.92); } }

/* bottom tab bar (phones) */
.tabbar { position: fixed; bottom: 0; inset-inline: 0; z-index: 1030; display: flex; background: rgba(255,255,255,.96); -webkit-backdrop-filter: saturate(180%) blur(12px); backdrop-filter: saturate(180%) blur(12px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -4px 18px rgba(0,0,0,.05); }
.tabbar a { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 58px; color: var(--muted); text-decoration: none; font-size: .72rem; font-weight: 700; position: relative; }
.tabbar a i { font-size: 1.32rem; line-height: 1; transition: transform .15s; }
.tabbar a.active { color: var(--brand); }
.tabbar a.active::before { content: ""; position: absolute; top: 0; width: 28px; height: 3px; border-radius: 0 0 3px 3px; background: var(--brand); }
.tabbar a:active i { transform: scale(.88); }

/* segmented tabs (admin editing a participant) */
.seg-tabs { display: flex; gap: 4px; background: #ebe9e3; padding: 4px; border-radius: 12px; overflow-x: auto; scrollbar-width: none; }
.seg-tabs::-webkit-scrollbar { display: none; }
.seg-tabs a { flex: 1 0 auto; text-align: center; padding: .5rem .8rem; border-radius: 9px; color: var(--ink-2); text-decoration: none; font-weight: 700; font-size: .9rem; white-space: nowrap; }
.seg-tabs a.active { background: #fff; color: var(--brand); box-shadow: 0 1px 3px rgba(0,0,0,.1); }

/* install card */
.install-card { display: flex; align-items: center; gap: .75rem; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem .9rem; margin-bottom: 1rem; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.install-card[hidden] { display: none; }
.install-card img { border-radius: 11px; flex: 0 0 auto; }

/* participant cards (admin list on phones) */
.p-cards { display: flex; flex-direction: column; gap: .6rem; }
.p-card { display: block; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem .95rem; color: inherit; text-decoration: none; }
.p-card:active { background: #fcfbf9; transform: scale(.99); }
.p-card .top { display: flex; align-items: flex-start; gap: .6rem; }
.p-card .avatar { width: 40px; height: 40px; border-radius: 12px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 800; flex: 0 0 auto; }
.p-card .nm { font-weight: 800; line-height: 1.3; }
.p-card .sub { color: var(--muted); font-size: .8rem; }
.p-card .chips { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .55rem; }

.icon-btn { min-width: 38px; min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: .25rem; }

@media (max-width: 767.98px) {
  body.has-tabbar { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  body.has-tabbar .site-footer { padding-bottom: .5rem; }
  .topbar { padding-top: env(safe-area-inset-top); }
  .topbar > .container-xl { padding-top: .45rem; padding-bottom: .45rem; }
  .brand-mark { width: 34px; height: 34px; border-radius: 10px; font-size: 1rem; }
  .brand-text strong { font-size: .95rem; }
  .brand-text small { font-size: .72rem; }
  main.container-xl { padding-top: 1rem !important; }
  body.has-tabbar .sticky-actions { bottom: calc(58px + env(safe-area-inset-bottom)); }
  .sticky-actions { padding-bottom: .6rem; display: flex; align-items: center; gap: .5rem; }
  .sticky-actions .btn-primary { flex: 1; }
  .table-desktop { display: none; }
  .filters-toggle { display: inline-flex !important; }
  .filters.collapse:not(.show) { display: none; }
  .kv { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem .9rem; }
  .tech-head { padding: 1rem; gap: .75rem; }
  .tech-head h2 { font-size: 1.15rem; }
  .tech-avatar { width: 48px; height: 48px; font-size: 1.25rem; border-radius: 13px; }
  .tech-head .progress-ring { width: 64px; height: 64px; }
  .tech-head .progress-ring span { width: 52px; height: 52px; font-size: .95rem; }
  .tech-body { padding: 1rem; }
  .flash-msg { border-radius: 12px; }
  .page-actions { width: 100%; flex-wrap: nowrap !important; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .page-actions::-webkit-scrollbar { display: none; }
  .page-actions .btn { flex: 0 0 auto; font-size: .85rem; padding: .35rem .75rem; min-height: 38px; white-space: nowrap; }
}
@media (min-width: 768px) {
  .p-cards { display: none; }
  .filters-toggle { display: none !important; }
  .filters.collapse { display: flex !important; }
}

@media (max-width: 575.98px) {
  main.container-xl { padding-left: 16px; padding-right: 16px; }
  .panel { padding: 1rem; border-radius: 16px; }
  .page-title { font-size: 1.3rem; }
  .page-sub { font-size: .92rem; }
  .hero-card { padding: 1.15rem; border-radius: 20px; }
  .hero-card h2 { font-size: 1.25rem; }
  .hero-card .countdown strong { font-size: 2rem; }
  .progress-ring { width: 74px; height: 74px; }
  .progress-ring span { width: 60px; height: 60px; font-size: 1rem; }
  .barlist li { grid-template-columns: minmax(80px, 42%) 1fr auto; }
  .stat-tile { padding: .85rem; }
  .stat-tile .value { font-size: 1.6rem; }
  /* no zoom-on-focus on iPhone: inputs must be >= 16px */
  .form-control, .form-select, .form-control-sm, .form-select-sm, .input-group-sm > .form-control { font-size: 16px !important; }
  .form-control, .form-select { min-height: 48px; }
  input[type=date].form-control, input[type=time].form-control { min-height: 48px; }
  .btn { min-height: 44px; }
  .btn-sm { min-height: 38px; }
  .btn-lg { min-height: 52px; }
  .choice-group { gap: .4rem; }
  .choice-group .btn { flex: 1 1 auto; }
  .step-card { padding: .95rem; }
  .auth-wrap { margin: .75rem auto; }
  .auth-hero .logo { width: 64px; height: 64px; font-size: 1.7rem; }
  .chart-box { height: 210px; }
  .leg-box { padding: .85rem; }
}

/* =====================================================================
   Guide, help windows, notifications, home
   ===================================================================== */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.page-head .page-sub { margin-bottom: 0; }
.help-btn { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: #fff; color: var(--brand); display: grid; place-items: center; font-size: 1.15rem; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.help-btn:active { transform: scale(.92); }

/* first-login guide bar */
.guide-bar { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: .65rem .8rem; margin-bottom: 1rem; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.guide-num { width: 42px; height: 42px; border-radius: 12px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: .95rem; flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.guide-label { font-weight: 700; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.guide-dots { display: flex; gap: 4px; margin-top: .35rem; }
.guide-dots span { flex: 1; height: 5px; border-radius: 3px; background: #ebe9e3; }
.guide-dots span.done { background: var(--good); }
.guide-dots span.now { background: var(--brand); }
.guide-skip { color: var(--muted); font-size: .85rem; text-decoration: none; padding: .4rem; }

/* step-by-step form */
.wiz-head { margin-bottom: .75rem; }
.wiz-progress { height: 6px; border-radius: 3px; background: #ebe9e3; overflow: hidden; }
.wiz-progress span { display: block; height: 100%; background: var(--brand); border-radius: 3px; transition: width .25s; }
.wiz-meta { font-size: .85rem; color: var(--ink-2); font-weight: 700; margin-top: .4rem; }
.wiz-nav { display: flex; gap: .5rem; }
form[data-wizard] .wiz-step + .wiz-step { margin-top: 0; }
form[data-wizard] .sticky-actions { display: flex; gap: .5rem; }
form[data-wizard] .sticky-actions[hidden], .wiz-nav[hidden] { display: none !important; }
.form-control.is-invalid, .form-select.is-invalid { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* help windows (coach marks) */
body.tour-on { overflow: hidden; }
.tour-overlay { position: fixed; inset: 0; z-index: 2100; background: transparent; }
.tour-spot { position: fixed; z-index: 2101; border-radius: 12px; box-shadow: 0 0 0 9999px rgba(15, 10, 12, .62), 0 0 0 3px #fff inset; pointer-events: none; transition: top .25s, left .25s, width .25s, height .25s; }
.tour-pop { position: fixed; z-index: 2102; inset-inline: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); max-width: 440px; margin-inline: auto; background: #fff; border-radius: 18px; padding: 1rem 1.1rem .9rem; box-shadow: 0 18px 50px rgba(0,0,0,.3); animation: popIn .2s ease-out; }
.tour-pop.at-top { bottom: auto; top: calc(70px + env(safe-area-inset-top)); }
@keyframes popIn { from { transform: translateY(8px); } to { transform: none; } }
.tour-head { display: flex; align-items: center; margin-bottom: .25rem; }
.tour-count { font-size: .78rem; font-weight: 800; color: var(--brand); background: var(--brand-soft); border-radius: 999px; padding: .1rem .55rem; }
.tour-x { border: 0; background: transparent; color: var(--muted); width: 34px; height: 34px; border-radius: 50%; }
.tour-pop h3 { font-size: 1.05rem; font-weight: 800; margin: .2rem 0 .3rem; }
.tour-pop p { color: var(--ink-2); margin: 0 0 .8rem; line-height: 1.75; font-size: .95rem; }
.tour-foot { display: flex; align-items: center; gap: .5rem; }
.tour-foot .btn { min-height: 40px; padding-inline: 1rem; }
.tour-dots { display: flex; gap: 4px; margin-inline-end: auto; }
.tour-dots span { width: 6px; height: 6px; border-radius: 3px; background: #dcdad3; transition: width .2s; }
.tour-dots span.on { width: 18px; background: var(--brand); }
@media (min-width: 768px) { .tour-pop { bottom: 24px; } }

/* field-by-field guide: the highlighted field stays usable, the rest is blocked */
.tour-block { position: fixed; z-index: 2100; background: transparent; }
.tour-pop.is-field { bottom: auto; top: 70px; padding: .85rem 1rem .8rem; border: 2px solid var(--brand); box-shadow: 0 14px 40px rgba(0,0,0,.28); }
.tour-pop.is-field h3 { font-size: 1rem; }
.tour-pop.is-field p { font-size: .92rem; margin-bottom: .65rem; line-height: 1.7; }
.tour-pop.is-field .tour-foot { justify-content: flex-end; }
.tour-pop.is-field .tour-foot .btn-primary { min-width: 110px; }
body.guide-on .sticky-actions { position: static; background: none; }
body.guide-on .tabbar { pointer-events: none; }
.tour-req, .tour-opt { font-size: .72rem; font-weight: 800; border-radius: 999px; padding: .1rem .5rem; margin-inline-start: .35rem; }
.tour-req { background: #fde8e8; color: #9b1c1c; }
.tour-opt { background: #f1f0ec; color: var(--ink-2); }
.tour-head .tour-x { margin-inline-start: auto; }
.tour-err { background: #fde8e8; color: #9b1c1c; border-radius: 10px; padding: .45rem .65rem; font-size: .86rem; font-weight: 700; margin: -.2rem 0 .65rem; }

/* bell */
.bell-btn { position: relative; }
.bell-badge { position: absolute; top: -5px; inset-inline-end: -5px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px; background: #ffd166; color: #5c1010; font-size: .7rem; font-weight: 800; display: grid; place-items: center; line-height: 1; box-shadow: 0 0 0 2px var(--brand); }
.bell-btn.is-on { background: #fff; color: var(--brand); }

/* flash messages as toasts */
.flash-stack { position: relative; z-index: 1040; }
@media (max-width: 767.98px) {
  .flash-stack { position: fixed; top: calc(62px + env(safe-area-inset-top)); inset-inline: 12px; }
  .flash-stack .alert { box-shadow: 0 10px 30px rgba(0,0,0,.18); margin-bottom: .5rem; }
}

/* home: next step + timeline */
.next-card { display: flex; align-items: center; gap: .85rem; background: #fff; border: 2px solid var(--brand); border-radius: 18px; padding: .9rem 1rem; text-decoration: none; color: inherit; box-shadow: 0 8px 22px rgba(163,16,42,.12); }
.next-card:active { transform: scale(.985); }
.next-card small { display: block; color: var(--brand); font-weight: 700; font-size: .78rem; }
.next-card strong { display: block; font-size: 1.05rem; line-height: 1.45; }
.next-ico { width: 48px; height: 48px; border-radius: 14px; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 1.35rem; flex: 0 0 auto; }
.next-go { background: var(--brand); color: #fff; border-radius: 999px; padding: .45rem .9rem; font-weight: 800; font-size: .9rem; white-space: nowrap; }
.next-card.is-soft { border-color: #f3dca0; box-shadow: none; }
.next-card.is-soft .next-ico { background: #fff5dc; color: #8a5a00; }
.next-card.is-soft small { color: #8a5a00; }
.next-card.is-soft strong { font-size: .95rem; }
.next-card.is-soft .next-go { background: #fff5dc; color: #8a5a00; }
.next-card.is-done { border-color: #bfe5bf; box-shadow: none; }
.next-card.is-done .next-ico { background: #e6f5e6; color: var(--good-text); }
.next-card.is-done small { color: var(--good-text); }

.step-list { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: .35rem .9rem; }
.step-row { display: flex; gap: .85rem; padding: .85rem 0; text-decoration: none; color: inherit; position: relative; }
.step-row + .step-row { border-top: 1px solid #f0eee8; }
.step-row:active { opacity: .7; }
.step-dot { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; flex: 0 0 auto; background: var(--brand-soft); color: var(--brand); font-variant-numeric: tabular-nums; }
.step-row.is-done .step-dot { background: var(--good); color: #fff; }
.step-row.is-partial .step-dot { background: #fff5dc; color: #8a5a00; }
.step-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.step-sum { color: var(--ink-2); font-size: .88rem; margin-top: .1rem; }
.step-body .step-state { margin-top: .3rem; }

.push-mini { display: flex; align-items: center; gap: .75rem; background: #fff; border: 1px dashed #d9d7cf; border-radius: 16px; padding: .75rem .9rem; }
.push-mini[hidden] { display: none; }
.push-ico { width: 42px; height: 42px; border-radius: 12px; background: #fff5dc; color: #8a5a00; display: grid; place-items: center; font-size: 1.2rem; flex: 0 0 auto; }
.push-panel .push-state { display: flex; gap: .85rem; align-items: center; }
.push-panel .push-ico { width: 52px; height: 52px; font-size: 1.5rem; }
[data-push-state="on"] .push-ico, .push-panel [data-push-state="on"] .push-ico { background: #e6f5e6; color: var(--good-text); }
[data-push-state="denied"] .push-ico { background: #fde8e8; color: #9b1c1c; }

.notif-list { display: flex; flex-direction: column; gap: .5rem; }
.notif-item { display: flex; gap: .75rem; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: .8rem .9rem; color: inherit; text-decoration: none; }
.notif-item.unread { border-color: var(--brand); background: #fffafa; }
.notif-ico { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: 0 0 auto; background: #f1f0ec; color: var(--ink-2); }
.notif-ico.reminder { background: #fff5dc; color: #8a5a00; }
.notif-ico.admin { background: var(--brand-soft); color: var(--brand); }

.celebrate { text-align: center; border-color: #bfe5bf; background: linear-gradient(180deg, #f2fbf2, #fff); }
.celebrate-emoji { font-size: 2.6rem; line-height: 1; animation: pop 0.6s ease-out; }
.celebrate h2 { font-weight: 800; font-size: 1.2rem; margin: .5rem 0 .25rem; }
.celebrate p { color: var(--ink-2); margin: 0; }
@keyframes pop { 0% { transform: scale(.3); } 70% { transform: scale(1.15); } 100% { transform: scale(1); } }

.recent-list li { display: flex; gap: .75rem; align-items: baseline; padding: .55rem 0; font-size: .92rem; }
.recent-list li + li { border-top: 1px solid #f0eee8; }

.hero-card .countdown span { line-height: 1.3; }

/* ---------- print ---------- */
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; font-size: 12px; }
  .topbar, .site-footer, .no-print, .alert, .btn, .tabbar, #navProgress, .install-card { display: none !important; }
  body.has-tabbar { padding-bottom: 0 !important; }
  main.container-xl { max-width: none; padding: 0 !important; }
  .tech-card { border: 1px solid #999; break-inside: avoid-page; }
  .print-card-wrap + .print-card-wrap { break-before: page; margin-top: 0 !important; }
  .tech-head { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .tech-section { break-inside: avoid; }
  .badge-status, .chip, .timeline .dot { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .table-wrap { border: 0; overflow: visible; }
  a { color: inherit !important; text-decoration: none !important; }
}
