/* ==========================================================================
   Первак HR — единая таблица стилей.
   Стиль: яркий современный, карточки, скругления, цветные бейджи.
   ========================================================================== */

:root {
  --bg: #f4f3fb;
  --surface: #ffffff;
  --surface-2: #faf9ff;
  --text: #1f1b2e;
  --muted: #6b7280;
  --muted-2: #9aa0ac;
  --border: #ececf3;
  --border-strong: #dcdae8;

  --accent: #7c3aed;
  --accent-600: #6d28d9;
  --accent-700: #5b21b6;
  --accent-soft: #f1e9ff;
  --accent-grad: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);

  --ok-bg: #dcfce7;    --ok-fg: #15803d;
  --warn-bg: #fef3c7;  --warn-fg: #b45309;
  --bad-bg: #fee2e2;   --bad-fg: #b91c1c;
  --info-bg: #dbeafe;  --info-fg: #1d4ed8;

  --pos: #15803d;
  --neg: #dc2626;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(24, 20, 42, .06), 0 1px 3px rgba(24, 20, 42, .05);
  --shadow-md: 0 8px 24px rgba(89, 33, 182, .10);
  --sidebar-w: 244px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", "Roboto", -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }

/* ---------- App shell ---------------------------------------------------- */

.app { display: flex; min-height: 100%; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 18px;
}
.brand .logo {
  width: 34px; height: 34px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: var(--shadow-md);
}
.brand .name { font-weight: 800; font-size: 16px; }
.brand .sub { font-size: 11px; color: var(--muted-2); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }

.nav-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted-2);
  padding: 14px 12px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-700); }

.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); }

.userbox {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
}
.userbox:hover { background: var(--surface-2); }
.userbox .meta { min-width: 0; }
.userbox .meta .n { font-weight: 700; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.userbox .meta .r { font-size: 11px; color: var(--muted-2); }

/* ---------- Main --------------------------------------------------------- */

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 62px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,.8);
  backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 10;
}
.topbar .crumbs { font-size: 13px; color: var(--muted); font-weight: 600; }
.topbar .crumbs b { color: var(--text); }
.topbar .spacer { flex: 1; }

.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  min-width: 240px;
}
.search input { border: 0; background: transparent; outline: none; font: inherit; width: 100%; color: var(--text); }
.search svg { width: 16px; height: 16px; color: var(--muted-2); }

.bell {
  position: relative;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
}
.bell:hover { background: var(--surface-2); color: var(--text); }
.bell svg { width: 18px; height: 18px; }
.bell-dot {
  position: absolute; top: -6px; right: -6px;
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 999px;
  background: var(--neg); color: #fff;
  font-size: 10px; font-weight: 800;
  display: grid; place-items: center;
  border: 2px solid var(--surface);
}

.content { padding: 26px 28px 60px; max-width: 1180px; width: 100%; }

.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 22px; }
.page-head h1 { font-size: 24px; }
.page-head .desc { color: var(--muted); font-size: 13px; margin-top: 4px; }
.page-head .spacer { flex: 1; }

/* ---------- Buttons ---------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit; font-weight: 600;
  cursor: pointer;
  transition: transform .05s, box-shadow .12s, background .12s;
}
.btn:hover { box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--accent-grad); border-color: transparent; color: #fff; box-shadow: var(--shadow-md); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn.danger { color: var(--neg); border-color: #f3c9c9; }
.btn.danger:hover { background: var(--bad-bg); }

/* ---------- Cards ------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card .card-h {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.card .card-h h3 { font-size: 15px; }
.card .card-h .spacer { flex: 1; }
.card .card-b { padding: 18px 20px; }
.card .card-b.flush { padding: 0; }

.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; } }

/* ---------- Stat cards ------------------------------------------------- */

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.stat .label { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat .value { font-size: 28px; font-weight: 800; margin-top: 6px; letter-spacing: -.02em; }
.stat .trend { font-size: 12px; margin-top: 4px; color: var(--muted-2); }
.stat .trend.up { color: var(--pos); }
.stat .trend.down { color: var(--neg); }
.stat .ico {
  width: 38px; height: 38px; border-radius: 11px;
  background: var(--accent-soft); color: var(--accent-700);
  display: grid; place-items: center; float: right;
}
.stat .ico svg { width: 20px; height: 20px; }

/* ---------- Tables --------------------------------------------------- */

.table-wrap { overflow-x: auto; }

table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data thead th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}
table.data thead th.sortable { cursor: pointer; }
table.data thead th.sortable:hover { color: var(--accent-700); }
table.data thead th .arrow { opacity: .4; font-size: 10px; }
table.data thead th.sorted .arrow { opacity: 1; color: var(--accent); }
table.data tbody td { padding: 13px 16px; border-bottom: 1px solid var(--border); }
table.data tbody tr { transition: background .1s; }
table.data tbody tr:hover { background: var(--surface-2); cursor: pointer; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr.is-trashed { opacity: .6; }
table.data tbody tr.is-trashed:hover { opacity: 1; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }

.name-cell { display: flex; align-items: center; gap: 11px; }

/* ---------- Avatars ------------------------------------------------- */

.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px; color: #fff;
  flex-shrink: 0;
}
.avatar.lg { width: 76px; height: 76px; font-size: 27px; border-radius: 22px; }
.avatar.sm { width: 26px; height: 26px; font-size: 11px; }
.a0 { background: linear-gradient(135deg,#7c3aed,#c084fc); }
.a1 { background: linear-gradient(135deg,#2563eb,#38bdf8); }
.a2 { background: linear-gradient(135deg,#db2777,#fb7185); }
.a3 { background: linear-gradient(135deg,#059669,#34d399); }
.a4 { background: linear-gradient(135deg,#d97706,#fbbf24); }
.a5 { background: linear-gradient(135deg,#4f46e5,#818cf8); }

/* ---------- Badges -------------------------------------------------- */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok   { background: var(--ok-bg);   color: var(--ok-fg); }
.badge.warn { background: var(--warn-bg); color: var(--warn-fg); }
.badge.bad  { background: var(--bad-bg);  color: var(--bad-fg); }
.badge.info { background: var(--info-bg); color: var(--info-fg); }
.badge.muted{ background: #eef0f4;        color: var(--muted); }
.badge.role-admin   { background: #ede9fe; color: #6d28d9; }
.badge.role-cultorg { background: #cffafe; color: #0e7490; }
.badge.role-student { background: #eef0f4; color: var(--muted); }

.badge.dir-dance   { background: #fce7f3; color: #be185d; }
.badge.dir-decor   { background: #fef3c7; color: #b45309; }
.badge.dir-act     { background: #dbeafe; color: #1d4ed8; }
.badge.dir-emerald { background: #d1fae5; color: #047857; }
.badge.dir-violet  { background: #ede9fe; color: #6d28d9; }
.badge.dir-cyan    { background: #cffafe; color: #0e7490; }
.badge.dir-orange  { background: #ffedd5; color: #c2410c; }
.badge.dir-slate   { background: #e2e8f0; color: #334155; }

.points {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.points.pos { color: var(--pos); }
.points.neg { color: var(--neg); }
.points.zero { color: var(--muted); }

.pill-group {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent-700);
  font-weight: 700;
  font-size: 12px;
}

/* ---------- Toolbar / filters ------------------------------------- */

.toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.toolbar .spacer { flex: 1; }

.select, .input {
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface);
  font: inherit;
  color: var(--text);
  outline: none;
}
.select:focus, .input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-weight: 600; font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- Profile ---------------------------------------------- */

.profile-head {
  display: flex; gap: 20px; align-items: center;
  padding: 22px;
}
.profile-head .info h1 { font-size: 22px; }
.profile-head .info .meta-row {
  display: flex; gap: 18px; flex-wrap: wrap;
  margin-top: 8px; color: var(--muted); font-size: 13px;
}
.profile-head .info .meta-row b { color: var(--text); font-weight: 700; }
.profile-head .bal {
  margin-left: auto; text-align: right;
  padding-left: 20px; border-left: 1px solid var(--border);
}
.profile-head .bal .label { font-size: 11px; color: var(--muted-2); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.profile-head .bal .v { font-size: 40px; font-weight: 800; letter-spacing: -.03em; }

/* timeline */
.timeline { list-style: none; margin: 0; padding: 4px 0; }
.timeline li {
  display: flex; gap: 14px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
}
.timeline li:last-child { border-bottom: 0; }
.timeline .tl-ico {
  width: 32px; height: 32px; border-radius: 10px;
  display: grid; place-items: center; flex-shrink: 0;
  font-weight: 800;
}
.timeline .tl-ico.pos { background: var(--ok-bg); color: var(--ok-fg); }
.timeline .tl-ico.neg { background: var(--bad-bg); color: var(--bad-fg); }
.timeline .tl-body { flex: 1; min-width: 0; }
.timeline .tl-body .tl-top { display: flex; align-items: baseline; gap: 8px; }
.timeline .tl-body .tl-reason { font-weight: 600; }
.timeline .tl-body .tl-delta { font-weight: 800; font-variant-numeric: tabular-nums; }
.timeline .tl-body .tl-delta.pos { color: var(--pos); }
.timeline .tl-body .tl-delta.neg { color: var(--neg); }
.timeline .tl-body .tl-sub { font-size: 12px; color: var(--muted-2); margin-top: 2px; }

/* ---------- Calendar ------------------------------------------- */

.cal-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.cal-nav-btn {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  flex-shrink: 0;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 18px; line-height: 1;
  text-decoration: none;
}
.cal-nav-btn:hover { background: var(--surface-2); color: var(--text); }
.cal-nav-label {
  font-weight: 700;
  font-size: 14px;
  text-transform: capitalize;
  min-width: 132px;
  text-align: center;
}
.cal-nav-today {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-700);
  text-decoration: none;
}
.cal-nav-today:hover { text-decoration: underline; }

.cal {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.cal .dow {
  text-align: center; font-size: 11px; font-weight: 700;
  color: var(--muted-2); text-transform: uppercase; letter-spacing: .04em;
  padding-bottom: 4px;
}
.cal .day {
  aspect-ratio: 1 / 1;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  position: relative;
  background: var(--surface);
}
.cal .day.out { opacity: .35; }
.cal .day.today { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.cal .day .tag {
  position: absolute; left: 6px; right: 6px; bottom: 6px;
  font-size: 10px; font-weight: 800;
  border-radius: 6px; padding: 2px 4px; text-align: center;
}
.cal .day.ev-ok   .tag { background: var(--ok-bg);   color: var(--ok-fg); }
.cal .day.ev-warn .tag { background: var(--warn-bg); color: var(--warn-fg); }
.cal .day.ev-bad  .tag { background: var(--bad-bg);  color: var(--bad-fg); }
.cal .day.ev-info .tag { background: var(--info-bg); color: var(--info-fg); }
.cal .day.ev-none .tag { background: #eef0f4; color: var(--muted); }

.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 14px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- Attendance marking ------------------------------- */

.att-row {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.att-row:last-child { border-bottom: 0; }
.att-row .who { flex: 1; min-width: 0; display: flex; align-items: center; gap: 11px; }
.att-row .who .n { font-weight: 600; }
.att-row .who .g { font-size: 12px; color: var(--muted-2); }

.seg {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  overflow: hidden;
}
.seg button {
  border: 0; background: var(--surface);
  padding: 7px 12px;
  font: inherit; font-weight: 600; font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
  border-right: 1px solid var(--border);
}
.seg button:last-child { border-right: 0; }
.seg button:hover { background: var(--surface-2); }
.seg button.on-ok   { background: var(--ok-bg);   color: var(--ok-fg); }
.seg button.on-warn { background: var(--warn-bg); color: var(--warn-fg); }
.seg button.on-bad  { background: var(--bad-bg);  color: var(--bad-fg); }
.seg button.on-info { background: var(--info-bg); color: var(--info-fg); }

/* ---------- Login ------------------------------------------- */

.auth-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
}
.auth-side {
  background: var(--accent-grad);
  color: #fff;
  padding: 56px;
  display: flex; flex-direction: column; justify-content: space-between;
}
.auth-side .logo {
  width: 52px; height: 52px; border-radius: 15px;
  background: #fff;
  padding: 6px;
  object-fit: contain;
  box-shadow: 0 10px 24px -8px rgba(0,0,0,.35);
}
.auth-side h2 { font-size: 32px; margin-top: 26px; line-height: 1.2; }
.auth-side p { opacity: .85; margin-top: 14px; max-width: 400px; font-size: 15px; }
.auth-side .feats { display: grid; gap: 12px; margin-top: 30px; }
.auth-side .feats div { display: flex; gap: 10px; align-items: center; opacity: .95; }
.auth-side .feats svg { width: 18px; height: 18px; }
.auth-side .foot { font-size: 12px; opacity: .7; }

.auth-main { display: grid; place-items: center; padding: 40px; }
.auth-card { width: 100%; max-width: 360px; }
.auth-card h1 { font-size: 24px; }
.auth-card .sub { color: var(--muted); margin-top: 6px; margin-bottom: 26px; font-size: 13px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: 12.5px; margin-bottom: 6px; }
.field input {
  width: 100%; padding: 11px 13px;
  border: 1px solid var(--border-strong); border-radius: 10px;
  font: inherit; outline: none;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.role-switch { display: flex; gap: 8px; margin-bottom: 22px; }
.role-switch button {
  flex: 1; padding: 9px; border-radius: 9px;
  border: 1px solid var(--border-strong); background: var(--surface);
  font: inherit; font-weight: 600; font-size: 12.5px; color: var(--muted);
  cursor: pointer;
}
.role-switch button.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-700); }
@media (max-width: 820px) { .auth-wrap { grid-template-columns: 1fr; } .auth-side { display: none; } }

/* ---------- Misc ------------------------------------------- */

.muted { color: var(--muted); }
.small { font-size: 12px; }
.mt-0 { margin-top: 0; }
.mb-16 { margin-bottom: 16px; }
.row { display: flex; align-items: center; gap: 10px; }
.wrap { flex-wrap: wrap; }
.hr { height: 1px; background: var(--border); border: 0; margin: 18px 0; }

.section-title {
  font-size: 12px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted-2);
  margin: 26px 0 12px;
}

.note {
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 12.5px;
  color: var(--muted);
}

.empty { text-align: center; padding: 40px; color: var(--muted-2); }

/* ==========================================================================
   МОБИЛЬНАЯ ВЕРСИЯ
   Большинство пользователей заходят с телефона — телефон здесь основной,
   десктоп остаётся как есть выше.
   ========================================================================== */

/* Кнопка-гамбургер и подложка выезжающего меню (по умолчанию скрыты) */
.menu-btn {
  display: none;
  width: 40px; height: 40px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
}
.menu-btn svg { width: 20px; height: 20px; }
.sidebar-backdrop { display: none; }

@media (max-width: 768px) {
  html, body { overflow-x: hidden; }

  /* --- Навигация: выезжающая панель --------------------------------- */
  .menu-btn { display: grid; }

  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    height: 100%;
    width: min(280px, 82vw);
    z-index: 60;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: 0 0 48px rgba(20, 16, 42, .28);
  }
  .sidebar.open { transform: none; }

  .sidebar-backdrop.show {
    display: block;
    position: fixed; inset: 0;
    background: rgba(20, 16, 42, .42);
    z-index: 55;
  }

  .main { width: 100%; min-width: 0; }

  /* --- Шапка ------------------------------------------------------- */
  .topbar {
    height: 56px;
    padding: 0 12px;
    gap: 10px;
  }
  .topbar .crumbs { display: none; }
  .topbar .search { display: none; }
  .topbar .spacer { flex: 1; }

  /* --- Контент --------------------------------------------------- */
  .content { padding: 16px 14px 96px; }

  .page-head { flex-wrap: wrap; align-items: flex-start; gap: 10px; }
  .page-head h1 { font-size: 20px; }
  .page-head .spacer { display: none; }
  .page-head > .btn,
  .page-head .btn.primary { width: 100%; justify-content: center; }

  /* --- Сетки ---------------------------------------------------- */
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .grid.cols-4 { grid-template-columns: 1fr 1fr; }   /* карточки-счётчики 2 в ряд */
  .grid { gap: 14px; }

  /* --- Кнопки: увеличенные зоны нажатия ----------------------- */
  .btn { min-height: 42px; }
  .btn.sm { min-height: 36px; }
  .nav-item { padding: 12px; }

  /* --- Карточки ---------------------------------------------- */
  .card .card-h { padding: 14px 16px; flex-wrap: wrap; }
  .card .card-b { padding: 14px 16px; }

  /* --- Таблицы -> карточки ---------------------------------- */
  table.data { display: block; }
  table.data thead { display: none; }
  table.data tbody { display: block; }
  table.data tbody tr {
    display: block;
    margin: 10px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
  }
  table.data tbody tr:hover { background: var(--surface); }
  table.data td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 6px 0;
    border: 0;
    text-align: right;
  }
  table.data td::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted-2);
    text-align: left;
    flex-shrink: 0;
  }
  table.data td.td-main {
    display: block;
    text-align: left;
    padding: 0 0 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 6px;
  }
  table.data td.td-main::before { display: none; }
  table.data td.td-action { display: block; padding-top: 10px; }
  table.data td.td-action::before { display: none; }
  table.data td.td-action .btn { width: 100%; justify-content: center; }
  table.data td:empty { display: none; }
  .table-wrap { overflow: visible; }

  /* --- Профиль --------------------------------------------- */
  .profile-head { flex-direction: column; align-items: flex-start; gap: 14px; padding: 18px; }
  .profile-head .avatar.lg { width: 60px; height: 60px; font-size: 22px; border-radius: 18px; }
  .profile-head .info h1 { font-size: 19px; }
  .profile-head .info .row { flex-wrap: wrap; }
  .profile-head .bal {
    margin-left: 0;
    border-left: 0;
    border-top: 1px solid var(--border);
    padding-left: 0;
    padding-top: 14px;
    width: 100%;
    text-align: left;
  }
  .profile-head .bal .v { font-size: 34px; }
  .profile-head .bal .row { justify-content: flex-start !important; flex-wrap: wrap; }
  .profile-head .bal .row .btn { flex: 1; min-width: 130px; justify-content: center; }

  /* --- Отметка посещаемости ------------------------------ */
  .att-row { flex-direction: column; align-items: stretch; gap: 10px; padding: 12px 14px; }
  .att-row .who { width: 100%; }
  .att-row .seg { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .att-row .seg button {
    padding: 12px 8px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
  }
  .att-row .seg button:nth-child(2n) { border-right: 0; }
  .att-row .seg button:nth-child(n+3) { border-bottom: 0; }

  /* --- Тулбар фильтров студентов ------------------------ */
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar .search { min-width: 0; width: 100%; }
  .toolbar .select, .toolbar .btn { width: 100%; }
  .toolbar .spacer { display: none; }
  .toolbar > .muted { text-align: right; }

  /* --- Формы ------------------------------------------- */
  .card[style*="max-width"] { max-width: 100% !important; }
  .field input, .field .input, .field .select { font-size: 16px; } /* без авто-зума iOS */

  /* --- Прочее ---------------------------------------- */
  .auth-main { padding: 24px 18px; }
}

@media (max-width: 560px) {
  /* Календарь: на телефоне заливаем всю клетку цветом статуса — так очевиднее */
  .cal { gap: 4px; }
  .cal .day { font-size: 12px; padding: 4px; border-radius: 8px; display: grid; place-items: center; }
  .cal .dow { font-size: 10px; }
  .cal .day .tag { display: none; }
  .cal .day[class*="ev-"] { font-weight: 800; }
  .cal .day.ev-ok   { background: var(--ok-bg);   border-color: var(--ok-fg);   color: var(--ok-fg); }
  .cal .day.ev-warn { background: var(--warn-bg); border-color: var(--warn-fg); color: var(--warn-fg); }
  .cal .day.ev-bad  { background: var(--bad-bg);  border-color: var(--bad-fg);  color: var(--bad-fg); }
  .cal .day.ev-info { background: var(--info-bg); border-color: var(--info-fg); color: var(--info-fg); }
  .cal .day.ev-none { background: #eef0f4;        border-color: var(--border-strong); color: var(--muted); }
  .cal .day.today   { box-shadow: 0 0 0 2px var(--accent); }
}

@media (max-width: 440px) {
  .grid.cols-4 { grid-template-columns: 1fr; }
  .page-head .btn.sm { width: auto; }
}

/* Непрочитанное уведомление — акцентная полоса слева */
.timeline li.notice-unread { border-left: 3px solid var(--accent); padding-left: 11px; border-radius: 0 8px 8px 0; }

@media (max-width: 768px) {
  .timeline li { gap: 10px; padding: 12px 2px; }
  .timeline .tl-top { flex-wrap: wrap; row-gap: 4px; }
  .card .card-h .chip-row { width: 100%; }
}

@media (max-width: 768px) {
  table.data td.td-action .row { justify-content: stretch; }
  table.data td.td-action .row .btn,
  table.data td.td-action .row form { flex: 1; }
  table.data td.td-action .row form .btn { width: 100%; }
}

/* Справочники — строки редактирования */
.ref-list { display: flex; flex-direction: column; }
.ref-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.ref-row:last-child { border-bottom: 0; }
.ref-row .input, .ref-row .select { padding: 7px 10px; }
