/* Kids Gardenia School — Results
   Palette: sky #EAF6FF, sun #FFC53D, leaf #4CA771, coral #FF7A5C, ink #1F3348, cream #FFFDF7
   Type: Baloo 2 (display/headings), Nunito (body)
*/

@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;700;800&family=Nunito:wght@400;600;700;800&display=swap');

:root{
  --sky: #EAF6FF;
  --sun: #FFC53D;
  --leaf: #4CA771;
  --leaf-dark: #37895a;
  --coral: #FF7A5C;
  --ink: #1F3348;
  --cream: #FFFDF7;
  --line: #D8E9F0;
  --radius: 18px;
}

*{ box-sizing: border-box; }

body{
  margin: 0;
  background: var(--sky);
  color: var(--ink);
  font-family: 'Nunito', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
}

h1, h2, h3, .brand{
  font-family: 'Baloo 2', sans-serif;
  font-weight: 700;
  margin: 0;
}

/* ---------- garden header ---------- */
.site-header{
  position: relative;
  padding: 28px 20px 46px;
  overflow: hidden;
  background: linear-gradient(180deg, #DFF2FF 0%, var(--sky) 100%);
}

.sun{
  position: absolute;
  top: -40px;
  right: -30px;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: var(--sun);
  box-shadow: 0 0 0 14px rgba(255,197,61,0.25);
}

.header-inner{
  position: relative;
  max-width: 720px;
  margin: 0 auto;
  text-align: center;
}

.brand{
  font-size: 2rem;
  color: var(--leaf-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.brand .leaf-icon{
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  object-fit: contain;
}

.tagline{
  margin-top: 6px;
  font-weight: 700;
  color: var(--ink);
  opacity: 0.75;
  letter-spacing: 0.2px;
}

/* fence divider */
.fence{
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 22px;
  background-image: repeating-linear-gradient(
    to right,
    var(--leaf) 0px, var(--leaf) 18px,
    transparent 18px, transparent 34px
  );
  opacity: 0.9;
}

/* ---------- layout ---------- */
main{
  max-width: 560px;
  margin: -14px auto 60px;
  padding: 0 20px;
  position: relative;
}

.card{
  background: var(--cream);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: 0 10px 24px rgba(31,51,72,0.08);
  padding: 26px 24px;
}

.card + .card{
  margin-top: 20px;
}

/* ---------- watermark logo on cards ---------- */
.card{
  position: relative;
  overflow: hidden;
}

.card .watermark{
  position: absolute;
  right: -34px;
  bottom: -34px;
  width: 200px;
  height: 200px;
  opacity: 0.07;
  pointer-events: none;
  object-fit: contain;
}

.card > *{
  position: relative;
  z-index: 1;
}

/* ---------- form ---------- */
.field{
  margin-bottom: 16px;
}

.field label{
  display: block;
  font-weight: 800;
  font-size: 0.88rem;
  color: var(--leaf-dark);
  margin-bottom: 6px;
}

.field .hint{
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--ink);
  opacity: 0.55;
  margin-left: 4px;
}

input[type="text"],
select{
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: #fff;
  font: inherit;
  color: var(--ink);
  transition: border-color .15s ease;
}

input[type="text"]:focus,
select:focus{
  outline: none;
  border-color: var(--leaf);
}

.gender-row{
  display: flex;
  gap: 10px;
}

.gender-option{
  flex: 1;
  position: relative;
}

.gender-option input{
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}

.gender-option span{
  display: block;
  text-align: center;
  padding: 10px 8px;
  border-radius: 12px;
  border: 2px solid var(--line);
  font-weight: 700;
  background: #fff;
}

.gender-option input:checked + span{
  border-color: var(--coral);
  background: rgba(255,122,92,0.12);
  color: var(--coral);
}

button, .btn{
  font: inherit;
  font-weight: 800;
  font-family: 'Baloo 2', sans-serif;
  letter-spacing: 0.2px;
  border: none;
  border-radius: 12px;
  padding: 13px 20px;
  cursor: pointer;
  transition: transform .1s ease, opacity .15s ease;
}

button:active{ transform: scale(0.98); }

.btn-primary{
  width: 100%;
  background: var(--leaf);
  color: #fff;
}

.btn-primary:hover{ background: var(--leaf-dark); }

.btn-secondary{
  background: #fff;
  color: var(--ink);
  border: 2px solid var(--line);
}

.btn-danger{
  background: #fff;
  color: var(--coral);
  border: 2px solid rgba(255,122,92,0.4);
  padding: 8px 14px;
  font-size: 0.85rem;
}

.btn-small{
  padding: 8px 14px;
  font-size: 0.85rem;
}

/* ---------- result card ---------- */
.result-header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.result-header h2{
  font-size: 1.3rem;
  color: var(--leaf-dark);
}

.pill{
  display: inline-block;
  background: var(--sun);
  color: var(--ink);
  font-weight: 800;
  font-size: 0.78rem;
  padding: 5px 12px;
  border-radius: 999px;
}

.result-grid{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 18px;
}

.result-grid .full{ grid-column: 1 / -1; }

.result-grid dt{
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--ink);
  opacity: 0.55;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin: 0 0 3px;
}

.result-grid dd{
  margin: 0;
  font-weight: 700;
  font-size: 1.05rem;
}

.marks-table{
  width: 100%;
  border-collapse: collapse;
  margin-top: 6px;
}

.marks-table th, .marks-table td{
  text-align: left;
  padding: 9px 6px;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
}

.marks-table th{
  color: var(--ink);
  opacity: 0.55;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.total-row td{
  font-weight: 800;
  color: var(--leaf-dark);
}

.empty-state, .message{
  text-align: center;
  padding: 20px 10px;
  font-weight: 700;
  color: var(--ink);
  opacity: 0.7;
}

.message.error{
  color: var(--coral);
  opacity: 1;
}

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

.admin-row{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.admin-row .who{
  font-weight: 700;
}

.admin-row .meta{
  font-size: 0.82rem;
  opacity: 0.6;
  font-weight: 600;
}

.admin-row-actions{
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.top-bar{
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.top-bar h1{
  font-size: 1.4rem;
  color: var(--leaf-dark);
}

a.link-back{
  display: inline-block;
  margin-top: 4px;
  color: var(--leaf-dark);
  font-weight: 700;
  text-decoration: none;
  font-size: 0.9rem;
}

a.link-back:hover{ text-decoration: underline; }

.subject-row{
  display: grid;
  grid-template-columns: 1fr 90px 32px;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.subject-row input{ margin: 0; }

.remove-subject{
  background: none;
  border: none;
  color: var(--coral);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}

.add-subject-btn{
  background: none;
  border: 2px dashed var(--line);
  color: var(--leaf-dark);
  width: 100%;
  padding: 10px;
  border-radius: 12px;
  font-size: 0.9rem;
  margin-bottom: 16px;
}

footer.credit{
  text-align: center;
  font-size: 0.78rem;
  color: var(--ink);
  opacity: 0.45;
  font-weight: 700;
  padding-bottom: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

footer.credit img{
  width: 28px;
  height: 28px;
  object-fit: contain;
  opacity: 0.7;
}

/* ---------- student photo ---------- */
.avatar-row{
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 6px;
}

.avatar{
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--sun);
  background: #fff;
  flex-shrink: 0;
}

.avatar-placeholder{
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--sky);
  border: 3px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Baloo 2', sans-serif;
  font-weight: 800;
  color: var(--leaf-dark);
  font-size: 1.4rem;
  flex-shrink: 0;
}

.photo-upload{
  display: flex;
  align-items: center;
  gap: 12px;
}

.photo-upload .avatar,
.photo-upload .avatar-placeholder{
  width: 56px;
  height: 56px;
}

.photo-upload input[type="file"]{
  flex: 1;
  font-size: 0.85rem;
  font-weight: 600;
}

.photo-remove-btn{
  background: none;
  border: none;
  color: var(--coral);
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 4px 6px;
}

/* ---------- grade badge ---------- */
.grade-badges{
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 4px 0 14px;
}

.grade-badge{
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: 12px;
  background: rgba(76,167,113,0.12);
  min-width: 74px;
}

.grade-badge .g-label{
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--leaf-dark);
  opacity: 0.7;
}

.grade-badge .g-value{
  font-family: 'Baloo 2', sans-serif;
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--leaf-dark);
}

/* ---------- action buttons row ---------- */
.result-actions{
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.result-actions button{ flex: 1; }

/* ---------- settings card ---------- */
.settings-toggle{
  color: var(--leaf-dark);
  font-weight: 800;
  font-size: 0.85rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.message.success{
  color: var(--leaf-dark);
  opacity: 1;
}

/* ---------- print ---------- */
@media print{
  body{ background: #fff; }
  .site-header, footer.credit, .no-print,
  #loginView, .top-bar #logoutBtn{
    display: none !important;
  }
  main{ margin: 0; max-width: 100%; padding: 0; }
  .card{
    box-shadow: none;
    border: none;
  }
  #resultArea .card .watermark{ opacity: 0.05; }
}

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