*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ===== LOGIN ===== */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #EDE7F6 0%, #E8EAF6 100%);
  padding: 24px;
}
.login-card {
  background: #fff;
  border-radius: 24px;
  padding: 40px 32px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: 0 8px 40px rgba(92,107,192,.2);
}
.login-logo { font-size: 64px; margin-bottom: 16px; line-height: 1; }
.login-titulo { font-size: 22px; font-weight: 800; color: #1A1A2E; margin-bottom: 8px; }
.login-sub { font-size: 14px; color: #777; line-height: 1.6; margin-bottom: 28px; }
.g_id_signin { display: flex; justify-content: center; margin-bottom: 16px; }
.login-erro { font-size: 13px; color: #E53935; margin-bottom: 12px; }
.login-hint { font-size: 12px; color: #B0B0B0; line-height: 1.6; margin-top: 20px; }

/* ===== INSTALL / LOGOUT ===== */
.install-btn {
  background: rgba(255,255,255,.2);
  color: #fff;
  border: 1px solid rgba(255,255,255,.4);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: background .15s;
}
.install-btn:hover { background: rgba(255,255,255,.3); }
.logout-btn {
  background: rgba(255,255,255,.2);
  color: #fff;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.logout-btn:hover { background: rgba(255,255,255,.35); }
html { -webkit-tap-highlight-color: transparent; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #F0F2F8;
  color: #1A1A2E;
  min-height: 100vh;
  padding-bottom: 72px;
  overscroll-behavior: none;
}

/* ===== HEADER ===== */
header {
  background: linear-gradient(135deg, #5C6BC0 0%, #3949AB 100%);
  padding: 14px 18px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 16px rgba(57,73,171,.35);
}
.header-inner {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.header-brand { display: flex; align-items: center; gap: 10px; }
.brand-emoji { font-size: 26px; }
h1 { color: #fff; font-size: 16px; font-weight: 800; line-height: 1.2; }
.student-name {
  color: rgba(255,255,255,.75);
  font-size: 11px;
  cursor: pointer;
  margin-top: 2px;
  transition: color .15s;
}
.student-name:hover { color: #fff; }
.today-chip {
  background: rgba(255,255,255,.2);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 99px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ===== MAIN ===== */
main {
  max-width: 640px;
  margin: 0 auto;
  padding: 14px 14px 0;
}
.tab-content { display: none; }
.tab-content.active { display: block; }
.tab-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
.section-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 14px;
}
.btn-add {
  background: #5C6BC0;
  color: #fff;
  border: none;
  padding: 9px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s;
}
.btn-add:hover { background: #3949AB; }

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #fff;
  border-top: 1px solid #E8EAF6;
  display: flex;
  z-index: 50;
  box-shadow: 0 -2px 16px rgba(0,0,0,.08);
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 4px 10px;
  border: none;
  background: none;
  cursor: pointer;
  position: relative;
  font-family: inherit;
  transition: background .1s;
}
.nav-item:active { background: #F0F2F8; }
.nav-icon { font-size: 20px; line-height: 1; }
.nav-label { font-size: 10px; font-weight: 500; color: #9E9E9E; margin-top: 2px; }
.nav-item.active .nav-label { color: #5C6BC0; font-weight: 700; }
.nav-badge {
  position: absolute;
  top: 5px;
  right: calc(50% - 20px);
  background: #E53935;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  min-width: 15px;
  height: 15px;
  border-radius: 99px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}
.nav-badge:empty { display: none; }

/* ===== HORÁRIO ===== */
.horario-table {
  border-collapse: separate;
  border-spacing: 3px;
  min-width: 340px;
  width: 100%;
}
.horario-table th {
  background: #5C6BC0;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  padding: 7px 4px;
  border-radius: 7px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.horario-table th.hoje { background: #FF8F00; }
.horario-table th.num { background: transparent; color: #9E9E9E; font-size: 10px; }
.horario-table td { padding: 0; height: 46px; min-width: 58px; }
.horario-table td.num-col {
  min-width: 28px;
  width: 28px;
  text-align: center;
  background: #E8EAF6;
  border-radius: 7px;
  font-size: 10px;
  font-weight: 700;
  color: #5C6BC0;
}
.slot {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9.5px;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  border-radius: 7px;
  padding: 3px 2px;
  line-height: 1.3;
  color: #fff;
  border: none;
  font-family: inherit;
  transition: filter .12s, transform .12s;
  background: #ECEFF1;
}
.slot.vazio { color: transparent; }
.slot:hover { filter: brightness(.92); transform: scale(.97); }
.horario-hint {
  text-align: center;
  font-size: 11px;
  color: #B0B0B0;
  margin-top: 10px;
  padding-bottom: 4px;
}

/* ===== CARDS ===== */
.card {
  background: #fff;
  border-radius: 14px;
  padding: 13px 14px;
  margin-bottom: 9px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  box-shadow: 0 1px 6px rgba(0,0,0,.06);
}
.card-left { flex: 1; min-width: 0; }
.materia-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  color: #fff;
  margin-bottom: 4px;
}
.card-desc {
  font-size: 14px;
  font-weight: 600;
  color: #1A1A2E;
  margin-bottom: 2px;
  word-break: break-word;
}
.card-desc.done { text-decoration: line-through; color: #BDBDBD; }
.card-meta { font-size: 11px; color: #9E9E9E; }
.card-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}
.prazo-chip {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 99px;
  white-space: nowrap;
}
.ok      { background: #E8F5E9; color: #2E7D32; }
.hoje-p  { background: #FFF3E0; color: #E65100; }
.atrasado{ background: #FFEBEE; color: #C62828; }
.breve   { background: #E3F2FD; color: #1565C0; }
.btn-del {
  background: none;
  border: none;
  color: #CFCFCF;
  font-size: 15px;
  cursor: pointer;
  padding: 2px;
  line-height: 1;
  transition: color .15s;
}
.btn-del:hover { color: #E53935; }
.check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #5C6BC0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
  transition: all .2s;
  background: #fff;
}
.check.done { background: #5C6BC0; border-color: #5C6BC0; }
.check.done::after { content: '✓'; color: #fff; font-size: 12px; font-weight: 700; }

.group-label {
  font-size: 11px;
  font-weight: 700;
  color: #9E9E9E;
  text-transform: uppercase;
  letter-spacing: .07em;
  margin: 18px 0 8px;
}
.dias-num {
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  min-width: 36px;
}
.dias-txt {
  font-size: 9px;
  font-weight: 600;
  color: #9E9E9E;
  text-align: center;
}
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: #CFCFCF;
}
.empty-state .empty-icon { font-size: 52px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; line-height: 1.6; }

/* ===== MATÉRIAS ===== */
.mat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.mat-card {
  background: #fff;
  border-radius: 14px;
  padding: 14px 14px 14px 16px;
  border-left: 5px solid #5C6BC0;
  box-shadow: 0 1px 6px rgba(0,0,0,.06);
  position: relative;
}
.mat-nome { font-size: 14px; font-weight: 700; color: #1A1A2E; margin-bottom: 2px; padding-right: 44px; }
.mat-prof { font-size: 11px; color: #9E9E9E; }
.mat-acts { position: absolute; top: 8px; right: 8px; display: flex; gap: 2px; }
.mat-acts button {
  background: none;
  border: none;
  font-size: 14px;
  cursor: pointer;
  padding: 3px;
  opacity: .6;
  transition: opacity .15s;
}
.mat-acts button:hover { opacity: 1; }

/* ===== MODAL ===== */
#overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26,26,46,.5);
  backdrop-filter: blur(3px);
  z-index: 100;
}
#overlay.open { display: block; }
.modal {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #fff;
  border-radius: 22px 22px 0 0;
  z-index: 110;
  max-width: 640px;
  margin: 0 auto;
  box-shadow: 0 -4px 40px rgba(0,0,0,.2);
  animation: slideUp .22s ease;
  max-height: 90vh;
  overflow-y: auto;
}
.modal.open { display: block; }
@keyframes slideUp { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 14px;
  border-bottom: 1px solid #F0F2F8;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}
.modal-top h3 { font-size: 16px; font-weight: 700; }
.close-btn {
  background: #F0F2F8;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  color: #666;
}
.modal-body { padding: 14px 18px; }
.field-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: #5C6BC0;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 6px;
  margin-top: 14px;
}
.field-label:first-child { margin-top: 0; }
.field-input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid #E8EAF6;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  color: #1A1A2E;
  outline: none;
  background: #F8F9FF;
  transition: border-color .15s;
}
.field-input:focus { border-color: #5C6BC0; background: #fff; }
.modal-btns {
  display: flex;
  gap: 10px;
  padding: 12px 18px 22px;
}
.btn-cancel {
  flex: 1;
  padding: 13px;
  border: 1.5px solid #E8EAF6;
  border-radius: 10px;
  background: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  color: #5C6BC0;
  transition: background .15s;
}
.btn-cancel:hover { background: #F0F2F8; }
.btn-cancel.btn-danger { color: #E53935; border-color: #FFEBEE; }
.btn-save {
  flex: 2;
  padding: 13px;
  border: none;
  border-radius: 10px;
  background: #5C6BC0;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s;
}
.btn-save:hover { background: #3949AB; }

/* Color grid */
.color-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
  padding-bottom: 4px;
}
.color-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: transform .15s, border-color .15s;
}
.color-dot.sel { border-color: #1A1A2E; transform: scale(1.18); }

/* ===== CARD CLICÁVEL ===== */
.card-click { cursor: pointer; transition: transform .15s, box-shadow .15s; }
.card-click:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,.1); }

/* ===== MINI PROGRESSO (no card) ===== */
.card-progress { display:flex; align-items:center; gap:6px; margin-top:6px; }
.mini-bar { flex:1; max-width:100px; height:4px; background:#E8EAF6; border-radius:99px; overflow:hidden; }
.mini-fill { height:100%; background:#5C6BC0; border-radius:99px; transition:width .3s; }
.mini-label { font-size:10px; color:#9E9E9E; white-space:nowrap; }

/* ===== BARRA DE PROGRESSO (modal) ===== */
.study-progress { display:flex; align-items:center; gap:10px; margin-bottom:16px; }
.prog-bar { flex:1; height:8px; background:#E8EAF6; border-radius:99px; overflow:hidden; }
.prog-fill { height:100%; background:linear-gradient(90deg,#5C6BC0,#7986CB); border-radius:99px; transition:width .4s ease; }
.prog-label { font-size:12px; font-weight:700; color:#5C6BC0; white-space:nowrap; }

/* ===== CHIP DE DIAS ===== */
.dias-chip { font-size:10px; font-weight:700; padding:2px 8px; border-radius:99px; background:#E8EAF6; color:#5C6BC0; }
.dias-chip.urgente { background:#FFEBEE; color:#C62828; }
.dias-chip.breve   { background:#FFF3E0; color:#E65100; }

/* ===== TÓPICOS ===== */
#pd-topicos { margin-bottom:4px; }
.topico-item {
  display:flex; align-items:center; gap:10px;
  padding:9px 0; border-bottom:1px solid #F0F2F8;
}
.topico-item:last-child { border-bottom:none; }
.topico-check {
  width:22px; height:22px; border-radius:6px;
  border:2px solid #5C6BC0; cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  flex-shrink:0; transition:all .2s;
}
.topico-check.done { background:#5C6BC0; border-color:#5C6BC0; }
.topico-check.done::after { content:'✓'; color:#fff; font-size:12px; font-weight:700; }
.topico-txt { flex:1; font-size:13px; color:#1A1A2E; transition:color .2s; }
.topico-txt.done { text-decoration:line-through; color:#C0C0C0; }
.topico-del {
  background:none; border:none; color:#D0D0D0; font-size:14px;
  cursor:pointer; padding:3px; transition:color .15s;
}
.topico-del:hover { color:#E53935; }

/* ===== ADICIONAR TÓPICO ===== */
.add-topic-row { display:flex; gap:8px; margin-top:10px; }
.add-topic-row .field-input { flex:1; }
.btn-add-topic {
  background:#5C6BC0; color:#fff; border:none;
  width:42px; height:42px; border-radius:10px; font-size:22px;
  cursor:pointer; display:flex; align-items:center; justify-content:center;
  flex-shrink:0; transition:background .15s;
}
.btn-add-topic:hover { background:#3949AB; }
