:root {
  --bg: #eef4f7;
  --surface: #ffffff;
  --surface-2: #f7fbfd;
  --text: #12313f;
  --muted: #627987;
  --primary: #0b5c75;
  --primary-2: #0f7898;
  --accent: #d7a93b;
  --border: #d8e5eb;
  --danger: #a23b3b;
  --ok: #246b4b;
  --shadow: 0 18px 45px rgba(12, 46, 61, 0.12);
}

body[data-theme="natureza"] {
  --bg: #eef6ef;
  --surface: #ffffff;
  --surface-2: #f7fbf7;
  --text: #173823;
  --muted: #5c7863;
  --primary: #2e6f43;
  --primary-2: #4b8c5d;
  --accent: #d0a43b;
  --border: #d9eadb;
}

body[data-theme="dourado"] {
  --bg: #f8f2e5;
  --surface: #fffdf8;
  --surface-2: #fbf5e8;
  --text: #3f3216;
  --muted: #806f4f;
  --primary: #73571b;
  --primary-2: #a17422;
  --accent: #c9972c;
  --border: #eadfc6;
}

body[data-theme="rose"] {
  --bg: #f8eef1;
  --surface: #ffffff;
  --surface-2: #fdf7f9;
  --text: #421f2c;
  --muted: #876273;
  --primary: #8a3f5e;
  --primary-2: #ad5578;
  --accent: #d2a044;
  --border: #ead7df;
}

body[data-theme="noturno"] {
  --bg: #101821;
  --surface: #182433;
  --surface-2: #223244;
  --text: #eef5f8;
  --muted: #a9bac7;
  --primary: #65a9c6;
  --primary-2: #86c6dd;
  --accent: #d6b45a;
  --border: #30465b;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

.hidden {
  display: none !important;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  border-radius: 12px;
  padding: 10px 14px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

button:hover {
  filter: brightness(0.98);
}

.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: white;
  border: 0;
}

.link-button {
  background: transparent;
  color: var(--primary);
  padding: 6px 0;
  text-decoration: underline;
}

.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.danger {
  background: var(--danger);
  color: #fff;
}

.full {
  width: 100%;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at top left, rgba(11, 92, 117, 0.18), transparent 35%), var(--bg);
}

.login-card {
  width: min(460px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.brand-line {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 22px;
}

.brand-line img {
  width: 74px;
  height: 74px;
  object-fit: contain;
}

.brand-line h1 {
  margin: 0;
  font-size: 28px;
}

.brand-line p {
  margin: 2px 0 0;
  color: var(--muted);
}

label {
  display: block;
  margin: 12px 0 6px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
}

textarea {
  min-height: 130px;
  resize: vertical;
}

.hint,
.muted {
  color: var(--muted);
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 270px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.side-brand img {
  width: 46px;
  height: 46px;
}

.side-brand span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.nav {
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 14px;
}

.nav.active,
.nav:hover {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--primary);
  font-weight: 700;
}

.theme-box {
  margin-top: auto;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.theme-box span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.main {
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.52);
  backdrop-filter: blur(12px);
}

body[data-theme="noturno"] .topbar {
  background: rgba(24, 36, 51, 0.75);
}

.topbar h2 {
  margin: 0;
  font-size: 26px;
}

.topbar p {
  margin: 2px 0 0;
  color: var(--muted);
}

.user-pill {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 10px 14px;
  text-align: right;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.04);
}

.user-pill span {
  display: block;
  font-weight: 800;
}

.user-pill small {
  color: var(--muted);
}

.content {
  padding: 26px;
}

.grid {
  display: grid;
  gap: 18px;
}

.grid.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 20px;
  box-shadow: 0 8px 28px rgba(12, 46, 61, 0.06);
}

.metric .num {
  font-size: 44px;
  line-height: 1;
  font-weight: 900;
  color: var(--primary);
}

.metric .label {
  color: var(--muted);
  font-weight: 700;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 18px 0 12px;
}

.section-title h3 {
  margin: 0;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.process-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 800;
  color: var(--primary);
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.doc-tree {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.doc-card {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 18px;
  overflow: hidden;
}

.doc-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.doc-body {
  padding: 16px;
}

.section {
  margin: 14px 0;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(247, 251, 253, 0.85);
}

.section h4 {
  margin: 0 0 8px;
}

.section p,
.material p,
.material li,
.report-preview p {
  text-align: justify;
}

.tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.small {
  padding: 6px 9px;
  font-size: 13px;
  border-radius: 10px;
}

.material-page {
  max-width: 920px;
  margin: 0 auto;
}

.material-print-header {
  display: grid;
  grid-template-columns: 70px 1fr 70px;
  gap: 16px;
  align-items: center;
  margin: 0 auto 12px;
  padding: 12px 22px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: 0 8px 28px rgba(12, 46, 61, 0.06);
}

.material-print-logo {
  display: flex;
  align-items: center;
  justify-content: center;
}

.material-print-logo img {
  width: 50px;
  height: 50px;
  object-fit: contain;
}

.branding-grid {
  margin-top: 16px;
}

.branding-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.branding-preview {
  width: 116px;
  height: 116px;
  object-fit: contain;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}

.material-print-titles {
  text-align: center;
}

.material-print-line {
  font-size: 12px;
  line-height: 1.25;
}

.material-print-line.strong {
  font-weight: 700;
}

.material-print-divider {
  height: 1px;
  background: var(--border);
  margin: 7px 0 9px;
}

.material-print-titles h1 {
  margin: 0;
  font-size: 18px;
}

.material-print-subtitle,
.material-print-meta {
  margin: 4px 0 0;
  color: var(--muted);
}

.material {
  max-width: 920px;
  margin: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 28px;
}

.material h1 {
  margin-top: 0;
}

.material h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.material section {
  padding: 0 0 12px;
  margin: 14px 0;
  border-bottom: 1px solid var(--border);
}

.material section:last-of-type {
  border-bottom: 0;
  padding-bottom: 0;
}

.material-closing {
  margin-top: 24px;
}

.notice {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  color: var(--muted);
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}

.check-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 7px 9px;
  background: var(--surface-2);
}

.print-lines div {
  height: 28px;
  border-bottom: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: 14px;
  overflow: hidden;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

th {
  background: var(--surface-2);
  font-size: 13px;
}

dialog {
  border: 0;
  border-radius: 22px;
  padding: 0;
  width: min(820px, 92vw);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding: 14px 18px;
}

.modal-head h3 {
  margin: 0;
}

#modalBody {
  padding: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.report-preview {
  background: white;
  color: #000;
  padding: 28px;
  border: 1px solid #ddd;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.tab.active {
  background: var(--primary);
  color: white;
}

.empty {
  padding: 24px;
  border: 1px dashed var(--border);
  border-radius: 16px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .grid.cols-4,
  .grid.cols-3,
  .grid.cols-2,
  .check-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .process-card,
  .material-print-header {
    grid-template-columns: 1fr;
  }
}

@page {
  size: A4;
  margin: 1.5cm;
}

@media print {
  body {
    background: white;
    color: #000;
    font: 12pt/1.55 "Times New Roman", Georgia, serif;
  }

  .sidebar,
  .topbar,
  .tools,
  .nav,
  button,
  .theme-box,
  .user-pill {
    display: none !important;
  }

  .app {
    display: block;
    min-height: auto;
  }

  .main,
  .content {
    padding: 0 !important;
  }

  .material-page {
    max-width: none;
    margin: 0;
  }

  .material-print-header {
    display: grid;
    grid-template-columns: 66px 1fr 66px;
    margin: 0 0 4pt;
    padding: 0 0 3pt;
    border: 0;
    border-bottom: 1px solid #777;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
  }

  .material-print-logo img {
    width: 54px;
    height: 54px;
  }

  .material-print-line {
    font-size: 8pt;
    color: #000;
    line-height: 1.15;
  }

  .material-print-line.strong {
    font-size: 8.6pt;
  }

  .material-print-divider {
    margin: 3pt 0 4pt;
    background: #777;
  }

  .material-print-titles h1 {
    font-size: 10.2pt;
    letter-spacing: 0.2pt;
  }

  .material-print-subtitle,
  .material-print-meta,
  .muted {
    color: #333 !important;
  }

  .material {
    border: 0;
    box-shadow: none;
    border-radius: 0;
    max-width: none;
    margin: 0;
    padding: 0;
    background: transparent;
  }

  .material section {
    break-inside: auto;
    page-break-inside: auto;
    margin: 4pt 0 5pt;
    padding: 0 0 4pt;
    border-bottom: 1px solid #c8c8c8;
  }

  .material section:last-of-type {
    border-bottom: 0;
  }

  .material h2 {
    font-size: 10pt;
    margin-bottom: 2pt;
  }

  .material p,
  .material li {
    margin: 0 0 2pt;
    line-height: 1.18;
  }

  .check-grid {
    gap: 2pt;
    margin-top: 2pt;
  }

  .notice {
    border: 1px solid #999;
    color: #000;
    background: transparent;
    padding: 7pt 8pt;
    border-radius: 0;
  }

  .check-item {
    break-inside: avoid;
    background: transparent;
    color: #000;
    padding: 2.5pt 4pt;
    border-radius: 4pt;
    line-height: 1.08;
  }

  .print-lines div {
    border-color: #999;
    height: 10pt;
  }

  .notice-print-helper {
    display: none !important;
  }

  .material-closing {
    margin-top: 10pt;
  }

  .material-professor-observacao .check-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .material-professor-observacao .check-item {
    font-size: 8.3pt;
  }

  .material-professor-observacao .material-section-checklist {
    margin-bottom: 3pt;
  }

  .material-professor-observacao .material-section-lines {
    margin-top: 3pt;
  }
}
