:root {
  --bg: #f2f5f8;
  --bg-alt: #e9eef4;
  --surface: #ffffff;
  --surface-2: #f8fbff;
  --ink: #17222d;
  --muted: #5f6d7a;
  --brand: #0f4c81;
  --brand-strong: #0a3b64;
  --line: #d7e1ea;
  --ok: #1c8b53;
  --warn: #9a6b00;
  --bad: #bc2f2f;
  --shadow: 0 18px 32px rgba(15, 38, 59, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(150deg, #f7fafc 0%, var(--bg) 45%, var(--bg-alt) 100%);
}

.bg-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.16;
  background-image: radial-gradient(#0f4c8115 1px, transparent 1px);
  background-size: 10px 10px;
}

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(6px);
}

.overline {
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
}

.brand h1 {
  margin: 0;
  font-size: clamp(1.3rem, 2vw, 1.8rem);
}

.status-strip {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.pill {
  font-size: 0.83rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 6px 10px;
  color: var(--muted);
}

.workspace {
  display: grid;
  grid-template-columns: 230px 1fr;
  min-height: 0;
}

.workspace.hidden {
  display: none;
}

.auth-gate {
  padding: 26px 20px 10px;
}

.auth-card {
  max-width: 980px;
  margin: 0 auto;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.75);
  padding: 20px 12px;
  display: grid;
  gap: 8px;
  align-content: start;
}

.nav-item {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.92rem;
  cursor: pointer;
}

.nav-item:hover {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

.nav-item.active {
  color: #fff;
  background: linear-gradient(130deg, var(--brand), var(--brand-strong));
  box-shadow: none;
}

.content {
  padding: 20px;
  overflow: auto;
}

.panel {
  display: none;
  animation: fade 180ms ease-out;
}

.panel.active {
  display: block;
}

@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.panel h2 {
  margin: 4px 0 14px;
  font-size: 1.28rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 14px 16px;
}

.stat-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.stat-card h3 {
  margin: 7px 0 0;
  font-size: 1.48rem;
}

.stat-card.danger h3 {
  color: var(--bad);
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 14px;
}

.card h3 {
  margin: 0 0 12px;
  font-size: 1.02rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 0.84rem;
  color: var(--muted);
}

input,
select,
button {
  font: inherit;
}

button {
  box-shadow: none !important;
}

input,
select {
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 9px 10px;
}

input:focus,
select:focus {
  outline: 2px solid #0f4c8140;
  border-color: var(--brand);
}

.primary-btn,
.ghost-btn {
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 10px 12px;
  cursor: pointer;
  box-shadow: none;
}

.primary-btn {
  background: linear-gradient(130deg, var(--brand), var(--brand-strong));
  color: #fff;
}

.ghost-btn {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.form-grid button {
  grid-column: 1 / -1;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 700px;
}

th,
td {
  text-align: left;
  padding: 10px 9px;
  border-bottom: 1px solid var(--line);
  font-size: 0.84rem;
  vertical-align: top;
}

th {
  background: var(--surface-2);
  color: var(--muted);
  position: sticky;
  top: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 3px 8px;
  font-size: 0.75rem;
}

.badge.pendente {
  border-color: #d8b66f;
  background: #fff8eb;
  color: var(--warn);
}

.badge.pago {
  border-color: #86cbad;
  background: #effbf4;
  color: var(--ok);
}

.badge.atrasado {
  border-color: #e2a0a0;
  background: #fff2f2;
  color: var(--bad);
}

.badge.admin {
  border-color: #acc2d8;
  background: #edf5ff;
  color: #29557a;
}

.badge.professor {
  border-color: #9ec7be;
  background: #ebf8f4;
  color: #1b6654;
}

.badge.aluno {
  border-color: #d7c39e;
  background: #fff8e9;
  color: #8e6300;
}

.upload-form {
  display: grid;
  gap: 6px;
}

.upload-form input[type="file"] {
  font-size: 0.77rem;
}

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.hidden {
  display: none;
}

.chat-head {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.chat-timeline {
  background: #f6f9fc;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  min-height: 320px;
  max-height: 460px;
  overflow: auto;
}

.chat-date {
  text-align: center;
  font-size: 0.78rem;
  color: var(--muted);
  margin: 10px 0;
}

.chat-msg {
  max-width: 78%;
  padding: 8px 10px;
  margin: 6px 0;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.34;
}

.chat-msg.self {
  margin-left: auto;
  background: linear-gradient(130deg, #ddeeff, #e9f4ff);
  border: 1px solid #c5dbf0;
}

.chat-msg.other {
  margin-right: auto;
  background: #fff;
  border: 1px solid var(--line);
}

.chat-msg.pending {
  border-style: dashed;
  opacity: 0.9;
}

.msg-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.72rem;
}

.chat-compose {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 10px;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  background: #17222d;
  color: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  opacity: 0;
  transform: translateY(8px);
  transition: all 180ms ease;
  pointer-events: none;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    grid-template-columns: repeat(6, minmax(150px, 1fr));
    overflow: auto;
    white-space: nowrap;
  }

  .nav-item {
    text-align: center;
  }
}

@media (max-width: 820px) {
  .topbar {
    padding: 14px;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .content {
    padding: 14px;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .chat-head {
    grid-template-columns: 1fr;
  }

  .chat-msg {
    max-width: 92%;
  }
}
