:root {
  --p51-blue: #123c7c;
  --p51-green: #2f9e44;
  --p51-red: #b42318;
  --p51-yellow: #b54708;
  --p51-bg: #f5f7fb;
  --p51-white: #ffffff;
  --p51-text: #1d2939;
  --p51-muted: #667085;
  --p51-border: #dde5ef;
  --p51-soft-blue: #eef5ff;
  --p51-soft-green: #effaf3;
  --p51-soft-yellow: #fffbeb;
  --p51-soft-red: #fef3f2;
  --p51-shadow: 0 12px 30px rgba(16, 24, 40, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: Arial, Helvetica, sans-serif;
}

body {
  background: var(--p51-bg);
  color: var(--p51-text);
}

.p51-app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.p51-header {
  height: 72px;
  background: var(--p51-white);
  border-bottom: 1px solid var(--p51-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 32px;
}

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

.p51-logo {
  width: 170px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #123c7c, #1f64c8);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

.p51-module {
  border-left: 1px solid var(--p51-border);
  padding-left: 16px;
}

.p51-module strong {
  display: block;
  color: var(--p51-blue);
  font-size: 17px;
}

.p51-module span {
  color: var(--p51-muted);
  font-size: 13px;
}

.p51-user {
  text-align: right;
  font-size: 13px;
  color: var(--p51-muted);
}

.p51-user strong {
  display: block;
  color: var(--p51-text);
  font-size: 14px;
}

.p51-layout {
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: calc(100vh - 72px);
}

.p51-sidebar {
  background: var(--p51-white);
  border-right: 1px solid var(--p51-border);
  padding: 24px 18px;
}

.p51-nav-title {
  font-size: 12px;
  color: var(--p51-muted);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 12px;
}

.p51-nav-item {
  height: 42px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  border-radius: 12px;
  color: #344054;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 6px;
  text-decoration: none;
}

.p51-nav-item.p51-active {
  background: var(--p51-soft-blue);
  color: var(--p51-blue);
}

.p51-main {
  padding: 32px;
}

.p51-page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.p51-page-head h1 {
  font-size: 28px;
  margin-bottom: 6px;
}

.p51-page-head p {
  color: var(--p51-muted);
  font-size: 15px;
  line-height: 1.45;
  max-width: 760px;
}

.p51-btn {
  height: 44px;
  border: none;
  padding: 0 18px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.p51-btn-primary {
  background: var(--p51-blue);
  color: white;
}

.p51-btn-secondary {
  background: white;
  border: 1px solid var(--p51-border);
  color: #344054;
}

.p51-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.p51-kpi {
  background: var(--p51-white);
  border: 1px solid var(--p51-border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 6px 18px rgba(16, 24, 40, .04);
}

.p51-kpi span {
  color: var(--p51-muted);
  font-size: 13px;
  font-weight: 700;
}

.p51-kpi strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.p51-content-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 24px;
  align-items: start;
}

.p51-card {
  background: var(--p51-white);
  border: 1px solid var(--p51-border);
  border-radius: 22px;
  box-shadow: var(--p51-shadow);
  overflow: hidden;
}

.p51-card-header {
  padding: 22px 24px;
  border-bottom: 1px solid var(--p51-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.p51-card-header h2 {
  font-size: 19px;
  margin-bottom: 4px;
}

.p51-card-header p {
  color: var(--p51-muted);
  font-size: 13px;
}

.p51-card-body {
  padding: 24px;
}

.p51-filter-bar {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 120px;
  gap: 12px;
  margin-bottom: 18px;
}

.p51-input,
.p51-select {
  height: 42px;
  border: 1px solid var(--p51-border);
  border-radius: 12px;
  padding: 0 12px;
  font-size: 14px;
  color: var(--p51-text);
  background: white;
  outline: none;
}

.p51-table {
  width: 100%;
  border-collapse: collapse;
}

.p51-table th {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--p51-border);
  color: var(--p51-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.p51-table td {
  padding: 14px 10px;
  border-bottom: 1px solid var(--p51-border);
  font-size: 14px;
  vertical-align: middle;
}

.p51-franchise strong {
  display: block;
  font-size: 14px;
}

.p51-franchise span {
  display: block;
  margin-top: 3px;
  color: var(--p51-muted);
  font-size: 12px;
}

.p51-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.p51-pill-ok {
  background: var(--p51-soft-green);
  color: var(--p51-green);
}

.p51-pill-warn {
  background: var(--p51-soft-yellow);
  color: var(--p51-yellow);
}

.p51-pill-error {
  background: var(--p51-soft-red);
  color: var(--p51-red);
}

.p51-action-link {
  color: var(--p51-blue);
  font-weight: 800;
  text-decoration: none;
  font-size: 13px;
}

.p51-side-card {
  position: sticky;
  top: 96px;
}

.p51-checklist-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--p51-border);
}

.p51-checklist-item div strong {
  display: block;
  font-size: 14px;
}

.p51-checklist-item div span {
  display: block;
  margin-top: 4px;
  color: var(--p51-muted);
  font-size: 12px;
  line-height: 1.35;
}

.p51-alert {
  margin-top: 18px;
  border-radius: 16px;
  padding: 14px;
  background: var(--p51-soft-yellow);
  border: 1px solid #fedf89;
  color: var(--p51-yellow);
  font-size: 13px;
  line-height: 1.45;
}

/* === FORMULÁRIOS DO PORTAL NF === */

.p51-form-section {
  margin-bottom: 26px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--p51-border);
}

.p51-form-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.p51-form-section h3 {
  font-size: 18px;
  margin-bottom: 6px;
}

.p51-form-section p {
  color: var(--p51-muted);
  font-size: 13px;
  margin-bottom: 16px;
  line-height: 1.45;
}

.p51-form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.p51-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.p51-field label {
  font-size: 13px;
  font-weight: 800;
  color: #344054;
}

.p51-field.p51-wide {
  grid-column: span 2;
}

.p51-field.p51-full {
  grid-column: span 3;
}

.p51-textarea {
  min-height: 96px;
  border: 1px solid var(--p51-border);
  border-radius: 12px;
  padding: 12px;
  font-size: 14px;
  color: var(--p51-text);
  background: white;
  outline: none;
  resize: vertical;
}

.p51-input:focus,
.p51-select:focus,
.p51-textarea:focus {
  border-color: var(--p51-blue);
  box-shadow: 0 0 0 3px rgba(18, 60, 124, .10);
}

.p51-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.p51-status-box {
  border: 1px solid var(--p51-border);
  border-radius: 18px;
  padding: 16px;
  background: #fbfcfe;
  margin-bottom: 14px;
}

.p51-status-box strong {
  display: block;
  font-size: 14px;
  margin-bottom: 6px;
}

.p51-status-box span {
  display: block;
  color: var(--p51-muted);
  font-size: 13px;
  line-height: 1.45;
}

.p51-danger-note {
  background: var(--p51-soft-red);
  border: 1px solid #fecdca;
  color: var(--p51-red);
  border-radius: 16px;
  padding: 14px;
  font-size: 13px;
  line-height: 1.45;
  margin-top: 14px;
}

@media (max-width: 1180px) {
  .p51-form-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .p51-field.p51-wide,
  .p51-field.p51-full {
    grid-column: span 2;
  }
}
