* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  background: #f5f5f5;
  color: #222;
}

.bg-login {
  background: radial-gradient(circle at top left, #009688 0, #0c4313 55%, #00251a 100%);
  min-height: 100vh;
}

.portal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 24px;
  background: #0c4313;
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.35);
}

.portal-header-login {
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  height: 44px;
  width: auto;
}

.title-block {
  display: flex;
  flex-direction: column;
}

.portal-subtitle {
  font-size: 0.75rem;
  opacity: 0.85;
}

.portal-title {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.user-area {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
}

.user-name {
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.portal-wrapper {
  display: flex;
  min-height: calc(100vh - 70px);
}

.sidebar {
  width: 240px;
  background: #e0f2f1;
  padding: 16px 14px;
  border-right: 1px solid #b2dfdb;
}

.sidebar ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar li {
  margin-bottom: 6px;
}

.sidebar-section {
  margin-top: 14px;
  margin-bottom: 4px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #0c4313;
  opacity: 0.85;
}

.sidebar a {
  display: block;
  text-decoration: none;
  color: #0c4313;
  font-size: 0.9rem;
  padding: 6px 8px;
  border-radius: 4px;
}

.sidebar a:hover {
  background: #b2dfdb;
}

.content {
  flex: 1;
  padding: 20px 24px 60px;
}

.page-title {
  margin-top: 0;
  margin-bottom: 16px;
  font-size: 1.4rem;
  color: #0c4313;
}

.section-title {
  margin: 24px 0 8px;
  font-size: 1.1rem;
  font-weight: 600;
  color: #0c4313;
}

.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 70px);
  padding: 24px;
}

.card {
  background: #ffffff;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.card-login {
  width: 100%;
  max-width: 380px;
  text-align: left;
}

.card-login h2 {
  margin-top: 0;
  margin-bottom: 18px;
  text-align: center;
  color: #0c4313;
}

.card-dashboard h2 {
  margin-top: 0;
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 4px;
  font-size: 0.9rem;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 4px;
  border: 1px solid #cfd8dc;
  font-size: 0.9rem;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: #00796b;
  box-shadow: 0 0 0 1px rgba(0, 150, 136, 0.25);
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 4px;
  border: none;
  text-decoration: none;
  background: #00796b;
  color: #ffffff;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s ease, transform 0.05s ease;
}

.btn:hover {
  background: #00695c;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: #00796b;
}

.btn-outline {
  border: 1px solid #ffffff;
  background: transparent;
}

.btn-sm {
  padding: 4px 8px;
  font-size: 0.8rem;
}

.btn-danger {
  background: #c62828;
}

/* =============================
   Visualizador seguro (view.php)
   ============================= */

.secure-view-card {
  padding: 14px;
}

.secure-view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.secure-file-name {
  font-weight: 700;
  font-size: 1.0rem;
  color: #0c4313;
  word-break: break-word;
}

.secure-file-meta {
  font-size: 0.85rem;
  opacity: 0.85;
}

.secure-file-meta .sep {
  margin: 0 6px;
}

.secure-view-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.secure-viewer {
  position: relative;
  border: 1px solid #cfd8dc;
  border-radius: 8px;
  background: #0f1416;
  overflow: hidden;
}

.secure-pages {
  position: relative;
  z-index: 1;
  padding: 14px 10px 18px;
}

.secure-page {
  display: flex;
  justify-content: center;
  padding: 10px 6px;
}

.secure-page img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.45);
  user-select: none;
  -webkit-user-drag: none;
}

.secure-watermark {
  position: absolute;
  inset: 0;
  background-repeat: repeat;
  pointer-events: none;
  z-index: 2;
  opacity: 1;
}

.secure-view-hint {
  margin-top: 10px;
  font-size: 0.85rem;
  opacity: 0.85;
  color: #37474f;
}

.secure-text {
  width: 100%;
  min-height: 60vh;
  border: 1px solid #cfd8dc;
  border-radius: 8px;
  padding: 12px;
  background: #111;
  color: #e0f2f1;
  overflow: auto;
  user-select: none;
}

/* Escurece quando a aba perde foco (dissuasão de captura) */
body.secure-hidden::before {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.95);
  z-index: 9999;
}

body.secure-hidden::after {
  content: 'Conteúdo protegido';
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 10000;
  color: rgba(255,255,255,1);
  font-size: 1.05rem;
  font-weight: 700;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(0,0,0,0.70);
  border: 1px solid rgba(255,255,255,0.25);
}

.btn-full {
  width: 100%;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.categories-grid {
  margin-top: 1rem;
}

.category-card h3 {
  margin-bottom: 0.35rem;
  font-size: 1rem;
}

.category-card p {
  font-size: 0.85rem;
  opacity: 0.9;
}

.card-link {
  text-decoration: none;
  color: inherit;
}

.card-dashboard {
  min-height: 110px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.table th,
.table td {
  padding: 8px 10px;
  border-bottom: 1px solid #eceff1;
  text-align: left;
}

.table th {
  background: #e0f2f1;
  font-weight: 600;
  color: #0c4313;
}

.file-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  margin-right: 6px;
  color: #ffffff;
}

.file-icon-pdf {
  background-color: #d32f2f;
}

.file-icon-word {
  background-color: #1565c0;
}

.file-icon-excel {
  background-color: #2e7d32;
}

.file-icon-powerpoint {
  background-color: #e64a19;
}

.file-icon-text {
  background-color: #616161;
}

.file-icon-other {
  background-color: #455a64;
}

.table-sm th,
.table-sm td {
  padding: 6px 8px;
}

.error-msg {
  background: #ffebee;
  color: #b71c1c;
  padding: 10px;
  border-radius: 4px;
  margin-bottom: 10px;
  font-size: 0.85rem;
}

.alert {
  background: #e3f2fd;
  color: #0d47a1;
  padding: 10px;
  border-radius: 4px;
  margin-bottom: 15px;
  font-size: 0.85rem;
}

.alert-warning {
  background: #fff3cd;
  color: #856404;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px 16px;
}

.portal-footer {
  width: 100%;
  padding: 8px 16px;
  background: #0c4313;
  color: #ffffff;
  font-size: 0.8rem;
  text-align: center;
  position: relative;
}

.footer-login {
  position: fixed;
  bottom: 0;
  left: 0;
}

@media (max-width: 768px) {
  .portal-wrapper {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid #b2dfdb;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .sidebar ul {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .sidebar li {
    margin-bottom: 0;
  }

  .content {
    padding: 14px 10px 60px;
  }

  .portal-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .user-area {
    align-self: flex-end;
  }
}
