@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/inter-var.woff2') format('woff2');
}

:root {
  --bg: #F8F5EF;
  --surface: #FFFFFF;
  --text: #131210;
  --muted: #6E675A;
  --accent: #A9834C;
  --accent-dark: #8A6B3D;
  --accent-soft: #C9A96B;
  --danger: #A13D2D;
  --warning: #A13D2D;
  --ok: #5B7B54;
  --border: rgba(19, 18, 16, 0.14);
  --dark: #0D0C0A;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.topbar {
  background: var(--surface);
  color: var(--text);
  border-bottom: 1px solid var(--border);
  padding: env(safe-area-inset-top, 0) 16px 12px;
  padding-top: calc(env(safe-area-inset-top, 0) + 14px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
}

.brand img {
  height: 30px;
  width: auto;
  display: block;
}

.link-btn {
  background: none;
  border: none;
  color: var(--muted);
  opacity: 1;
  font-size: 0.9rem;
  padding: 6px 8px;
  font-family: 'Inter', sans-serif;
}

.view {
  flex: 1;
  padding: 16px 16px 96px;
  overflow-y: auto;
}

.section-title {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  margin: 22px 0 10px;
  color: var(--muted);
  letter-spacing: 0.06em;
}

.section-title:first-child { margin-top: 4px; }

/* Login */
.login-card {
  max-width: 360px;
  margin: 15vh auto 0;
  background: var(--surface);
  padding: 32px 26px;
  border-radius: 2px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 24px rgba(19, 18, 16, 0.06);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-card h1 {
  margin: 0 0 8px;
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 1.4rem;
  letter-spacing: -0.01em;
  text-align: center;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

input, select, textarea {
  font-size: 1rem;
  padding: 10px 12px;
  border-radius: 2px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-family: inherit;
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.error-text {
  color: var(--danger);
  font-size: 0.85rem;
  min-height: 1em;
  margin: 0;
}

.btn-primary, .btn-secondary, .btn-danger {
  border: none;
  border-radius: 2px;
  padding: 11px 16px;
  font-size: 0.9rem;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.btn-primary { background: var(--dark); color: var(--bg); }
.btn-primary:active { background: var(--accent-dark); }
.btn-secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }

/* Dashboard */
.cards-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 14px 8px;
  text-align: center;
}

.stat-card span { display: block; font-family: 'Inter', sans-serif; font-size: 1.7rem; font-weight: 700; letter-spacing: -0.02em; }
.stat-card small { color: var(--muted); font-size: 0.72rem; letter-spacing: 0.03em; }
.stat-card.ok span { color: var(--ok); }
.stat-card.warn span { color: var(--danger); }
.stat-card.muted span { color: var(--muted); }

/* Lists */
.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
}

.list-item .primary { font-weight: 500; }
.list-item .secondary { color: var(--muted); font-size: 0.82rem; }

.badge {
  font-size: 0.7rem;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.badge.ok { background: rgba(91, 123, 84, 0.12); color: var(--ok); }
.badge.warn { background: rgba(161, 61, 45, 0.1); color: var(--danger); }
.badge.muted { background: rgba(110, 103, 90, 0.12); color: var(--muted); }

.empty-hint {
  color: var(--muted);
  text-align: center;
  padding: 24px 12px;
  font-size: 0.9rem;
}

/* Views with header actions */
.view-header {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.view-header input[type="search"] { flex: 1; min-width: 120px; }

/* Schedule */
.day-block { margin-bottom: 18px; }
.day-block h3 {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 8px;
}

.slot-item {
  border-left: 3px solid var(--accent);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: 2px;
  padding: 10px 12px;
  margin-bottom: 6px;
  cursor: pointer;
}

.slot-item .time { font-weight: 600; font-size: 0.85rem; }
.slot-item .type { font-weight: 600; font-family: 'Inter', sans-serif; }
.slot-item .meta { color: var(--muted); font-size: 0.8rem; }

/* Curricula anual */
.curriculum-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.curriculum-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
}

.curriculum-block-body {
  padding: 0 14px 14px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.exercise-list {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.exercise-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.exercise-item:last-child { border-bottom: none; }

.exercise-info { flex: 1; }

.exercise-reorder {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.exercise-reorder button {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1;
  padding: 3px;
  cursor: pointer;
}

.exercise-reorder button:disabled {
  opacity: 0.3;
  cursor: default;
}

/* Bottom nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom, 0);
  z-index: 10;
}

.nav-btn {
  flex: 1;
  background: none;
  border: none;
  padding: 12px 4px 10px;
  font-size: 0.76rem;
  color: var(--muted);
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  letter-spacing: 0.02em;
}

.nav-btn.active { color: var(--accent-dark); }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13, 12, 10, 0.5);
  display: flex;
  align-items: flex-end;
  z-index: 50;
}

.modal-content {
  background: #fff;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  border-radius: 2px 2px 0 0;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom, 0));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@media (min-width: 640px) {
  .modal-overlay { align-items: center; justify-content: center; }
  .modal-content { max-width: 480px; border-radius: 2px; }
}

.modal-content h2 { font-family: 'Inter', sans-serif; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 4px; font-size: 1.15rem; }
.modal-actions { display: flex; gap: 8px; margin-top: 6px; }
.modal-actions > * { flex: 1; }
.field-row { display: flex; gap: 10px; }
.field-row > label { flex: 1; }

.close-btn {
  align-self: flex-end;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.3rem;
  line-height: 1;
  padding: 4px 8px;
}

.color-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.type-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.toast {
  position: fixed;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--dark);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.85rem;
  z-index: 60;
  max-width: 90vw;
  text-align: center;
}

.payment-history-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

[hidden] { display: none !important; }
