/* Отметка группы — light accent-ladder
   Правила: плоские поверхности (разделение 1px линией), цвет только на данных,
   одна залитая кнопка на экране, табличные цифры, движение только как отклик. */

:root {
  --paper: #fafaf7;
  --surface: #ffffff;
  --line: #e4e4e9;
  --line-strong: #c9c9d2;
  --ink: #23203a;
  --muted: #6e6b7e;
  --accent: #5b4cc4;
  --accent-hover: #4c3dae;
  --pale: #edebf8;

  --ok-ink: #1e7a46;
  --ok-bg: #eaf5ee;
  --bad-ink: #b3372f;
  --bad-bg: #fbebea;
  --warn-ink: #8a5a18;
  --warn-bg: #f9f4ec;
  --part-ink: #56536b;
  --part-bg: #efeef2;

  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 12px;

  --fs: 15px;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

/* ── база ────────────────────────────────────────────── */

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: var(--fs);
  line-height: 1.45;
  color: var(--ink);
  background: var(--paper);
  min-height: 100dvh;
}

.hidden { display: none !important; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--bad-ink); font-size: 13px; }

b { font-weight: 600; }

.grow { flex: 1; min-width: 0; }
.w60 { flex: 0 0 88px; font-variant-numeric: tabular-nums; color: var(--muted); }

::selection { background: var(--pale); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── кнопки ──────────────────────────────────────────── */

button {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 10px 16px;
  min-height: 44px;
  cursor: pointer;
  transition: background-color 130ms ease-out, border-color 130ms ease-out,
              color 130ms ease-out, transform 90ms ease-out;
}
button:hover { background: #f4f3f0; }
button:active { transform: scale(0.97); }
button:disabled {
  background: #eceae6;
  color: #a3a0ac;
  border-color: var(--line);
  cursor: default;
  transform: none;
}

.btn-primary,
#btn-add-user,
#btn-present {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover,
#btn-add-user:hover,
#btn-present:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary:active,
#btn-add-user:active,
#btn-present:active { transform: scale(0.97); }
#btn-present:disabled { background: #eceae6; border-color: var(--line); color: #a3a0ac; }

.btn-ghost,
.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}
.btn-ghost:hover,
.ghost:hover { background: #f4f3f0; }

button.mini {
  flex: 0 0 36px;
  min-height: 36px;
  padding: 0;
  color: var(--muted);
  font-size: 14px;
}
button.mini:hover { background: var(--bad-bg); border-color: transparent; color: var(--bad-ink); }

.wide { flex-basis: 100%; }

/* ── поля ────────────────────────────────────────────── */

input, select {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 10px 14px;
  min-height: 44px;
  width: 100%;
  transition: border-color 130ms ease-out, box-shadow 130ms ease-out;
}
input:hover { border-color: var(--line-strong); }
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--pale);
}
input::placeholder { color: #a3a0ac; }

/* ── вход ────────────────────────────────────────────── */

#auth {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth {
  width: min(360px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
}
@media (min-width: 641px) {
  #auth { background: var(--paper); }
  .auth { box-shadow: 0 1px 2px rgba(35, 32, 58, 0.05); }
}

.mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  border-radius: 12px;
}

.auth-head { margin-top: 16px; }
.brand { display: block; font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
.brand-sub { display: block; margin-top: 2px; font-size: 12.5px; color: var(--muted); }

.auth-form { margin-top: 20px; display: grid; gap: 10px; }
.qlabel {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
#pin {
  font-size: 21px;
  font-weight: 600;
  letter-spacing: 0.45em;
  text-indent: 0.45em; /* компенсирует трекинг у последней цифры */
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.hints { margin-top: 20px; }
.hints div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 7px 0;
}
.hints div + div { border-top: 1px solid var(--line); }
.hints dt { font-size: 13px; color: var(--muted); }
.hints dd { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ── верхняя панель ──────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 10px 20px;
}

.who { display: flex; align-items: center; gap: 10px; min-width: 0; margin-right: auto; }
.mark.sm { width: 30px; height: 30px; font-size: 14px; border-radius: 8px; flex: none; }
.who-name { font-size: 15px; font-weight: 600; line-height: 1.2; }
.who-role { font-size: 12px; color: var(--muted); }

#btn-logout { padding: 8px 14px; min-height: 36px; border: none; color: var(--muted); }
#btn-logout:hover { color: var(--bad-ink); background: var(--bad-bg); border-radius: var(--r-md); }

#tabs { display: flex; gap: 4px; align-self: stretch; }
.tab {
  border: none;
  background: none;
  min-height: 100%;
  padding: 0 4px;
  color: var(--muted);
  border-radius: 0;
  box-shadow: inset 0 -2px 0 transparent;
}
.tab:hover { background: none; color: var(--ink); transform: none; }
.tab.active {
  color: var(--ink);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--accent); /* линия активной вкладки, не пилюля */
}

/* ── контент ─────────────────────────────────────────── */

main {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

p.muted { margin: 4px 0; }

/* ── календарь ───────────────────────────────────────── */

.month-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.month-nav h2 {
  flex: 1;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.month-nav button {
  flex: 0 0 44px;
  padding: 0;
  font-size: 18px;
  color: var(--muted);
}
.month-nav button:hover { color: var(--ink); }

.weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 6px;
}
.weekdays div {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.weekdays div:nth-child(n + 6) { color: #b3b0bc; } /* сб–вс тише */

.grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cell {
  min-height: 68px;
  padding: 6px 7px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: background-color 130ms ease-out, box-shadow 130ms ease-out,
              transform 90ms ease-out;
}
.cell:hover { background: #f1f0ec; }
.cell:active { transform: scale(0.96); }
.cell.empty { cursor: default; background: none; }
.cell.empty:active { transform: none; }

.cell .num { font-size: 12px; font-weight: 600; color: var(--ink); }

.cell.today {
  box-shadow: inset 0 0 0 1px var(--accent); /* «сегодня» — линия цвета данных, не заливка */
}
.cell.sel {
  background: var(--pale);
}
.cell.sel.today { background: var(--pale); }

.badge {
  align-self: stretch;
  max-width: 64px;
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 650;
  text-align: center;
  white-space: nowrap;
}
.badge.ok   { background: var(--ok-bg);    color: var(--ok-ink); }
.badge.bad  { background: var(--bad-bg);   color: var(--bad-ink); }
.badge.part { background: var(--part-bg);  color: var(--part-ink); }

/* ── карточки ────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px 18px;
}
.card + .card, .card + #future-box, #day-detail + #future-box { margin-top: 14px; }
#future-box .card { margin-top: 0; }

.card h3 {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.card p { font-size: 14.5px; }
.card p + p { margin-top: 8px; }
.card.warn { background: var(--warn-bg); border-color: #ece0c8; }
.card.status { padding: 18px; }

.ok-big {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ok-ink);
  margin: 2px 0 12px;
  font-variant-numeric: tabular-nums;
}
.bad-big {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--bad-ink);
  margin: 2px 0 12px;
}

/* ── строки ──────────────────────────────────────────── */

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
}
.row + .row { border-top: 1px solid var(--line); }

.row p, .row div { font-size: 14.5px; }

.stu.clickable {
  cursor: pointer;
  border-radius: var(--r-sm);
}
.stu.clickable:hover { background: #f6f5f2; }

/* штамп ✔ / ✘ — цвет на данных */
.mark.ok {
  flex: none;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ok-bg);
  color: var(--ok-ink);
  font-size: 13px;
  font-weight: 700;
}
.mark.bad {
  flex: none;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--bad-bg);
  color: var(--bad-ink);
  font-size: 13px;
  font-weight: 700;
}

/* ── участники ───────────────────────────────────────── */

.add-user {
  display: grid;
  grid-template-columns: 2fr 0.9fr 1fr auto;
  gap: 8px;
  margin-bottom: 14px;
}

/* ── кноп. стек ──────────────────────────────────────── */

.btns { display: flex; gap: 8px; }
.btns + .btns { margin-top: 8px; }
.btns button { flex: 1; }

/* ── модалка ─────────────────────────────────────────── */

#modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(35, 32, 58, 0.44);
}

.modal-card {
  width: min(380px, 100%);
  background: var(--surface);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 8px 30px rgba(35, 32, 58, 0.18);
}
.modal-card h3 {
  font-size: 16px;
  font-weight: 650;
  margin-bottom: 14px;
}
.modal-card input { margin-bottom: 6px; }
#modal-date-row input { margin-bottom: 10px; }

/* ── адаптив ─────────────────────────────────────────── */

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; row-gap: 2px; padding: 10px 14px; }
  #tabs { order: 3; flex-basis: 100%; justify-content: center; margin-top: 4px; }
  main { padding: 16px 12px 40px; }

  .cell { min-height: 54px; padding: 5px 6px; }
  .cell .num { font-size: 11px; }
  .badge { max-width: none; font-size: 9.5px; padding: 1px 4px; }

  .add-user { grid-template-columns: 1fr 1fr; }
  .add-user button { grid-column: 1 / -1; }

  .btns button { min-height: 46px; }
  .w60 { flex-basis: 76px; font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ── шапка: гостевой вход ────────────────────────────── */

.login-zone { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.login-who { font-size: 13px; font-weight: 600; line-height: 1.3; text-align: right; }

button.sm, .btn-ghost.sm, .btn-primary.sm {
  min-height: 36px;
  padding: 7px 14px;
  border-radius: 9px;
  font-size: 13.5px;
}

.wide { width: 100%; margin-top: 6px; }

/* ── оверлеи ─────────────────────────────────────────── */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(35, 32, 58, 0.44);
  overflow: auto;
}

#modal { background: rgba(35, 32, 58, 0.44); }

/* ── расписание ──────────────────────────────────────── */

.day-note { margin: 0 0 12px; }

.page-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin: 0 0 14px;
}

.sched-day { padding: 14px 16px; }
.sched-day + .sched-day { margin-top: 12px; }

.sched-day h3 {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}
.sched-day h3 > span:first-child {
  color: var(--ink);
  font-size: 13px;
  letter-spacing: 0.03em;
  text-transform: none;
}

.sched-row {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr) 64px minmax(0, 1.1fr);
  gap: 2px 12px;
  align-items: baseline;
  padding: 9px 0;
}
.sched-row + .sched-row { border-top: 1px solid var(--line); }
.slot-time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.slot-subject { font-size: 14.5px; }
.sroom { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.stch { color: var(--muted); font-size: 13px; }

@media (max-width: 640px) {
  .sched-row { display: block; padding: 8px 0; }
  .sched-row > div { padding: 1px 0; }
}

/* редактор расписания */

.sedit-row {
  display: grid;
  grid-template-columns: 104px minmax(0, 1.2fr) 64px minmax(0, 1fr) 36px;
  gap: 8px;
  align-items: center;
  padding: 6px 0;
  border-top: 1px solid var(--line);
}
.sedit-row input {
  min-height: 36px;
  padding: 6px 9px;
  font-size: 13px;
}
.add-slot { margin-top: 10px; }

/* ── новости ─────────────────────────────────────────── */

.post-head { display: flex; align-items: baseline; gap: 10px; }
.post-head h3 {
  flex: 1;
  color: var(--ink);
  text-transform: none;
  letter-spacing: 0;
  font-size: 15px;
  font-weight: 650;
}
.post-head + p { margin-top: 4px; }
.post p { white-space: pre-wrap; }

.add-post { display: grid; gap: 8px; }

textarea {
  display: block;
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 10px 14px;
  resize: vertical;
  transition: border-color 130ms ease-out, box-shadow 130ms ease-out;
}
textarea:hover { border-color: var(--line-strong); }
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--pale);
}
textarea::placeholder { color: #a3a0ac; }

/* ── apk-карточка ────────────────────────────────────── */

.apk-card {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
}
.apk-ico {
  flex: none;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  background: var(--pale);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  border-radius: 10px;
  letter-spacing: 0.02em;
}
.apk-title { font-size: 14.5px; font-weight: 650; }

a.as-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  text-decoration: none;
  white-space: nowrap;
  flex: none;
}

/* ── мобайл: добивка ─────────────────────────────────── */

@media (max-width: 640px) {
  body { -webkit-tap-highlight-color: transparent; }

  .topbar { gap: 10px; padding: 8px 12px; }
  #tabs { flex-wrap: wrap; row-gap: 0; }
  .tab { padding: 0 8px; min-height: 38px; }

  .sedit-row { grid-template-columns: 1fr 1fr; }
  .sedit-row .et { grid-column: 1; }
  .sedit-row .es { grid-column: 2; }
  .sedit-row .er { grid-column: 1; }
  .sedit-row .eh { grid-column: 2; }
  .sedit-row .mini { grid-column: 1 / -1; justify-self: end; }

  .apk-card { gap: 10px; padding: 12px 14px; }
  .apk-ico { width: 40px; height: 40px; }
  .apk-card .muted.small { line-height: 1.35; }

  .day-note { display: none; } /* на телефоне очевидно, что дни сверху */
}

@media (max-width: 480px) {
  .login-who div:first-child { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  a.as-btn { padding: 7px 10px; }
  .apk-card .grow .muted.small { font-size: 11.5px; }
}

/* ── недельная ротация ───────────────────────────────── */

.week-flag {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 13.5px;
  color: var(--muted);
}
.week-flag b { color: var(--accent); font-weight: 650; }
.wk-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.week-switch { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; }
.wk-tab { padding: 6px 12px; min-height: 34px; font-size: 13px; }
.wk-tab.active {
  background: var(--pale);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}
@media (max-width: 640px) {
  .week-flag { font-size: 12px; }
  .week-switch { flex-wrap: wrap; }
  .week-switch .muted.small { flex-basis: 100%; }
}
