:root {
  --blue-950: #08264a;
  --blue-850: #0d3b73;
  --blue-700: #155ea8;
  --blue-600: #1f73c9;
  --blue-100: #eaf4ff;
  --blue-50: #f5faff;
  --white: #ffffff;
  --ink: #142033;
  --muted: #617089;
  --line: #d9e6f5;
  --success: #0f9270;
  --warning: #d48214;
  --danger: #d14343;
  --shadow: 0 18px 55px rgba(10, 47, 91, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--blue-50);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px;
  color: var(--white);
  background: var(--blue-950);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  color: var(--blue-950);
  background: var(--white);
  font-weight: 800;
  overflow: hidden;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-mark.large {
  width: 72px;
  height: 72px;
  color: var(--white);
  background: var(--blue-700);
  font-size: 1.35rem;
}

.brand strong,
.brand small {
  display: block;
}

.brand small,
.sidebar-card small,
.sidebar-card span {
  color: rgba(255, 255, 255, 0.72);
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item {
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.78);
  text-align: left;
  background: transparent;
}

.nav-item:hover,
.nav-item.active {
  color: var(--white);
  background: rgba(255, 255, 255, 0.12);
}

.sidebar-card {
  display: grid;
  gap: 7px;
  margin-top: 28px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.main {
  min-width: 0;
  padding: 28px;
}

.topbar,
.section-heading,
.panel-heading,
.calendar-head,
.message-box,
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 24px;
}

.topbar h1,
.section-heading h2,
.hero-panel h2 {
  margin: 0;
  color: var(--blue-950);
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(1.7rem, 3vw, 2.4rem);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--blue-600);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.top-actions,
.hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-btn,
.ghost-btn,
.icon-btn,
.segmented button,
.slot-list button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--white);
}

.primary-btn {
  padding: 0 16px;
  border-color: var(--blue-700);
  color: var(--white);
  background: var(--blue-700);
  font-weight: 700;
}

.ghost-btn {
  padding: 0 16px;
  color: var(--blue-850);
  font-weight: 700;
}

.icon-btn,
.menu-toggle {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: var(--blue-850);
  font-size: 1.2rem;
  font-weight: 800;
}

.menu-toggle {
  display: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 20px;
}

.hero-panel,
.panel,
.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  box-shadow: var(--shadow);
}

.hero-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 28px;
}

.hero-panel p,
.practice-card p,
.admin-card p {
  color: var(--muted);
  line-height: 1.6;
}

.status-pill,
.counter {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
}

.risk-medium {
  color: #744205;
  background: #fff1d8;
}

.metrics-grid,
.practice-grid,
.admin-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.panel-note {
  max-width: 680px;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.brand-config {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.brand-preview {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: center;
  background: var(--blue-50);
}

.brand-preview strong {
  color: var(--blue-950);
}

.brand-preview small {
  color: var(--muted);
}

.commercial-notes {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.commercial-notes span {
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--blue-850);
  background: var(--blue-100);
  font-size: 0.86rem;
  font-weight: 700;
}

.integration-status {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.integration-status span {
  padding: 8px 11px;
  border-radius: 999px;
  color: var(--danger);
  background: #fff0f0;
  font-size: 0.82rem;
  font-weight: 800;
}

.integration-status span.ready {
  color: var(--success);
  background: #e8fff8;
}

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

fieldset {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--blue-50);
}

legend {
  padding: 0 8px;
  color: var(--blue-950);
  font-weight: 800;
}

.check-row {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 10px;
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

.coverage-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.coverage-grid span {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--blue-850);
  background: var(--blue-50);
  font-size: 0.86rem;
  font-weight: 700;
}

.metric {
  padding: 18px;
}

.metric span,
.metric strong {
  display: block;
}

.metric span {
  color: var(--muted);
  font-size: 0.9rem;
}

.metric strong {
  margin: 10px 0;
  color: var(--blue-950);
  font-size: 2rem;
}

.bar {
  overflow: hidden;
  height: 8px;
  border-radius: 999px;
  background: var(--blue-100);
}

.bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--blue-600);
}

.content-grid,
.planner-layout,
.calendar-layout,
.profile-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(300px, 0.8fr);
  gap: 18px;
}

.panel {
  padding: 20px;
}

.panel h3 {
  margin: 0 0 16px;
  color: var(--blue-950);
}

.panel-heading h3,
.calendar-head h3 {
  margin: 0;
}

.task-list,
.alert-list,
.rule-list,
.student-list,
.payment-list,
.slot-list {
  display: grid;
  gap: 12px;
}

.task {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--blue-50);
}

.task input {
  width: 18px;
  height: 18px;
}

.task strong,
.alert strong,
.student-list strong,
.payment-list strong {
  display: block;
}

.task span,
.alert span,
.student-list span,
.payment-list span {
  color: var(--muted);
  font-size: 0.9rem;
}

.task.done {
  opacity: 0.6;
}

.task.done strong {
  text-decoration: line-through;
}

.tag {
  padding: 6px 9px;
  border-radius: 999px;
  color: var(--blue-850);
  background: var(--blue-100);
  font-size: 0.75rem;
  font-weight: 800;
}

.alert,
.student-list div,
.payment-list div {
  padding: 14px;
  border-left: 4px solid var(--blue-600);
  border-radius: 8px;
  background: var(--blue-50);
}

.segmented {
  display: flex;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.segmented button {
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  color: var(--muted);
}

.segmented button.active {
  color: var(--white);
  background: var(--blue-700);
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--blue-950);
  font-size: 0.88rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--white);
}

.rule-list span {
  padding: 12px;
  border-radius: 8px;
  color: var(--blue-850);
  background: var(--blue-100);
  font-weight: 700;
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(120px, 1fr));
  gap: 10px;
  overflow-x: auto;
}

.day-card {
  min-height: 170px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--blue-50);
}

.day-card strong {
  color: var(--blue-950);
}

.day-card ul {
  margin: 12px 0 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.6;
}

.toolbar {
  justify-content: flex-start;
}

.toolbar input {
  max-width: 420px;
}

.toolbar select {
  max-width: 220px;
}

.topic-table {
  display: grid;
  gap: 10px;
}

.topic-row {
  display: grid;
  grid-template-columns: 90px minmax(180px, 1.4fr) minmax(130px, 0.8fr) repeat(4, minmax(90px, 0.55fr));
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  box-shadow: var(--shadow);
}

.topic-row.header {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  box-shadow: none;
}

.state {
  color: var(--blue-850);
  font-weight: 800;
}

.state.Crítico {
  color: var(--danger);
}

.state.Estudiado {
  color: var(--success);
}

.state.En-repaso {
  color: var(--warning);
}

.practice-card strong {
  color: var(--blue-700);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(90px, 1fr));
  gap: 10px;
}

.calendar-day {
  min-height: 112px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--blue-50);
}

.calendar-day strong {
  display: block;
  margin-bottom: 8px;
}

.calendar-event {
  display: block;
  margin-top: 6px;
  padding: 6px;
  border-radius: 6px;
  color: var(--white);
  background: var(--blue-700);
  font-size: 0.72rem;
  font-weight: 700;
}

.calendar-event.tutoring {
  background: var(--success);
}

.tutoring-card {
  display: grid;
  gap: 7px;
  margin-bottom: 16px;
  padding: 16px;
  border-radius: 8px;
  background: var(--blue-100);
}

.tutoring-card span {
  color: var(--muted);
}

.slot-list button {
  padding: 0 12px;
  color: var(--blue-850);
  text-align: left;
  font-weight: 700;
}

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

.wide {
  grid-column: 1 / -1;
}

.message-box input {
  flex: 1;
}

.auth-modal {
  width: min(460px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-modal::backdrop {
  background: rgba(8, 38, 74, 0.45);
}

.auth-modal form {
  position: relative;
  padding: 14px;
}

.close-modal {
  position: absolute;
  top: 8px;
  right: 8px;
}

.auth-grid {
  display: grid;
  gap: 12px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 360px;
  padding: 14px 16px;
  border-radius: 8px;
  color: var(--white);
  background: var(--blue-950);
  box-shadow: var(--shadow);
  transform: translateY(120px);
  transition: transform 0.2s ease;
  z-index: 10;
}

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

@media (max-width: 1180px) {
  .metrics-grid,
  .practice-grid,
  .admin-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topic-row {
    grid-template-columns: 80px minmax(180px, 1fr) minmax(120px, 0.8fr);
  }

  .topic-row span:nth-child(n + 4) {
    display: none;
  }
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 280px;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 20;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .menu-toggle {
    display: grid;
  }

  .main {
    padding: 18px;
  }

  .topbar,
  .section-heading,
  .hero-panel {
    align-items: flex-start;
    flex-direction: column;
  }

  .content-grid,
  .planner-layout,
  .calendar-layout,
  .profile-layout,
  .mentor-grid,
  .brand-config,
  .integration-grid {
    grid-template-columns: 1fr;
  }

  .form-grid,
  .metrics-grid,
  .practice-grid,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .calendar-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .top-actions,
  .hero-actions,
  .toolbar,
  .segmented,
  .message-box {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .primary-btn,
  .ghost-btn {
    width: 100%;
  }

  .topic-row {
    grid-template-columns: 1fr;
  }

  .topic-row.header {
    display: none;
  }
}
