:root {
  --bg: #0d1117;
  --bg-card: #161b22;
  --border: #30363d;
  --text: #c9d1d9;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --green: #3fb950;
  --yellow: #d29922;
  --red: #f85149;
  --brand: #ff5a8a;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  background: linear-gradient(180deg, #11161d 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background:
    radial-gradient(circle at 30% 30%, #ff8db4 0%, var(--brand) 50%, #b94370 100%);
  box-shadow: 0 2px 12px rgba(255, 90, 138, 0.4);
}

.brand-text h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.01em;
  font-weight: 600;
}

.brand-text p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
  padding: 8px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 0 rgba(248, 81, 73, 0.6);
}

.status-dot.on {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(63, 185, 80, 0.18);
  animation: pulse 2.5s infinite;
}

.status-dot.off {
  background: var(--red);
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(63, 185, 80, 0.18); }
  50% { box-shadow: 0 0 0 8px rgba(63, 185, 80, 0.05); }
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto;
  grid-template-areas:
    "form dossier"
    "history kpi";
  gap: 20px;
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
}

.form-panel { grid-area: form; }
.dossier-panel { grid-area: dossier; }
.history-panel { grid-area: history; }
.kpi-panel { grid-area: kpi; }

@media (max-width: 980px) {
  .grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "form"
      "dossier"
      "history"
      "kpi";
  }
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.panel h2 {
  margin: 0 0 16px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.panel-head h2 { margin: 0; }

.badge {
  background: rgba(88, 166, 255, 0.12);
  color: var(--accent);
  padding: 3px 10px;
  border-radius: 12px;
  font-family: var(--mono);
  font-size: 11px;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.form input,
.form select,
.form textarea {
  background: #0a0e14;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form input:focus,
.form select:focus,
.form textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.18);
}

.form textarea {
  resize: vertical;
  min-height: 80px;
  font-family: var(--font);
}

.primary {
  background: var(--brand);
  border: none;
  color: white;
  font-weight: 600;
  font-size: 13px;
  padding: 11px 18px;
  border-radius: 8px;
  cursor: pointer;
  transition: filter 0.12s, transform 0.12s;
  font-family: var(--font);
  letter-spacing: 0.01em;
}

.primary:hover { filter: brightness(1.1); }
.primary:active { transform: translateY(1px); }
.primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.feedback {
  margin: 0;
  font-size: 12px;
  min-height: 16px;
  font-family: var(--mono);
}

.feedback.ok { color: var(--green); }
.feedback.err { color: var(--red); }
.feedback.info { color: var(--text-muted); }

.dossier {
  min-height: 220px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dossier.empty {
  align-items: center;
  justify-content: center;
}

.dossier .muted {
  color: var(--text-muted);
  font-size: 12px;
}

.dossier-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: fade-in 0.32s ease-out;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.dossier-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.04);
}

.dossier-row:last-child { border-bottom: none; }

.dossier-label {
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.dossier-value {
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  text-align: right;
  word-break: break-word;
}

.fit-pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.fit-pill.green { background: rgba(63, 185, 80, 0.16); color: var(--green); }
.fit-pill.yellow { background: rgba(210, 153, 34, 0.16); color: var(--yellow); }
.fit-pill.red { background: rgba(248, 81, 73, 0.16); color: var(--red); }

.angoli {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.angoli li {
  background: #0a0e14;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  padding: 9px 12px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--text);
  line-height: 1.5;
}

.keyword-chip {
  display: inline-block;
  padding: 3px 9px;
  background: rgba(88, 166, 255, 0.12);
  color: var(--accent);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 11px;
  margin: 2px 4px 2px 0;
}

.history {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 4px;
}

.history::-webkit-scrollbar { width: 6px; }
.history::-webkit-scrollbar-track { background: transparent; }
.history::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: #0a0e14;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.12s;
}

.history-item:hover {
  border-color: var(--accent);
  transform: translateX(2px);
}

.history-item .name {
  font-weight: 600;
  font-size: 13px;
}

.history-item .meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
}

.history-item .right {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.kpi {
  background: #0a0e14;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kpi-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.kpi-value {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
}

.footbar {
  display: flex;
  justify-content: space-between;
  padding: 14px 28px;
  border-top: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 10px;
}
