* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: #f4f5f7;
  color: #222;
}

#toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: center;
  background: #99a1a4;
  padding: 10px 16px;
}

.tool-group {
  display: flex;
  gap: 6px;
  padding-right: 12px;
  border-right: 1px solid #555;
}
.tool-group:last-child { border-right: none; }

.tool-btn {
  background: #454b4d;
  color: #fff;
  border: 1px solid #aab1b4;
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
}

/* Cor botões do diagrama UML - DER */ 
.tool-btn:hover { background: #75caf1; }
.tool-btn.active { background: #0984e3; border-color: #0984e3; }
.tool-btn.primary { background: #194d9c; border-color: #00b894; }
.tool-btn.primary:hover { background: #05c98a; }
.link-btn.active { background: #e17055; border-color: #e17055; }

/* Cor barra botões do diagrama UML - DER */ 
#status-bar {
  background: #dfe6e9;
  padding: 6px 16px;
  font-size: 13px;
  color: #2d3436;
  border-bottom: 1px solid #b2bec3;
}

main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
}

#canvas-wrap {
  background: #fff;
  border: 1px solid #d0d3d6;
  border-radius: 8px;
  overflow: hidden;
}

#diagram {
  display: block;
  background:
    linear-gradient(90deg, #f0f0f0 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(#f0f0f0 1px, transparent 1px) 0 0 / 24px 24px;
  cursor: default;
}

.node { cursor: grab; }
.node.selected .node-shape { stroke: #0984e3; stroke-width: 3; }
.node.link-source .node-shape { stroke: #e17055; stroke-width: 3; }

.usecase-shape { fill: #ffe17d; stroke: #b8860b; stroke-width: 1.5; }
.actor-shape-line { stroke: #2d3436; stroke-width: 2.5; fill: none; }
.actor-shape-head { fill: #fff; stroke: #2d3436; stroke-width: 2.5; }

.node-label {
  font-size: 12px;
  fill: #1e1e1e;
  text-anchor: middle;
  pointer-events: none;
  user-select: none;
}
.usecase-label {
  font-size: 11px;
  fill: #1e1e1e;
  text-anchor: middle;
  pointer-events: none;
  user-select: none;
}

.edge-line { stroke: #333; stroke-width: 1.6; fill: none; marker-end: url(#arrow); }
.edge-line.include, .edge-line.extend { stroke-dasharray: 6,4; }
.edge-line.generalization { marker-end: none; }
.edge-label {
  font-size: 10px;
  fill: #444;
  text-anchor: middle;
  font-style: italic;
  user-select: none;
}

#table-wrap {
  background: #fff;
  border: 1px solid #d0d3d6;
  border-radius: 8px;
  padding: 12px 16px;
}
#table-wrap h2 { font-size: 16px; margin: 4px 0 12px; }

table#rastreabilidade-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
#rastreabilidade-table th, #rastreabilidade-table td {
  border: 1px solid #d0d3d6;
  padding: 6px 8px;
  text-align: left;
}
#rastreabilidade-table th {
  background: #f0f2f4;
}

/* Formulário Modal */
#modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}
#modal-overlay.hidden { display: none; }
#modal-box {
  background: #fff; border-radius: 10px; padding: 20px 24px;
  width: 360px; max-width: 90vw;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}
#modal-box h3 { margin-top: 0; }
#modal-fields label {
  display: block; font-size: 12.5px; margin: 10px 0 4px; color: #444;
}
#modal-fields input, #modal-fields select {
  width: 100%; padding: 7px 8px; border: 1px solid #ccc; border-radius: 5px; font-size: 13px;
}
.modal-actions {
  display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px;
}
.modal-actions button {
  padding: 7px 14px; border-radius: 6px; border: 1px solid #ccc; cursor: pointer; background: #eee;
}
#modal-ok { background: #0984e3; color: #fff; border-color: #0984e3; }

/* Controles adicionais na barra de ferramentas */
.tool-label {
  color: #dfe6e9;
  font-size: 12.5px;
  align-self: center;
  margin-right: -2px;
}
.tool-select {
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid #636e72;
  font-size: 13px;
  background: #454b4d;
  color: #fff;
}

/* Páginas auxiliares: classes geradas / diagramas */
a.tool-btn { text-decoration: none; display: inline-flex; align-items: center; }

.page-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
}
.page-content section {
  background: #fff;
  border: 1px solid #d0d3d6;
  border-radius: 8px;
  padding: 12px 16px;
}
.page-content h2 { font-size: 16px; margin: 4px 0 12px; }

.code-block {
  background: #1e272e;
  color: #dcdde1;
  padding: 12px 14px;
  border-radius: 6px;
  overflow-x: auto;
  font-family: "Consolas", "Menlo", monospace;
  font-size: 12.5px;
  line-height: 1.5;
  white-space: pre;
}

.class-card { margin-bottom: 18px; }
.class-card h3 { margin: 0 0 6px; font-size: 14px; color: #2d3436; }

#diagram-svg-wrap {
  background: #fff;
  border: 1px solid #d0d3d6;
  border-radius: 8px;
  overflow: auto;
}
#diagram-svg {
  display: block;
  background:
    linear-gradient(90deg, #f0f0f0 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(#f0f0f0 1px, transparent 1px) 0 0 / 24px 24px;
}

.er-box { fill: #fff4e0; stroke: #e17055; stroke-width: 1.5; }
.er-head { fill: #fab1a0; stroke: #e17055; stroke-width: 1.5; }
.er-group { cursor: pointer; }
.er-group:hover .er-box { fill: #ffe9c7; }
.er-title { font-size: 13px; font-weight: bold; text-anchor: middle; fill: #1e1e1e; pointer-events: none; }
.er-divider { stroke: #e17055; stroke-width: 1; }
.er-attr { font-size: 11px; fill: #2d3436; font-family: Consolas, Menlo, monospace; pointer-events: none; white-space: pre; }
.er-attr .k { font-weight: bold; fill: #d63031; }
.er-attr .t { fill: #0984e3; }
.er-edge { stroke: #636e72; stroke-width: 1.5; }
.er-card-label { font-size: 12px; font-weight: bold; fill: #d63031; text-anchor: middle; }
.er-hint { font-size: 12px; color: #636e72; }

.er-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 50; }
.er-overlay.hidden { display: none; }
.er-modal { background: #fff; border-radius: 10px; padding: 18px 22px; max-height: 92vh; overflow: auto; width: min(1000px, 96vw); }
.er-modal h3 { margin-top: 0; }
.er-modal h4 { margin: 16px 0 6px; font-size: 13px; }
.er-modal label { font-size: 12px; display: block; }
.er-modal input[type=text], .er-modal select { padding: 5px 6px; border: 1px solid #ccc; border-radius: 5px; font-size: 12.5px; width: 100%; }
.er-modal table { width: 100%; border-collapse: collapse; font-size: 12px; }
.er-modal th { text-align: left; background: #f1f2f6; padding: 4px 6px; }
.er-modal td { padding: 3px 4px; border-bottom: 1px solid #eee; vertical-align: middle; }
.er-modal td.c { text-align: center; }
.er-modal .mini { padding: 3px 8px; border: 1px solid #ccc; background: #eee; border-radius: 5px; cursor: pointer; }
.er-modal .mini.danger { color: #d63031; }
.er-row { display: flex; gap: 10px; align-items: flex-end; margin-bottom: 8px; }
.er-row label { flex: 1; }
.er-err { color: #d63031; font-size: 12px; min-height: 16px; }
.er-warn { color: #b7791f; font-size: 12px; }
.er-modal .code-block { max-height: 50vh; overflow: auto; }
.er-modal .modal-actions button { padding: 7px 14px; border-radius: 6px; border: 1px solid #ccc; cursor: pointer; background: #eee; }
.er-modal .modal-actions .ok { background: #0984e3; color: #fff; border-color: #0984e3; }
