:root {
  --orange: #ff5a00;
  --orange-dark: #d94c00;
  --orange-soft: #fff0e7;
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #667085;
  --border: #e4e7ec;
  --green: #138a4b;
  --green-soft: #e9f8ef;
  --red: #c53030;
  --red-soft: #fff0f0;
  --yellow: #9a6700;
  --yellow-soft: #fff7db;
  --shadow: 0 8px 24px rgba(16, 24, 40, .08);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif; color: var(--text); background: var(--bg); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.app-header { position: sticky; top: 0; z-index: 50; height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px max(14px, env(safe-area-inset-left)); background: rgba(255,255,255,.96); border-bottom: 1px solid var(--border); backdrop-filter: blur(12px); }
.brand-button { border: 0; background: transparent; display: flex; gap: 10px; align-items: center; padding: 0; color: var(--text); text-align: left; }
.brand-button small { display: block; color: var(--muted); font-size: 11px; font-weight: 600; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; color: white; background: var(--orange); border-radius: 12px; font-weight: 900; font-size: 24px; }
.save-state { min-width: 92px; text-align: right; color: var(--muted); font-size: 12px; }
.save-state.ok { color: var(--green); }
.save-state.error { color: var(--red); }
.app-main { width: min(1180px, 100%); margin: 0 auto; padding: 18px 16px calc(96px + var(--safe-bottom)); }
.hero { padding: 26px; border-radius: 24px; background: linear-gradient(135deg, #ff5a00, #ff8b45); color: white; box-shadow: var(--shadow); }
.hero h1 { font-size: clamp(27px, 5vw, 46px); line-height: 1.05; margin: 0 0 12px; }
.hero p { margin: 0; max-width: 720px; opacity: .93; line-height: 1.55; }
.grid { display: grid; gap: 14px; }
.home-grid { grid-template-columns: repeat(2, minmax(0,1fr)); margin-top: 18px; }
.action-card { display: flex; align-items: center; justify-content: space-between; min-height: 112px; padding: 20px; border: 1px solid var(--border); border-radius: 20px; background: var(--card); box-shadow: var(--shadow); color: var(--text); text-align: left; }
.action-card:hover { border-color: #ffb58a; transform: translateY(-1px); }
.action-card strong { display: block; font-size: 18px; margin-bottom: 6px; }
.action-card small { color: var(--muted); line-height: 1.35; }
.icon-circle { flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--orange-soft); color: var(--orange); font-size: 22px; }
.notice { margin-top: 18px; padding: 14px 16px; border: 1px solid #ffd7bf; background: var(--orange-soft); border-radius: 16px; color: #78350f; line-height: 1.45; }
.panel { background: var(--card); border: 1px solid var(--border); border-radius: 20px; padding: 20px; box-shadow: var(--shadow); }
.panel + .panel { margin-top: 16px; }
.panel h1, .panel h2, .panel h3 { margin-top: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label { font-weight: 700; font-size: 13px; }
.field input, .field select, .field textarea, .search-input { width: 100%; border: 1px solid #d0d5dd; border-radius: 12px; padding: 12px 13px; background: white; color: var(--text); outline: none; }
.field textarea { min-height: 88px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .search-input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(255,90,0,.13); }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.btn { min-height: 44px; border-radius: 12px; border: 1px solid transparent; padding: 10px 16px; font-weight: 750; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn-primary { color: white; background: var(--orange); }
.btn-primary:hover { background: var(--orange-dark); }
.btn-secondary { background: white; border-color: #d0d5dd; color: var(--text); }
.btn-danger { color: var(--red); border-color: #f3b3b3; background: white; }
.btn-success { color: white; background: var(--green); }
.btn-small { min-height: 36px; padding: 7px 10px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.audit-top { position: sticky; top: 64px; z-index: 40; background: var(--bg); padding: 8px 0 12px; }
.audit-summary { background: #1f2937; color: white; border-radius: 18px; padding: 14px; box-shadow: var(--shadow); }
.audit-title-row { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; }
.audit-title-row h1 { margin: 0; font-size: 19px; }
.audit-title-row p { margin: 5px 0 0; color: #d0d5dd; font-size: 12px; }
.score-badge { flex: 0 0 auto; text-align: center; background: rgba(255,255,255,.11); border-radius: 13px; padding: 8px 12px; min-width: 90px; }
.score-badge strong { display: block; font-size: 22px; }
.score-badge small { color: #d0d5dd; }
.progress { height: 8px; background: rgba(255,255,255,.15); border-radius: 999px; overflow: hidden; margin-top: 12px; }
.progress > span { display: block; height: 100%; background: var(--orange); border-radius: inherit; }
.metric-row { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 8px; margin-top: 12px; }
.metric { text-align: center; background: rgba(255,255,255,.07); padding: 8px 4px; border-radius: 10px; }
.metric strong { display: block; font-size: 15px; }
.metric small { display: block; color: #d0d5dd; font-size: 10px; margin-top: 2px; }
.audit-layout { display: grid; grid-template-columns: 285px minmax(0,1fr); gap: 16px; align-items: start; }
.sidebar { position: sticky; top: 246px; max-height: calc(100vh - 270px); overflow: auto; }
.section-list { display: flex; flex-direction: column; gap: 8px; }
.section-btn { width: 100%; border: 1px solid var(--border); background: white; border-radius: 12px; padding: 11px; text-align: left; color: var(--text); }
.section-btn.active { color: white; background: var(--orange); border-color: var(--orange); }
.section-btn strong { display: block; font-size: 13px; }
.section-btn small { display: block; margin-top: 4px; opacity: .75; }
.tools { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-bottom: 12px; }
.filters { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; }
.filter-chip { white-space: nowrap; border: 1px solid #d0d5dd; background: white; border-radius: 999px; padding: 8px 11px; font-size: 12px; }
.filter-chip.active { color: white; background: #344054; border-color: #344054; }
.section-heading { display: flex; gap: 10px; justify-content: space-between; align-items: flex-start; margin: 4px 0 12px; }
.section-heading h2 { margin: 0; font-size: 21px; }
.section-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.item-card { background: var(--card); border: 1px solid var(--border); border-left: 5px solid #d0d5dd; border-radius: 16px; padding: 16px; margin-bottom: 12px; box-shadow: 0 4px 12px rgba(16,24,40,.04); scroll-margin-top: 245px; }
.item-card.answer-yes { border-left-color: var(--green); }
.item-card.answer-no { border-left-color: var(--red); background: #fffdfd; }
.item-card.answer-na { border-left-color: #667085; }
.item-card.answer-unchecked { border-left-color: #d39b00; }
.item-meta { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 9px; }
.tag { border-radius: 999px; background: #f2f4f7; padding: 5px 8px; color: #475467; font-size: 11px; font-weight: 700; }
.tag.weight { color: #8a3e00; background: var(--orange-soft); }
.tag.warning { color: var(--red); background: var(--red-soft); }
.item-question { font-size: 15px; line-height: 1.45; font-weight: 700; white-space: pre-line; }
.item-note { margin-top: 9px; padding: 9px 11px; border-radius: 10px; background: #f8fafc; color: var(--muted); font-size: 12px; line-height: 1.4; white-space: pre-line; }
.answer-group { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 7px; margin-top: 14px; }
.answer-btn { min-height: 43px; border: 1px solid #d0d5dd; background: white; border-radius: 11px; font-weight: 800; color: #475467; }
.answer-btn.yes.active { color: white; background: var(--green); border-color: var(--green); }
.answer-btn.no.active { color: white; background: var(--red); border-color: var(--red); }
.answer-btn.na.active { color: white; background: #667085; border-color: #667085; }
.answer-btn.unchecked.active { color: #412b00; background: #f6c344; border-color: #f6c344; }
.details { margin-top: 13px; padding-top: 13px; border-top: 1px dashed #d0d5dd; }
.details-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.check-row { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; }
.check-label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; }
.check-label input { width: 20px; height: 20px; accent-color: var(--orange); }
.photo-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(125px,1fr)); gap: 9px; margin-top: 10px; }
.photo { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: #f8fafc; }
.photo img { display: block; width: 100%; aspect-ratio: 4/3; object-fit: cover; cursor: zoom-in; }
.photo-body { padding: 7px; }
.photo-body input { width: 100%; border: 0; border-bottom: 1px solid #d0d5dd; background: transparent; padding: 5px 0; font-size: 11px; }
.photo-tools { display: flex; justify-content: space-between; margin-top: 6px; }
.photo-tools button { border: 0; background: transparent; color: var(--red); padding: 3px; font-size: 11px; }
.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; display: flex; justify-content: center; padding: 9px 12px calc(9px + var(--safe-bottom)); background: rgba(255,255,255,.97); border-top: 1px solid var(--border); backdrop-filter: blur(10px); }
.bottom-nav-inner { width: min(900px,100%); display: grid; grid-template-columns: repeat(4,1fr); gap: 7px; }
.bottom-nav .btn { min-width: 0; font-size: 12px; padding-left: 8px; padding-right: 8px; }
.archive-list { display: grid; gap: 12px; }
.audit-card { background: white; border: 1px solid var(--border); border-radius: 16px; padding: 15px; }
.audit-card-top { display: flex; justify-content: space-between; gap: 12px; }
.audit-card h3 { margin: 0 0 5px; font-size: 16px; }
.audit-card p { margin: 0; color: var(--muted); font-size: 12px; }
.status { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 8px; font-size: 11px; font-weight: 800; }
.status.draft { background: var(--yellow-soft); color: var(--yellow); }
.status.completed, .status.exported { background: var(--green-soft); color: var(--green); }
.status.cancelled { background: var(--red-soft); color: var(--red); }
.audit-card-metrics { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; margin: 12px 0; }
.audit-card-metrics > div { background: #f8fafc; border-radius: 10px; padding: 8px; text-align: center; }
.audit-card-metrics strong { display:block; }
.audit-card-metrics small { font-size:10px; color:var(--muted); }
.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.toast { position: fixed; z-index: 100; left: 50%; bottom: calc(88px + var(--safe-bottom)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: #101828; color: white; padding: 11px 16px; border-radius: 12px; box-shadow: var(--shadow); transition: .2s ease; max-width: min(90vw,560px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%,0); }
.modal-backdrop { position: fixed; inset: 0; z-index: 90; background: rgba(16,24,40,.72); display: grid; place-items: center; padding: 16px; }
.modal { width: min(720px,100%); max-height: 92vh; overflow: auto; background: white; border-radius: 18px; padding: 18px; }
.modal img.full-photo { width: 100%; max-height: 72vh; object-fit: contain; background: #111827; border-radius: 12px; }
.analysis-table { width: 100%; border-collapse: collapse; }
.analysis-table th, .analysis-table td { padding: 9px; border-bottom: 1px solid var(--border); text-align: left; font-size: 13px; vertical-align: top; }
.analysis-table th { color: var(--muted); font-size: 11px; text-transform: uppercase; }
.warning-box { background: var(--yellow-soft); color: #6f4b00; border: 1px solid #f3d36e; padding: 12px; border-radius: 12px; margin-bottom: 12px; line-height: 1.45; }
.danger-box { background: var(--red-soft); color: #8f1d1d; border: 1px solid #efb1b1; padding: 12px; border-radius: 12px; margin-bottom: 12px; line-height: 1.45; }
@media (max-width: 820px) {
  .app-main { padding-left: 11px; padding-right: 11px; }
  .home-grid, .form-grid, .details-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .audit-layout { display: block; }
  .sidebar { position: static; max-height: none; margin-bottom: 12px; }
  .section-list { flex-direction: row; overflow-x: auto; padding-bottom: 5px; }
  .section-btn { min-width: 190px; }
  .audit-top { top: 64px; }
  .metric-row { grid-template-columns: repeat(5,1fr); gap: 5px; }
  .metric { padding: 7px 2px; }
  .answer-group { grid-template-columns: repeat(2,1fr); }
  .bottom-nav-inner { grid-template-columns: repeat(4,1fr); }
  .audit-card-metrics { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 520px) {
  .hero { padding: 21px 18px; border-radius: 20px; }
  .home-grid { grid-template-columns: 1fr; }
  .action-card { min-height: 92px; }
  .audit-summary { border-radius: 14px; }
  .metric small { font-size: 9px; }
  .bottom-nav .btn { font-size: 10px; gap: 3px; }
  .item-card { padding: 13px; }
  .section-heading h2 { font-size: 18px; }
}
