/* ─── KML Design Tokens ─── */
:root {
  --c-primary:   #F9A83A;
  --c-dark:      #35393E;
  --c-bg:        #FFF8EC;
  --c-white:     #FCFCFC;
  --c-border:    #E8D8C0;
  --c-muted:     #7A7570;
  --c-dark-mid:  #4A4F55;
  --c-danger:    #CC2A37;
  --radius:      12px;
  --radius-sm:   8px;
  --shadow:      0 2px 8px rgba(53,57,62,.08);
  --header-h:    56px;
  --nav-h:       60px;
  --font:        'Golos Text', sans-serif;
}

/* ─── Reset ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--c-bg);
  color: var(--c-dark);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ─── Utilities ─── */
.hidden { display: none !important; }

/* ─── Buttons ─── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  padding: .55em 1.2em;
  border: none; border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 15px; font-weight: 600;
  cursor: pointer; transition: opacity .15s, transform .1s;
  text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn-primary  { background: var(--c-primary); color: var(--c-dark); }
.btn-dark     { background: var(--c-dark); color: var(--c-white); }
.btn-ghost    { background: transparent; color: var(--c-dark); border: 1.5px solid var(--c-border); }
.btn-danger   { background: var(--c-danger); color: #fff; }
.btn-sm       { padding: .35em .9em; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

/* ─── Inputs ─── */
.input, select.input {
  width: 100%; padding: .6em .85em;
  border: 1.5px solid var(--c-border); border-radius: var(--radius-sm);
  background: var(--c-white); color: var(--c-dark);
  font-family: var(--font); font-size: 15px;
  appearance: none;
  outline: none; transition: border-color .15s;
}
.input:focus { border-color: var(--c-primary); }
textarea.input { resize: vertical; min-height: 90px; }

/* ─── Form groups ─── */
.form-group { display: flex; flex-direction: column; gap: .35em; }
.form-label { font-size: 13px; font-weight: 600; color: var(--c-muted); }
.form-actions { display: flex; gap: .6em; margin-top: .5em; }
.form-actions .btn { flex: 1; }

/* ─── Auth screen ─── */
.auth-screen {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
}
.auth-card {
  background: var(--c-white); border-radius: var(--radius);
  padding: 2rem 1.8rem; max-width: 360px; width: 100%;
  box-shadow: var(--shadow); text-align: center;
}
.auth-logo {
  font-size: 13px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--c-primary); margin-bottom: 1rem;
}
.auth-title { font-size: 26px; font-weight: 700; margin-bottom: .6rem; }
.auth-hint  { color: var(--c-muted); font-size: 15px; line-height: 1.6; }

.recovery-details { margin-top: 1.5rem; text-align: left; }
.recovery-details summary {
  cursor: pointer; color: var(--c-muted); font-size: 13px;
  text-align: center; list-style: none;
}
.recovery-details summary::-webkit-details-marker { display: none; }
.recovery-form { display: flex; flex-direction: column; gap: .6rem; margin-top: .8rem; }

/* ─── Header ─── */
.header {
  position: fixed; top: 0; left: 0; right: 0; height: var(--header-h);
  background: var(--c-white); border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; gap: .5rem;
  padding: 0 1rem; z-index: 100;
}
.header-title {
  flex: 1; font-weight: 700; font-size: 17px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.back-btn {
  background: none; border: none; cursor: pointer;
  font-size: 22px; color: var(--c-primary); padding: .2em .4em;
  line-height: 1; border-radius: var(--radius-sm);
}
.back-btn:active { background: var(--c-bg); }

/* ─── Main content ─── */
#main {
  padding-top: var(--header-h);
  padding-bottom: var(--nav-h);
  min-height: 100dvh;
}

/* ─── Bottom nav ─── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; height: var(--nav-h);
  background: var(--c-white); border-top: 1px solid var(--c-border);
  display: flex; z-index: 100;
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px;
  border: none; background: none; cursor: pointer;
  font-family: var(--font); font-size: 11px; font-weight: 500;
  color: var(--c-muted); transition: color .15s;
}
.nav-btn.active { color: var(--c-primary); }
.nav-icon { font-size: 20px; line-height: 1; }

/* ─── List wrapper ─── */
.list { display: flex; flex-direction: column; gap: .6rem; padding: .8rem; }

/* ─── Student card (list) ─── */
.student-card {
  background: var(--c-white); border-radius: var(--radius);
  border: 1.5px solid var(--c-border); padding: .9rem 1rem;
  cursor: pointer; display: flex; align-items: center; gap: .8rem;
  transition: border-color .15s, box-shadow .15s;
}
.student-card:active { border-color: var(--c-primary); }
.student-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, var(--c-primary), var(--c-dark));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; color: var(--c-white); flex-shrink: 0;
}
.student-info { flex: 1; min-width: 0; }
.student-name { font-weight: 600; font-size: 16px; }
.student-meta { font-size: 12px; color: var(--c-muted); margin-top: 2px; }
.student-arrow { color: var(--c-border); font-size: 18px; flex-shrink: 0; }

/* ─── Student meta card (detail) ─── */
.student-meta-card {
  background: var(--c-white); margin: .8rem;
  border-radius: var(--radius); border: 1.5px solid var(--c-border);
  padding: 1rem;
}
.student-meta-card .s-name { font-size: 20px; font-weight: 700; }
.student-meta-card .s-contact { font-size: 14px; color: var(--c-muted); margin-top: 3px; }
.student-meta-card .s-actions { display: flex; gap: .5rem; margin-top: .8rem; flex-wrap: wrap; }
.badge-archived {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  background: #fde8d0; color: var(--c-primary); font-size: 12px; font-weight: 600;
  margin-left: .4em; vertical-align: middle;
}

/* ─── Entry card ─── */
.entry-card {
  background: var(--c-white); border-radius: var(--radius);
  border: 1.5px solid var(--c-border); padding: .9rem 1rem;
}
.entry-header {
  display: flex; align-items: center; gap: .5rem; margin-bottom: .4rem;
}
.entry-date { font-weight: 700; font-size: 14px; }
.entry-student-name { font-size: 13px; color: var(--c-muted); }
.entry-note { font-size: 14px; line-height: 1.55; color: var(--c-dark); }
.entry-next {
  margin-top: .5rem; font-size: 13px; color: var(--c-muted);
  display: flex; align-items: center; gap: .3em;
}
.entry-actions { display: flex; gap: .5rem; margin-top: .7rem; }

/* ─── Add button (floating) ─── */
.add-entry-btn {
  display: flex; align-items: center; gap: .5em;
  margin: 0 .8rem .2rem; padding: .65em 1em;
  background: var(--c-bg); border: 1.5px dashed var(--c-border);
  border-radius: var(--radius); cursor: pointer;
  font-family: var(--font); font-size: 14px; font-weight: 600;
  color: var(--c-muted); transition: border-color .15s, color .15s;
}
.add-entry-btn:active { border-color: var(--c-primary); color: var(--c-primary); }

/* ─── Filters ─── */
.filters {
  display: flex; flex-direction: column; gap: .6rem;
  padding: .8rem; background: var(--c-white);
  border-bottom: 1px solid var(--c-border);
}
.filter-dates { display: flex; align-items: center; gap: .4rem; }
.filter-dates .input { flex: 1; }
.date-sep { color: var(--c-muted); flex-shrink: 0; }

/* ─── Empty state ─── */
.empty {
  text-align: center; padding: 3rem 1rem; color: var(--c-muted);
}
.empty-icon { font-size: 40px; margin-bottom: .5rem; }
.empty-text { font-size: 15px; }

/* ─── Section header ─── */
.section-header {
  font-size: 12px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--c-muted);
  padding: .8rem 1rem .3rem;
}

/* ─── Modal ─── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 200; padding: 0;
}
.modal {
  background: var(--c-white); border-radius: var(--radius) var(--radius) 0 0;
  width: 100%; max-width: 540px; max-height: 90dvh;
  overflow-y: auto; padding: 1.2rem 1.2rem 2rem;
  position: relative;
}
.modal-close {
  position: absolute; top: .8rem; right: .8rem;
  background: var(--c-bg); border: none; border-radius: 50%;
  width: 30px; height: 30px; font-size: 18px; line-height: 1;
  cursor: pointer; color: var(--c-muted); display: flex;
  align-items: center; justify-content: center;
}
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 1rem; padding-right: 2rem; }
.modal-form { display: flex; flex-direction: column; gap: .8rem; }

/* ─── Confirm dialog ─── */
.confirm-text { font-size: 15px; margin-bottom: 1rem; color: var(--c-muted); }

/* ─── Toast ─── */
.toast {
  position: fixed; bottom: calc(var(--nav-h) + .8rem); left: 50%;
  transform: translateX(-50%); z-index: 300;
  background: var(--c-dark); color: var(--c-white);
  padding: .6em 1.2em; border-radius: 20px; font-size: 14px;
  pointer-events: none; opacity: 0; transition: opacity .2s;
  white-space: nowrap;
}
.toast.show { opacity: 1; }
.toast.error { background: var(--c-danger); }

/* ─── Desktop ─── */
@media (min-width: 640px) {
  .modal-overlay { align-items: center; padding: 1rem; }
  .modal { border-radius: var(--radius); max-height: 85dvh; }
  #main, .header, .bottom-nav { max-width: 600px; margin: 0 auto; left: 0; right: 0; }
  .header { left: 50%; right: auto; transform: translateX(-50%); width: 100%; }
}
