:root {
  --unp-navy: #1B2C55;
  --unp-navy-dark: #14213D;
  --unp-red: #C0392B;
  --unp-red-dark: #A8321F;
  --unp-blue-accent: #1E56C4;
  --unp-bg: #F4F6FB;
  --unp-white: #FFFFFF;
  --unp-text: #2A3346;
  --unp-text-muted: #7B8499;
  --unp-border: #E4E8F1;
  --unp-success: #2E9E5B;
  --unp-shadow: 0 2px 10px rgba(27, 44, 85, 0.06);
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', Roboto, -apple-system, sans-serif;
  background: var(--unp-bg);
  color: var(--unp-text);
}

/* ===== LAYOUT ===== */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: 250px;
  background: var(--unp-white);
  border-right: 1px solid var(--unp-border);
  padding: 24px 16px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px 24px 10px;
}

.sidebar-logo img {
  height: 42px;
  width: auto;
  display: block;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  color: var(--unp-red);
  font-weight: 600;
  text-decoration: none;
  font-size: 15px;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-item .icon { font-size: 18px; width: 22px; text-align: center; }

.nav-item:hover {
  background: #FDE9E7;
  color: var(--unp-red-dark);
}

.nav-item.active {
  background: var(--unp-navy);
  color: var(--unp-white);
}

.nav-item.active:hover {
  background: var(--unp-navy);
  color: var(--unp-white);
}

.nav-item.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* ===== MAIN ===== */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  background: var(--unp-navy);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.search-box {
  flex: 1;
  max-width: 620px;
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 11px 16px 11px 40px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  outline: none;
  background: var(--unp-white);
}

.search-box .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--unp-text-muted);
  font-size: 15px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-left: auto;
  color: var(--unp-white);
}

.bell { font-size: 18px; cursor: pointer; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--unp-red);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}

.content {
  padding: 28px 32px 48px 32px;
}

.page-title {
  font-size: 28px;
  font-weight: 800;
  color: var(--unp-navy);
  margin: 0 0 4px 0;
}

.page-subtitle {
  color: var(--unp-text-muted);
  font-size: 14px;
  margin: 0 0 24px 0;
}

/* ===== DASHBOARD CARDS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-top: 8px;
}

.stat-card {
  background: var(--unp-white);
  border-radius: var(--radius);
  border-top: 3px solid var(--unp-red);
  box-shadow: var(--unp-shadow);
  padding: 24px 20px;
  text-align: center;
}

.stat-card .label {
  color: var(--unp-text-muted);
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 10px;
}

.stat-card .value {
  color: var(--unp-blue-accent);
  font-weight: 800;
  font-size: 30px;
}

.stat-card.loading .value { color: var(--unp-text-muted); font-size: 16px; }

/* ===== TOOLBAR (page action row) ===== */
.toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.toolbar .search-box { max-width: 360px; }
.toolbar .search-box input { background: var(--unp-white); border: 1px solid var(--unp-border); }

.btn {
  border: none;
  border-radius: 8px;
  padding: 11px 18px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: filter 0.15s ease, transform 0.05s ease;
}
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--unp-navy); color: white; }
.btn-primary:hover { filter: brightness(1.15); }

.btn-accent { background: var(--unp-blue-accent); color: white; }
.btn-accent:hover { filter: brightness(1.1); }

.btn-outline {
  background: var(--unp-white);
  color: var(--unp-navy);
  border: 1px solid var(--unp-border);
}
.btn-outline:hover { background: #F1F3FA; }

.btn-danger { background: var(--unp-red); color: white; }
.btn-danger:hover { filter: brightness(1.1); }

.btn-icon {
  width: 34px; height: 34px;
  border-radius: 7px;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: white;
  font-size: 14px;
}
.btn-icon.edit { background: var(--unp-blue-accent); }
.btn-icon.view { background: #5C6B8A; }
.btn-icon.delete { background: var(--unp-red); }
.btn-icon:hover { filter: brightness(1.12); }

.spacer { flex: 1; }

/* ===== TABLE CARD ===== */
.table-card {
  background: var(--unp-white);
  border-radius: var(--radius);
  box-shadow: var(--unp-shadow);
  overflow: hidden;
}

.table-scroll { overflow-x: auto; }

table.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1100px;
}

table.data-table thead th {
  background: var(--unp-navy);
  color: white;
  text-align: left;
  padding: 14px 16px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  position: sticky;
  top: 0;
}

table.data-table tbody td {
  padding: 14px 16px;
  font-size: 13.5px;
  border-bottom: 1px solid var(--unp-border);
  color: var(--unp-text);
  white-space: nowrap;
}

table.data-table tbody tr:hover { background: #F8F9FD; }

.actions-cell { display: flex; gap: 6px; }

.status-pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
}
.status-sim { background: #E2F6EA; color: var(--unp-success); }
.status-selecao { background: #FFF3D6; color: #B8860B; }
.status-nao { background: #FDE6E4; color: var(--unp-red); }

.empty-state, .loading-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--unp-text-muted);
}

.empty-state .icon { font-size: 34px; margin-bottom: 10px; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 33, 61, 0.55);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 100;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--unp-white);
  border-radius: 14px;
  width: 100%;
  max-width: 640px;
  padding: 28px 30px 26px 30px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.modal-header h2 {
  margin: 0;
  color: var(--unp-navy);
  font-size: 20px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--unp-text-muted);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }

.form-group label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--unp-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.form-group input,
.form-group select {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--unp-border);
  font-size: 14px;
  outline: none;
  font-family: inherit;
}
.form-group input:focus,
.form-group select:focus { border-color: var(--unp-blue-accent); }

.form-group input:disabled { background: #F4F6FB; color: var(--unp-text-muted); }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.view-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 20px;
}
.view-item { border-bottom: 1px solid var(--unp-border); padding-bottom: 8px; }
.view-item .k { font-size: 11.5px; color: var(--unp-text-muted); font-weight: 700; text-transform: uppercase; }
.view-item .v { font-size: 14.5px; margin-top: 3px; }

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--unp-navy);
  color: white;
  padding: 14px 20px;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  font-size: 14px;
  font-weight: 600;
  z-index: 200;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.25s ease;
  max-width: 320px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--unp-red); }
.toast.success { background: var(--unp-success); }

@media (max-width: 900px) {
  .sidebar { display: none; }
  .form-grid, .view-grid { grid-template-columns: 1fr; }
}
