:root {
  --ink: #1e2b25;
  --muted: #718078;
  --line: #dfe7e1;
  --surface: #ffffff;
  --paper: #f4f7f4;
  --green: #1e7a4e;
  --green-soft: #e7f4eb;
  --red: #bd4f4f;
  --red-soft: #fff0ef;
  --amber: #b87924;
  --amber-soft: #fff5df;
  --navy: #16271f;
  --shadow: 0 12px 32px rgba(27, 57, 39, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--paper); }
button, select, input, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid rgba(30, 122, 78, .28); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.app-shell { min-height: 100vh; padding-bottom: 84px; }
.app-shell.locked { display: none; }
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--paper); }
.login-screen:not(.visible) { display: none; }
.login-card { width: min(390px, 100%); padding: 34px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
.brand-mark.large { width: 50px; height: 50px; margin-bottom: 24px; font-size: 22px; }
.login-card h1 { margin: 10px 0 8px; font-size: 28px; }
.login-note { margin: 0 0 24px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.form-control { width: 100%; height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; outline: none; color: var(--ink); background: #fbfcfb; }
.form-control:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(30, 122, 78, .12); }
.login-submit { width: 100%; margin-top: 22px; }
.form-error { min-height: 18px; margin: 10px 0 -10px; color: var(--red); font-size: 12px; }
.loading-row { min-height: 76px; padding: 22px 16px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); background: #fff; font-size: 13px; }
.topbar { height: 76px; padding: 0 5vw; display: flex; align-items: center; justify-content: space-between; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand, .topbar-actions, .user-chip, .heading-meta, .toolbar-actions, .panel-heading, .task-main, .task-actions, .task-time, .now-card, .modal-actions { display: flex; align-items: center; }
.brand { gap: 12px; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; background: var(--navy); color: #e7f2e9; font-weight: 800; font-size: 18px; }
.brand h1 { margin: 3px 0 0; font-size: 16px; font-weight: 700; }
.eyebrow { margin: 0; color: var(--muted); font-size: 10px; letter-spacing: .14em; font-weight: 800; }
.eyebrow.accent { color: var(--green); }
.topbar-actions { gap: 14px; }
.select-wrap { position: relative; display: inline-flex; }
.select-wrap select { appearance: none; min-width: 132px; height: 38px; padding: 0 32px 0 12px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23718078' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 11px center; outline: none; }
.select-wrap select:focus, .number-input:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(30, 122, 78, .12); }
.context-chip { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 12px; font-weight: 700; }
.context-chip span:last-child { padding-left: 8px; border-left: 1px solid var(--line); color: var(--green); }
.icon-button { width: 44px; height: 44px; border: 1px solid var(--line); background: #fff; border-radius: 8px; color: var(--green); font-size: 20px; }
.user-chip { gap: 8px; color: var(--ink); font-size: 13px; }
.avatar { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: #dcefe1; color: var(--green); font-weight: 800; }
.role { color: var(--muted); font-size: 12px; }
.logout-button { border: 0; color: var(--muted); background: transparent; font-size: 12px; }

.workspace { max-width: 1440px; margin: 0 auto; padding: 42px 5vw 32px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.page-heading h2 { max-width: 650px; margin: 10px 0 8px; font-size: clamp(25px, 3vw, 38px); line-height: 1.18; letter-spacing: 0; }
.subheading { margin: 0; color: var(--muted); font-size: 14px; }
.heading-meta { gap: 16px; color: var(--muted); font-size: 12px; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: #42a86d; box-shadow: 0 0 0 4px #dff1e5; }

.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 28px; }
.summary-card { min-height: 126px; padding: 20px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.summary-card.dark { color: #ecf5ef; border-color: var(--navy); background: var(--navy); }
.summary-label { color: var(--muted); font-size: 12px; font-weight: 700; }
.dark .summary-label, .dark .summary-foot { color: #a8bcaf; }
.summary-value { margin: 13px 0 5px; color: var(--ink); font-size: 32px; line-height: 1; font-weight: 800; }
.dark .summary-value { color: #fff; }
.summary-value.red { color: var(--red); }
.summary-value.amber { color: var(--amber); }
.summary-value.green { color: var(--green); }
.summary-foot { color: var(--muted); font-size: 12px; }

.content-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(300px, .72fr); gap: 24px; }
.section-toolbar { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 14px; }
h3 { margin: 5px 0 0; font-size: 21px; }
.toolbar-actions { gap: 10px; }
.segmented { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: #edf2ee; }
.segment { padding: 7px 12px; border: 0; border-radius: 6px; color: var(--muted); background: transparent; font-size: 12px; }
.segment.active { color: var(--ink); background: #fff; box-shadow: 0 1px 4px rgba(24, 55, 37, .12); font-weight: 700; }
.now-card { gap: 14px; min-height: 82px; margin-bottom: 12px; padding: 14px 16px; border-radius: 10px; background: #e9f4ec; }
.now-icon { width: 32px; height: 32px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; background: var(--green); color: #fff; font-weight: 800; }
.now-copy { display: grid; gap: 3px; flex: 1; }
.now-copy strong { font-size: 14px; }
.now-copy span:last-child { color: var(--muted); font-size: 12px; }
.primary-button, .secondary-button, .text-button { border: 0; border-radius: 8px; transition: transform .15s ease, background .15s ease; }
.primary-button { min-height: 44px; padding: 0 15px; color: #fff; background: var(--green); font-weight: 700; font-size: 13px; }
.primary-button:hover, .secondary-button:hover { transform: translateY(-1px); }
.secondary-button { min-height: 44px; padding: 0 14px; border: 1px solid var(--line); color: var(--ink); background: #fff; font-size: 13px; }
.secondary-button.full { width: 100%; }
.text-button { padding: 5px 0; color: var(--green); background: transparent; font-size: 13px; font-weight: 700; }
.text-button span { margin-left: 7px; }

.task-list { display: grid; gap: 8px; }
.task-row { display: grid; grid-template-columns: 76px minmax(0, 1fr) auto; align-items: center; gap: 14px; min-height: 76px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.task-row:hover { border-color: #b7cdbd; box-shadow: 0 5px 16px rgba(27, 57, 39, .05); }
.task-time { gap: 6px; color: var(--muted); font-size: 12px; }
.task-time strong { color: var(--ink); font-size: 14px; }
.task-main { min-width: 0; gap: 10px; }
.task-indicator { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: #b7c3ba; }
.task-indicator.complete { background: var(--green); }
.task-indicator.pending { background: var(--red); }
.task-indicator.exception { background: var(--amber); }
.task-copy { min-width: 0; }
.task-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.task-copy span { display: block; margin-top: 4px; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.task-actions { gap: 10px; }
.status-pill, .score-badge, .count-pill { display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; font-size: 11px; font-weight: 800; }
.status-pill { min-width: 54px; height: 26px; padding: 0 9px; }
.status-pill.complete { color: var(--green); background: var(--green-soft); }
.status-pill.pending { color: var(--red); background: var(--red-soft); }
.status-pill.exception { color: var(--amber); background: var(--amber-soft); }
.status-pill.none { color: var(--muted); background: #eef2ef; }
.task-action { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 7px; color: var(--green); background: #fff; font-weight: 800; }

.side-column { display: grid; align-content: start; gap: 16px; }
.panel { padding: 20px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.panel-heading { justify-content: space-between; gap: 12px; }
.score-badge { height: 24px; padding: 0 9px; color: var(--green); background: var(--green-soft); }
.score-badge.warn { color: var(--amber); background: var(--amber-soft); }
.score-ring { position: relative; width: 134px; height: 134px; display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 24px auto 16px; border-radius: 50%; background: conic-gradient(var(--green) calc(var(--score) * 1%), #dfeee3 0); }
.score-ring::before { position: absolute; inset: 10px; border-radius: 50%; background: #fff; content: ""; }
.score-ring strong, .score-ring span { position: relative; z-index: 1; }
.score-ring strong { font-size: 36px; line-height: 1; }
.score-ring span { margin-top: 3px; color: var(--muted); font-size: 12px; }
.panel-note { margin: 0 0 16px; color: var(--muted); text-align: center; font-size: 12px; line-height: 1.6; }
.deduction-list { display: grid; gap: 7px; margin: 16px 0; }
.inspection-checklist-heading { display: flex; align-items: end; justify-content: space-between; gap: 10px; margin-top: 18px; }
.inspection-checklist-heading .field-label { margin-bottom: 7px; }
.checklist-hint { color: var(--muted); font-size: 11px; }
.inspection-total { margin: 0 0 8px; padding: 9px 10px; border-radius: 7px; color: var(--amber); background: var(--amber-soft); font-size: 12px; font-weight: 800; }
.inspection-checklist { display: grid; gap: 7px; max-height: 270px; overflow: auto; padding-right: 3px; }
.inspection-group { margin-top: 8px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.inspection-group summary { display: flex; justify-content: space-between; padding: 11px; color: var(--green); background: #f7faf7; font-size: 12px; font-weight: 800; cursor: pointer; }
.inspection-group-body { display: grid; gap: 7px; padding: 8px; }
.inspection-item { display: grid; grid-template-columns: minmax(0, 1fr) 96px; gap: 8px; align-items: center; padding: 8px 9px; border: 1px solid var(--line); border-radius: 7px; background: #fbfcfb; }
.inspection-item.redline { border-color: #e7c5a0; background: var(--amber-soft); }
.inspection-item-copy { min-width: 0; }
.inspection-item-copy strong { display: block; font-size: 12px; }
.inspection-item-copy span { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; line-height: 1.4; }
.inspection-status { width: 92px; height: 32px; padding: 0 6px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: #fff; font-size: 11px; }
.inspection-detail { grid-column: 1 / -1; display: none; grid-template-columns: 96px minmax(0, 1fr); gap: 6px; }
.inspection-item.has-issue .inspection-detail { display: grid; }
.inspection-deduction, .inspection-owner { width: 100%; height: 32px; padding: 0 7px; border: 1px solid var(--line); border-radius: 6px; outline: none; color: var(--ink); background: #fff; font-size: 11px; }
.inspection-deduction:focus, .inspection-owner:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(30, 122, 78, .12); }
.deduction-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 7px; background: var(--amber-soft); color: var(--amber); font-size: 12px; }
.deduction-item span { font-size: 10px; font-weight: 800; }
.deduction-item strong { color: var(--ink); font-weight: 600; }
.count-pill { min-width: 25px; height: 25px; color: var(--red); background: var(--red-soft); }
.focus-list { display: grid; gap: 10px; margin: 20px 0 16px; }
.focus-item { display: grid; grid-template-columns: 7px minmax(0, 1fr); gap: 9px; align-items: start; }
.focus-item i { width: 7px; height: 7px; margin-top: 5px; border-radius: 50%; background: var(--red); }
.focus-item.amber i { background: var(--amber); }
.focus-item strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.focus-item span { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.empty-focus { color: var(--muted); font-size: 13px; }
.network-banner { position: sticky; z-index: 6; top: 0; padding: 10px 16px; color: #7a4810; background: var(--amber-soft); border-bottom: 1px solid #efd59f; text-align: center; font-size: 12px; font-weight: 700; }

.bottom-nav { position: fixed; z-index: 5; right: 0; bottom: 0; left: 0; display: flex; justify-content: center; gap: 34px; height: 70px; padding: 8px; border-top: 1px solid var(--line); background: rgba(255,255,255,.96); backdrop-filter: blur(16px); }
.nav-item { position: relative; min-width: 70px; display: grid; place-items: center; gap: 3px; border: 0; color: var(--muted); background: transparent; font-size: 11px; }
.nav-item.active { color: var(--green); font-weight: 800; }
.nav-icon { font-size: 20px; line-height: 1; }
.nav-badge { position: absolute; top: 0; right: 8px; min-width: 17px; height: 17px; display: grid; place-items: center; border-radius: 9px; color: #fff; background: var(--red); font-size: 10px; }

.modal { width: min(440px, calc(100% - 28px)); padding: 0; border: 0; border-radius: 12px; box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(14, 28, 20, .38); backdrop-filter: blur(3px); }
.modal-card { position: relative; padding: 26px; }
.modal-close { position: absolute; top: 14px; right: 16px; border: 0; color: var(--muted); background: transparent; font-size: 24px; }
.modal-meta { margin: 9px 0 20px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.status-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0 20px; }
.status-choice { height: 44px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 13px; font-weight: 700; }
.status-choice.selected.complete { border-color: var(--green); color: var(--green); background: var(--green-soft); }
.status-choice.selected.pending { border-color: var(--red); color: var(--red); background: var(--red-soft); }
.status-choice.selected.exception { border-color: var(--amber); color: var(--amber); background: var(--amber-soft); }
.field-label { display: flex; justify-content: space-between; margin: 14px 0 7px; font-size: 12px; font-weight: 800; }
.field-label span { color: var(--muted); font-weight: 500; }
.handoff-check { display: flex; align-items: center; gap: 8px; margin-top: 10px; color: var(--ink); font-size: 12px; font-weight: 700; }
.handoff-check input { width: 16px; height: 16px; accent-color: var(--green); }
.meeting-items { display: grid; gap: 8px; }
.meeting-item { display: grid; grid-template-columns: minmax(0, 1fr) 110px 34px; gap: 6px; }
.meeting-item input, .meeting-item select { height: 36px; padding: 0 8px; border: 1px solid var(--line); border-radius: 7px; background: #fbfcfb; font-size: 12px; }
.meeting-item button { border: 1px solid var(--line); border-radius: 7px; color: var(--red); background: #fff; }
.other-deduction-row { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 8px; margin-top: 8px; }
.focus-section { display: grid; gap: 8px; }
.focus-section + .focus-section { margin-top: 14px; }
.focus-section-title { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; font-weight: 800; }
.focus-actions { display: flex; gap: 6px; margin-top: 6px; }
.focus-action { padding: 4px 7px; border: 1px solid var(--line); border-radius: 6px; color: var(--green); background: #fff; font-size: 10px; }
textarea, .number-input { width: 100%; border: 1px solid var(--line); border-radius: 8px; outline: none; background: #fbfcfb; }
.file-input { width: 100%; padding: 9px; border: 1px dashed #b7cdbd; border-radius: 8px; color: var(--muted); background: #fbfcfb; font-size: 12px; }
.photo-preview { margin-top: 8px; }
.photo-preview img { width: 76px; height: 56px; display: block; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
textarea { resize: vertical; padding: 10px 12px; line-height: 1.5; }
.number-input { height: 48px; padding: 0 12px; font-size: 20px; font-weight: 800; }
.modal-actions { justify-content: flex-end; gap: 8px; margin-top: 22px; }
.bot-message { margin: 18px 0; padding: 16px; white-space: pre-wrap; border-radius: 8px; background: #f2f6f2; color: var(--ink); font-size: 14px; line-height: 1.8; }
.dialog-list { display: grid; gap: 10px; max-height: 56vh; margin-top: 18px; overflow-y: auto; }
.dialog-list-item { padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: #fbfcfb; }
.dialog-list-item strong { display: block; font-size: 13px; }
.dialog-list-item span { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.dialog-list-item .focus-actions { margin-top: 10px; }

@media (max-width: 900px) {
  .content-grid { grid-template-columns: 1fr; }
  .side-column { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .topbar { height: auto; min-height: 68px; padding: 10px 16px; flex-wrap: wrap; gap: 8px; }
  .brand { flex: 1; }
  .brand .eyebrow { display: none; }
  .brand-mark { width: 34px; height: 34px; border-radius: 8px; font-size: 16px; }
  .topbar-actions { width: 100%; gap: 7px; justify-content: space-between; }
  .topbar .select-wrap { flex: 1; }
  .topbar .select-wrap select { width: 100%; min-width: 0; max-width: none; }
  .user-chip #contextUser, .user-chip .avatar { display: none; }
  .role { display: none; }
  .context-chip { display: none; }
  .workspace { padding: 28px 16px 22px; }
  .page-heading { display: block; }
  .heading-meta { margin-top: 18px; justify-content: space-between; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .summary-card { min-height: 108px; padding: 15px; }
  .summary-value { font-size: 28px; }
  .section-toolbar { display: block; }
  .toolbar-actions { margin-top: 12px; justify-content: space-between; }
  .task-row { grid-template-columns: 58px minmax(0, 1fr) auto; gap: 8px; padding: 12px 10px; }
  .task-actions { gap: 5px; }
  .task-time { display: grid; gap: 2px; }
  .task-time strong { font-size: 12px; }
  .task-copy span { overflow: visible; text-overflow: clip; white-space: normal; line-height: 1.5; }
  .status-pill { min-width: 48px; padding: 0 6px; }
  .now-card { align-items: flex-start; flex-wrap: wrap; }
  .now-copy { min-width: calc(100% - 50px); }
  .now-card .primary-button { margin-left: 46px; }
  .side-column { grid-template-columns: 1fr; }
  .bottom-nav { gap: 10px; justify-content: space-around; }
  .inspection-modal { width: 100vw; max-width: none; height: 100dvh; max-height: none; margin: 0; border-radius: 0; }
  .inspection-modal-card { height: 100%; overflow-y: auto; padding: 22px 16px 104px; }
  .inspection-modal .modal-close { position: sticky; z-index: 2; top: -8px; float: right; width: 44px; height: 44px; border-radius: 22px; background: #fff; }
  .inspection-modal .inspection-checklist { max-height: none; overflow: visible; }
  .inspection-modal .modal-actions { position: fixed; z-index: 3; right: 0; bottom: 0; left: 0; margin: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgba(255,255,255,.97); box-shadow: 0 -8px 24px rgba(27,57,39,.08); }
  .inspection-modal .modal-actions > button { flex: 1; }
  .inspection-item { grid-template-columns: minmax(0, 1fr) 88px; }
  .inspection-status { width: 88px; height: 44px; }
  .inspection-deduction, .inspection-owner { height: 44px; }
}
/* Account workflows remain usable on narrow phones and with the keyboard open. */
#accountDialog { width: min(560px, calc(100% - 24px)); max-height: 88dvh; overflow: auto; box-sizing: border-box; border: 1px solid #dbe4de; border-radius: 8px; padding: 20px; }
#accountDialog::backdrop { background: rgb(0 0 0 / 32%); }
#accountDialog label.field-label { display: block; margin-top: 12px; }
#accountDialog label.field-label .form-control { display: block; margin-top: 8px; }
#accountDialog .form-control { width: 100%; min-width: 0; box-sizing: border-box; }
.review-account { border-bottom: 1px solid #ddd; padding: 16px 0; }
#registrationForm { margin-top: 16px; }
.login-screen.visible { overflow-y: auto; }
.topbar-actions { flex-wrap: wrap; }
.user-chip { flex-wrap: wrap; }
#accountContent p { overflow-wrap: anywhere; }
