:root {
    --navy: #17324d;
    --navy-2: #0e2438;
    --blue: #2563eb;
    --blue-dark: #1d4ed8;
    --bg: #f3f6f9;
    --panel: #ffffff;
    --text: #16212c;
    --muted: #667585;
    --line: #dce3ea;
    --success: #16794a;
    --success-bg: #e9f7ef;
    --warning: #956000;
    --warning-bg: #fff5d6;
    --danger: #b42318;
    --danger-bg: #ffebe9;
    --shadow: 0 10px 30px rgba(21, 42, 62, .08);
    --radius: 16px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; color: var(--text); background: var(--bg); font: 15px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
a { color: var(--blue-dark); text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, .btn { -webkit-tap-highlight-color: transparent; }

.topbar { position: sticky; top: 0; z-index: 50; min-height: 70px; display: flex; align-items: center; gap: 24px; padding: 0 28px; color: #fff; background: var(--navy); box-shadow: 0 3px 16px rgba(0,0,0,.16); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 175px; color: #fff; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; color: var(--navy); background: #fff; font-size: 13px; font-weight: 900; letter-spacing: .04em; }
.brand > span:last-child { display: flex; flex-direction: column; line-height: 1.05; }
.brand small { opacity: .72; font-size: 11px; margin-top: 4px; }
.main-nav { display: flex; align-items: stretch; align-self: stretch; gap: 3px; flex: 1; }
.main-nav a { display: flex; align-items: center; position: relative; padding: 0 13px; color: rgba(255,255,255,.76); font-weight: 650; font-size: 14px; }
.main-nav a:hover, .main-nav a.active { color: #fff; background: rgba(255,255,255,.07); }
.main-nav a.active:after { content: ""; position: absolute; left: 12px; right: 12px; bottom: 0; height: 3px; border-radius: 4px 4px 0 0; background: #7db4ff; }
.user-menu { display: flex; align-items: center; gap: 9px; margin-left: auto; }
.user-avatar { display: grid; place-items: center; width: 35px; height: 35px; border-radius: 50%; background: rgba(255,255,255,.17); font-weight: 800; }
.user-details { display: flex; flex-direction: column; max-width: 150px; line-height: 1.15; }
.user-details strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13px; }
.user-details small { margin-top: 3px; opacity: .65; font-size: 11px; }
.logout-link { padding: 8px; color: rgba(255,255,255,.75); font-size: 13px; }
.nav-toggle { display: none; margin-left: auto; padding: 8px 10px; border: 1px solid rgba(255,255,255,.25); border-radius: 9px; color: #fff; background: transparent; font-size: 20px; }

.app-shell { width: min(1450px, calc(100% - 48px)); margin: 0 auto; padding: 30px 0 60px; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 25px; background: radial-gradient(circle at top left, #2a5275 0, var(--navy-2) 42%, #091926 100%); }
.login-card { width: min(440px, 100%); padding: 36px; border-radius: 22px; background: #fff; box-shadow: 0 28px 80px rgba(0,0,0,.28); }
.login-logo { display: grid; place-items: center; width: 64px; height: 64px; margin-bottom: 22px; border-radius: 18px; color: #fff; background: var(--navy); font-weight: 900; letter-spacing: .06em; }
.login-heading h1 { margin: 0 0 7px; font-size: 28px; }
.login-heading p { margin: 0 0 25px; color: var(--muted); }
.login-note { display: block; margin-top: 20px; color: var(--muted); text-align: center; }

.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 25px; }
.page-heading.compact { align-items: center; }
.page-heading h1 { margin: 2px 0 5px; font-size: clamp(27px, 3vw, 38px); line-height: 1.12; letter-spacing: -.025em; }
.page-heading p { margin: 0; color: var(--muted); }
.eyebrow { color: var(--blue-dark) !important; font-size: 12px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.heading-actions, .heading-badges, .form-actions, .filter-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.heading-badges { margin-top: 10px; }

.panel { padding: 23px; border: 1px solid rgba(190,202,214,.72); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); }
.panel + .panel { margin-top: 18px; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 15px; margin-bottom: 18px; }
.panel-heading h2 { margin: 0 0 3px; font-size: 18px; }
.panel-heading p { margin: 0; color: var(--muted); font-size: 13px; }
.count-pill { display: grid; place-items: center; min-width: 34px; height: 30px; padding: 0 10px; border-radius: 99px; color: var(--navy); background: #eaf0f6; font-weight: 800; }
.content-grid { display: grid; gap: 20px; }
.two-columns { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.tool-detail-grid { grid-template-columns: minmax(350px, .82fr) minmax(0, 1.18fr); align-items: start; }
.stack-panels { min-width: 0; }
.stack-panels .panel:first-child { margin-top: 0; }
.checklist-admin-grid { grid-template-columns: 380px minmax(0, 1fr); align-items: start; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { display: flex; align-items: center; gap: 15px; min-height: 108px; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); background: #fff; box-shadow: var(--shadow); transition: transform .15s ease, box-shadow .15s ease; }
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 15px 35px rgba(21,42,62,.12); }
.stat-icon { display: grid; place-items: center; width: 52px; height: 52px; flex: 0 0 auto; border-radius: 15px; background: #eaf2ff; font-size: 25px; }
.stat-card strong { display: block; font-size: 30px; line-height: 1; }
.stat-card span:last-child { display: block; margin-top: 7px; color: var(--muted); font-size: 13px; }
.stat-card.stat-danger .stat-icon { background: var(--danger-bg); }
.stat-card.stat-warning .stat-icon { background: var(--warning-bg); }

.btn { display: inline-flex; justify-content: center; align-items: center; min-height: 42px; padding: 9px 15px; border: 1px solid transparent; border-radius: 10px; cursor: pointer; font-weight: 750; line-height: 1; transition: .15s ease; }
.btn:hover { transform: translateY(-1px); }
.btn:disabled { cursor: wait; opacity: .55; transform: none; }
.btn-primary { color: #fff; background: var(--blue); border-color: var(--blue); }
.btn-primary:hover { background: var(--blue-dark); }
.btn-light { color: var(--navy); background: #fff; border-color: var(--line); }
.btn-light:hover { background: #f5f8fa; }
.btn-danger-outline { color: var(--danger); background: #fff; border-color: #efb7b2; }
.btn-small { min-height: 34px; padding: 7px 11px; border-radius: 8px; font-size: 12px; }
.btn-block { width: 100%; }

label { display: flex; flex-direction: column; gap: 7px; min-width: 0; color: #30404f; font-weight: 650; font-size: 13px; }
label > small { color: var(--muted); font-weight: 400; }
input, select, textarea { width: 100%; min-height: 43px; padding: 9px 11px; border: 1px solid #cbd5df; border-radius: 9px; outline: none; color: var(--text); background: #fff; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.11); }
.stack-form { display: grid; gap: 17px; }
.password-wrap { position: relative; }
.password-wrap input { padding-right: 80px; }
.password-wrap button { position: absolute; right: 5px; top: 5px; bottom: 5px; border: 0; color: var(--blue-dark); background: transparent; font-size: 12px; font-weight: 750; cursor: pointer; }
.form-panel { padding: 26px; }
.form-section + .form-section { margin-top: 28px; padding-top: 26px; border-top: 1px solid var(--line); }
.section-title { margin-bottom: 17px; }
.section-title h2 { margin: 0 0 3px; font-size: 18px; }
.section-title p { margin: 0; color: var(--muted); font-size: 13px; }
.form-grid { display: grid; gap: 16px; }
.form-grid.two { grid-template-columns: repeat(2,minmax(0,1fr)); }
.form-grid.three { grid-template-columns: repeat(3,minmax(0,1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.align-start { align-items: start; }
.form-actions { margin-top: 24px; }
.sticky-actions { position: sticky; z-index: 20; bottom: 12px; width: fit-content; margin-left: auto; padding: 10px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.92); box-shadow: 0 9px 28px rgba(22,45,65,.16); backdrop-filter: blur(10px); }
.form-preview { display: block; width: 150px; height: 110px; margin-top: 7px; border-radius: 10px; object-fit: cover; border: 1px solid var(--line); }

.filter-panel { margin-bottom: 16px; padding: 17px; }
.filter-grid { display: grid; grid-template-columns: minmax(220px, 2fr) repeat(3, minmax(130px, .8fr)) auto; gap: 12px; align-items: end; }
.filter-grid.inspections-filter { grid-template-columns: minmax(220px, 2fr) repeat(3,minmax(140px,.8fr)) auto; }
.filter-actions { flex-wrap: nowrap; }
.table-panel { overflow: hidden; padding: 0; }
.table-panel > .panel-heading { padding: 21px 23px 0; }
.responsive-table { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 15px 17px; border-bottom: 1px solid #e6ebf0; text-align: left; vertical-align: middle; }
th { color: #5f6e7c; background: #f8fafc; font-size: 11px; letter-spacing: .05em; text-transform: uppercase; }
tbody tr:hover { background: #fbfdff; }
tbody tr:last-child td { border-bottom: 0; }
.cell-subtitle { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
.row-actions { width: 1%; white-space: nowrap; text-align: right; }
.row-actions form { display: inline; }

.badge { display: inline-flex; align-items: center; width: fit-content; min-height: 25px; padding: 4px 9px; border-radius: 99px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.badge-success { color: var(--success); background: var(--success-bg); }
.badge-warning { color: var(--warning); background: var(--warning-bg); }
.badge-danger { color: var(--danger); background: var(--danger-bg); }
.badge-muted { color: #536170; background: #edf1f4; }
.badge-stack { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }

.mobile-list { display: grid; gap: 9px; }
.list-card { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-width: 0; padding: 13px; border: 1px solid #e1e7ed; border-radius: 11px; color: var(--text); background: #fff; }
.list-card:hover { border-color: #b8c8d7; background: #fbfdff; }
.list-card-main { min-width: 0; }
.list-card-main strong, .list-card-main span { display: block; overflow: hidden; text-overflow: ellipsis; }
.list-card-main strong { font-size: 13px; }
.list-card-main span { margin-top: 4px; color: var(--muted); font-size: 12px; }
.empty-state { display: grid; place-items: center; min-height: 180px; padding: 25px; color: var(--muted); text-align: center; }
.empty-state.small { min-height: 110px; }
.empty-state span { font-size: 28px; }
.empty-state p { margin: 8px 0 0; }

.tool-identity { overflow: hidden; }
.tool-photo { width: 100%; height: 260px; margin-bottom: 20px; border-radius: 13px; object-fit: cover; background: #eef2f5; }
.tool-photo.placeholder { display: grid; place-items: center; font-size: 65px; }
.detail-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.detail-list > div { min-width: 0; padding: 13px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.detail-list > div:nth-child(2n) { border-right: 0; }
.detail-list > div:nth-last-child(-n+2) { border-bottom: 0; }
.detail-list span, .report-meta span { display: block; margin-bottom: 3px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.detail-list strong { overflow-wrap: anywhere; font-size: 13px; }
.detail-list.wide { margin-bottom: 18px; }
.notes-box { margin-top: 16px; padding: 15px; border-radius: 11px; background: #f5f8fa; }
.notes-box strong { display: block; margin-bottom: 5px; }
.notes-box p { margin: 0; white-space: normal; }
.notes-box small { display: block; margin-top: 8px; color: var(--muted); }
.success-box { background: var(--success-bg); }
.danger-zone { display: flex; justify-content: flex-end; margin-top: 20px; }

.inspection-form { display: grid; gap: 18px; }
.inspection-summary { display: grid; grid-template-columns: minmax(260px,.8fr) minmax(0,1.2fr); gap: 25px; align-items: center; }
.tool-mini { display: flex; align-items: center; gap: 13px; }
.tool-mini-icon { display: grid; place-items: center; width: 50px; height: 50px; flex: 0 0 auto; border-radius: 14px; background: #eaf2ff; font-size: 24px; }
.tool-mini strong, .tool-mini span { display: block; }
.tool-mini span:last-child { margin-top: 4px; color: var(--muted); font-size: 12px; }
.result-output { display: flex; align-items: center; min-height: 43px; padding: 9px 12px; border-radius: 9px; background: #edf1f4; font-weight: 800; }
.result-success { color: var(--success); background: var(--success-bg); }
.result-danger { color: var(--danger); background: var(--danger-bg); }
.checklist-panel { padding: 0; overflow: hidden; }
.checklist-panel > .panel-heading { margin: 0; padding: 21px 23px; border-bottom: 1px solid var(--line); }
.checklist-list { display: grid; }
.check-item { padding: 20px 23px; border-bottom: 1px solid var(--line); transition: background .15s ease; }
.check-item:last-child { border-bottom: 0; }
.check-item.is-failed { background: #fff9f8; }
.check-question { display: flex; align-items: flex-start; gap: 12px; }
.check-number { display: grid; place-items: center; width: 28px; height: 28px; flex: 0 0 auto; border-radius: 50%; color: var(--navy); background: #eaf0f6; font-size: 12px; font-weight: 900; }
.check-question strong, .check-question small { display: block; }
.check-question small { margin-top: 4px; color: var(--muted); font-weight: 400; }
.answer-options { display: flex; gap: 8px; margin: 14px 0 0 40px; }
.answer-pill { position: relative; display: block; cursor: pointer; }
.answer-pill input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.answer-pill span { display: inline-flex; align-items: center; min-height: 36px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 9px; background: #fff; font-size: 12px; font-weight: 750; transition: .12s ease; }
.answer-conforme input:checked + span { color: var(--success); border-color: #8ac6a8; background: var(--success-bg); }
.answer-nao_conforme input:checked + span { color: var(--danger); border-color: #e6a29b; background: var(--danger-bg); }
.answer-nao_aplicavel input:checked + span { color: #4e5d6b; border-color: #bfc8d1; background: #edf1f4; }
.failure-fields { margin: 16px 0 0 40px; padding: 16px; border: 1px solid #efc5c0; border-radius: 11px; background: #fff; }
.failure-fields[hidden] { display: none; }
.failure-fields > .full { margin-bottom: 14px; }
.choice-boxes { display: grid; gap: 10px; }
.choice-box { display: flex; flex-direction: row; align-items: flex-start; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 11px; cursor: pointer; }
.choice-box input { width: 18px; min-height: 18px; margin-top: 2px; }
.choice-box strong, .choice-box small { display: block; }
.choice-box small { margin-top: 3px; color: var(--muted); font-weight: 400; }
.danger-choice { border-color: #efc5c0; background: #fffafa; }

.report-meta { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; margin-bottom: 18px; }
.report-meta > div { padding: 10px; border-right: 1px solid var(--line); }
.report-meta > div:last-child { border-right: 0; }
.report-answer-list { display: grid; }
.report-answer { display: grid; grid-template-columns: 28px minmax(0,1fr) auto; align-items: start; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.report-answer:first-child { padding-top: 0; }
.report-answer:last-child { padding-bottom: 0; border-bottom: 0; }
.report-answer-text p { margin: 6px 0 0; color: var(--danger); }
.evidence-photo { display: block; max-width: 650px; width: 100%; max-height: 520px; margin-top: 15px; border-radius: 12px; object-fit: contain; background: #eef2f5; }

.flash { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 15px; padding: 13px 15px; border-radius: 11px; transition: opacity .3s ease, transform .3s ease; }
.flash button { border: 0; color: inherit; background: transparent; cursor: pointer; font-size: 20px; }
.flash-success { color: var(--success); background: var(--success-bg); border: 1px solid #b4ddc8; }
.flash-error { color: var(--danger); background: var(--danger-bg); border: 1px solid #efb9b4; }
.flash-warning { color: var(--warning); background: var(--warning-bg); border: 1px solid #ead494; }
.flash-hide { opacity: 0; transform: translateY(-6px); }
code { padding: 2px 5px; border-radius: 5px; background: #edf1f4; }

@media (max-width: 1120px) {
    .topbar { padding: 0 18px; gap: 12px; }
    .brand { min-width: auto; }
    .brand > span:last-child { display: none; }
    .main-nav a { padding: 0 9px; font-size: 12px; }
    .user-details { display: none; }
    .stats-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .filter-grid, .filter-grid.inspections-filter { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .filter-search { grid-column: 1 / -1; }
    .filter-actions { justify-self: end; }
    .tool-detail-grid, .checklist-admin-grid { grid-template-columns: 1fr; }
    .checklist-admin-grid > form { position: static; }
}

@media (max-width: 760px) {
    .topbar { min-height: 62px; flex-wrap: wrap; padding: 9px 13px; }
    .brand-mark { width: 39px; height: 39px; }
    .nav-toggle { display: block; }
    .main-nav { display: none; order: 4; width: 100%; flex-basis: 100%; align-self: auto; padding: 6px 0 3px; border-top: 1px solid rgba(255,255,255,.13); }
    .main-nav.open { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); }
    .main-nav a { min-height: 42px; padding: 8px 10px; border-radius: 8px; }
    .main-nav a.active:after { display: none; }
    .user-menu { margin-left: 0; }
    .app-shell { width: min(100% - 24px, 1450px); padding: 20px 0 45px; }
    .page-heading, .page-heading.compact { align-items: stretch; flex-direction: column; gap: 13px; }
    .heading-actions > .btn, .page-heading > .btn { flex: 1; }
    .stats-grid, .two-columns, .form-grid.two, .form-grid.three, .inspection-summary, .report-meta { grid-template-columns: 1fr; }
    .stat-card { min-height: 92px; }
    .panel, .form-panel { padding: 17px; border-radius: 13px; }
    .filter-panel { padding: 13px; }
    .filter-grid, .filter-grid.inspections-filter { grid-template-columns: 1fr; }
    .filter-search { grid-column: auto; }
    .filter-actions { justify-self: stretch; }
    .filter-actions .btn { flex: 1; }
    .table-panel { padding: 0; }
    .responsive-table { overflow: visible; }
    table, thead, tbody, tr, th, td { display: block; }
    thead { display: none; }
    tbody { display: grid; gap: 11px; padding: 12px; }
    tbody tr { padding: 13px; border: 1px solid var(--line); border-radius: 11px; background: #fff; }
    tbody tr:hover { background: #fff; }
    td { display: grid; grid-template-columns: minmax(105px,.85fr) minmax(0,1.15fr); gap: 10px; padding: 8px 0; border: 0; text-align: right; }
    td:before { content: attr(data-label); color: var(--muted); font-size: 11px; font-weight: 750; text-align: left; text-transform: uppercase; }
    td .badge, td strong, td .cell-subtitle { justify-self: end; text-align: right; }
    td.row-actions { display: block; width: 100%; padding-top: 11px; border-top: 1px solid var(--line); }
    td.row-actions:before { display: none; }
    td.row-actions .btn, td.row-actions form, td.row-actions form .btn { width: 100%; }
    .detail-list { grid-template-columns: 1fr; }
    .detail-list > div, .detail-list > div:nth-child(2n), .detail-list > div:nth-last-child(-n+2) { border-right: 0; border-bottom: 1px solid var(--line); }
    .detail-list > div:last-child { border-bottom: 0; }
    .tool-photo { height: 220px; }
    .checklist-panel { padding: 0; }
    .checklist-panel > .panel-heading { align-items: flex-start; flex-direction: column; padding: 17px; }
    .check-item { padding: 17px; }
    .answer-options { display: grid; grid-template-columns: 1fr 1fr 70px; margin-left: 0; }
    .answer-pill span { justify-content: center; width: 100%; padding: 7px 5px; }
    .failure-fields { margin-left: 0; }
    .sticky-actions { position: sticky; bottom: 8px; width: 100%; margin-top: 15px; padding: 8px; }
    .sticky-actions .btn { flex: 1; }
    .report-meta > div { border-right: 0; border-bottom: 1px solid var(--line); }
    .report-meta > div:last-child { border-bottom: 0; }
    .report-answer { grid-template-columns: 28px minmax(0,1fr); }
    .report-answer > .badge { grid-column: 2; }
}

@media (max-width: 430px) {
    .login-shell { padding: 15px; }
    .login-card { padding: 25px 20px; }
    .stats-grid { grid-template-columns: 1fr; }
    .stat-card { min-height: 80px; }
    .page-heading h1 { font-size: 27px; }
    .answer-options { grid-template-columns: 1fr 1fr; }
    .answer-nao_aplicavel { grid-column: 1 / -1; }
}

@media print {
    body { background: #fff; font-size: 11px; }
    .no-print, .topbar, .flash, .heading-actions, .sticky-actions { display: none !important; }
    .app-shell { width: 100%; padding: 0; }
    .panel { border-color: #aaa; box-shadow: none; break-inside: avoid; }
    .page-heading { margin-bottom: 15px; }
    .page-heading h1 { font-size: 24px; }
    .badge { border: 1px solid currentColor; }
    a { color: inherit; }
}
