/* Rubik (SIL OFL 1.1, see fonts/OFL.txt), self-hosted: Hebrew and Latin subsets. */
@font-face {
  font-family: 'Rubik';
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url(../fonts/rubik-hebrew-400.woff2) format('woff2');
  unicode-range: U+0307-0308,U+0590-05FF,U+200C-2010,U+20AA,U+25CC,U+FB1D-FB4F;
}
@font-face {
  font-family: 'Rubik';
  font-style: normal;
  font-display: swap;
  font-weight: 500;
  src: url(../fonts/rubik-hebrew-500.woff2) format('woff2');
  unicode-range: U+0307-0308,U+0590-05FF,U+200C-2010,U+20AA,U+25CC,U+FB1D-FB4F;
}
@font-face {
  font-family: 'Rubik';
  font-style: normal;
  font-display: swap;
  font-weight: 700;
  src: url(../fonts/rubik-hebrew-700.woff2) format('woff2');
  unicode-range: U+0307-0308,U+0590-05FF,U+200C-2010,U+20AA,U+25CC,U+FB1D-FB4F;
}
@font-face {
  font-family: 'Rubik';
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url(../fonts/rubik-latin-400.woff2) format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'Rubik';
  font-style: normal;
  font-display: swap;
  font-weight: 500;
  src: url(../fonts/rubik-latin-500.woff2) format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'Rubik';
  font-style: normal;
  font-display: swap;
  font-weight: 700;
  src: url(../fonts/rubik-latin-700.woff2) format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f0f3f8;
  --text: #1d2433;
  --muted: #66708a;
  --border: #dde2ec;
  --primary: #3b6fd8;
  --primary-text: #ffffff;
  --primary-soft: #e6eefc;
  --success: #1f9a6f;
  --success-soft: #e1f5ec;
  --warning: #b7791f;
  --warning-soft: #fdf2dc;
  --danger: #c93c3c;
  --danger-soft: #fbe5e5;
  --purple: #7a4fd0;
  --purple-soft: #efe8fc;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(20 30 60 / 6%), 0 2px 8px rgb(20 30 60 / 5%);
  --font: 'Rubik', 'Segoe UI', 'Arial Hebrew', Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #12161f;
    --surface: #1b212d;
    --surface-2: #232b3a;
    --text: #e6e9f0;
    --muted: #97a1b8;
    --border: #2f3849;
    --primary: #6d97ee;
    --primary-text: #0d1320;
    --primary-soft: #23324f;
    --success: #4cc59a;
    --success-soft: #173a2e;
    --warning: #e2a94b;
    --warning-soft: #3a2f17;
    --danger: #ee7373;
    --danger-soft: #3d1f22;
    --purple: #ab8cf0;
    --purple-soft: #2e2547;
    --shadow: none;
  }
}

:root[data-theme='dark'] {
  --bg: #12161f;
  --surface: #1b212d;
  --surface-2: #232b3a;
  --text: #e6e9f0;
  --muted: #97a1b8;
  --border: #2f3849;
  --primary: #6d97ee;
  --primary-text: #0d1320;
  --primary-soft: #23324f;
  --success: #4cc59a;
  --success-soft: #173a2e;
  --warning: #e2a94b;
  --warning-soft: #3a2f17;
  --danger: #ee7373;
  --danger-soft: #3d1f22;
  --purple: #ab8cf0;
  --purple-soft: #2e2547;
  --shadow: none;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; margin-top: 1.1em; color: var(--muted); font-weight: 500; }

hr { border: 0; border-top: 1px solid var(--border); margin: 1.5rem 0; }

.muted { color: var(--muted); }
.small { font-size: .875rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.error-text { color: var(--danger); }
.overdue { color: var(--danger); }

/* ------------------------------------------------------------ header */

.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: .6rem 16px;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 1.15rem; color: var(--text); }
.brand:hover { text-decoration: none; }
#nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
#nav a {
  padding: .35rem .75rem;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}
#nav a:hover { background: var(--surface-2); text-decoration: none; }
#nav a.active { background: var(--primary-soft); color: var(--primary); }

.status { font-size: .85rem; padding: .25rem .6rem; border-radius: 999px; border: 0; font: inherit; font-size: .85rem; }
.status.ok { color: var(--success); background: var(--success-soft); }
.status.pending { color: var(--muted); background: var(--surface-2); }
.status.error { color: var(--danger); background: var(--danger-soft); }
button.status { cursor: pointer; }
.link-btn { background: none; border: 0; color: inherit; text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }

/* ------------------------------------------------------------ layout */

.container { max-width: 1200px; margin: 0 auto; padding: 1rem 16px 4rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.25rem;
  margin-bottom: 1rem;
  min-width: 0;
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .5rem; }
.card-head h2 { margin: 0; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 + .card, .card + .grid-2 { margin-top: 1rem; }
.student-grid .col > .card { margin-bottom: 1rem; }
@media (max-width: 820px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

.welcome { max-width: 620px; margin: 2rem auto; }
.welcome-card { text-align: center; padding: 2rem; }

.count {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 .45em;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: .8rem;
  font-weight: 500;
  text-align: center;
  vertical-align: middle;
}

.empty { padding: 1rem; text-align: center; color: var(--muted); background: var(--surface-2); border-radius: 8px; }
.empty-action { margin-top: .75rem; }

/* ------------------------------------------------------------ forms & buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  padding: .5rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: var(--primary-text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn.secondary { background: var(--surface); color: var(--primary); }
.btn.danger { background: var(--surface); color: var(--danger); border-color: var(--danger); }
.btn.small { padding: .3rem .7rem; font-size: .875rem; }
.file-btn { position: relative; }

.icon-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  font-size: .85rem;
  line-height: 1;
  padding: .3rem .4rem;
  min-width: 28px;
  min-height: 28px;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.icon-btn:disabled { opacity: .3; cursor: default; }

input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .45rem .6rem;
  width: 100%;
  min-width: 0;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .icon-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
input[type='checkbox'] { width: auto; accent-color: var(--primary); width: 1.05rem; height: 1.05rem; margin: 0; flex: none; }

.field { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .75rem; flex: 1; min-width: 140px; }
.field > span { font-size: .85rem; color: var(--muted); }
.field.narrow { flex: 0 0 110px; min-width: 110px; }
.field.grow { flex: 3; }
.field.inline { flex-direction: row; align-items: center; gap: .6rem; margin-top: .25rem; }
.field.inline > span { white-space: nowrap; }
.field-row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end; }
.field-row > .btn, .field-row > .check { margin-bottom: .75rem; }
.field-row .hint { flex: 2; margin: 0 0 .9rem; min-width: 200px; }
fieldset { border: 1px solid var(--border); border-radius: 8px; margin: 0 0 .75rem; padding: .5rem .75rem; }
legend { color: var(--muted); font-size: .85rem; padding: 0 .3rem; }
fieldset .check { margin: .3rem 0; }
.form-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.toolbar input[type='search'] { width: 220px; }
.days { display: flex; gap: 1rem; flex-wrap: wrap; }

.check { display: inline-flex; align-items: flex-start; gap: .5rem; cursor: pointer; }
.check > input { margin-top: .2rem; }
.check.grow { flex: 1; min-width: 0; }

details > summary { cursor: pointer; color: var(--primary); margin: .4rem 0; }
details.contact { margin-top: .5rem; }
.contact-body { padding: .5rem 0; display: grid; gap: .35rem; }
.phones { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; }
.danger-zone { display: flex; gap: .5rem; flex-wrap: wrap; border-top: 1px dashed var(--border); padding-top: .75rem; }

/* ------------------------------------------------------------ badges */

.badge {
  display: inline-block;
  padding: .05rem .5rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 500;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
  vertical-align: middle;
}
.badges { display: inline-flex; gap: .3rem; flex-wrap: wrap; }
.badges.small { margin-top: .2rem; }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.kind-scheduled, .badge.owner-teacher, .badge.scope-everyone { background: var(--primary-soft); color: var(--primary); }
.badge.kind-checkup, .badge.owner-student { background: var(--purple-soft); color: var(--purple); }
.badge.kind-suggested { background: var(--surface-2); color: var(--muted); }
.badge.scope-class { background: var(--success-soft); color: var(--success); }
.badge.scope-student { background: var(--warning-soft); color: var(--warning); }
.badge.type-discipline { background: var(--danger-soft); color: var(--danger); }
.badge.type-checkup { background: var(--purple-soft); color: var(--purple); }
.badge.type-academic { background: var(--success-soft); color: var(--success); }

/* ------------------------------------------------------------ dashboard */

.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.stats-row.compact { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .8rem 1rem;
  display: flex;
  flex-direction: column;
}
.card .stat { background: var(--surface-2); border-color: transparent; }
.stat-value { font-size: 1.6rem; font-weight: 700; }
.stat-label { color: var(--muted); font-size: .85rem; }
.stat.warn .stat-value { color: var(--danger); }

.suggestions, .simple-list, .bar-list, .goal-list, .goal-items, .meetings, .import-list, .goal-matrix { list-style: none; padding: 0; margin: 0; }

.suggestion {
  display: grid;
  grid-template-columns: 110px 1fr auto;
  gap: .75rem;
  align-items: center;
  padding: .65rem 0;
  border-bottom: 1px solid var(--border);
}
.suggestion:last-child { border-bottom: 0; }
.suggestion-date { display: flex; flex-direction: column; line-height: 1.3; }
.suggestion-actions { display: flex; gap: .35rem; }
.suggestion.missed .suggestion-date strong { color: var(--danger); }
@media (max-width: 520px) {
  .suggestion { grid-template-columns: 1fr; gap: .3rem; }
  .suggestion-date { flex-direction: row; gap: .5rem; flex-wrap: wrap; }
}

.simple-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .5rem;
  padding: .45rem 0;
  border-bottom: 1px solid var(--border);
}
.simple-list li:last-child { border-bottom: 0; }
.simple-list li.is-done { color: var(--muted); }

.bar-list li { padding: .45rem 0; }
.bar-head { display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; }
.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: .3rem; }
.card .progress { background: var(--border); }
.progress-fill { height: 100%; border-radius: 999px; transition: width .3s; }
.progress-fill.good { background: var(--success); }
.progress-fill.mid { background: var(--warning); }
.progress-fill.low { background: var(--danger); }
/* Bar widths in steps of 5% (the CSP forbids inline style=). */
.pct-0 { width: 0%; }
.pct-5 { width: 5%; }
.pct-10 { width: 10%; }
.pct-15 { width: 15%; }
.pct-20 { width: 20%; }
.pct-25 { width: 25%; }
.pct-30 { width: 30%; }
.pct-35 { width: 35%; }
.pct-40 { width: 40%; }
.pct-45 { width: 45%; }
.pct-50 { width: 50%; }
.pct-55 { width: 55%; }
.pct-60 { width: 60%; }
.pct-65 { width: 65%; }
.pct-70 { width: 70%; }
.pct-75 { width: 75%; }
.pct-80 { width: 80%; }
.pct-85 { width: 85%; }
.pct-90 { width: 90%; }
.pct-95 { width: 95%; }
.pct-100 { width: 100%; }

/* ------------------------------------------------------------ tables */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: start; padding: .55rem .5rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { color: var(--muted); font-weight: 500; font-size: .85rem; }
.table tr.inactive { opacity: .6; }
.student-link { font-weight: 500; }
@media (max-width: 640px) {
  .table thead { display: none; }
  .table tr { display: block; padding: .5rem 0; border-bottom: 1px solid var(--border); }
  .table td { display: flex; justify-content: space-between; border: 0; padding: .15rem 0; }
  .table td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: .85rem; }
}

/* ------------------------------------------------------------ student page */

.student-title { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.student-title h1 { margin-bottom: .2rem; }
.meeting-form { border-color: var(--primary); }
.next-meeting { background: var(--surface-2); border-radius: 8px; padding: .6rem .8rem; margin-bottom: .75rem; }

.topics { list-style: none; padding: 0; margin: .25rem 0 0; counter-reset: topic; }
.topic {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .45rem .4rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: .4rem;
  background: var(--surface);
}
.topic.editing { display: block; }
.topic.editing .field-row { align-items: center; }
.topic.editing .field-row > * { margin: 0; }
.topic.editing input { flex: 1; }
.topic.dragging { opacity: .4; }
.topic.drop-target { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.drag-handle { cursor: grab; color: var(--muted); user-select: none; letter-spacing: -2px; padding: 0 .2rem; }
.row-actions { display: inline-flex; gap: .1rem; flex: none; }

.goal-check {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .25rem .75rem;
  padding: .5rem 0;
  border-bottom: 1px solid var(--border);
}
.goal-check:last-child { border-bottom: 0; }
.goal-check.is-done .goal-title { color: var(--muted); text-decoration: line-through; }
.goal-check.is-done.recurring .goal-title { text-decoration: none; }
.goal-status { font-size: .8rem; color: var(--muted); }
.goal-status.overdue { color: var(--danger); }
.goal-desc { flex-basis: 100%; font-size: .85rem; color: var(--muted); padding-inline-start: 1.6rem; }
.add-goal { margin-top: .75rem; }
.add-goal form { margin-top: .5rem; }

.meeting { padding: .75rem 0; border-bottom: 1px solid var(--border); }
.meeting:last-child { border-bottom: 0; }
.meeting-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.meeting-head .row-actions { margin-inline-start: auto; }
.meeting-summary { white-space: pre-wrap; margin-top: .35rem; overflow-wrap: anywhere; }
.meeting-extras { margin-top: .35rem; display: grid; gap: .15rem; }
.notes { min-height: 120px; }

/* ------------------------------------------------------------ goals page */

.goal-item { padding: .75rem 0; border-bottom: 1px solid var(--border); }
.goal-item:last-child { border-bottom: 0; }
.goal-item.archived { opacity: .6; }
.goal-item-head { display: flex; justify-content: space-between; gap: .5rem; align-items: flex-start; }
.goal-item .goal-list { margin-top: .25rem; }
.goal-matrix { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .35rem 1rem; padding: .25rem 0; }
.goal-matrix li.is-overdue { color: var(--danger); }
.goal-edit { background: var(--surface-2); padding: .75rem; border-radius: 8px; }

.import-list { max-height: 420px; overflow: auto; margin: .75rem 0; border: 1px solid var(--border); border-radius: 8px; }
.import-list li { padding: .4rem .75rem; border-bottom: 1px solid var(--border); }
.import-list li:last-child { border-bottom: 0; }
.import-list .check > span { display: flex; flex-wrap: wrap; gap: .25rem .6rem; align-items: center; }

/* ------------------------------------------------------------ toast */

.toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translate(-50%, 150%);
  background: var(--text);
  color: var(--bg);
  padding: .6rem 1.1rem;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgb(0 0 0 / 20%);
  transition: transform .25s;
  z-index: 100;
  max-width: calc(100% - 32px);
}
.toast.show { transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }

@media (max-width: 640px) {
  .header-inner { gap: .5rem; }
  #nav { order: 3; flex-basis: 100%; overflow-x: auto; flex-wrap: nowrap; }
  #save-status { margin-inline-start: auto; }
  .card { padding: 1rem; }
  .toolbar input[type='search'] { width: 100%; }
}

/* ------------------------------------------------------------ sign-in */

.google-btn { background: var(--surface); color: var(--text); border-color: var(--border); font-weight: 500; padding: .6rem 1.2rem; }
.google-btn:hover { background: var(--surface-2); }
.g-icon { width: 18px; height: 18px; flex: none; }
.welcome form .google-btn { margin-bottom: .5rem; }
.footer-links { margin-top: 1.5rem; }
article.welcome ul { padding-inline-start: 1.25rem; }
