/* ==========================================================
   Smart Lock Installation Pro - members app
   Design tokens
   ========================================================== */
:root {
  --navy: #142D4E;
  --navy-2: #1B3A61;
  --navy-3: #2B4C77;
  --teal: #00A896;
  --teal-hover: #008F80;
  --teal-text: #00796B;      /* teal for small text on white (AA contrast) */
  --teal-light: #3CC9B9;
  --teal-soft: #E6F6F4;
  --white: #FFFFFF;
  --offwhite: #F7FAF9;
  --gray: #64748B;
  --gray-text: #334155;
  --gray-light: #E2E8F0;
  --warn: #B45309;
  --warn-soft: #FEF3C7;
  --danger: #B91C1C;
  --danger-soft: #FEE2E2;

  --radius: 14px;
  --radius-sm: 10px;
  --header-h: 56px;
  --tabbar-h: 64px;
  --sidebar-w: 300px;
  --ease: 0.2s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--offwhite);
  color: var(--gray-text);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--teal-text); }
button { font: inherit; }
:focus-visible { outline: 3px solid var(--teal-light); outline-offset: 2px; border-radius: 6px; }
#view:focus { outline: none; }

h1, h2, h3, h4 { color: var(--navy); line-height: 1.25; }
h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.4px; }
h2 { font-size: 20px; font-weight: 800; letter-spacing: -0.2px; }
h3 { font-size: 17px; font-weight: 700; }
.muted { color: var(--gray); }
.small { font-size: 14px; }
.kicker {
  font-size: 12px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--teal-text); margin-bottom: 6px;
}

/* ==========================================================
   Layout
   ========================================================== */
.app-header {
  position: sticky; top: 0; z-index: 40;
  height: var(--header-h);
  background: var(--navy); color: var(--white);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--white); text-decoration: none; min-width: 0; }
.brand-mark { width: 30px; height: 30px; flex: 0 0 30px; }
.brand-text { line-height: 1.1; min-width: 0; }
.brand-name { font-weight: 800; font-size: 14px; letter-spacing: 0.6px; white-space: nowrap; }
.brand-name span { color: var(--teal-light); }
.brand-sub { font-size: 11px; color: #A9B8CC; white-space: nowrap; }
@media (max-width: 420px) {
  .brand-name { font-size: 12px; letter-spacing: 0.2px; }
  .plan-pill { font-size: 10px; padding: 4px 8px; }
}
.plan-pill {
  font-size: 11px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase;
  padding: 5px 10px; border-radius: 999px; background: var(--navy-3); color: var(--white); white-space: nowrap;
}
.plan-pill.premium { background: var(--teal); }

.shell { display: block; }
.sidebar { display: none; }
main { padding: 20px 16px calc(var(--tabbar-h) + 32px); min-height: 70vh; }
.content { max-width: 720px; margin: 0 auto; }

/* Bottom tab bar (mobile) */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: var(--tabbar-h);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--white); border-top: 1px solid var(--gray-light);
  display: grid; grid-template-columns: repeat(5, 1fr);
}
.tabbar[hidden], .plan-pill[hidden] { display: none; }
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  text-decoration: none; color: var(--gray); font-size: 11px; font-weight: 600;
  min-height: 48px;
}
.tabbar a svg { width: 22px; height: 22px; }
.tabbar a.active { color: var(--teal-text); }

/* Desktop */
@media (min-width: 1024px) {
  .tabbar { display: none; }
  .shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; }
  .sidebar {
    display: block; position: sticky; top: var(--header-h);
    height: calc(100vh - var(--header-h)); overflow-y: auto;
    background: var(--white); border-right: 1px solid var(--gray-light);
    padding: 18px 14px 30px;
  }
  main { padding: 32px 40px 60px; }
  h1 { font-size: 32px; }
  h2 { font-size: 22px; }
}
.side-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px;
  color: var(--gray-text); text-decoration: none; font-size: 14px; font-weight: 600;
}
.side-nav a:hover { background: var(--offwhite); }
.side-nav a.active { background: var(--teal-soft); color: var(--navy); }
.side-nav a svg { width: 18px; height: 18px; flex: 0 0 18px; color: var(--gray); }
.side-progress { margin: 4px 10px 16px; }
.side-group { margin-top: 14px; }
.side-group-title {
  font-size: 11px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase;
  color: var(--gray); padding: 0 10px 6px;
}
.side-lesson { font-weight: 500 !important; font-size: 13px !important; padding: 7px 10px !important; }
.dot {
  width: 16px; height: 16px; flex: 0 0 16px; border-radius: 50%;
  border: 2px solid var(--gray-light); display: grid; place-items: center;
}
.dot.done { background: var(--teal); border-color: var(--teal); }
.dot.done::after { content: ""; width: 6px; height: 3px; border: solid var(--white); border-width: 0 0 2px 2px; transform: rotate(-45deg) translate(1px, -1px); }

/* ==========================================================
   Components
   ========================================================== */
.card {
  background: var(--white); border: 1px solid var(--gray-light);
  border-radius: var(--radius); padding: 18px;
}
.card + .card, .card + .block, .block + .card { margin-top: 14px; }
.block { margin-top: 14px; }
.stack > * + * { margin-top: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 12px 20px;
  background: var(--teal); color: var(--white);
  font-weight: 700; font-size: 15px; text-decoration: none;
  border: 0; border-radius: var(--radius-sm); cursor: pointer;
  transition: background-color var(--ease), transform var(--ease);
}
.btn:hover { background: var(--teal-hover); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 18px; height: 18px; }
.btn.secondary { background: var(--white); color: var(--navy); border: 1.5px solid var(--gray-light); }
.btn.secondary:hover { border-color: var(--teal); background: var(--white); }
.btn.navy { background: var(--navy); }
.btn.navy:hover { background: var(--navy-2); }
.btn.block-btn { width: 100%; }
.btn.sm { min-height: 40px; padding: 8px 14px; font-size: 14px; }

.progress { height: 10px; background: var(--gray-light); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--teal); border-radius: 999px; transition: width 0.5s ease; }
.progress.thin { height: 6px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  background: var(--offwhite); color: var(--gray); border: 1px solid var(--gray-light);
}
.badge.done { background: var(--teal-soft); color: var(--teal-text); border-color: transparent; }
.badge svg { width: 13px; height: 13px; }

/* Dashboard */
.hero-card {
  background: var(--navy); color: var(--white);
  border-radius: var(--radius); padding: 22px 18px; overflow: hidden; position: relative;
}
.hero-card h1 { color: var(--white); margin-bottom: 8px; }
.hero-card p { color: #C9D5E3; font-size: 15px; }
.hero-card .progress { background: rgba(255,255,255,0.15); margin: 18px 0 8px; }
.hero-card .hero-meta { display: flex; justify-content: space-between; font-size: 13px; color: #C9D5E3; margin-bottom: 16px; }
.hero-card .btn { width: 100%; }
@media (min-width: 640px) { .hero-card .btn { width: auto; } .hero-card { padding: 28px; } }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 28px 0 12px; }
.section-head a { font-size: 14px; font-weight: 600; text-decoration: none; }

.module-list { display: grid; gap: 12px; }
@media (min-width: 640px) { .module-list.two { grid-template-columns: 1fr 1fr; } }
.module-card {
  display: flex; gap: 14px; align-items: center;
  background: var(--white); border: 1px solid var(--gray-light); border-radius: var(--radius);
  padding: 12px; text-decoration: none; color: inherit;
  transition: border-color var(--ease), box-shadow var(--ease);
}
.module-card:hover { border-color: var(--teal-light); box-shadow: 0 6px 18px rgba(20,45,78,0.08); }
.module-thumb {
  width: 84px; height: 84px; flex: 0 0 84px; border-radius: 10px;
  background: var(--navy-2) center/cover no-repeat; position: relative;
}
.module-thumb .num {
  position: absolute; top: 6px; left: 6px;
  background: var(--teal); color: var(--white); font-weight: 800; font-size: 12px;
  padding: 2px 7px; border-radius: 6px;
}
.module-card .info { flex: 1; min-width: 0; }
.module-card h3 { font-size: 16px; margin-bottom: 3px; }
.module-card .meta { font-size: 13px; color: var(--gray); margin-bottom: 8px; }

.start-here {
  display: flex; gap: 14px; align-items: center; text-decoration: none; color: inherit;
  background: var(--teal-soft); border: 1px solid #BFE8E2; border-radius: var(--radius); padding: 16px;
}
.start-here .icon {
  width: 44px; height: 44px; flex: 0 0 44px; border-radius: 12px; background: var(--teal);
  display: grid; place-items: center; color: var(--white);
}
.start-here .icon svg { width: 22px; height: 22px; }
.start-here h3 { margin-bottom: 2px; }

.bonus-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 640px) { .bonus-grid { grid-template-columns: 1fr 1fr; } }
.bonus-card {
  display: flex; flex-direction: column; text-decoration: none; color: inherit;
  background: var(--white); border: 1px solid var(--gray-light); border-radius: var(--radius); overflow: hidden;
  transition: border-color var(--ease), box-shadow var(--ease);
}
.bonus-card:hover { border-color: var(--teal-light); box-shadow: 0 6px 18px rgba(20,45,78,0.08); }
.bonus-cover { aspect-ratio: 16/10; background: #0F2440 center/contain no-repeat; position: relative; }
.bonus-card.locked .bonus-cover { filter: grayscale(0.6) brightness(0.55); }
.bonus-lock {
  position: absolute; top: 10px; right: 10px;
  background: rgba(20,45,78,0.92); color: var(--white);
  font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: 8px;
  display: inline-flex; gap: 6px; align-items: center;
}
.bonus-lock svg { width: 13px; height: 13px; }
.bonus-card .body { padding: 14px 16px 16px; }
.bonus-card h3 { margin-bottom: 4px; }
.bonus-card p { font-size: 14px; color: var(--gray); }

/* Extras */
.extra-card { display: flex; flex-direction: column; }
.extra-cover { margin: -18px -18px 14px; border-radius: var(--radius) var(--radius) 0 0; overflow: hidden; line-height: 0; }
.extra-cover svg { width: 100%; height: auto; display: block; }
.extra-hero { padding: 0; overflow: hidden; }
.extra-hero svg { max-width: none; border-radius: var(--radius); }

/* Lesson */
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.crumbs a { color: var(--gray); text-decoration: none; font-weight: 600; min-height: 32px; display: inline-flex; align-items: center; }
.crumbs a:hover { color: var(--teal-text); }
.crumbs span { color: var(--gray-light); }

.lesson-header { margin-bottom: 16px; }
.lesson-header h1 { margin-bottom: 8px; }
.lesson-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.lesson-intro { font-size: 17px; color: var(--gray-text); }

.learn-list { list-style: none; display: grid; gap: 8px; margin-top: 8px; }
.learn-list li { display: flex; gap: 10px; font-size: 15px; }
.learn-list svg { width: 18px; height: 18px; flex: 0 0 18px; color: var(--teal); margin-top: 3px; }

.figure { background: var(--white); border: 1px solid var(--gray-light); border-radius: var(--radius); padding: 14px; }
.figure svg { width: 100%; max-width: 480px; height: auto; display: block; margin: 0 auto; }
.figure figcaption { font-size: 13px; color: var(--gray); margin-top: 10px; text-align: center; }
.photo { border-radius: var(--radius); aspect-ratio: 16/9; background: var(--navy-2) center/cover no-repeat; }

.steps { list-style: none; counter-reset: s; }
.step { display: flex; gap: 14px; padding: 16px 0; border-top: 1px solid var(--gray-light); }
.step:first-child { border-top: 0; padding-top: 4px; }
.step-num {
  width: 32px; height: 32px; flex: 0 0 32px; border-radius: 50%;
  background: var(--navy); color: var(--white); font-weight: 800; font-size: 14px;
  display: grid; place-items: center;
}
.step-body { flex: 1; min-width: 0; }
.step-body h3 { margin: 4px 0 6px; }
.prose p { margin-bottom: 10px; }
.prose p:last-child { margin-bottom: 0; }
.prose ul, .prose ol { margin: 0 0 10px 20px; }
.prose li { margin-bottom: 6px; }
.prose strong { color: var(--navy); }
.prose .term { font-weight: 700; color: var(--navy); border-bottom: 1px dotted var(--gray); }

.callout {
  display: flex; gap: 12px; border-radius: var(--radius-sm); padding: 14px;
  font-size: 15px; border: 1px solid;
}
.callout svg { width: 20px; height: 20px; flex: 0 0 20px; margin-top: 2px; }
.callout .title { font-weight: 800; color: var(--navy); display: block; margin-bottom: 2px; }
.callout.tip { background: var(--teal-soft); border-color: #BFE8E2; }
.callout.tip svg { color: var(--teal-text); }
.callout.warn { background: var(--warn-soft); border-color: #FCD34D; }
.callout.warn svg { color: var(--warn); }
.callout.danger { background: var(--danger-soft); border-color: #FCA5A5; }
.callout.danger svg { color: var(--danger); }
.callout.generic { background: var(--offwhite); border-color: var(--gray-light); }
.callout.generic svg { color: var(--gray); }

/* Tables -> stacked rows on mobile */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { text-align: left; padding: 10px; border-bottom: 1px solid var(--gray-light); vertical-align: top; }
table.data th { background: var(--offwhite); color: var(--navy); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
@media (max-width: 560px) {
  table.data.stack-sm thead { display: none; }
  table.data.stack-sm tr { display: block; border: 1px solid var(--gray-light); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; background: var(--white); }
  table.data.stack-sm td { display: block; border: 0; padding: 3px 0; }
  table.data.stack-sm td::before { content: attr(data-label); display: block; font-size: 11px; font-weight: 800; letter-spacing: 0.6px; text-transform: uppercase; color: var(--gray); }
}

/* Checklist */
.checklist { list-style: none; display: grid; gap: 8px; margin-top: 10px; }
.checklist label {
  display: flex; gap: 12px; align-items: flex-start; min-height: 48px;
  padding: 12px; border: 1px solid var(--gray-light); border-radius: var(--radius-sm);
  background: var(--white); cursor: pointer; font-size: 15px;
  transition: border-color var(--ease), background-color var(--ease);
}
.checklist label:hover { border-color: var(--teal-light); }
.checklist input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.checklist .box {
  width: 22px; height: 22px; flex: 0 0 22px; border-radius: 6px; border: 2px solid #CBD5E1;
  display: grid; place-items: center; transition: background-color var(--ease), border-color var(--ease);
}
.checklist input:checked + .box { background: var(--teal); border-color: var(--teal); }
.checklist input:checked + .box::after { content: ""; width: 9px; height: 5px; border: solid var(--white); border-width: 0 0 2.5px 2.5px; transform: rotate(-45deg) translate(1px, -1px); }
.checklist input:checked ~ .txt { color: var(--gray); }
.checklist input:focus-visible + .box { outline: 3px solid var(--teal-light); outline-offset: 2px; }
.checklist-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.check-count { font-size: 13px; font-weight: 700; color: var(--gray); }

/* Lesson footer */
.complete-bar { margin-top: 18px; }
.complete-btn.is-done { background: var(--navy); }
.complete-btn.is-done:hover { background: var(--navy-2); }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.pager a {
  display: flex; flex-direction: column; gap: 2px; text-decoration: none;
  background: var(--white); border: 1px solid var(--gray-light); border-radius: var(--radius-sm);
  padding: 10px 12px; min-height: 56px; color: var(--navy); font-weight: 700; font-size: 14px;
}
.pager a:hover { border-color: var(--teal-light); }
.pager a small { font-size: 11px; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase; color: var(--gray); }
.pager a.next { text-align: right; grid-column: 2; }

/* Accordion */
.acc { border: 1px solid var(--gray-light); border-radius: var(--radius-sm); background: var(--white); overflow: hidden; }
.acc + .acc { margin-top: 8px; }
.acc summary {
  list-style: none; cursor: pointer; min-height: 52px;
  padding: 14px 44px 14px 14px; position: relative; font-weight: 700; color: var(--navy); font-size: 15px;
}
.acc summary::-webkit-details-marker { display: none; }
.acc summary::after {
  content: ""; position: absolute; right: 18px; top: 50%; width: 9px; height: 9px;
  border: solid var(--teal); border-width: 0 2.5px 2.5px 0; transform: translateY(-70%) rotate(45deg);
  transition: transform var(--ease);
}
.acc[open] summary::after { transform: translateY(-30%) rotate(-135deg); }
.acc .acc-body { padding: 0 14px 14px; font-size: 15px; }
.acc .acc-body h4 { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--teal-text); margin: 10px 0 4px; }
.acc .acc-body ol, .acc .acc-body ul { margin-left: 20px; }
.acc .acc-body li { margin-bottom: 4px; }

/* Troubleshooter */
.ts-options { display: grid; gap: 8px; margin-top: 10px; }
.ts-option {
  text-align: left; background: var(--white); border: 1.5px solid var(--gray-light); border-radius: var(--radius-sm);
  padding: 12px 14px; min-height: 48px; cursor: pointer; color: var(--navy); font-weight: 600; font-size: 15px;
  transition: border-color var(--ease), background-color var(--ease);
}
.ts-option:hover { border-color: var(--teal-light); }
.ts-option[aria-pressed="true"] { border-color: var(--teal); background: var(--teal-soft); }
.ts-result { margin-top: 14px; }
.ts-result h4 { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--teal-text); margin: 12px 0 4px; }
.ts-result ol, .ts-result ul { margin-left: 20px; }

/* Forms */
.form-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 640px) { .form-grid.two { grid-template-columns: 1fr 1fr; } }
.field label { display: block; font-weight: 700; color: var(--navy); font-size: 15px; margin-bottom: 3px; }
.field .hint { font-size: 13px; color: var(--gray); margin-bottom: 6px; }
.field select, .field input, .search-input {
  width: 100%; min-height: 48px; padding: 10px 12px;
  border: 1.5px solid var(--gray-light); border-radius: var(--radius-sm);
  font: inherit; font-size: 16px; background: var(--white); color: var(--gray-text);
}
.field select:focus, .field input:focus, .search-input:focus { outline: none; border-color: var(--teal); }
.result { margin-top: 16px; display: grid; gap: 8px; }
.result-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 15px; }
.result-row.ok { background: var(--teal-soft); }
.result-row.check { background: var(--warn-soft); }
.result-row.stop { background: var(--danger-soft); }
.result-row .ic { font-weight: 800; flex: 0 0 16px; }

/* Calendar */
table.cal { width: 100%; border-collapse: collapse; font-size: 14px; }
table.cal th, table.cal td { border: 1px solid var(--gray-light); padding: 8px; text-align: left; vertical-align: top; }
table.cal th { background: var(--navy); color: var(--white); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }
table.cal td.due { font-weight: 700; color: var(--navy); white-space: nowrap; }
table.cal input { width: 20px; height: 20px; accent-color: var(--teal); }

/* Progress page */
.mod-progress + .mod-progress { margin-top: 12px; }
.mod-progress .top { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.mod-progress .top strong { color: var(--navy); }
.lesson-rows { list-style: none; margin-top: 10px; }
.lesson-rows li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--gray-light); font-size: 14px; }
.lesson-rows a { flex: 1; color: var(--gray-text); text-decoration: none; }
.lesson-rows a:hover { color: var(--teal-text); }

/* Upgrade */
.upgrade {
  background: var(--navy); color: var(--white); border-radius: var(--radius); padding: 20px;
}
.upgrade h3 { color: var(--white); margin-bottom: 6px; }
.upgrade p { color: #C9D5E3; font-size: 15px; margin-bottom: 14px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 16px); z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--navy); color: var(--white); font-weight: 700; font-size: 14px;
  padding: 10px 16px; border-radius: 999px; display: flex; gap: 8px; align-items: center;
  transition: opacity 0.25s ease, transform 0.25s ease; box-shadow: 0 8px 20px rgba(20,45,78,0.25);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast svg { width: 18px; height: 18px; color: var(--teal-light); }
@media (min-width: 1024px) { .toast { bottom: 24px; } }

.app-footer { text-align: center; font-size: 12px; color: var(--gray); padding: 24px 16px calc(var(--tabbar-h) + 24px); }
@media (min-width: 1024px) { .app-footer { padding-bottom: 24px; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

@media print {
  .app-header, .tabbar, .sidebar, .no-print, .app-footer, .toast, .pager, .complete-bar, .crumbs { display: none !important; }
  .shell { display: block; }
  body { background: #fff; font-size: 12px; }
  main { padding: 0; }
  .card, .figure, .acc, .callout { break-inside: avoid; border-color: #bbb; }
  .acc .acc-body { display: block !important; }
  .checklist label { min-height: 0; padding: 6px 8px; }
  .photo { display: none; }
}
