:root {
  --bg: #eef3f1;
  --bg-accent: #d9e8e2;
  --ink: #14231f;
  --muted: #5a6d67;
  --card: rgba(255, 255, 255, 0.92);
  --line: #c9d8d2;
  --teal: #0f6b5c;
  --teal-deep: #0a4a40;
  --amber: #c47a12;
  --rose: #a33b3b;
  --blue: #1f5f8b;
  --green: #2f6b3a;
  --shadow: 0 10px 30px rgba(20, 35, 31, 0.08);
  --radius: 14px;
  --font: "Source Sans 3", "Segoe UI", sans-serif;
  --display: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #cfe7df 0%, transparent 55%),
    radial-gradient(900px 400px at 100% 0%, #f3e2c4 0%, transparent 50%),
    linear-gradient(180deg, #f7faf8 0%, var(--bg) 40%, #e7efe9 100%);
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(10px);
  background: rgba(247, 250, 248, 0.9);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0.85rem 1rem;
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}
.brand-mark {
  margin: 0;
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--teal-deep);
}
.brand-sub {
  margin: 0.1rem 0 0;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-transform: uppercase;
}
.nav-links { display: flex; gap: 0.4rem; }
.nav-link {
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 600;
}
.nav-link.active, .nav-link:hover {
  background: #dff0ea;
  color: var(--teal-deep);
}
.user-block {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.15; }
.user-name { font-weight: 700; font-size: 0.92rem; }
.user-rol { font-size: 0.75rem; color: var(--muted); }
.sync-badge {
  font-size: 0.75rem;
  color: var(--teal);
  background: #dff0ea;
  border: 1px solid #b7ddd2;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
}

.page-main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.25rem 1rem 2.5rem;
}
.page-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.page-header h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  color: var(--teal-deep);
}
.page-lead { margin: 0.35rem 0 0; color: var(--muted); max-width: 42rem; }
.header-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.55rem 0.95rem;
  cursor: pointer;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-deep); }
.btn-secondary { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-secondary:hover { background: #f3f7f5; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--ink); background: #e8f0ec; }
.btn-danger { background: #f8e8e8; color: var(--rose); border-color: #efcfcf; }
.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.85rem; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
@media (min-width: 800px) {
  .kpi-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow);
  border-top: 3px solid var(--teal);
}
.kpi-label { margin: 0; color: var(--muted); font-size: 0.82rem; font-weight: 600; }
.kpi-value {
  margin: 0.25rem 0 0;
  font-family: var(--display);
  font-size: 1.55rem;
  font-weight: 700;
}
.kpi-teal { border-top-color: var(--teal); }
.kpi-green { border-top-color: var(--green); }
.kpi-amber { border-top-color: var(--amber); }
.kpi-blue { border-top-color: var(--blue); }
.kpi-slate { border-top-color: #5f736c; }
.kpi-rose { border-top-color: var(--rose); }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
  overflow: hidden;
}
.panel-head {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}
.panel-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-family: var(--display);
}
.panels-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}
@media (min-width: 900px) {
  .panels-2 { grid-template-columns: 1fr 1fr; }
}

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
  font-size: 0.92rem;
}
.data-table th, .data-table td {
  padding: 0.65rem 0.8rem;
  border-bottom: 1px solid #e4ece8;
  text-align: left;
  white-space: nowrap;
}
.data-table th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  background: #f4f8f6;
}
.data-table tbody tr:hover { background: #f7fbf9; }
.data-table tfoot td {
  font-weight: 700;
  background: #eef6f2;
}
.align-right { text-align: right !important; }
.align-center { text-align: center !important; }
.empty-cell { text-align: center; color: var(--muted); padding: 1.5rem !important; }

.alert {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  background: #eef4ff;
  border: 1px solid #d5e2f7;
}
.alert-error {
  background: #fceeee;
  border-color: #efcfcf;
  color: var(--rose);
}
.alert-ok {
  background: #eaf6ee;
  border-color: #c7e5d0;
  color: var(--green);
}

/* Login */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.login-card {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 1.5rem;
}
.login-card h1 {
  margin: 0.35rem 0 0.15rem;
  font-family: var(--display);
  font-size: 1.7rem;
  color: var(--teal-deep);
}
.login-card .lede { margin: 0 0 1.25rem; color: var(--muted); }
.login-card label {
  display: block;
  margin-bottom: 0.85rem;
  font-weight: 600;
  font-size: 0.9rem;
}
.login-card input,
.login-card select,
.aula-form input,
.aula-form select,
.aula-form textarea {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.login-card .btn { width: 100%; margin-top: 0.5rem; }
.hint { margin-top: 1rem; font-size: 0.82rem; color: var(--muted); }

/* Aulas list */
.aula-cards { display: grid; gap: 0.75rem; }
.aula-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}
.aula-card-top {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
}
.aula-title {
  margin: 0;
  font-family: var(--display);
  font-size: 1.1rem;
}
.aula-meta { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.88rem; }
.pill {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  background: #dff0ea;
  color: var(--teal-deep);
}
.pill.virtual { background: #e7eef8; color: var(--blue); }
.stats-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.4rem;
  margin-top: 0.85rem;
}
.stat {
  background: #f4f8f6;
  border-radius: 10px;
  padding: 0.45rem;
  text-align: center;
}
.stat b { display: block; font-size: 1rem; }
.stat span { font-size: 0.7rem; color: var(--muted); }
.aula-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.85rem; }
.filters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.filters input, .filters select {
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  min-width: 140px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 28, 25, 0.45);
  display: none;
  place-items: end center;
  z-index: 50;
  padding: 0;
}
.modal-backdrop.is-open {
  display: grid;
}
.modal-backdrop[hidden] {
  display: none !important;
}
@media (min-width: 720px) {
  .modal-backdrop.is-open { place-items: center; padding: 1rem; }
}
.modal {
  width: min(720px, 100%);
  max-height: 92vh;
  overflow: auto;
  background: #fff;
  border-radius: 16px 16px 0 0;
  box-shadow: var(--shadow);
}
@media (min-width: 720px) {
  .modal { border-radius: 16px; }
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: #fff;
}
.modal-head h2 { margin: 0; font-family: var(--display); font-size: 1.2rem; }
.aula-form { padding: 1rem 1.1rem 1.25rem; display: grid; gap: 0.75rem; }
.aula-form label { font-weight: 600; font-size: 0.88rem; display: block; }
.form-grid-2, .form-grid-5 {
  display: grid;
  gap: 0.75rem;
}
@media (min-width: 640px) {
  .form-grid-2 { grid-template-columns: 1fr 1fr; }
  .form-grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.obs {
  margin: 0.65rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  white-space: pre-wrap;
}

@media (max-width: 640px) {
  .stats-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .data-table { min-width: 560px; }
  .nav-links { order: 3; width: 100%; }
}
