:root {
  --primary: #E20074;
  --strong-blue: #232D4B;
  --yellow: #F5F340;
  --bg: #f4f7f6;
  --sap-blue: #008FD3;
  --white: #ffffff;
  --gray-100: #f8f9fa;
  --gray-200: #e9ecef;
  --gray-400: #adb5bd;
  --gray-600: #6c757d;
  --success: #28a745;
  --warning: #ffc107;
  --danger: #dc3545;
  --sidebar-width: 260px;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(35, 45, 75, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Poppins', sans-serif;
  background: var(--bg);
  color: var(--strong-blue);
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--strong-blue);
  color: var(--white);
  padding: 1.5rem 0 0;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.sidebar-nav {
  flex: 1;
}

.sidebar-brand {
  padding: 0 1.5rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 1rem;
}

.sidebar-brand h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--white);
}

.sidebar-brand span {
  font-size: 0.75rem;
  color: var(--yellow);
  font-weight: 500;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.5rem;
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: rgba(226, 0, 116, 0.2);
  color: var(--white);
  text-decoration: none;
}

.sidebar-nav a.active {
  border-left: 3px solid var(--primary);
}

.sidebar-status {
  margin: 1.5rem 1.5rem 0.75rem;
  padding: 1rem;
  background: rgba(255,255,255,0.05);
  border-radius: var(--radius);
  font-size: 0.75rem;
}

.sidebar-footer {
  margin-top: auto;
  padding-bottom: 1rem;
}

.sidebar-version {
  padding: 0 1.5rem;
  font-size: 0.65rem;
  color: rgba(255,255,255,0.45);
  text-align: center;
  letter-spacing: 0.02em;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.4rem;
}

.status-dot.ok { background: var(--success); }
.status-dot.warn { background: var(--warning); }
.status-dot.err { background: var(--danger); }

.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 2rem;
  min-width: 0;
}

.page-header {
  margin-bottom: 2rem;
}

.page-header h2 {
  font-size: 1.75rem;
  font-weight: 700;
}

.page-header p {
  color: var(--gray-600);
  margin-top: 0.25rem;
}

.flash-messages { margin-bottom: 1.5rem; }

.flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}

.flash.success { background: #d4edda; color: #155724; }
.flash.error { background: #f8d7da; color: #721c24; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.stat-card .label {
  font-size: 0.8rem;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-card .value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  margin-top: 0.25rem;
}

.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--gray-200);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: var(--white);
}

.btn-primary:hover {
  background: #c40065;
  text-decoration: none;
  color: var(--white);
}

.btn-secondary {
  background: var(--strong-blue);
  color: var(--white);
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
}

.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
  font-size: 0.875rem;
}

th {
  font-weight: 600;
  color: var(--gray-600);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-pendente { background: var(--gray-200); color: var(--gray-600); }
.badge-inicial { background: #e8f4fd; color: #0c5460; }
.badge-em_andamento { background: #fff3cd; color: #856404; }
.badge-concluido { background: #d4edda; color: #155724; }

.filters-card h3 { margin-bottom: 1rem; }

.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  align-items: end;
}

.filters-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding-bottom: 0.15rem;
}

.form-group select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.875rem;
  background: var(--white);
}

.form-group input[type="date"] {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.875rem;
}

.pipeline-flow {
  display: flex;
  align-items: center;
  gap: 0;
  overflow-x: auto;
  padding: 1rem 0;
}

.pipeline-step {
  flex: 1;
  min-width: 140px;
  text-align: center;
  position: relative;
}

.pipeline-step .circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--gray-200);
  color: var(--gray-600);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 0.5rem;
  font-weight: 700;
  font-size: 1rem;
}

.pipeline-step.done .circle { background: var(--primary); color: var(--white); }
.pipeline-step.active .circle { background: var(--sap-blue); color: var(--white); }

.pipeline-step .label { font-size: 0.75rem; font-weight: 600; }

.pipeline-arrow {
  color: var(--gray-400);
  font-size: 1.25rem;
  flex-shrink: 0;
}

.form-group { margin-bottom: 1.25rem; }

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--strong-blue);
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.875rem;
}

.form-group textarea { min-height: 120px; resize: vertical; }

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(226, 0, 116, 0.15);
}

.code-preview {
  background: var(--strong-blue);
  color: #e0e0e0;
  padding: 1.25rem;
  border-radius: var(--radius);
  font-family: 'Courier New', monospace;
  font-size: 0.8rem;
  overflow-x: auto;
  white-space: pre-wrap;
  max-height: 500px;
  overflow-y: auto;
}

.code-preview.error { border: 2px solid var(--danger); }

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.modal-panel {
  position: relative;
  width: min(960px, 100%);
  max-height: calc(100vh - 3rem);
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
}

.modal-meta {
  margin: 0 0 0.75rem;
  font-size: 0.75rem;
  color: var(--gray-600);
}

.modal-body {
  max-height: calc(100vh - 12rem);
  margin: 0;
}

.modal-body.modal-body--html {
  background: var(--gray-100);
  border-radius: var(--radius);
  max-height: calc(100vh - 11rem);
  overflow: hidden;
  padding: 0;
}

.output-preview-frame {
  background: var(--white);
  border: none;
  display: block;
  height: calc(100vh - 12rem);
  min-height: 480px;
  width: 100%;
}

.assets-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 1.5rem;
}

.assets-list a {
  display: block;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius);
  color: var(--strong-blue);
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}

.assets-list a.active,
.assets-list a:hover {
  background: rgba(226, 0, 116, 0.1);
  color: var(--primary);
  text-decoration: none;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.async-job-notice {
  background: rgba(0, 143, 211, 0.1);
  border: 1px solid rgba(0, 143, 211, 0.35);
  border-radius: var(--radius);
  color: var(--strong-blue);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
  padding: 0.75rem 1rem;
}

.applaud-embed-frame {
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  display: block;
  height: min(70vh, 720px);
  min-height: 420px;
  width: 100%;
}

@media (max-width: 768px) {
  .sidebar { width: 100%; position: relative; }
  .main { margin-left: 0; }
  .layout { flex-direction: column; }
  .settings-grid { grid-template-columns: 1fr; }
  .assets-layout { grid-template-columns: 1fr; }
}

.auth-card { max-width: 520px; margin: 8vh auto; background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 2rem; }
.auth-card h2 { margin-bottom: 0.75rem; }
.auth-card p { color: var(--gray-600); margin-bottom: 1.5rem; }
.auth-card label { display:block; font-size:0.8rem; font-weight:600; margin-bottom:0.4rem; }
.auth-card input { width:100%; padding:0.75rem; border:1px solid var(--gray-200); border-radius:var(--radius); margin-bottom:1rem; font-family:inherit; }
.auth-card .btn { width:100%; justify-content:center; }
