:root {
  --ink: #15120d;
  --muted: #736b5f;
  --paper: #f7f0e5;
  --panel: #fffaf0;
  --line: #dfd1bd;
  --steel: #263238;
  --amber: #e7a72e;
  --orange: #d65a31;
  --green: #2f8f64;
  --red: #bd3b2f;
  --blue: #386f8f;
  --shadow: 0 24px 70px rgba(54, 39, 19, 0.18);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Segoe UI", Tahoma, sans-serif;
  background:
    radial-gradient(circle at 18% 12%, rgba(231, 167, 46, 0.28), transparent 26rem),
    radial-gradient(circle at 88% 8%, rgba(56, 111, 143, 0.22), transparent 24rem),
    linear-gradient(135deg, #f2ddbd 0%, #f8f0e4 42%, #ded6c7 100%);
}

button, input, select { font: inherit; }

.shell {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 18px;
  background: rgba(21, 18, 13, 0.92);
  color: #fff7e8;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border-radius: 16px;
  color: #20180e;
  background: linear-gradient(135deg, #f4c65a, #d65a31);
  font-weight: 900;
}

.brand small, .status-card span { color: rgba(255, 247, 232, 0.68); }

.tabs {
  display: grid;
  gap: 8px;
}

.tab {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 14px;
  color: rgba(255, 247, 232, 0.84);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.tab:hover, .tab.active {
  color: #fff;
  border-color: rgba(244, 198, 90, 0.42);
  background: rgba(255, 255, 255, 0.08);
}

.tab.risk-warn {
  border-color: rgba(214, 90, 49, .72);
  color: #ffd0bd;
}

.tab.risk-danger {
  border-color: rgba(189, 59, 47, .95);
  color: #ffd8d4;
  background: rgba(189, 59, 47, .24);
}

.status-card {
  margin-top: 28px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.08);
}

.project-box {
  display: grid;
  gap: 10px;
  margin-bottom: 20px;
  padding: 14px;
  border: 1px solid rgba(244, 198, 90, .2);
  border-radius: 18px;
  background: rgba(255,255,255,.08);
}

.project-box h3 {
  margin: 0;
  color: #f4c65a;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: .88rem;
}

.project-box label {
  color: rgba(255, 247, 232, .72);
  font-size: .78rem;
}

.project-box input {
  padding: 9px 10px;
  border-color: rgba(255,255,255,.16);
  color: #fff7e8;
  background: rgba(0,0,0,.18);
}

.project-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.project-actions button,
.full-report-btn {
  border: 1px solid rgba(244, 198, 90, .35);
  border-radius: 12px;
  padding: 10px;
  color: #fff7e8;
  background: rgba(244, 198, 90, .12);
  font-weight: 800;
  cursor: pointer;
}

.full-report-btn {
  background: linear-gradient(135deg, #e7a72e, #d65a31);
  color: #15120d;
}

#projectRevision {
  color: rgba(255, 247, 232, .58);
}

.status-card strong {
  display: block;
  margin-top: 6px;
  color: #f4c65a;
}

main {
  padding: 32px;
}

.panel {
  border: 1px solid rgba(91, 66, 36, 0.18);
  border-radius: 28px;
  background: rgba(255, 250, 240, 0.82);
  box-shadow: var(--shadow);
}

.panel {
  padding: 24px;
}

.module-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
  margin-bottom: 20px;
}

.module-actions {
  display: grid;
  gap: 10px;
  min-width: 300px;
}

.report-btn {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  border: 1px solid rgba(244, 198, 90, .48);
  border-radius: 20px;
  padding: 16px 18px;
  color: #fffaf0;
  background:
    radial-gradient(circle at 18% 0%, rgba(255, 224, 138, .34), transparent 34%),
    linear-gradient(135deg, #2f3d42, #15120d 72%);
  box-shadow: 0 18px 42px rgba(21, 18, 13, .22), inset 0 1px rgba(255,255,255,.16);
  font-weight: 900;
  cursor: pointer;
  text-align: left;
}

.report-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 22px 48px rgba(21, 18, 13, .27), inset 0 1px rgba(255,255,255,.2);
}

.report-btn__icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  flex: 0 0 54px;
  border-radius: 16px;
  color: #15120d;
  background: linear-gradient(135deg, #ffe08a, #e7a72e);
  box-shadow: inset 0 -6px rgba(0,0,0,.12);
  font-size: .82rem;
  letter-spacing: .08em;
}

.report-btn strong {
  display: block;
  font-size: 1.08rem;
  letter-spacing: -.02em;
}

.report-btn small {
  display: block;
  margin-top: 3px;
  color: rgba(255, 250, 240, .72);
  font-size: .78rem;
  font-weight: 700;
}

.module-head h2 {
  margin: 0 0 6px;
  font-size: clamp(1.6rem, 3vw, 2.5rem);
  letter-spacing: -0.04em;
}

.module-head p { margin: 0; color: var(--muted); }

.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
}

.card {
  grid-column: span 6;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.58);
}

.card.full { grid-column: 1 / -1; }
.card.third { grid-column: span 4; }

.card h3 {
  margin: 0 0 14px;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: .88rem;
  font-weight: 700;
}

input, select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid #d7c6ae;
  border-radius: 12px;
  color: var(--ink);
  background: #fffdf8;
}

input[readonly].locked-field {
  background: #e9e9e9;
  color: #616161;
  border-color: #d0d0d0;
  cursor: not-allowed;
}

.field-note {
  margin-top: -4px;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 600;
}

.result {
  display: grid;
  gap: 10px;
}

.metric {
  padding: 14px;
  border-radius: 16px;
  background: #f3e4ca;
}

.metric span { display: block; color: var(--muted); font-size: .82rem; }
.metric strong { font-size: 1.55rem; letter-spacing: -0.04em; }

.ok { color: var(--green); }
.warn { color: var(--orange); }
.danger { color: var(--red); }

.diagram {
  position: relative;
  min-height: 230px;
  border-radius: 20px;
  background:
    radial-gradient(circle at 18% 8%, rgba(231, 167, 46, .12), transparent 22rem),
    linear-gradient(90deg, rgba(38, 50, 56, .055) 1px, transparent 1px),
    linear-gradient(rgba(38, 50, 56, .055) 1px, transparent 1px),
    linear-gradient(145deg, #fffdfa, #f8f4eb 62%, #f1eadf);
  background-size: 100% 100%, 28px 28px, 28px 28px, 100% 100%;
  border: 1px solid rgba(151, 121, 73, .22);
  box-shadow: inset 0 1px rgba(255, 255, 255, .72), 0 18px 40px rgba(21, 18, 13, .1);
  overflow: hidden;
  cursor: zoom-in;
}

.diagram::after {
  content: "Clique para ampliar";
  position: absolute;
  right: 12px;
  top: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  color: #fff8ec;
  background: rgba(21, 18, 13, .78);
  font-size: 12px;
  font-weight: 800;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity .18s ease, transform .18s ease;
  pointer-events: none;
}

.diagram:hover::after {
  opacity: 1;
  transform: translateY(0);
}

svg {
  width: 100%;
  height: auto;
  display: block;
  max-width: 100%;
}

svg text {
  fill: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

svg text.svg-light { fill: #fff8ec; }
svg text.svg-muted { fill: #736b5f; }
svg text.svg-dark { fill: #15120d; }
svg text.svg-title {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .02em;
}
svg text.svg-note {
  fill: #5f574d;
  font-size: 12px;
  font-weight: 800;
}

.diagram-modal[hidden] { display: none; }

.diagram-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 22px;
}

.diagram-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(21, 18, 13, .72);
  backdrop-filter: blur(8px);
}

.diagram-modal__window {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(1120px, 96vw);
  height: min(760px, 92vh);
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: 26px;
  background: var(--panel);
  box-shadow: 0 32px 90px rgba(0, 0, 0, .42);
  overflow: hidden;
}

.diagram-modal__bar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 250, 240, .94);
}

.diagram-modal__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.diagram-modal__actions button {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 11px;
  color: var(--ink);
  background: #fff8ec;
  cursor: pointer;
}

#diagramZoomLabel {
  min-width: 48px;
  text-align: center;
  color: var(--muted);
  font-weight: 800;
}

.diagram-modal__canvas {
  overflow: auto;
  padding: 24px;
  background:
    linear-gradient(90deg, rgba(38, 50, 56, .055) 1px, transparent 1px),
    linear-gradient(rgba(38, 50, 56, .055) 1px, transparent 1px),
    #fffdfa;
  background-size: 32px 32px;
}

.diagram-modal__content {
  width: min(980px, 100%);
  margin: 0 auto;
  transform-origin: top center;
}

.diagram-modal__content svg {
  width: 100%;
  min-width: 620px;
}

.webgl-scene {
  display: block;
  width: 100%;
  min-width: 620px;
  max-width: 980px;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fffdfa;
  box-shadow: 0 18px 44px rgba(21, 18, 13, .15);
}

.validation-panel {
  padding: 14px;
  border-radius: 16px;
  border: 1px solid #dfd1bd;
  background: #fffdfa;
}

.validation-panel strong {
  display: block;
  margin-bottom: 8px;
}

.validation-panel.warn {
  border-color: rgba(214, 90, 49, .45);
  background: #fff2e9;
}

.validation-panel.danger {
  border-color: rgba(189, 59, 47, .55);
  background: #fff0ee;
}

.validation {
  margin: 0;
  padding-left: 18px;
}

.cadastro-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, .8fr);
  gap: 18px;
}

.cadastro-card {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, .64);
}

.cadastro-card h3 {
  margin: 0 0 18px;
  color: var(--orange);
  text-transform: uppercase;
  letter-spacing: .1em;
}

.actions-card p {
  color: var(--muted);
}

.cadastro-actions {
  display: grid;
  gap: 12px;
}

.cadastro-actions button {
  border: 1px solid rgba(244, 198, 90, .4);
  border-radius: 16px;
  padding: 14px;
  color: #fffaf0;
  background: linear-gradient(135deg, #263238, #15120d);
  font-weight: 900;
  cursor: pointer;
}

.cadastro-actions button[data-full-report] {
  color: #15120d;
  background: linear-gradient(135deg, #ffe08a, #d65a31);
}

.cadastro-actions button[data-delete-crane] {
  color: #7a1f1f;
  background: linear-gradient(135deg, #f5d0cc, #ef9b94);
  border-color: rgba(189, 59, 47, .35);
}

#projectRevision {
  display: block;
  margin-top: 16px;
  color: var(--muted);
}

.selected-crane {
  display: block;
  margin-top: 10px;
  color: var(--ink);
  font-size: .88rem;
  line-height: 1.4;
}

table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 14px;
}

th, td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; }

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  main { padding: 18px; }
  .card, .card.third { grid-column: 1 / -1; }
  .cadastro-layout { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .module-head { display: block; }
  .module-actions { margin-top: 14px; }
}
