:root {
  color-scheme: light;
  --ink: #182426;
  --muted: #667476;
  --line: #dfe7e5;
  --surface: #ffffff;
  --canvas: #f3f7f5;
  --brand: #086f65;
  --brand-dark: #05544d;
  --accent: #dff5ef;
  --danger: #b42318;
  --danger-soft: #fff0ee;
  --success: #16794b;
  --shadow: 0 14px 38px rgba(20, 54, 49, .09);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); font-family: Inter, "Segoe UI", Arial, sans-serif; line-height: 1.45; }
a { color: inherit; }
button, input, textarea, select { font: inherit; }

.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; min-height: 68px; padding: 10px clamp(18px, 4vw, 56px); background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); }
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--brand); color: #fff; font-weight: 800; }
.brand strong, .brand small { display: block; }
.brand small { color: var(--muted); font-size: 12px; }
.user-panel { display: flex; align-items: center; gap: 14px; color: var(--muted); }

.page-shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 34px 0 64px; }
.detail-shell { width: min(1080px, calc(100% - 32px)); }
.page-heading, .detail-hero, .section-heading, .card-topline, .finding-header, .hero-status-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(30px, 4vw, 46px); letter-spacing: -.035em; }
h2 { margin-bottom: 12px; }
.eyebrow { margin-bottom: 5px; color: var(--brand); font-size: 12px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.muted { color: var(--muted); }
.metric { min-width: 110px; padding: 15px 20px; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; }
.metric strong, .metric span { display: block; }
.metric strong { font-size: 26px; }
.metric span { color: var(--muted); font-size: 13px; }

.status-filters { display: flex; gap: 8px; padding: 20px 0 24px; overflow-x: auto; }
.filter-pill { flex: 0 0 auto; padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--muted); text-decoration: none; }
.filter-pill.active { border-color: var(--brand); background: var(--brand); color: #fff; }

.inspection-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.inspection-card { display: block; padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 1px 0 rgba(0,0,0,.02); text-decoration: none; transition: transform .16s ease, box-shadow .16s ease; }
.inspection-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.inspection-card h2 { margin: 19px 0 2px; font-size: 25px; }
.machine-name { color: var(--brand-dark); font-weight: 700; }
.card-facts, .facts-grid { margin: 20px 0 0; }
.card-facts div { display: flex; justify-content: space-between; gap: 15px; padding: 9px 0; border-top: 1px solid var(--line); }
dt { color: var(--muted); }
dd { margin: 0; font-weight: 650; text-align: right; }

.status { display: inline-flex; align-items: center; padding: 5px 10px; border-radius: 999px; background: #edf1f0; color: #42504e; font-size: 12px; font-weight: 800; }
.status-in_review { background: #fff2ce; color: #7a5500; }
.status-ready { background: #dff5e8; color: #12653f; }
.status-changes_requested { background: var(--danger-soft); color: var(--danger); }
.status-preparing { background: #e4efff; color: #265f9f; }
.status.neutral { background: #edf1f0; }

.back-link { display: inline-block; margin-bottom: 18px; color: var(--brand); font-weight: 700; text-decoration: none; }
.detail-hero { align-items: flex-end; padding: 28px; background: linear-gradient(135deg, #0a6f65, #064c48); color: #fff; border-radius: 26px; box-shadow: var(--shadow); }
.detail-hero .muted { color: #cde3df; }
.detail-hero .status { background: rgba(255,255,255,.16); color: #fff; }
.hero-machine { margin-bottom: 0; color: #d9eeea; font-size: 20px; font-weight: 700; }
.meter-card { min-width: 180px; padding: 18px; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.18); border-radius: 18px; text-align: right; }
.meter-card span, .meter-card small, .meter-card strong { display: block; }
.meter-card strong { font-size: 34px; }

.facts-panel, .content-section, .action-panel { margin-top: 18px; padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; }
.facts-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; overflow: hidden; background: var(--line); border: 1px solid var(--line); border-radius: 14px; }
.facts-grid div { padding: 15px; background: var(--surface); }
.facts-grid dd { margin-top: 4px; text-align: left; }
.section-heading { margin-bottom: 17px; }
.section-heading h2 { margin: 0; }
.count-badge { display: grid; place-items: center; min-width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: var(--brand); font-weight: 800; }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.photo-card { overflow: hidden; background: var(--canvas); border: 1px solid var(--line); border-radius: 15px; text-decoration: none; }
.photo-card img { display: block; width: 100%; height: 170px; object-fit: cover; }
.photo-card > span { display: block; padding: 12px; }
.photo-card small { display: block; color: var(--muted); }
.file-placeholder { display: grid !important; place-items: center; min-height: 150px; font-weight: 800; }
.photo-strip { display: flex; gap: 8px; margin-top: 13px; overflow-x: auto; }
.photo-strip img { width: 112px; height: 90px; object-fit: cover; border: 1px solid var(--line); border-radius: 11px; }

.finding-list { display: grid; gap: 12px; }
.finding-card { padding: 18px; border: 1px solid var(--line); border-left: 5px solid #7b8a88; border-radius: 14px; }
.finding-card.critical { border-left-color: var(--danger); background: #fffafa; }
.finding-card h3 { margin: 4px 0 8px; }
.finding-card p:last-child { margin-bottom: 0; }
.critical-label { color: var(--danger); font-size: 11px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }

.response-section { margin-top: 10px; border: 1px solid var(--line); border-radius: 15px; overflow: hidden; }
.response-section summary { display: flex; justify-content: space-between; gap: 12px; padding: 15px 17px; background: var(--canvas); cursor: pointer; font-weight: 800; }
.response-section summary span { color: var(--muted); }
.response-list { display: grid; }
.response-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 18px; padding: 16px; border-top: 1px solid var(--line); }
.response-title { display: flex; align-items: flex-start; gap: 10px; }
.response-title span { flex: 0 0 auto; display: grid; place-items: center; min-width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--brand-dark); font-size: 12px; font-weight: 800; }
.response-value { align-self: start; padding: 5px 9px; border-radius: 9px; background: #edf1f0; font-size: 13px; font-weight: 800; }
.response-comment, .response-row .photo-strip { grid-column: 1 / -1; margin: 0; }

.section-note { color: var(--muted); }
.report-list { display: grid; gap: 10px; }
.report-card { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 15px; border: 1px solid var(--line); border-radius: 13px; background: var(--canvas); }
.report-card strong, .report-card small, .report-card code { display: block; }
.report-card small { margin-top: 3px; color: var(--muted); }
.report-card code { max-width: 720px; margin-top: 7px; overflow-wrap: anywhere; color: #42504e; font-size: 11px; }
.button:disabled { cursor: not-allowed; opacity: .48; }

.timeline { margin: 0; padding: 0; list-style: none; }
.timeline li { display: grid; grid-template-columns: 14px 1fr; gap: 14px; position: relative; padding-bottom: 19px; }
.timeline li > span { position: relative; z-index: 1; width: 12px; height: 12px; margin-top: 5px; border: 3px solid var(--brand); border-radius: 50%; background: #fff; }
.timeline li:not(:last-child)::before { content: ""; position: absolute; left: 5px; top: 15px; bottom: -4px; width: 2px; background: var(--line); }
.timeline small { display: block; color: var(--muted); }
.timeline p { margin: 5px 0 0; }

.action-panel { border-color: #b8dcd4; background: #f6fffc; }
.review-actions { display: grid; gap: 15px; }
.return-form { display: grid; gap: 8px; padding-top: 15px; border-top: 1px solid var(--line); }
textarea, input, select { width: 100%; padding: 11px 12px; border: 1px solid #bfcac8; border-radius: 10px; background: #fff; }
textarea:focus, input:focus, select:focus { outline: 3px solid rgba(8,111,101,.15); border-color: var(--brand); }
label { font-weight: 700; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 8px 15px; border: 0; border-radius: 10px; cursor: pointer; font-weight: 800; text-decoration: none; }
.button-primary { background: var(--brand); color: #fff; }
.button-primary:hover { background: var(--brand-dark); }
.button-success { background: var(--success); color: #fff; }
.button-danger { background: var(--danger); color: #fff; }
.button-quiet { background: transparent; color: var(--brand); }
.button-wide { width: 100%; }

.autosave-banner { position: sticky; top: 78px; z-index: 7; display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 18px 0; padding: 12px 16px; border: 1px solid #b8dcd4; border-radius: 13px; background: rgba(246,255,252,.96); color: #24564f; box-shadow: 0 8px 22px rgba(20,54,49,.06); backdrop-filter: blur(10px); }
.autosave-banner .save-error { color: var(--danger); font-weight: 800; }
.editor-grid, .response-editor { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.editor-grid label, .response-editor label { display: grid; gap: 6px; }
.editor-wide { grid-column: 1 / -1; }
.observation-editor { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.photo-upload-form { display: flex; align-items: center; gap: 9px; margin-top: 12px; }
.photo-upload-form input[type="file"] { min-width: 0; padding: 8px; background: var(--canvas); }
.photo-add { flex: 0 0 auto; }
.photo-delete { align-self: flex-start; min-width: 31px; min-height: 31px; padding: 4px 8px; border: 1px solid #f0b7b0; border-radius: 50%; background: var(--danger-soft); color: var(--danger); cursor: pointer; font-weight: 900; }
.photo-delete:hover { background: #ffe0dc; }

.notice, .empty-state, .empty-inline { padding: 16px 18px; border: 1px solid #c7dfda; border-radius: 13px; background: #edf9f6; color: #24564f; }
.notice-error { border-color: #f0b7b0; background: var(--danger-soft); color: var(--danger); }
.notice-success { border-color: #b9dfca; background: #ebf8f0; color: var(--success); }
.message-stack { width: min(900px, calc(100% - 32px)); margin: 16px auto -12px; }
.empty-state { margin-top: 10px; padding: 50px 20px; text-align: center; }
.empty-state p, .empty-inline { margin-bottom: 0; color: var(--muted); }
.pagination { display: flex; justify-content: center; gap: 18px; padding-top: 25px; }
.pagination a { color: var(--brand); font-weight: 800; }

.platform-login-shell { display: grid; min-height: 100vh; min-height: 100svh; place-items: center; padding: 32px 20px; background: #edf2f4; color: #17324d; line-height: 1.5; }
.platform-login-shell .platform-login-card { width: min(400px, 100%); min-width: 0; padding: 32px; background: #fff; border: 1px solid #cbd8df; border-radius: 8px; box-shadow: 0 4px 16px rgba(23, 50, 77, .05); }
.platform-login-shell .login-intro { padding-bottom: 24px; border-bottom: 1px solid #dce5e9; }
.platform-login-shell .login-intro h2 { margin: 0; color: #17324d; font-size: 28px; font-weight: 750; line-height: 1.2; letter-spacing: .035em; }
.platform-login-shell .login-wordmark { display: block; width: 260px; max-width: 100%; height: auto; }
.platform-login-shell .login-tagline { margin: 8px 0 0; color: #536b7a; font-size: 14px; }
.platform-login-shell .login-form-panel { padding-top: 24px; min-width: 0; }
.platform-login-shell .login-form-panel h1 { margin: 0 0 20px; font-size: 22px; font-weight: 650; line-height: 1.3; letter-spacing: 0; }
.platform-login-shell .login-form-panel .form-stack { gap: 8px; margin: 0; }
.platform-login-shell .login-form-panel label { color: #27475e; font-size: 14px; font-weight: 600; }
.platform-login-shell .login-form-panel input:not([type="hidden"]) { width: 100%; min-width: 0; min-height: 44px; padding: 10px 12px; border: 1px solid #aabdc9; border-radius: 5px; background: #fff; color: #17324d; font-size: 16px; }
.platform-login-shell .login-form-panel input + label { margin-top: 10px; }
.platform-login-shell .login-form-panel input:focus { border-color: #176c69; outline: 3px solid #176c69; outline-offset: 2px; }
.platform-login-shell .login-form-panel input[aria-invalid="true"] { border-color: #b42318; }
.platform-login-shell .login-form-panel .button { min-height: 44px; margin-top: 16px; border: 1px solid #176c69; border-radius: 6px; background: #176c69; color: #fff; font-size: 15px; font-weight: 650; }
.platform-login-shell .login-form-panel .button:hover { background: #125854; border-color: #125854; }
.platform-login-shell .login-form-panel .button:focus-visible { outline: 3px solid #17324d; outline-offset: 3px; }
.platform-login-shell .login-form-panel .notice-error { margin: 0 0 18px; padding: 12px 14px; border-radius: 6px; font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.form-stack { display: grid; gap: 9px; margin-top: 22px; }
.form-stack .button { margin-top: 10px; }

@media (max-width: 760px) {
  .topbar, .page-heading, .detail-hero, .user-panel { align-items: flex-start; }
  .topbar { gap: 8px; }
  .user-panel { flex-direction: column; gap: 0; font-size: 13px; }
  .page-heading, .detail-hero { flex-direction: column; }
  .detail-hero { align-items: stretch; }
  .meter-card { text-align: left; }
  .facts-grid { grid-template-columns: 1fr 1fr; }
  .response-row { grid-template-columns: 1fr; }
  .response-value, .response-comment, .response-row .photo-strip { grid-column: 1; }
  .editor-grid, .response-editor { grid-template-columns: 1fr; }
  .editor-wide { grid-column: 1; }
  .photo-upload-form { align-items: stretch; flex-direction: column; }
  .report-section .section-heading, .report-card { align-items: stretch; flex-direction: column; }
  .report-card .button { width: 100%; }
}

@media (max-width: 480px) {
  .platform-login-shell { padding: 24px 16px; }
  .platform-login-shell .platform-login-card { padding: 24px; }
  .page-shell, .detail-shell { width: min(100% - 20px, 1180px); padding-top: 20px; }
  .facts-grid { grid-template-columns: 1fr; }
  .facts-panel, .content-section, .action-panel { padding: 17px; border-radius: 16px; }
  .detail-hero { padding: 21px; border-radius: 19px; }
}
