/* Reusable components */

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  --btn-border: var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px;
  border-radius: var(--r-sm);
  background: var(--btn-bg); color: var(--btn-fg);
  border: 1px solid var(--btn-border);
  font-weight: 600; font-size: var(--fs-base); line-height: 1;
  white-space: nowrap;
  box-shadow: var(--shadow-xs);
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
  user-select: none;
}
.btn:hover { text-decoration: none; background: var(--surface-hover); }
.btn:active:not(:disabled) { transform: translateY(1px) scale(0.985); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }
.btn:disabled, .btn[aria-disabled='true'] { opacity: 0.5; cursor: not-allowed; }
.btn .icon { color: currentColor; }

.btn--primary { --btn-bg: var(--primary); --btn-fg: var(--on-primary); --btn-border: var(--primary); box-shadow: 0 1px 2px rgba(79, 70, 229, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.12); }
.btn--primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn--dark { --btn-bg: var(--navy-800); --btn-fg: #fff; --btn-border: var(--navy-800); }
.btn--dark:hover { background: var(--navy-700); }
.btn--soft { --btn-bg: var(--primary-soft); --btn-fg: var(--primary-text); --btn-border: transparent; box-shadow: none; }
.btn--soft:hover { background: var(--primary-soft-2); }
.btn--ghost { --btn-bg: transparent; --btn-border: transparent; box-shadow: none; color: var(--text-2); }
.btn--ghost:hover { background: var(--surface-hover); color: var(--text); }
.btn--danger { --btn-bg: var(--error); --btn-fg: #fff; --btn-border: var(--error); }
.btn--danger:hover { background: #B91C1C; }
.btn--success { --btn-bg: var(--success); --btn-fg: #fff; --btn-border: var(--success); }
.btn--success:hover { background: #15803D; }
.btn--danger-soft { --btn-bg: var(--error-soft); --btn-fg: var(--error-text); --btn-border: transparent; box-shadow: none; }
.btn--glass { --btn-bg: rgba(255, 255, 255, 0.12); --btn-fg: #fff; --btn-border: rgba(255, 255, 255, 0.22); box-shadow: none; backdrop-filter: blur(6px); }
.btn--glass:hover { background: rgba(255, 255, 255, 0.2); }
.btn--white { --btn-bg: #fff; --btn-fg: var(--navy-800); --btn-border: #fff; }
.btn--white:hover { background: #EEF0FF; }
.btn--sm { height: 32px; padding: 0 12px; font-size: var(--fs-sm); gap: 6px; }
.btn--lg { height: 48px; padding: 0 22px; font-size: var(--fs-md); border-radius: var(--r-md); }
.btn--block { width: 100%; }
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--btn-fg) transparent var(--btn-fg) var(--btn-fg);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  position: relative;
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: var(--r-sm);
  color: var(--text-2);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn--bordered { border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-xs); }
.icon-btn--sm { width: 32px; height: 32px; }
.icon-btn[aria-expanded='true'] { background: var(--primary-soft); color: var(--primary); }
.icon-btn__dot {
  position: absolute; top: 8px; right: 9px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--error); box-shadow: 0 0 0 2px var(--bg);
}

.link-btn { color: var(--primary); font-weight: 600; font-size: var(--fs-sm); display: inline-flex; align-items: center; gap: 4px; }
.link-btn:hover { text-decoration: underline; text-underline-offset: 2px; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4) var(--sp-4); }
.form-grid .span-2 { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field__label { font-size: var(--fs-sm); font-weight: 600; color: var(--text); }
.field__label .req { color: var(--error); margin-left: 2px; }
.field__hint { font-size: var(--fs-xs); color: var(--text-3); }
.field__error { font-size: var(--fs-xs); color: var(--error-text); font-weight: 500; display: flex; gap: 4px; align-items: center; }
.field__error:empty { display: none; }

.input, .select, .textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: var(--fs-base);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--text-4); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-4); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.input[aria-invalid='true'], .select[aria-invalid='true'], .textarea[aria-invalid='true'] { border-color: var(--error); }
.input[aria-invalid='true']:focus { box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2); }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--surface-sunken); color: var(--text-3); cursor: not-allowed; }
.textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.select {
  appearance: none; -webkit-appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.select--sm, .input--sm { min-height: 34px; height: 34px; padding-top: 5px; padding-bottom: 5px; font-size: var(--fs-sm); }

.input-icon { position: relative; }
.input-icon > .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-4); pointer-events: none; }
.input-icon > .input { padding-left: 38px; }
.kbd {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font-size: 11px; font-weight: 600; color: var(--text-3);
  border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; background: var(--surface-2);
}

.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: var(--fs-base); }
.check input {
  appearance: none; -webkit-appearance: none; flex: none;
  width: 18px; height: 18px; margin: 2px 0 0; border-radius: 5px;
  border: 1.5px solid var(--border-strong); background: var(--surface);
  display: grid; place-items: center; cursor: pointer;
  transition: background var(--dur-fast), border-color var(--dur-fast);
}
.check input:checked { background: var(--primary); border-color: var(--primary); }
.check input:checked::after {
  content: ''; width: 10px; height: 6px; border: 2px solid #fff; border-top: 0; border-right: 0;
  transform: rotate(-45deg) translate(1px, -1px);
}
.check input:focus-visible { box-shadow: var(--ring); outline: none; }
.check input[aria-invalid='true'] { border-color: var(--error); }

.switch { position: relative; display: inline-flex; align-items: center; gap: 12px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch__track {
  width: 40px; height: 24px; border-radius: var(--r-full); background: var(--border-strong); flex: none;
  position: relative; transition: background var(--dur) var(--ease);
}
.switch__track::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow-sm); transition: transform var(--dur) var(--ease);
}
.switch input:checked + .switch__track { background: var(--primary); }
.switch input:checked + .switch__track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch__track { box-shadow: var(--ring); }

.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  padding: var(--sp-5); border: 1.5px dashed var(--border-strong); border-radius: var(--r-md);
  background: var(--surface-2); color: var(--text-3); cursor: pointer;
  transition: border-color var(--dur-fast), background var(--dur-fast);
  position: relative;
}
.dropzone:hover, .dropzone.is-drag { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-text); }
.dropzone input[type='file'] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone:focus-within { box-shadow: var(--ring); border-color: var(--primary); }
.dropzone__title { font-weight: 600; color: var(--text); font-size: var(--fs-sm); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
  min-width: 0;
}
.card--pad { padding: var(--sp-5); }
.card--hover { transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease), border-color var(--dur) var(--ease); }
.card--hover:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: var(--border-strong); }
.card__head {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
  min-height: 60px;
}
.card__head--flush { border-bottom: 0; padding-bottom: 0; }
.card__title { font-size: var(--fs-md); font-weight: 700; letter-spacing: -0.01em; }
.card__sub { font-size: var(--fs-xs); color: var(--text-3); margin-top: 2px; }
.card__body { padding: var(--sp-5); }
.card__body--flush { padding: 0; }
.card__foot { padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--border); display: flex; align-items: center; gap: var(--sp-2); }

/* KPI */
.kpi { padding: var(--sp-4) var(--sp-5); display: flex; flex-direction: column; gap: 10px; position: relative; overflow: hidden; }
.kpi__top { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.kpi__label { font-size: var(--fs-sm); color: var(--text-2); font-weight: 500; }
.kpi__icon { width: 34px; height: 34px; border-radius: var(--r-sm); display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.kpi__icon--teal { background: var(--accent-soft); color: var(--accent-text); }
.kpi__icon--amber { background: var(--warning-soft); color: var(--warning-text); }
.kpi__icon--rose { background: var(--error-soft); color: var(--error-text); }
.kpi__icon--blue { background: var(--info-soft); color: var(--info-text); }
.kpi__icon--violet { background: var(--cat-cultural-soft); color: var(--cat-cultural); }
.kpi__value { font-family: var(--font-display); font-size: 28px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi__value small { font-size: var(--fs-md); font-weight: 600; color: var(--text-3); letter-spacing: 0; margin-left: 2px; }
.kpi__meta { font-size: var(--fs-xs); color: var(--text-3); display: flex; align-items: center; gap: 6px; }
a.kpi { color: inherit; }
a.kpi:hover { text-decoration: none; }

/* ---------- Badges & pills ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px;
  border-radius: var(--r-full);
  font-size: var(--fs-xs); font-weight: 600; line-height: 1;
  white-space: nowrap;
  background: var(--neutral-soft); color: var(--neutral-text);
  border: 1px solid var(--neutral-border);
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.badge--plain::before { display: none; }
.badge--success { background: var(--success-soft); color: var(--success-text); border-color: var(--success-border); }
.badge--warning { background: var(--warning-soft); color: var(--warning-text); border-color: var(--warning-border); }
.badge--error { background: var(--error-soft); color: var(--error-text); border-color: var(--error-border); }
.badge--info { background: var(--info-soft); color: var(--info-text); border-color: var(--info-border); }
.badge--primary { background: var(--primary-soft); color: var(--primary-text); border-color: transparent; }
.badge--teal { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }

.tag {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px;
  border-radius: var(--r-xs); font-size: var(--fs-xs); font-weight: 600;
  background: var(--surface-sunken); color: var(--text-2);
}
.cat-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--c, var(--cat-general)); }
.cat-tag { background: var(--cs, var(--cat-general-soft)); color: var(--c, var(--cat-general)); }

/* Category color hooks */
[data-cat='academic'] { --c: var(--cat-academic); --cs: var(--cat-academic-soft); }
[data-cat='sports'] { --c: var(--cat-sports); --cs: var(--cat-sports-soft); }
[data-cat='cultural'] { --c: var(--cat-cultural); --cs: var(--cat-cultural-soft); }
[data-cat='examination'] { --c: var(--cat-exam); --cs: var(--cat-exam-soft); }
[data-cat='holiday'] { --c: var(--cat-holiday); --cs: var(--cat-holiday-soft); }
[data-cat='meeting'] { --c: var(--cat-meeting); --cs: var(--cat-meeting-soft); }
[data-cat='announcement'] { --c: var(--cat-general); --cs: var(--cat-general-soft); }

/* ---------- Avatar ---------- */
.avatar {
  --size: 36px;
  width: var(--size); height: var(--size); flex: none;
  border-radius: 50%;
  display: inline-grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: calc(var(--size) * 0.36);
  color: var(--av-fg, #3730A3); background: var(--av-bg, #E0E3FF);
  letter-spacing: 0;
}
.avatar--sm { --size: 28px; }
.avatar--lg { --size: 48px; }
.avatar--xl { --size: 72px; }
.avatar--sq { border-radius: var(--r-md); }

/* ---------- Tables & lists ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { font-size: var(--fs-sm); }
.table th {
  text-align: left; font-weight: 600; font-size: var(--fs-xs); color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.04em;
  padding: 10px var(--sp-4); background: var(--surface-2);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table th:first-child, .table td:first-child { padding-left: var(--sp-5); }
.table th:last-child, .table td:last-child { padding-right: var(--sp-5); }
.table td { padding: 12px var(--sp-4); border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { transition: background var(--dur-fast); }
.table tbody tr:hover { background: var(--surface-hover); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .is-right { text-align: right; }
.th-sort { display: inline-flex; align-items: center; gap: 4px; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; }
.th-sort:hover { color: var(--text); }
.th-sort[aria-sort] .icon { opacity: 1; }
.th-sort .icon { opacity: 0.4; }
tr.is-clickable { cursor: pointer; }

.list-row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 12px var(--sp-5);
  border-bottom: 1px solid var(--border);
  min-width: 0;
  color: inherit;
  transition: background var(--dur-fast);
}
.list-row:last-child { border-bottom: 0; }
a.list-row:hover, button.list-row:hover { background: var(--surface-hover); text-decoration: none; }
button.list-row { width: 100%; text-align: left; }
.list-row__title { font-weight: 600; font-size: var(--fs-sm); line-height: 1.35; }
.list-row__meta { font-size: var(--fs-xs); color: var(--text-3); }
.list-row__aside { margin-left: auto; display: flex; align-items: center; gap: var(--sp-2); flex: none; }

/* Responsive table → cards on small screens */
@media (max-width: 767px) {
  .table--stack thead { display: none; }
  .table--stack, .table--stack tbody, .table--stack tr, .table--stack td { display: block; width: 100%; }
  .table--stack tr { padding: 12px var(--sp-4); border-bottom: 1px solid var(--border); }
  .table--stack tr:last-child { border-bottom: 0; }
  .table--stack td { border: 0; padding: 3px 0 !important; display: flex; justify-content: space-between; gap: var(--sp-3); text-align: right; }
  .table--stack td::before { content: attr(data-label); color: var(--text-3); font-size: var(--fs-xs); font-weight: 500; text-align: left; flex: none; }
  .table--stack td[data-label=''] ::before, .table--stack td.td-primary::before { display: none; }
  .table--stack td.td-primary { text-align: left; justify-content: flex-start; padding-bottom: 6px !important; }
  .table--stack td.is-right { justify-content: space-between; }
}

/* ---------- Tabs / segmented ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative; padding: 10px 14px; font-weight: 600; font-size: var(--fs-sm); color: var(--text-3);
  white-space: nowrap; display: inline-flex; align-items: center; gap: 8px;
}
.tab:hover { color: var(--text); }
.tab[aria-selected='true'] { color: var(--primary-text); }
.tab[aria-selected='true']::after { content: ''; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--primary); }
.tab__count { font-size: 11px; padding: 1px 7px; border-radius: var(--r-full); background: var(--surface-sunken); color: var(--text-2); font-variant-numeric: tabular-nums; }
.tab[aria-selected='true'] .tab__count { background: var(--primary-soft); color: var(--primary-text); }

.segmented {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-sunken); border: 1px solid var(--border); border-radius: var(--r-md);
  max-width: 100%; overflow-x: auto; scrollbar-width: none;
}
.segmented button {
  height: 32px; padding: 0 12px; border-radius: 7px; font-size: var(--fs-sm); font-weight: 600; color: var(--text-2);
  white-space: nowrap; display: inline-flex; align-items: center; gap: 6px;
  transition: background var(--dur-fast), color var(--dur-fast), box-shadow var(--dur-fast);
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed='true'], .segmented button[aria-selected='true'] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.chips { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: var(--r-full);
  border: 1px solid var(--border); background: var(--surface);
  font-size: var(--fs-sm); font-weight: 500; color: var(--text-2);
  transition: all var(--dur-fast) var(--ease);
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip[aria-pressed='true'] { background: var(--navy-800); border-color: var(--navy-800); color: #fff; }
[data-theme='dark'] .chip[aria-pressed='true'] { background: var(--primary); border-color: var(--primary); }
.chip[aria-pressed='true'] .cat-dot { box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.6); }

/* Toolbar */
.toolbar { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; padding: var(--sp-3) var(--sp-5); border-bottom: 1px solid var(--border); }
.toolbar .input-icon { flex: 1 1 220px; max-width: 320px; }
.toolbar .select { width: auto; min-width: 140px; }

/* ---------- Popover / dropdown ---------- */
.popover {
  position: absolute; z-index: 60;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  transform-origin: top right;
  animation: pop-in var(--dur) var(--ease) both;
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(0.98); } to { opacity: 1; transform: none; } }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border-radius: var(--r-sm);
  font-size: var(--fs-sm); font-weight: 500; color: var(--text); text-align: left;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-hover); text-decoration: none; outline: none; }
.menu-item .icon { color: var(--text-3); }
.menu-item--danger { color: var(--error-text); }
.menu-item--danger .icon { color: var(--error-text); }
.menu-sep { height: 1px; background: var(--border); margin: 6px 4px; }

/* ---------- Dialog / drawer / sheet ---------- */
.dlg {
  border: 0; padding: 0; margin: auto;
  width: min(560px, calc(100vw - 32px));
  max-height: min(88dvh, 860px);
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex; flex-direction: column;
}
.dlg:not([open]) { display: none; }
.dlg--lg { width: min(760px, calc(100vw - 32px)); }
.dlg--xl { width: min(980px, calc(100vw - 32px)); }
.dlg--sm { width: min(440px, calc(100vw - 32px)); }
.dlg::backdrop { background: var(--scrim); backdrop-filter: blur(2px); }
.dlg[open] { animation: dlg-in var(--dur-slow) var(--ease) both; }
.dlg[open]::backdrop { animation: fade-in var(--dur) var(--ease) both; }
.dlg.is-closing { animation: dlg-out var(--dur) var(--ease) both; }
@keyframes dlg-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes dlg-out { to { opacity: 0; transform: translateY(8px) scale(0.98); } }
@keyframes fade-in { from { opacity: 0; } }

.dlg__head { display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-5) var(--sp-6) var(--sp-4); border-bottom: 1px solid var(--border); }
.dlg__title { font-size: var(--fs-lg); font-weight: 700; }
.dlg__desc { color: var(--text-3); font-size: var(--fs-sm); margin-top: 4px; }
.dlg__close { margin: -6px -10px 0 auto; }
.dlg__body { padding: var(--sp-5) var(--sp-6); overflow-y: auto; flex: 1 1 auto; overscroll-behavior: contain; }
.dlg__foot {
  display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-2); flex-wrap: wrap;
  padding: var(--sp-4) var(--sp-6); border-top: 1px solid var(--border); background: var(--surface-2);
}
.dlg__foot .note { margin-right: auto; font-size: var(--fs-xs); color: var(--text-3); }

/* Drawer variant (right side panel) */
.dlg--drawer {
  margin: 0 0 0 auto; height: 100dvh; max-height: 100dvh;
  width: min(520px, 100vw); border-radius: var(--r-xl) 0 0 var(--r-xl);
}
.dlg--drawer[open] { animation: drawer-in var(--dur-slow) var(--ease) both; }
.dlg--drawer.is-closing { animation: drawer-out var(--dur) var(--ease) both; }
@keyframes drawer-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes drawer-out { to { transform: translateX(40px); opacity: 0; } }

.confirm-icon { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); flex: none; }
.confirm-icon--danger { background: var(--error-soft); color: var(--error-text); }
.confirm-icon--success { background: var(--success-soft); color: var(--success-text); }

/* ---------- Toast ---------- */
.toast-region {
  position: fixed; z-index: 1100; right: 20px; bottom: 20px;
  display: flex; flex-direction: column; gap: 10px; align-items: flex-end;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 10px;
  min-width: 280px; max-width: 400px;
  padding: 12px 14px;
  background: var(--navy-800); color: #fff;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-sm);
  animation: toast-in var(--dur-slow) var(--ease) both;
}
.toast.is-leaving { animation: toast-out var(--dur) var(--ease) both; }
.toast__icon { margin-top: 1px; }
.toast--success .toast__icon { color: #4ADE80; }
.toast--error .toast__icon { color: #F87171; }
.toast--warning .toast__icon { color: #FBBF24; }
.toast--info .toast__icon { color: #93C5FD; }
.toast__title { font-weight: 600; }
.toast__msg { color: rgba(255, 255, 255, 0.78); margin-top: 1px; }
.toast__close { margin-left: auto; color: rgba(255, 255, 255, 0.6); width: 24px; height: 24px; display: grid; place-items: center; border-radius: 6px; flex: none; }
.toast__close:hover { color: #fff; background: rgba(255, 255, 255, 0.1); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }

/* ---------- Empty / skeleton / progress ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--sp-2);
  padding: var(--sp-10) var(--sp-6);
  color: var(--text-3);
}
.empty__icon {
  width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; margin-bottom: var(--sp-2);
  background: var(--surface-sunken); color: var(--text-3);
  position: relative;
}
.empty__icon::after { content: ''; position: absolute; inset: -6px; border-radius: 20px; border: 1px dashed var(--border-strong); }
.empty__title { color: var(--text); font-weight: 700; font-family: var(--font-display); font-size: var(--fs-md); }
.empty__text { max-width: 40ch; font-size: var(--fs-sm); }
.empty .btn { margin-top: var(--sp-3); }
.empty--sm { padding: var(--sp-6) var(--sp-4); }

.skeleton {
  border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--surface-sunken) 0%, var(--surface-hover) 40%, var(--surface-sunken) 80%);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.progress { height: 8px; border-radius: var(--r-full); background: var(--surface-sunken); overflow: hidden; }
.progress__bar { height: 100%; border-radius: inherit; background: var(--primary); transition: width var(--dur-slow) var(--ease); }
.progress__bar--teal { background: var(--accent); }
.progress__bar--warning { background: var(--warning); }
.progress__bar--error { background: var(--error); }
.progress__bar--success { background: var(--success); }

/* Status legend dots (never color-only: always paired with text) */
.st { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: var(--fs-xs); }
.st__mark { width: 18px; height: 18px; border-radius: 5px; display: grid; place-items: center; font-size: 10px; font-weight: 800; color: #fff; flex: none; }
.st--present .st__mark { background: var(--success); }
.st--absent .st__mark { background: var(--error); }
.st--late .st__mark { background: var(--warning); }
.st--leave .st__mark { background: var(--info); }
.st--none .st__mark { background: var(--border-strong); }

/* Alert / callout */
.callout {
  display: flex; gap: var(--sp-3); align-items: flex-start;
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md);
  background: var(--info-soft); color: var(--info-text); border: 1px solid var(--info-border);
  font-size: var(--fs-sm);
}
.callout strong { color: inherit; }
.callout .icon { margin-top: 1px; }
.callout--warning { background: var(--warning-soft); color: var(--warning-text); border-color: var(--warning-border); }
.callout--neutral { background: var(--surface-2); color: var(--text-2); border-color: var(--border); }
.callout--success { background: var(--success-soft); color: var(--success-text); border-color: var(--success-border); }
.callout--error { background: var(--error-soft); color: var(--error-text); border-color: var(--error-border); }

/* Stepper */
.stepper { display: flex; gap: var(--sp-2); counter-reset: step; }
.step { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.step__bar { height: 4px; border-radius: var(--r-full); background: var(--border); position: relative; overflow: hidden; }
.step__bar::after { content: ''; position: absolute; inset: 0; background: var(--primary); transform: scaleX(0); transform-origin: left; transition: transform var(--dur-slow) var(--ease); }
.step.is-done .step__bar::after, .step.is-current .step__bar::after { transform: scaleX(1); }
.step.is-current .step__bar::after { background: linear-gradient(90deg, var(--primary), var(--violet-600)); }
.step__label { font-size: var(--fs-xs); font-weight: 600; color: var(--text-3); display: flex; gap: 6px; align-items: center; }
.step.is-current .step__label, .step.is-done .step__label { color: var(--text); }
.step__num { font-variant-numeric: tabular-nums; color: var(--text-4); }

/* Timeline */
.timeline { position: relative; padding-left: 4px; }
.tl-item { display: flex; gap: var(--sp-3); position: relative; padding-bottom: var(--sp-4); }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before { content: ''; position: absolute; left: 13px; top: 30px; bottom: 2px; width: 1px; background: var(--border); }
.tl-item:last-child::before { display: none; }
.tl-icon { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--surface-sunken); color: var(--text-2); border: 1px solid var(--border); }
.tl-text { font-size: var(--fs-sm); line-height: 1.45; padding-top: 3px; }
.tl-time { font-size: var(--fs-xs); color: var(--text-3); }

/* Media */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: var(--sp-2); }
.media-thumb {
  position: relative; aspect-ratio: 3 / 2; border-radius: var(--r-md); overflow: hidden;
  background: var(--surface-sunken); border: 1px solid var(--border);
}
.media-thumb img, .media-thumb video { width: 100%; height: 100%; object-fit: cover; }
.media-thumb__btn { position: absolute; inset: 0; width: 100%; height: 100%; }
.media-thumb__btn:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.media-thumb__play {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 40px; height: 40px; border-radius: 50%; background: rgba(11, 19, 40, 0.66); color: #fff;
  display: grid; place-items: center; pointer-events: none;
}
.media-thumb__remove { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 8px; background: rgba(11, 19, 40, 0.72); color: #fff; display: grid; place-items: center; }
.media-thumb__label { position: absolute; left: 6px; bottom: 6px; right: 6px; font-size: 11px; color: #fff; background: rgba(11, 19, 40, 0.6); padding: 2px 6px; border-radius: 5px; }
.media-thumb__missing { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 8px; font-size: 11px; color: var(--text-3); }

.lightbox {
  width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0;
  background: rgba(8, 12, 26, 0.94); border-radius: 0; color: #fff;
}
.lightbox .dlg__body { display: grid; place-items: center; padding: 64px 72px; position: relative; }
.lightbox__media { max-width: 100%; max-height: calc(100dvh - 160px); border-radius: var(--r-md); box-shadow: var(--shadow-lg); }
.lightbox__bar { display: flex; align-items: center; gap: var(--sp-3); padding: 16px 20px; position: absolute; top: 0; left: 0; right: 0; }
.lightbox__count { font-size: var(--fs-sm); color: rgba(255, 255, 255, 0.7); font-variant-numeric: tabular-nums; }
.lightbox__nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.1); color: #fff;
}
.lightbox__nav:hover { background: rgba(255, 255, 255, 0.2); }
.lightbox__nav--prev { left: 16px; }
.lightbox__nav--next { right: 16px; }
.lightbox .icon-btn { color: #fff; }
.lightbox .icon-btn:hover { background: rgba(255, 255, 255, 0.12); }

/* Description list */
.dl { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 10px var(--sp-4); font-size: var(--fs-sm); }
.dl dt { color: var(--text-3); }
.dl dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }

/* Section heading inside views */
.section-title { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-md); font-weight: 700; margin-bottom: var(--sp-3); }

/* Search results popover */
.search-results { left: 0; right: 0; top: calc(100% + 6px); max-height: 420px; overflow-y: auto; min-width: 320px; }
.search-group { padding: 6px 8px 2px; font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; }

/* Notification dropdown */
.notif-pop { width: 380px; right: 0; top: calc(100% + 8px); padding: 0; overflow: hidden; }
.notif-pop__head { display: flex; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.notif-pop__list { max-height: 420px; overflow-y: auto; }
.notif-pop__foot { border-top: 1px solid var(--border); padding: 8px; }

.notif {
  display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border);
  text-align: left; width: 100%; position: relative; color: inherit;
  transition: background var(--dur-fast);
}
.notif:hover { background: var(--surface-hover); text-decoration: none; }
.notif:last-child { border-bottom: 0; }
.notif.is-unread { background: color-mix(in srgb, var(--primary-soft) 55%, transparent); }
.notif.is-unread:hover { background: var(--primary-soft); }
.notif__icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--cs, var(--surface-sunken)); color: var(--c, var(--text-2)); }
.notif__title { font-weight: 600; font-size: var(--fs-sm); line-height: 1.35; }
.notif__body { font-size: var(--fs-sm); color: var(--text-2); margin-top: 2px; }
.notif__time { font-size: var(--fs-xs); color: var(--text-3); margin-top: 4px; display: flex; gap: 8px; align-items: center; }
.notif__unread-dot { position: absolute; right: 14px; top: 16px; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }

/* Notification type color hooks */
[data-ntype='fee'] { --c: var(--warning-text); --cs: var(--warning-soft); }
[data-ntype='absence'] { --c: var(--error-text); --cs: var(--error-soft); }
[data-ntype='leave'] { --c: var(--info-text); --cs: var(--info-soft); }
[data-ntype='homework'] { --c: var(--primary-text); --cs: var(--primary-soft); }
[data-ntype='activity'] { --c: var(--cat-cultural); --cs: var(--cat-cultural-soft); }
[data-ntype='event'] { --c: var(--accent-text); --cs: var(--accent-soft); }
[data-ntype='announcement'] { --c: var(--neutral-text); --cs: var(--neutral-soft); }
[data-ntype='admission'] { --c: var(--success-text); --cs: var(--success-soft); }
.toast-region[popover] { margin: 0; padding: 0; border: 0; background: transparent; overflow: visible; inset: auto 20px 20px auto; width: auto; height: auto; }


/* ---------- Glassmorphism icons ---------- */
.glass-ico { --g1: #818CF8; --g2: #4F46E5; --gi: #3730A3; --gv: #4F46E5; position: relative; display: inline-block; flex: none; width: var(--s); height: var(--s); }
.glass-ico--indigo { --g1: #A5B4FC; --g2: #6366F1; --gi: #3730A3; --gv: #4F46E5; }
.glass-ico--violet { --g1: #C4B5FD; --g2: #8B5CF6; --gi: #5B21B6; --gv: #7C3AED; }
.glass-ico--blue   { --g1: #93C5FD; --g2: #3B82F6; --gi: #1D4ED8; --gv: #2563EB; }
.glass-ico--teal   { --g1: #5EEAD4; --g2: #14B8A6; --gi: #0F766E; --gv: #0D9488; }
.glass-ico--green  { --g1: #86EFAC; --g2: #22C55E; --gi: #15803D; --gv: #16A34A; }
.glass-ico--amber  { --g1: #FCD34D; --g2: #F59E0B; --gi: #B45309; --gv: #D97706; }
.glass-ico--rose   { --g1: #FDA4AF; --g2: #F43F5E; --gi: #BE123C; --gv: #E11D48; }
.glass-ico--pink   { --g1: #F9A8D4; --g2: #EC4899; --gi: #BE185D; --gv: #DB2777; }
.glass-ico--slate  { --g1: #CBD5E1; --g2: #64748B; --gi: #334155; --gv: #475569; }
.glass-ico__back {
  position: absolute; top: 0; right: 0; width: 76%; height: 76%; border-radius: 32%;
  background: linear-gradient(140deg, var(--g1), var(--g2));
  box-shadow: 0 calc(var(--s) * 0.12) calc(var(--s) * 0.28) calc(var(--s) * -0.1) var(--g2);
  transform: rotate(14deg); transition: transform var(--dur) var(--ease);
}
.glass-ico__front {
  position: absolute; left: 0; bottom: 0; width: 80%; height: 80%; border-radius: 30%;
  display: grid; place-items: center; color: var(--gi);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0.14));
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.95), 0 6px 16px -6px rgba(20, 33, 61, 0.28);
  -webkit-backdrop-filter: blur(6px) saturate(180%); backdrop-filter: blur(6px) saturate(180%);
  transition: transform var(--dur) var(--ease);
}
.glass-ico__front .icon { filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.8)); }
[data-theme='dark'] .glass-ico__front { background: linear-gradient(145deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.06)); border-color: rgba(255, 255, 255, 0.28); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 6px 16px -6px rgba(0, 0, 0, 0.5); color: #fff; }
[data-theme='dark'] .glass-ico__front .icon { filter: none; }
/* Hosts become plain frames so the glass reads on the card surface */
.kpi__icon, .quick__icon, .facility__icon, .role-card__icon, .notif__icon, .empty__icon, .success__icon, .subject-icon {
  width: auto; height: auto; background: none !important; box-shadow: none; border-radius: 0; color: inherit;
}
.empty__icon::after { display: none; }
.card--hover:hover .glass-ico__back, .quick:hover .glass-ico__back, .role-card:hover .glass-ico__back, .nav-item:hover .glass-ico__back { transform: rotate(24deg) translate(6%, -4%); }
.card--hover:hover .glass-ico__front, .quick:hover .glass-ico__front, .role-card:hover .glass-ico__front { transform: translate(-2%, 2%); }
.nav-item .glass-ico, .bottom-nav__item .glass-ico { margin: -4px 0; }
.bottom-nav__item .icon-wrap { height: 34px; background: none !important; }
.role-card[aria-checked='true'] .glass-ico__front { border-color: var(--primary); }
@media (prefers-reduced-motion: reduce) { .glass-ico__back, .glass-ico__front { transition: none; } }

/* Navigation: "orb" glass tiles (same treatment as the dashboard brand orb), tinted per icon */
.nav-item .glass-ico, .bottom-nav__item .glass-ico { --s: 32px !important; }
.nav-item .glass-ico__back, .bottom-nav__item .glass-ico__back, .dl__row .glass-ico__back { display: none; }
.nav-item .glass-ico__front, .bottom-nav__item .glass-ico__front, .dl__row .glass-ico__front {
  inset: 0; width: 100%; height: 100%; border-radius: 11px; border: 0; color: var(--gv);
  background: radial-gradient(circle at 30% 25%, #fff, color-mix(in srgb, var(--g1) 30%, #fff) 58%, color-mix(in srgb, var(--g2) 20%, #fff));
  box-shadow: 0 8px 14px -8px color-mix(in srgb, var(--g2) 75%, transparent), inset 0 -3px 6px color-mix(in srgb, var(--g2) 18%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  -webkit-backdrop-filter: none; backdrop-filter: none;
}
.nav-item .glass-ico__front .icon, .bottom-nav__item .glass-ico__front .icon, .dl__row .glass-ico__front .icon {
  width: 17px; height: 17px; stroke-width: 2.3; color: inherit !important; filter: drop-shadow(0 2px 3px color-mix(in srgb, var(--gv) 30%, transparent));
}
.nav-item:hover .glass-ico__front { transform: translateY(-1px); }
.nav-item.is-active .glass-ico__front, [data-theme='dark'] .nav-item.is-active .glass-ico__front { background: transparent; box-shadow: none; color: currentColor; }
.nav-item.is-active .glass-ico__front .icon { filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2)); }
.bottom-nav__item:not(.is-active) .glass-ico { opacity: 0.9; }
.bottom-nav__item.is-active .glass-ico__front { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--g2), 0 8px 14px -8px var(--g2); }
[data-theme='dark'] .nav-item .glass-ico__front, [data-theme='dark'] .bottom-nav__item .glass-ico__front, [data-theme='dark'] .dl__row .glass-ico__front {
  color: color-mix(in srgb, var(--g1) 55%, #fff);
  background: radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--g1) 50%, #2A3150), color-mix(in srgb, var(--g2) 30%, #161C33) 75%);
  box-shadow: 0 8px 14px -8px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.14), inset 0 -3px 6px rgba(0, 0, 0, 0.25);
}

/* Detail lists as icon rows (rows are built by enhanceDetailLists in ui.js) */
.dl { display: flex; flex-direction: column; gap: 0; font-size: var(--fs-sm); }
.dl__row { display: grid; grid-template-columns: 34px minmax(0, 1fr); column-gap: 12px; row-gap: 1px; align-items: center; padding: 10px 0; border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent); }
.dl__row:first-child { padding-top: 2px; }
.dl__row:last-child { border-bottom: 0; padding-bottom: 2px; }
.dl__row > .glass-ico { grid-row: span 2; align-self: center; }
.dl__row dt { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); line-height: 1.3; }
.dl__row dd { margin: 0; font-weight: 600; color: var(--text); line-height: 1.4; overflow-wrap: anywhere; }
.dl__row dd a { font-weight: 600; }
.dl__row .glass-ico__front .icon { width: 16px; height: 16px; }

/* ---------- Dark mode: pastel avatars, solid fills under white text, required marks ---------- */
[data-theme='dark'] .avatar { background: color-mix(in srgb, var(--av-fg, #3730A3) 42%, #0E1528); color: color-mix(in srgb, var(--av-bg, #E0E3FF) 88%, #fff); }
[data-theme='dark'] .field__label .req { color: var(--error-text); }
[data-theme='dark'] .nav-badge, [data-theme='dark'] .nav-item.is-active .nav-badge,
[data-theme='dark'] .chip[aria-pressed='true'] { background: #5B5BF0; border-color: #5B5BF0; color: #fff; }
[data-theme='dark'] .btn--success { --btn-bg: #15803D; --btn-border: #15803D; }
[data-theme='dark'] .btn--success:hover { background: #166534; }
[data-theme='dark'] .st--present .st__mark,
[data-theme='dark'] .att-strip__cell--present,
[data-theme='dark'] .att-cal__day.is-present .att-cal__tag,
[data-theme='dark'] .mark--present[aria-checked='true'] { background: #15803D; border-color: #15803D; }
[data-style='v2'][data-theme='dark'] .nav-item.is-active .nav-badge { background: #fff; color: #4B47DE; }
[data-theme='dark'] .cal-day.is-today .cal-day__num { background: #5B5BF0; }
[data-theme='dark'] .mark[aria-checked='true'] .mark__short { background: rgba(0, 0, 0, 0.2); }
[data-theme='dark'] .week__time { color: color-mix(in srgb, var(--c) 68%, #fff); }
.logo--ondark { display: none; }
[data-theme='dark'] .logo--onlight { display: none; }
[data-theme='dark'] .logo--ondark { display: block; }
[data-theme='dark']:not([data-style='v2']) .btn--primary { --btn-bg: #5B5BF0; --btn-border: #5B5BF0; }
[data-theme='dark']:not([data-style='v2']) .btn--primary:hover { background: #4B47DE; border-color: #4B47DE; }

/* ---------- Themed dropdowns and date / time pickers (js/pickers.js) ---------- */
.pk-native { position: absolute !important; width: 1px !important; height: 1px !important; min-height: 0 !important; padding: 0 !important; margin: 0 !important; border: 0 !important; opacity: 0; pointer-events: none; clip-path: inset(50%); overflow: hidden; }
.pk-trigger { display: flex; align-items: center; text-align: left; cursor: pointer; font: inherit; font-size: var(--fs-base); font-weight: 500; }
.pk-trigger.select--sm { font-size: var(--fs-sm); }
.pk-trigger__text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pk-trigger[aria-expanded='true'] { border-color: var(--primary); box-shadow: var(--ring); }
.pk-trigger:focus-visible { outline: none; border-color: var(--primary); box-shadow: var(--ring); }

.pk-pop {
  position: fixed; inset: auto; margin: 0; z-index: 1000;
  padding: 6px; border: 1px solid var(--border); border-radius: 16px;
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-lg); overflow: hidden;
  animation: pk-in 140ms var(--ease) both;
}
@keyframes pk-in { from { opacity: 0; transform: translateY(-4px) scale(0.98); } }
[data-motion='reduced'] .pk-pop { animation: none; }
[data-style='v2'] .pk-pop { border-radius: 20px; border-color: var(--glass-border); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(20px) saturate(1.4); -webkit-backdrop-filter: blur(20px) saturate(1.4); }
[data-style='v2'][data-theme='dark'] .pk-pop { background: rgba(18, 26, 48, 0.97); border-color: rgba(148, 163, 255, 0.18); }

.pk-list { max-height: 300px; max-width: 380px; overflow-y: auto; outline: none; display: flex; flex-direction: column; gap: 2px; scrollbar-width: thin; }
.pk-opt { display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 7px 12px; border-radius: 10px; font-size: var(--fs-sm); font-weight: 500; color: var(--text-2); cursor: pointer; user-select: none; }
.pk-opt__text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pk-opt.is-active { background: var(--surface-hover); color: var(--text); }
.pk-opt[aria-selected='true'] { background: var(--primary-soft); color: var(--primary-text); font-weight: 600; }
.pk-opt[aria-selected='true'].is-active { background: var(--primary-soft-2); }
.pk-opt .icon { flex: none; color: var(--primary); }
.pk-opt[aria-disabled='true'] { opacity: 0.45; cursor: not-allowed; }
.pk-list:focus-visible .pk-opt.is-active { box-shadow: inset 0 0 0 2px var(--primary); }

.pk-date { position: relative; display: block; min-width: 0; }
.pk-date > .input { padding-right: 42px; }
.pk-date > .input--sm { padding-right: 36px; }
.has-pickers .pk-date > .input::-webkit-calendar-picker-indicator { display: none; }
.pk-date__btn { position: absolute; right: 5px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; color: var(--text-3); transition: background var(--dur-fast), color var(--dur-fast); }
.pk-date > .input--sm + .pk-date__btn { width: 26px; height: 26px; right: 4px; }
.pk-date__btn:hover, .pk-date__btn[aria-expanded='true'] { background: var(--primary-soft); color: var(--primary); }

.pk-cal { width: 300px; padding: 14px; }
.pk-cal__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.pk-cal__title { display: inline-flex; align-items: center; gap: 4px; padding: 6px 8px; margin-left: -4px; border-radius: 10px; font-family: var(--font-display); font-size: var(--fs-md); font-weight: 700; color: var(--text); }
.pk-cal__title .icon { color: var(--text-3); }
.pk-cal__title:hover { background: var(--surface-hover); }
.pk-cal__nav { display: flex; gap: 4px; }
.pk-iconbtn { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; color: var(--text-2); }
.pk-iconbtn:hover { background: var(--surface-hover); color: var(--text); }
.pk-cal__grid { width: 100%; border-collapse: separate; border-spacing: 2px; table-layout: fixed; }
.pk-cal__grid th { padding: 2px 0 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-3); }
.pk-day { width: 100%; aspect-ratio: 1; border-radius: 10px; display: grid; place-items: center; font-size: var(--fs-sm); font-weight: 500; color: var(--text); font-variant-numeric: tabular-nums; transition: background var(--dur-fast); }
.pk-day:hover { background: var(--surface-hover); }
.pk-day.is-out { color: var(--text-4); }
.pk-day.is-today { box-shadow: inset 0 0 0 1.5px var(--primary); color: var(--primary-text); font-weight: 700; }
.pk-day[aria-pressed='true'], .pk-month[aria-pressed='true'] { background: var(--indigo-600); color: #fff; font-weight: 700; box-shadow: 0 8px 16px -8px rgba(91, 91, 240, 0.9); }
[data-theme='dark'] .pk-day[aria-pressed='true'], [data-theme='dark'] .pk-month[aria-pressed='true'] { background: #5B5BF0; }
.pk-day:disabled, .pk-month:disabled { color: var(--text-4); opacity: 0.4; cursor: not-allowed; background: none; box-shadow: none; }
.pk-day:focus-visible, .pk-month:focus-visible, .pk-cal button:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.pk-months { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 4px 0; }
.pk-month { height: 44px; border-radius: 12px; font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.pk-month:hover { background: var(--surface-hover); color: var(--text); }
.pk-month.is-today { box-shadow: inset 0 0 0 1.5px var(--primary); color: var(--primary-text); }
.pk-cal__foot { display: flex; justify-content: space-between; margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--border); }
.pk-link { padding: 6px 10px; border-radius: 9px; font-size: var(--fs-sm); font-weight: 600; color: var(--primary); }
.pk-link:hover { background: var(--primary-soft); }
.pk-link:disabled { opacity: 0.4; cursor: not-allowed; background: none; }

/* Segmented switches: the selected pill must stand out in dark mode too */
[data-theme='dark'] .segmented button[aria-pressed='true'], [data-theme='dark'] .segmented button[aria-selected='true'],
[data-theme='dark'] .seg-radio input:checked + span { background: rgba(124, 124, 250, 0.26); color: #fff; box-shadow: inset 0 0 0 1px rgba(165, 171, 252, 0.35), 0 4px 12px -6px rgba(0, 0, 0, 0.6); }
[data-theme='dark'] .segmented button[aria-pressed='true'] .icon, [data-theme='dark'] .segmented button[aria-selected='true'] .icon { color: #C7CBFE; }

/* ---------- Light / dark toggle (top bar, sign-in, public form) ---------- */
.theme-toggle { position: relative; overflow: hidden; }
.theme-toggle > span { position: absolute; inset: 0; display: grid; place-items: center; transition: transform var(--dur-slow) var(--ease), opacity var(--dur) var(--ease); }
.theme-toggle__sun { opacity: 0; transform: rotate(-90deg) scale(0.6); }
.theme-toggle__moon { opacity: 1; transform: none; }
[data-theme='dark'] .theme-toggle__sun { opacity: 1; transform: none; color: #FCD34D; }
[data-theme='dark'] .theme-toggle__moon { opacity: 0; transform: rotate(90deg) scale(0.6); }
[data-motion='reduced'] .theme-toggle > span { transition: none; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 280ms; animation-timing-function: ease; }
.pk-trigger.is-placeholder .pk-trigger__text { color: var(--text-4); font-weight: 400; }

/* Icon boxes size to the glass icon they hold (they were sized for the older, smaller glyph tiles,
   so larger glass icons spilled onto the text below). */
:is(.kpi__icon, .quick__icon, .facility__icon, .notif__icon, .empty__icon, .success__icon, .subject-icon, .role-card__icon):has(> .glass-ico) { width: auto; height: auto; flex: none; }
.quick:has(.glass-ico) { gap: 12px; }
.facility:has(.glass-ico) { gap: 12px; }
