/* =========================================================================
   Trena — Components
   ========================================================================= */

/* -------------------------------------------------------------------------
   App shell: sidebar + topbar + content
   ------------------------------------------------------------------------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--sb-bg);
  color: var(--sb-text);
  padding: var(--s-4) var(--s-3);
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-2) var(--s-3);
  margin-bottom: var(--s-2);
}
.sidebar__logo {
  width: 32px; height: 32px;
  border-radius: var(--r-md);
  background: var(--brand);
  color: white;
  display: grid; place-items: center;
  font-weight: var(--fw-bold);
  font-size: 15px;
  letter-spacing: -0.02em;
}
.sidebar__name {
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  color: white;
  line-height: 1.2;
}
.sidebar__tagline {
  font-size: var(--fs-xs);
  color: var(--sb-text-muted);
  letter-spacing: 0;
  text-transform: none;
}
.sidebar__nav { display: flex; flex-direction: column; gap: 2px; }
.sb-link {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 8px var(--s-3);
  border-radius: var(--r-md);
  color: var(--sb-text);
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}
.sb-link:hover { background: var(--sb-bg-hover); color: white; }
.sb-link.is-active { background: var(--sb-active-bg); color: var(--sb-active-text); }
.sb-link__icon { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.95; }
.sidebar__divider { border-top: 1px solid #2a2a26; margin: var(--s-2) var(--s-3); }
.sidebar__foot { margin-top: auto; padding: var(--s-2) var(--s-3); font-size: var(--fs-xs); color: var(--sb-text-muted); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--s-6);
  position: sticky; top: 0; z-index: 30;
}
.topbar__left { display: flex; align-items: center; gap: var(--s-4); }
.topbar__right { display: flex; align-items: center; gap: var(--s-3); }
.topbar__title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); }
.topbar__breadcrumb { font-size: var(--fs-sm); color: var(--ink-muted); }
.topbar__search { flex-shrink: 0; }

.user-chip {
  display: flex; align-items: center; gap: var(--s-2);
  padding: 4px var(--s-3) 4px 4px;
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  cursor: pointer;
}
.user-chip__avatar {
  width: 24px; height: 24px;
  border-radius: var(--r-full);
  background: var(--ink);
  color: white;
  display: grid; place-items: center;
  font-size: 11px;
  font-weight: var(--fw-semibold);
}
.user-chip__name { font-size: var(--fs-sm); font-weight: var(--fw-medium); white-space: nowrap; }
.user-chip__role { font-size: 10px; color: var(--ink-muted); letter-spacing: var(--ls-wide); text-transform: uppercase; margin-left: 6px; white-space: nowrap; }
.topbar__title, .topbar__breadcrumb { white-space: nowrap; }

/* App boot loader — shared splash for v2 shell pages.
   Data-heavy screens still use local skeletons after shell boot. */
#trena-loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  background: var(--bg-app);
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
  opacity: 1;
  transition: opacity var(--t-slow) var(--ease), visibility 0s;
}
#trena-loader.is-leaving {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--t-slow) var(--ease), visibility 0s linear var(--t-slow);
}
.boot-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  animation: boot-loader-in 420ms var(--ease) both;
}
@keyframes boot-loader-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.boot-loader__logo {
  width: 72px;
  height: 72px;
  border-radius: var(--r-2xl);
  display: block;
  box-shadow: 0 8px 24px -10px rgba(197, 62, 45, 0.55), 0 2px 6px -2px rgba(20,20,18,0.08);
}
.boot-loader__word {
  margin-top: 20px;
  font-size: 26px;
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-tight);
  color: var(--ink);
  line-height: 1;
}
.boot-loader__tagline {
  margin-top: 7px;
  font-size: 13px;
  font-weight: var(--fw-medium);
  color: var(--ink-muted);
}
.boot-loader__spin {
  margin-top: 30px;
  min-height: 28px;
  display: grid;
  place-items: center;
}
.boot-loader__status {
  margin-top: 14px;
  min-height: 16px;
  font-size: 12px;
  color: var(--ink-muted);
}
.boot-loader__error {
  display: none;
  flex-direction: column;
  align-items: center;
  margin-top: 28px;
}
#trena-loader.is-error .boot-loader__spin,
#trena-loader.is-error .boot-loader__status { display: none; }
#trena-loader.is-error .boot-loader__error { display: flex; }
.boot-loader__error-icon {
  width: 40px; height: 40px;
  border-radius: var(--r-full);
  background: var(--danger-soft);
  color: var(--danger-ink);
  display: grid; place-items: center;
  margin-bottom: 14px;
}
.boot-loader__error-icon svg {
  width: 22px; height: 22px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}
.boot-loader__error-title {
  font-size: 15px;
  font-weight: var(--fw-semibold);
  color: var(--ink);
}
.boot-loader__error-sub {
  margin-top: 5px;
  font-size: 13px;
  color: var(--ink-secondary);
  max-width: 280px;
  line-height: 1.45;
}
.spinner {
  width: 26px;
  height: 26px;
  border: 2.5px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .boot-loader { animation: none; }
  .spinner { animation: spin 1.6s steps(8, end) infinite; }
}

/* Notifications bell — mobile-first panel + desktop dropdown.
   One row component for both shells; grouped by relative dates. */
.notif-wrap { position: relative; }
.notif-dot {
  position: absolute; top: 5px; right: 5px;
  width: 7px; height: 7px;
  background: var(--brand);
  border-radius: var(--r-full);
  border: 2px solid var(--surface);
  pointer-events: none;
}
.notif-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 380px; max-width: calc(100vw - 24px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-lg);
  z-index: 50;
  display: flex; flex-direction: column;
  overflow: hidden;
  max-height: 480px;
}
.notif-panel[hidden] { display: none; }
.notif-panel__head {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: var(--s-2);
  padding: var(--s-3) var(--s-3) var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.notif-panel__title {
  margin-right: auto;
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-tight);
}
.notif-panel__count {
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: var(--r-full);
  background: var(--brand-soft);
  color: var(--brand-active);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
  vertical-align: 2px;
}
.notif-panel__body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.notif-panel__foot {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: var(--s-2) var(--s-3);
}
.notif-panel__all {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: var(--r-md);
  color: var(--brand-active);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
}
.notif-panel__all:hover { background: var(--brand-soft); }
.notif-panel__empty {
  padding: var(--s-8) var(--s-4);
  text-align: center;
  font-size: var(--fs-sm);
  color: var(--ink-muted);
}
.notif-section {
  padding: 8px var(--s-4) 6px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink-muted);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
}
.notif-item {
  position: relative;
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: start;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 12px var(--s-4) 12px calc(var(--s-4) + 3px);
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  font: inherit;
  cursor: pointer;
}
.notif-item:hover { background: var(--bg-subtle); }
.notif-item:last-child { border-bottom: 0; }
.notif-item.is-unread {
  background: color-mix(in srgb, var(--brand-soft) 45%, var(--surface));
}
.notif-item.is-unread::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--brand);
}
.notif-item.is-unread .notif-item__title {
  color: var(--ink);
  font-weight: var(--fw-semibold);
}
.notif-item.is-read .notif-item__title { color: var(--ink-secondary); }
.notif-item.is-read .feed-item__icon { opacity: 0.72; }
.notif-item__body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.notif-item__title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--ink);
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  line-height: 1.32;
}
.notif-item__time {
  font-size: var(--fs-xs);
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}
.notif-item__amount {
  align-self: center;
  flex-shrink: 0;
}
.feed-item__icon {
  width: 28px; height: 28px;
  border-radius: var(--r-full);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.feed-item__icon svg { width: 14px; height: 14px; }
.feed-item__icon--payment  { background: var(--success-soft); color: var(--success-ink); }
.feed-item__icon--refund   { background: var(--danger-soft);  color: var(--danger-ink); }
.feed-item__icon--sick     { background: var(--info-soft);    color: var(--info-ink); }
.feed-item__icon--freeze   { background: var(--warning-soft); color: var(--warning-ink); }
.feed-item__icon--transfer { background: var(--line-soft);    color: var(--ink-secondary); }
.feed-item__icon--charge   { background: var(--bg-subtle);    color: var(--ink-muted); border: 1px dashed var(--line-strong); }
.feed-item__icon--praise { background: var(--brand-soft); color: var(--brand-active); }

@media (max-width: 768px) {
  .notif-panel {
    position: fixed;
    inset: 0;
    width: auto;
    max-width: none;
    max-height: none;
    border: 0;
    border-radius: 0;
    z-index: 120;
  }
  .notif-panel .btn--sm { min-height: 36px; }
  .notif-panel__head {
    padding-top: max(var(--s-4), calc(env(safe-area-inset-top) + var(--s-2)));
  }
  .notif-panel__body { flex: 1; }
}

.content { padding: var(--s-6) var(--s-8); flex: 1; min-width: 0; }
.content--bleed { padding: 0; }
.page-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  padding-bottom: var(--s-5);
  gap: var(--s-6);
}
.page-header__title { font-size: var(--fs-3xl); font-weight: var(--fw-semibold); letter-spacing: var(--ls-tight); }
.page-header__sub { color: var(--ink-secondary); margin-top: 4px; font-size: var(--fs-md); }
.page-header__actions { display: flex; gap: var(--s-2); }

/* -------------------------------------------------------------------------
   Button
   ------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 14px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
  user-select: none;
}
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.btn:focus-visible { outline: none; box-shadow: var(--sh-focus); }

.btn--primary { background: var(--brand); color: white; border-color: var(--brand); }
.btn--primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn--primary:active { background: var(--brand-active); border-color: var(--brand-active); }

.btn--secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn--secondary:hover { background: var(--bg-subtle); border-color: var(--line-strong); }

.btn--ghost { background: transparent; color: var(--ink); }
.btn--ghost:hover { background: var(--line-soft); }

.btn--danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn--danger:hover { background: #991b1b; border-color: #991b1b; }

.btn--danger-ghost { background: transparent; color: var(--danger); }
.btn--danger-ghost:hover { background: var(--danger-soft); }

.btn--sm  { height: 28px; padding: 0 10px; font-size: var(--fs-sm); }
.btn--lg  { height: 40px; padding: 0 18px; font-size: var(--fs-md); }
.btn--icon { width: 32px; padding: 0; }
.btn--icon.btn--sm { width: 28px; }
.btn--block { width: 100%; }
.btn[disabled], .btn.is-disabled { opacity: 0.55; cursor: not-allowed; }

.btn-group {
  display: inline-flex;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--r-md);
  overflow: hidden;
  padding: 2px;
  gap: 0;
}
.btn-group .btn-seg {
  height: 26px;
  padding: 0 12px;
  border: none;
  background: transparent;
  color: var(--ink-secondary);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}
.btn-group .btn-seg:hover { color: var(--ink); }
.btn-group .btn-seg.is-active { background: var(--ink); color: white; }

/* -------------------------------------------------------------------------
   Input / Field
   ------------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 4px; }
.field__label { font-size: var(--fs-xs); font-weight: var(--fw-medium); color: var(--ink-secondary); letter-spacing: var(--ls-wide); text-transform: uppercase; }
.field__hint  { font-size: var(--fs-xs); color: var(--ink-muted); }
.field__error { font-size: var(--fs-xs); color: var(--danger); }

.input,
.select,
.textarea {
  height: 32px;
  padding: 0 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--ink);
  font-family: inherit;
  font-size: var(--fs-base);
  line-height: 1;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  width: 100%;
}
.textarea { height: auto; padding: 8px 10px; line-height: 1.45; min-height: 64px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--ink-muted); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--line-strong); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: var(--sh-focus);
}
.input--with-icon { padding-left: 30px; }
.input-wrap { position: relative; }
.input-wrap__icon { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--ink-muted); pointer-events: none; }

/* Checkbox */
.checkbox { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-size: var(--fs-base); }
.checkbox__box {
  width: 16px; height: 16px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  background: var(--surface);
  transition: all var(--t-fast);
}
.checkbox__box svg { width: 11px; height: 11px; color: white; opacity: 0; transform: scale(0.6); transition: all var(--t-fast); }
.checkbox.is-checked .checkbox__box { background: var(--brand); border-color: var(--brand); }
.checkbox.is-checked .checkbox__box svg { opacity: 1; transform: scale(1); }

/* Radio (segmented inside chip) */
.radio { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.radio__dot {
  width: 16px; height: 16px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r-full);
  background: var(--surface);
  position: relative;
}
.radio.is-checked .radio__dot { border-color: var(--brand); }
.radio.is-checked .radio__dot::after {
  content:''; position: absolute; inset: 3px; border-radius: var(--r-full); background: var(--brand);
}

/* Switch */
.switch { width: 28px; height: 16px; background: var(--line-strong); border-radius: var(--r-full); position: relative; cursor: pointer; transition: background var(--t-fast); }
.switch::after { content:''; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; background: white; border-radius: var(--r-full); box-shadow: var(--sh-sm); transition: transform var(--t-fast); }
.switch.is-on { background: var(--brand); }
.switch.is-on::after { transform: translateX(12px); }

/* -------------------------------------------------------------------------
   Card
   ------------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.card--flat   { box-shadow: none; }
.card--raised { box-shadow: var(--sh-sm); }
.card--xl     { border-radius: var(--r-xl); }
.card__header { padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.card__title  { font-size: var(--fs-md); font-weight: var(--fw-semibold); }
.card__body   { padding: var(--s-5); }
.card__footer { padding: var(--s-3) var(--s-5); border-top: 1px solid var(--line); background: var(--bg-subtle); display: flex; align-items: center; justify-content: flex-end; gap: var(--s-2); }

/* -------------------------------------------------------------------------
   Badge
   ------------------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 18px;
  padding: 0 6px;
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-wide);
  line-height: 1;
  white-space: nowrap;
}
.badge svg { width: 10px; height: 10px; }
.badge--neutral { background: var(--line-soft); color: var(--ink-secondary); }
.badge--brand   { background: var(--brand-soft); color: var(--brand-active); }
.badge--success { background: var(--success-soft); color: var(--success-ink); }
.badge--warning { background: var(--warning-soft); color: var(--warning-ink); }
.badge--danger  { background: var(--danger-soft); color: var(--danger-ink); }
.badge--info    { background: var(--info-soft);   color: var(--info-ink); }
.badge--dot { padding-left: 4px; }
.badge--dot::before { content:''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.7; }
.badge--lg { height: 22px; padding: 0 8px; font-size: var(--fs-sm); }

/* -------------------------------------------------------------------------
   Chip (filter / selectable)
   ------------------------------------------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--r-full);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--ink-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--t-fast);
}
.chip:hover { border-color: var(--line-strong); color: var(--ink); }
.chip.is-active { background: var(--ink); color: white; border-color: var(--ink); }
.chip__swatch { width: 8px; height: 8px; border-radius: 50%; }
.chip__close {
  width: 14px; height: 14px;
  border-radius: 50%;
  display: grid; place-items: center;
  opacity: 0.55;
}
.chip__close:hover { opacity: 1; }
.chip__count { padding: 0 6px; height: 16px; border-radius: var(--r-full); background: var(--line-soft); color: var(--ink-muted); font-size: 10px; font-weight: var(--fw-semibold); display: inline-grid; place-items: center; }
.chip.is-active .chip__count { background: rgba(255,255,255,0.18); color: white; }

/* -------------------------------------------------------------------------
   Group pill (specific to occurrence/lesson visual)
   ------------------------------------------------------------------------- */
.gpill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 1px 8px 1px 6px;
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0;
  text-transform: none;
  line-height: 1.6;
}
.gpill::before { content:''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.g-malyshi { background: var(--g-malyshi-tint); color: var(--g-malyshi-ink); }
.g-junior  { background: var(--g-junior-tint);  color: var(--g-junior-ink); }
.g-middle  { background: var(--g-middle-tint);  color: var(--g-middle-ink); }
.g-senior  { background: var(--g-senior-tint);  color: var(--g-senior-ink); }
.g-teen    { background: var(--g-teen-tint);    color: var(--g-teen-ink); }

/* -------------------------------------------------------------------------
   List (rows with avatar + meta + actions)
   ------------------------------------------------------------------------- */
.list { display: flex; flex-direction: column; }
.list__item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--s-3);
  padding: 10px var(--s-4);
  border-bottom: 1px solid var(--line-soft);
}
.list__item:last-child { border-bottom: none; }
.list__item:hover { background: var(--bg-subtle); }
.list__item--compact { padding: 6px var(--s-3); }
.avatar {
  width: 32px; height: 32px;
  border-radius: var(--r-full);
  background: var(--bg-app);
  color: var(--ink-secondary);
  display: grid; place-items: center;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  flex-shrink: 0;
  border: 1px solid var(--line);
}
.avatar--sm { width: 24px; height: 24px; font-size: 10px; }
.avatar--lg { width: 40px; height: 40px; font-size: var(--fs-md); }
.avatar--brand { background: var(--brand-soft); color: var(--brand-active); border-color: var(--brand-soft-2); }
.avatar--ink   { background: var(--ink); color: white; border-color: var(--ink); }

.row-meta { min-width: 0; }
.row-meta__title { font-size: var(--fs-md); font-weight: var(--fw-medium); color: var(--ink); }
.row-meta__sub   { font-size: var(--fs-sm); color: var(--ink-muted); margin-top: 2px; }
.row-actions { display: flex; align-items: center; gap: var(--s-2); }

/* -------------------------------------------------------------------------
   Empty state
   ------------------------------------------------------------------------- */
.empty {
  padding: var(--s-10) var(--s-6);
  text-align: center;
  color: var(--ink-secondary);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-lg);
  background: var(--bg-subtle);
}
.empty__title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); color: var(--ink); margin-bottom: 4px; }
.empty__body  { font-size: var(--fs-md); color: var(--ink-muted); max-width: 360px; margin: 0 auto var(--s-4); }

/* -------------------------------------------------------------------------
   Loading: skeleton + spinner
   ------------------------------------------------------------------------- */
.skel {
  display: block;
  background: linear-gradient(90deg, var(--line-soft) 0%, var(--line) 50%, var(--line-soft) 100%);
  background-size: 200% 100%;
  animation: skel-pulse 1.4s ease-in-out infinite;
  border-radius: var(--r-sm);
}
.skel--line { height: 10px; }
.skel--text { height: 12px; width: 80%; }
.skel--block { height: 64px; }
@keyframes skel-pulse {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* -------------------------------------------------------------------------
   Modal + Drawer
   ------------------------------------------------------------------------- */
.scrim {
  position: fixed; inset: 0;
  background: rgba(20, 20, 18, 0.32);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-slow) var(--ease);
}
.scrim.is-open { opacity: 1; pointer-events: auto; }

.modal {
  position: fixed; left: 50%; top: 50%;
  transform: translate(-50%, -48%);
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-xl);
  width: min(520px, calc(100vw - 32px));
  max-height: 80vh;
  display: flex; flex-direction: column;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-slow) var(--ease), transform var(--t-slow) var(--ease);
}
.modal.is-open { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%); }
.modal__header { padding: var(--s-5) var(--s-5) 0; }
.modal__title { font-size: var(--fs-xl); font-weight: var(--fw-semibold); }
.modal__sub   { color: var(--ink-secondary); margin-top: 4px; }
.modal__body  { padding: var(--s-4) var(--s-5); overflow: auto; }
.modal__footer { padding: var(--s-3) var(--s-5); border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: var(--s-2); background: var(--bg-subtle); border-radius: 0 0 var(--r-xl) var(--r-xl); }
.modal__close { position: absolute; right: 12px; top: 12px; }

.drawer {
  position: fixed; right: 0; top: 0; bottom: 0;
  width: var(--drawer-w);
  background: var(--surface);
  box-shadow: var(--sh-lg);
  z-index: 100;
  transform: translateX(100%);
  transition: transform var(--t-slow) var(--ease);
  display: flex; flex-direction: column;
  border-left: 1px solid var(--line);
}
.drawer.is-open { transform: translateX(0); }
.drawer__head {
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--s-3);
}
.drawer__title { font-size: var(--fs-xl); font-weight: var(--fw-semibold); line-height: var(--lh-tight); }
.drawer__sub   { font-size: var(--fs-sm); color: var(--ink-muted); margin-top: 4px; }
.drawer__close {
  width: 28px; height: 28px; border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--surface);
  display: grid; place-items: center;
  cursor: pointer;
  color: var(--ink-secondary);
}
.drawer__close:hover { background: var(--bg-subtle); color: var(--ink); }
.drawer__body { flex: 1; overflow: auto; }
.drawer__section { padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--line-soft); }
.drawer__section h4 { font-size: var(--fs-xs); color: var(--ink-muted); letter-spacing: var(--ls-wider); text-transform: uppercase; font-weight: var(--fw-semibold); margin-bottom: var(--s-3); }
.drawer__foot {
  padding: var(--s-3) var(--s-5);
  border-top: 1px solid var(--line);
  background: var(--bg-subtle);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-2);
}

/* -------------------------------------------------------------------------
   Misc utilities
   ------------------------------------------------------------------------- */
.stack { display: flex; flex-direction: column; }
.stack-2 > * + * { margin-top: var(--s-2); }
.stack-3 > * + * { margin-top: var(--s-3); }
.stack-4 > * + * { margin-top: var(--s-4); }
.stack-5 > * + * { margin-top: var(--s-5); }
.row { display: flex; align-items: center; }
.row-gap-2 { gap: var(--s-2); }
.row-gap-3 { gap: var(--s-3); }
.row-gap-4 { gap: var(--s-4); }
.row-gap-6 { gap: var(--s-6); }
.grow { flex: 1; }
.divider { height: 1px; background: var(--line); margin: var(--s-4) 0; }
.kbd {
  display: inline-grid; place-items: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: var(--r-sm);
  background: var(--surface);
  font-family: var(--font-num);
  font-size: 10px;
  font-weight: var(--fw-semibold);
  color: var(--ink-secondary);
}

/* -------------------------------------------------------------------------
   Hamburger (mobile sidebar trigger)
   ------------------------------------------------------------------------- */
.topbar__hamburger {
  display: none;
  width: 32px; height: 32px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--r-md);
  cursor: pointer;
  align-items: center; justify-content: center;
  color: var(--ink);
}
.topbar__hamburger svg { width: 16px; height: 16px; }
.sidebar-scrim {
  display: none;
  position: fixed; inset: 0;
  background: rgba(20,20,18,0.35);
  z-index: 92;
  opacity: 0;
  transition: opacity var(--t-slow) var(--ease);
}
.sidebar-scrim.is-open { display: block; opacity: 1; }

/* -------------------------------------------------------------------------
   PWA install prompt
   ------------------------------------------------------------------------- */
.inst-root {
  position: fixed;
  inset: 0;
  z-index: 140;
  pointer-events: none;
}
.inst-root.is-open { pointer-events: auto; }
.inst-scrim {
  position: absolute;
  inset: 0;
  background: rgba(20, 20, 18, 0.42);
  opacity: 0;
  transition: opacity var(--t-slow) var(--ease);
}
.inst-root.is-open .inst-scrim { opacity: 1; }
.inst-sheet {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: min(420px, 100vw);
  transform: translate(-50%, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--sh-xl);
  padding: var(--s-4);
  padding-bottom: max(var(--s-4), env(safe-area-inset-bottom));
  transition: transform var(--t-slow) var(--ease);
}
.inst-root.is-open .inst-sheet { transform: translate(-50%, 0); }
.inst-sheet__grip {
  width: 38px;
  height: 4px;
  border-radius: var(--r-full);
  background: var(--line-strong);
  margin: 0 auto var(--s-4);
}
.inst-sheet__close {
  position: absolute;
  top: var(--s-3);
  right: var(--s-3);
}
.inst-sheet__close svg,
.inst-sheet .btn svg,
.inst-val__ic svg,
.inst-step__glyph svg { width: 18px; height: 18px; }
.inst-sheet__head {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding-right: 38px;
}
.inst-sheet__logo {
  width: 48px;
  height: 48px;
  border-radius: var(--r-lg);
  flex-shrink: 0;
  box-shadow: 0 8px 20px -12px rgba(197, 62, 45, 0.7);
}
.inst-sheet__title {
  font-size: var(--fs-xl);
  line-height: var(--lh-tight);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-tight);
}
.inst-sheet__sub {
  margin-top: 3px;
  color: var(--ink-muted);
  font-size: var(--fs-sm);
}
.inst-sheet__body { padding: var(--s-5) 0 var(--s-4); }
.inst-vals {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
.inst-val {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: var(--s-3);
  align-items: center;
}
.inst-val__ic,
.inst-step__glyph {
  width: 34px;
  height: 34px;
  border-radius: var(--r-full);
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand-active);
}
.inst-val__t,
.inst-step__txt {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--ink);
}
.inst-val__d {
  margin-top: 2px;
  font-size: var(--fs-xs);
  color: var(--ink-muted);
}
.inst-steps {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
.inst-step {
  display: grid;
  grid-template-columns: 26px 1fr 34px;
  align-items: center;
  gap: var(--s-3);
}
.inst-step__n {
  width: 26px;
  height: 26px;
  border-radius: var(--r-full);
  display: grid;
  place-items: center;
  background: var(--bg-subtle);
  color: var(--ink-secondary);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
}
.inst-step__glyph--ink {
  background: var(--bg-subtle);
  color: var(--ink);
}
.inst-step__glyph--ok {
  background: var(--success-soft);
  color: var(--success-ink);
}
.inst-note {
  margin-top: var(--s-4);
  padding: var(--s-3);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
  color: var(--ink-secondary);
  font-size: var(--fs-sm);
  line-height: var(--lh-normal);
}
.inst-sheet__foot {
  display: flex;
  gap: var(--s-2);
}
.inst-sheet__foot .btn--primary { flex: 1; }

@media (min-width: 769px) {
  .inst-root { inset: var(--header-h) var(--s-5) auto auto; }
  .inst-scrim { display: none; }
  .inst-sheet {
    position: relative;
    left: auto;
    bottom: auto;
    width: 360px;
    transform: translateY(-8px);
    border-radius: var(--r-xl);
    opacity: 0;
  }
  .inst-root.is-open .inst-sheet {
    transform: translateY(0);
    opacity: 1;
  }
  .inst-sheet__grip { display: none; }
}

/* =========================================================================
   RESPONSIVE
   ========================================================================= */

/* Tablet & narrow desktop: collapse sidebar to off-canvas, simpler split layouts */
@media (max-width: 1024px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: 240px;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform var(--t-slow) var(--ease);
    z-index: 95;
  }
  .sidebar.is-open { transform: translateX(0); box-shadow: var(--sh-xl); }
  .topbar__hamburger { display: inline-grid; }
  .content { padding: var(--s-5); }
  .page-header { flex-direction: column; align-items: flex-start; gap: var(--s-3); }
}

/* Mobile: stacked everything, full-screen drawer, sparse topbar */
@media (max-width: 768px) {
  :root { --header-h: 52px; --drawer-w: 100vw; }
  .topbar { padding: 0 var(--s-3); gap: var(--s-2); }
  .topbar__left { gap: var(--s-2); min-width: 0; flex: 1; }
  .topbar__right { gap: 4px; }
  .topbar__search { display: none; }
  .topbar__title {
    font-size: var(--fs-xl);
    line-height: var(--lh-tight);
    letter-spacing: var(--ls-tight);
  }
  .topbar__breadcrumb { display: none; }
  .user-chip { padding: 4px; }
  .user-chip__name, .user-chip__role { display: none; }
  .content { padding: var(--s-3); }
  .modal { width: calc(100vw - 16px); border-radius: var(--r-lg); }
  .drawer { width: 100vw !important; border-left: none; }
  .drawer__hero, .drawer__section { padding-left: var(--s-4); padding-right: var(--s-4); }
  .drawer__foot { padding-left: var(--s-4); padding-right: var(--s-4); flex-wrap: wrap; }
  .card__header, .card__body, .card__footer { padding-left: var(--s-4); padding-right: var(--s-4); }
}

@media (max-width: 480px) {
  .btn--lg { height: 36px; }
  .topbar__title { font-size: var(--fs-xl); }
  /* Single-column for attendance row on tiny screens */
  .row-meta__sub { font-size: 11px; }
}
