:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #182026;
  background: #f3f5f7;
  --ink: #182026;
  --muted: #66727c;
  --line: #d8dde2;
  --panel: #ffffff;
  --primary: #263238;
  --primary-2: #455a64;
  --ok: #196c42;
  --warn: #946200;
  --danger: #a42a2a;
  --soft-ok: #eaf6ef;
  --soft-warn: #fff5d9;
  --soft-danger: #fdecec;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: #f3f5f7; color: var(--ink); }
a { color: #174f7a; text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }
button, input, select, textarea { min-height: 44px; }
input, select, textarea {
  width: 100%; border: 1px solid #cbd2d8; border-radius: 10px; background: #fff;
  padding: 10px 12px; color: var(--ink); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: #6d7d88; box-shadow: 0 0 0 3px rgba(38,50,56,.09); }
input:disabled, select:disabled, textarea:disabled { background: #eef1f3; color: #56616a; }
label { display: grid; gap: 6px; font-weight: 650; font-size: 14px; }
textarea { resize: vertical; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center;
  gap: 16px; min-height: 58px; padding: 8px max(16px, calc((100vw - 1180px)/2));
  background: #263238; color: white; box-shadow: 0 2px 12px rgba(0,0,0,.15);
}
.topbar a { color: white; }
.brand { font-weight: 800; letter-spacing: .01em; }
.topbar nav { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.topbar form { margin: 0; }
.user-pill { color: #d7e0e5; }
.link-button { border: 0; background: transparent; color: white; min-height: auto; padding: 6px; cursor: pointer; }
.container { width: min(1180px, calc(100% - 28px)); margin: 24px auto 60px; }
h1 { margin: 0 0 6px; font-size: clamp(26px, 4vw, 38px); line-height: 1.08; }
h2 { margin: 0 0 14px; font-size: 20px; }
h3 { margin: 0 0 10px; }
.page-head { display: flex; justify-content: space-between; align-items: end; margin-bottom: 18px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 3px 12px rgba(20,30,40,.045); padding: 18px;
}
.narrow { max-width: 440px; margin: 9vh auto 0; }
.login-card h1 { font-size: 30px; }
.stack { display: grid; gap: 14px; }
.cards { display: grid; gap: 10px; }
.row-card, .machine-card { color: inherit; transition: transform .12s ease, border-color .12s ease; }
.row-card:hover, .machine-card:hover { text-decoration: none; transform: translateY(-1px); border-color: #aeb7be; }
.row-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; }
.machine-card { display: grid; gap: 7px; }
.machine-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.machine-code { font-size: 18px; }
.last-maintenance { font-weight: 650; color: var(--muted); }
.last-maintenance.overdue { color: var(--danger); }
.tag { display: inline-flex; width: fit-content; border-radius: 999px; background: #edf1f3; padding: 5px 9px; font-size: 12px; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.lead { font-size: 18px; }
.eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 800; }
.btn {
  border: 1px solid #aeb7be; border-radius: 10px; background: #fff; color: var(--ink); padding: 9px 14px;
  font-weight: 750; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
}
.btn:hover { background: #f4f6f7; }
.btn.primary { color: white; background: var(--primary); border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-2); }
.btn.warning { color: #4b3300; background: #ffefbc; border-color: #e0be5a; }
.btn.danger { color: white; background: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: #832121; }
.btn.big { min-height: 50px; font-size: 16px; }
.btn.full { width: 100%; }
.searchbar { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-bottom: 24px; }
.back { display: inline-block; margin-bottom: 12px; font-weight: 700; }
.equipment-card { display: grid; gap: 18px; }
.equipment-title, .maintenance-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.details-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; margin: 0; }
.details-grid div { border-top: 1px solid #eef0f2; padding-top: 10px; }
dt { font-size: 12px; color: var(--muted); font-weight: 700; }
dd { margin: 3px 0 0; font-weight: 700; }
.qr-box { display: flex; justify-content: space-between; align-items: center; gap: 12px; border-top: 1px solid var(--line); padding-top: 14px; }
.status { display: inline-flex; border-radius: 999px; padding: 6px 9px; font-size: 12px; font-weight: 800; text-transform: capitalize; white-space: nowrap; background: #eceff1; }
.status.finalized { background: var(--soft-ok); color: var(--ok); }
.status.pending_client_signature, .status.pending_operator_signature { background: var(--soft-warn); color: var(--warn); }
.status.in_progress, .status.draft { background: #eaf1f7; color: #24506e; }
.alert { margin: 14px 0; padding: 13px 15px; border-radius: 12px; border: 1px solid var(--line); }
.alert.error { background: var(--soft-danger); color: var(--danger); border-color: #efc5c5; }
.alert.success { background: var(--soft-ok); color: #1e573b; border-color: #c4e2d0; }
.empty { padding: 18px; border: 1px dashed #c8cfd4; border-radius: 12px; color: var(--muted); }
.maintenance-form, .form-section { margin-top: 14px; }
.form-section h2 { padding-bottom: 10px; border-bottom: 1px solid #edf0f2; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.field { padding: 10px; border: 1px solid #edf0f2; border-radius: 12px; background: #fbfcfc; align-content: start; }
.field-label { min-height: 34px; display: flex; align-items: end; }
.input-with-unit { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 8px; }
.unit { min-width: 42px; color: var(--muted); font-weight: 750; }
.range-hint { font-size: 11px; color: var(--muted); font-weight: 500; }
.save-line { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(160px,1fr)); gap: 10px; }
.photo-card { margin: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fafafa; }
.photo-card img { display: block; width: 100%; height: 150px; object-fit: cover; }
.photo-card figcaption { padding: 8px 10px; font-size: 12px; }
.link-danger { border: 0; background: transparent; color: var(--danger); cursor: pointer; padding: 8px 10px; min-height: auto; }
.photo-upload { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-top: 12px; align-items: end; }
.signature-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.signature-grid.single { grid-template-columns: 1fr; }
.signature-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: grid; gap: 10px; }
.signature-canvas { width: 100%; aspect-ratio: 800/260; background: white; border: 1px dashed #8d9aa3; border-radius: 10px; touch-action: none; }
.signature-actions { display: flex; justify-content: space-between; gap: 8px; }
.disabled-panel { opacity: .55; }
.signed-badge { display: inline-flex; width: fit-content; border-radius: 999px; padding: 7px 10px; background: var(--soft-ok); color: var(--ok); font-weight: 800; }
.document-list { display: flex; gap: 10px; flex-wrap: wrap; }
.document-list a { padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; }
.admin-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.admin-section-nav { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 8px; margin: 0 0 16px; padding: 8px; border: 1px solid var(--line); border-radius: 14px; background: white; position: sticky; top: 8px; z-index: 20; box-shadow: 0 4px 18px rgba(21,39,51,.08); }
.admin-section-button { min-height: 48px; padding: 9px 10px; border: 1px solid #c7d0d5; border-radius: 10px; background: #f5f7f8; color: #34444d; font-weight: 800; cursor: pointer; }
.admin-section-button:hover { background: #eaf0f3; border-color: #8fa2ac; }
.admin-section-button.active { background: #243f64; border-color: #243f64; color: white; }
[data-admin-section][hidden], .admin-grid[hidden] { display: none !important; }
.wide-card { grid-column: 1 / -1; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { padding: 9px 8px; border-bottom: 1px solid #e5e9ec; text-align: left; white-space: nowrap; }
.data-table th { background: #f6f8f9; }
.machines-table { table-layout: fixed; }
.machines-table .machine-col-code { width: 14%; }
.machines-table .machine-col-name { width: 18%; }
.machines-table .machine-col-serial { width: 13%; }
.machines-table .machine-col-location { width: 17%; }
.machines-table .machine-col-type { width: 20%; }
.machines-table .machine-col-status { width: 7%; }
.machines-table .machine-col-qr { width: 4%; }
.machines-table .machine-col-actions { width: 7%; }
.machines-table th,
.machines-table td {
  white-space: normal;
  overflow-wrap: anywhere;
  vertical-align: top;
}
.machines-table th:nth-child(6),
.machines-table td:nth-child(6),
.machines-table th:nth-child(7),
.machines-table td:nth-child(7),
.machines-table th:nth-child(8),
.machines-table td:nth-child(8) {
  white-space: nowrap;
  overflow-wrap: normal;
}
.btn.compact { min-height: auto; padding: 6px 10px; font-size: 12px; }
.check-line { display: flex; flex-direction: row; align-items: center; gap: 9px; }
.check-line input { width: auto; }
.edit-dialog { width: min(720px, calc(100% - 24px)); }
.admin-search { margin: 0 0 12px; max-width: 520px; }
.vrv-link-fields { padding: 14px; border: 1px solid #9db4c0; border-radius: 12px; background: #edf4f7; }
.system-progress { margin: 14px 0; }
.system-steps { display: flex; flex-wrap: wrap; gap: 7px; margin: 10px 0; }
.system-step { padding: 7px 10px; border: 1px solid var(--line); border-radius: 9px; background: #f7f9fa; font-size: 12px; }
.system-step.current { background: #dce8ef; border-color: #718b98; font-weight: 800; }
.field.previous-pending { background: #eef0f2; border-color: #aeb6bc; }
.field.previous-pending input, .field.previous-pending select { color: #7a8389; background: #f2f3f4; }
.validate-previous { width: fit-content; min-height: auto; margin-top: 7px; padding: 5px 8px; border: 1px solid #87949b; border-radius: 8px; background: white; color: #45545c; font-size: 11px; cursor: pointer; }
.template-list { display: grid; gap: 7px; }
.template-row { border: 1px solid var(--line); background: white; border-radius: 10px; padding: 10px 12px; display: flex; justify-content: space-between; text-align: left; cursor: pointer; }
.template-row:hover { background: #f7f8f9; }
.template-dialog { width: min(900px, calc(100% - 24px)); border: 0; border-radius: 16px; box-shadow: 0 18px 70px rgba(0,0,0,.35); }
.template-dialog::backdrop { background: rgba(0,0,0,.45); }
.template-dialog label { margin-top: 10px; }
.template-dialog textarea { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.dialog-close { float: right; border: 0; background: transparent; font-size: 28px; cursor: pointer; min-height: auto; }
.toast { position: fixed; right: 18px; bottom: 18px; max-width: min(420px, calc(100% - 36px)); background: #182026; color: white; border-radius: 12px; padding: 12px 14px; box-shadow: 0 8px 30px rgba(0,0,0,.25); z-index: 100; }
.toast.error { background: #802525; }

@media (max-width: 720px) {
  .container { width: min(100% - 18px, 1180px); margin-top: 14px; }
  .topbar { padding-inline: 12px; }
  .user-pill { display: none; }
  .field-grid, .signature-grid, .admin-grid, .details-grid { grid-template-columns: 1fr; }
  .admin-section-nav { grid-template-columns: repeat(2,minmax(0,1fr)); position: static; }
  .wide-card { grid-column: auto; }
  .photo-upload { grid-template-columns: 1fr; }
  .maintenance-head, .equipment-title { align-items: flex-start; }
  .card { padding: 14px; border-radius: 13px; }
  .field { padding: 8px; }
  .field-label { min-height: auto; }
  .row-card { align-items: flex-start; }
}
.field.out-of-range { border-color: #d79a33; background: #fff8e8; }
.field.out-of-range .field-label::after { content: "  · fora de rang"; color: #946200; font-size: 11px; margin-left: 5px; }
