:root {
  --uitm-purple: #4b1f73;
  --uitm-purple-700: #351650;
  --uitm-purple-100: #efe8f5;
  --uitm-gold: #c9a227;
  --uitm-gold-100: #f7efd1;
  --bg: #f6f3f8;
  --surface: #ffffff;
  --surface-soft: #fbfafc;
  --border: #e4ddea;
  --text: #23202a;
  --muted: #716a7a;
  --success: #176b4d;
  --danger: #9d2b38;
  --shadow: 0 14px 34px rgba(45, 28, 66, 0.08);
  --radius: 8px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
}

/* Base reset keeps the template predictable across mobile browsers. */
* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: #e9e3ee;
  font-size: 15px;
  line-height: 1.5;
}

body.has-modal {
  overflow: hidden;
}

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

button,
input,
select,
textarea {
  font: inherit;
}

input,
select,
textarea {
  font-size: 16px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.45rem, 2vw, 1.9rem);
  font-weight: 600;
  line-height: 1.2;
}

h2 {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.3;
}

.app-shell {
  width: min(100%, 430px);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
  box-shadow: 0 0 0 1px rgba(75, 31, 115, 0.06);
}

/* Mobile-first shell: desktop sidebar is enabled at the large breakpoint. */
.sidebar {
  display: none;
}

.main {
  width: 100%;
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top, 0px)) 16px calc(84px + var(--safe-bottom));
}

.brand,
.topbar,
.profile-card__header,
.section-header,
.topbar__actions,
.user-chip,
.progress-widget {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
}

.brand__mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: var(--radius);
  color: #ffffff;
  background: var(--uitm-purple);
  font-weight: 600;
  box-shadow: inset 0 -3px 0 rgba(201, 162, 39, 0.8);
}

.brand__name {
  font-weight: 600;
}

.brand__meta,
.small-text,
.muted,
.eyebrow {
  color: var(--muted);
}

.brand__meta,
.small-text {
  font-size: 0.82rem;
}

.eyebrow {
  margin-bottom: 4px;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.topbar__actions {
  gap: 10px;
}

.language-switcher {
  display: inline-grid;
  grid-template-columns: repeat(2, 1fr);
  overflow: hidden;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.language-switcher__button {
  min-width: 42px;
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
}

.language-switcher__button[aria-pressed="true"] {
  color: #ffffff;
  background: var(--uitm-purple);
}

.icon-button,
.primary-button,
.secondary-button {
  min-height: 42px;
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
}

.icon-button {
  display: grid;
  width: 42px;
  place-items: center;
  color: var(--uitm-purple);
  background: var(--surface);
  border: 1px solid var(--border);
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  font-weight: 600;
}

.primary-button {
  color: #ffffff;
  background: var(--uitm-purple);
}

.secondary-button {
  color: var(--uitm-purple);
  background: var(--uitm-purple-100);
}

.button-icon {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  color: var(--uitm-purple);
  background: #ffffff;
  font-weight: 600;
}

.avatar {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: var(--uitm-purple);
  background: var(--uitm-gold-100);
  font-size: 0.78rem;
  font-weight: 600;
  overflow: hidden;
}

.avatar--large {
  width: 52px;
  height: 52px;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-chip {
  gap: 8px;
  padding: 6px 10px 6px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}

.user-chip__text {
  display: none;
  font-weight: 600;
}

.login-panel {
  margin-bottom: 16px;
}

.install-prompt__icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: var(--radius);
  color: #ffffff;
  background: var(--uitm-purple);
  font-weight: 700;
}

.install-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: end center;
  padding: 16px 16px calc(112px + var(--safe-bottom));
}

.install-modal[hidden] {
  display: none;
}

.install-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(35, 32, 42, 0.5);
}

.install-modal__dialog {
  position: relative;
  z-index: 1;
  display: grid;
  width: min(100%, 398px);
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 20px 48px rgba(35, 32, 42, 0.22);
}

.install-modal__close {
  position: absolute;
  top: 12px;
  right: 12px;
}

.install-modal__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Shared card surface for reusable dashboard, form, table, and state blocks. */
.login-card,
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-card {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.dashboard-grid,
.content-grid {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.dashboard-grid {
  grid-template-columns: 1fr;
  margin-bottom: 14px;
}

.content-grid {
  grid-template-columns: 1fr;
}

.card {
  min-width: 0;
  padding: 16px;
}

.profile-card {
  display: grid;
  gap: 16px;
}

.profile-card__header {
  gap: 12px;
}

.info-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.info-list div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.info-list dt {
  color: var(--muted);
}

.info-list dd {
  margin: 0;
  font-weight: 600;
  text-align: right;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.status--ok {
  color: var(--success);
  background: #e7f4ef;
}

.status--due {
  color: var(--danger);
  background: #f9e8eb;
}

.stat-card {
  display: grid;
  gap: 8px;
}

.stat-card strong {
  color: var(--uitm-purple);
  font-size: 1.45rem;
  font-weight: 600;
}

.dashboard-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.metric-card {
  display: grid;
  min-width: 0;
  gap: 10px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

a.metric-card {
  color: inherit;
  text-decoration: none;
}

a.metric-card:focus-visible {
  outline: 3px solid var(--uitm-gold);
  outline-offset: 3px;
}

.metric-card__top {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.metric-card__top p {
  min-width: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.2;
}

.metric-card__icon {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: var(--radius);
  color: var(--uitm-purple);
  background: var(--uitm-purple-100);
  font-size: 0.82rem;
  font-weight: 800;
}

.metric-card strong {
  overflow-wrap: anywhere;
  color: var(--uitm-purple);
  font-size: 1.42rem;
  font-weight: 800;
  line-height: 1;
}

.metric-card__primary-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.2;
}

.metric-card > span {
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.25;
}

.metric-card--fine .metric-card__icon {
  color: #80640f;
  background: var(--uitm-gold-100);
}

.metric-card--fine strong {
  color: #80640f;
}

.fine-breakdown {
  display: grid;
  gap: 6px;
  margin: 0;
}

.fine-breakdown div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.fine-breakdown dt,
.fine-breakdown dd {
  min-width: 0;
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.25;
}

.fine-breakdown dt {
  color: var(--muted);
  font-weight: 700;
}

.fine-breakdown dd {
  overflow-wrap: anywhere;
  color: var(--text);
  font-weight: 800;
  text-align: right;
}

.metric-card--overdue .metric-card__icon,
.metric-card--lost .metric-card__icon {
  color: var(--danger);
  background: #f9e8eb;
}

.metric-card--overdue strong,
.metric-card--lost strong {
  color: var(--danger);
}

.trend {
  color: var(--muted);
  font-size: 0.86rem;
}

.trend--gold {
  color: #80640f;
}

.section-header {
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  margin-bottom: 14px;
}

.carousel-controls {
  display: inline-flex;
  gap: 8px;
}

.carousel-button {
  width: 38px;
  min-height: 38px;
  font-size: 1.35rem;
  line-height: 1;
}

.book-carousel {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  margin: 0;
}

.book-track {
  display: flex;
  width: 100%;
  max-width: 100%;
  gap: 12px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding: 2px 0 6px;
  scroll-padding-left: 0;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

.book-track::-webkit-scrollbar {
  display: none;
}

.book-slide {
  flex: 0 0 138px;
  max-width: 100%;
  scroll-snap-align: start;
}

.book-cover-link {
  display: grid;
  gap: 8px;
}

.book-cover-image {
  display: block;
  width: 100%;
  min-height: 206px;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: var(--radius);
  background: var(--uitm-purple-100);
  box-shadow: 0 12px 24px rgba(45, 28, 66, 0.16);
}

.book-slide__title {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.25;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.book-cover {
  position: relative;
  display: flex;
  min-height: 206px;
  aspect-ratio: 2 / 3;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  padding: 14px 12px;
  border-radius: var(--radius);
  color: #ffffff;
  background: linear-gradient(145deg, var(--uitm-purple), var(--uitm-purple-700));
  box-shadow: 0 12px 24px rgba(45, 28, 66, 0.16);
}

.book-cover::before,
.book-cover::after {
  position: absolute;
  content: "";
  pointer-events: none;
}

.book-cover::before {
  inset: 0 0 0 9px;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
}

.book-cover::after {
  right: -32px;
  bottom: -34px;
  width: 98px;
  height: 98px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
}

.book-cover__code,
.book-cover__title,
.book-cover__author {
  position: relative;
  z-index: 1;
}

.book-cover__code {
  width: max-content;
  padding: 4px 7px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 700;
}

.book-cover__title {
  display: block;
  overflow-wrap: anywhere;
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.15;
}

.book-cover__author {
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.72rem;
  font-weight: 600;
}

.book-cover--teal {
  background: linear-gradient(145deg, #0f766e, #134e4a);
}

.book-cover--gold {
  color: #2b230c;
  background: linear-gradient(145deg, #f4c95d, #c7931e);
}

.book-cover--rose {
  background: linear-gradient(145deg, #b8325f, #70213a);
}

.book-cover--navy {
  background: linear-gradient(145deg, #263f73, #17233f);
}

.book-cover--green {
  background: linear-gradient(145deg, #2f7d4f, #17432b);
}

.book-cover--orange {
  color: #2e1b0c;
  background: linear-gradient(145deg, #f08a3c, #b95118);
}

.book-cover--gold .book-cover__author,
.book-cover--orange .book-cover__author {
  color: rgba(46, 27, 12, 0.72);
}

.book-cover--blue {
  background: linear-gradient(145deg, #2364aa, #153b65);
}

.book-cover--slate {
  background: linear-gradient(145deg, #53616f, #2f3842);
}

.book-cover--maroon {
  background: linear-gradient(145deg, #7a1f36, #45111f);
}

.progress-widget {
  gap: 14px;
  margin-bottom: 14px;
}

.progress-ring {
  display: grid;
  width: 92px;
  height: 92px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--uitm-purple) 0 75%, var(--uitm-purple-100) 75% 100%);
}

.progress-ring span {
  display: grid;
  width: 68px;
  height: 68px;
  place-items: center;
  border-radius: 50%;
  background: var(--surface);
  color: var(--uitm-purple);
  font-weight: 600;
}

.progress-widget__value {
  color: var(--uitm-purple);
  font-size: 1.1rem;
  font-weight: 600;
}

.progress-bar {
  overflow: hidden;
  height: 9px;
  border-radius: 999px;
  background: var(--uitm-purple-100);
}

.progress-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--uitm-gold);
}

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

.loan-list {
  display: grid;
  gap: 10px;
}

.loan-item {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.loan-item--overdue {
  border-color: #f0c7cc;
  background: #fff7f8;
}

.loan-item__main {
  display: grid;
  gap: 4px;
}

.loan-item__title-row {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 8px;
}

.loan-item__main h3 {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 0.94rem;
  line-height: 1.25;
}

.loan-item__main p {
  color: var(--muted);
  font-size: 0.82rem;
}

.loan-item__meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.loan-item__meta div {
  min-width: 0;
}

.loan-item__meta dt {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.2;
  text-transform: uppercase;
}

.loan-item__meta dd {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.25;
}

.empty-inline {
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--surface-soft);
  text-align: center;
}

.barcode-scan {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
}

.scan-form,
.manual-scan,
.manual-accession {
  display: grid;
  gap: 10px;
}

.scan-form label,
.manual-scan label,
.manual-accession label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.scan-form select,
.manual-scan input,
.manual-accession input {
  min-height: 44px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 12px;
  color: var(--text);
  background: var(--surface);
}

.manual-accession {
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.manual-accession__header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.manual-accession__icon {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: var(--radius);
  color: #ffffff;
  background: var(--uitm-purple);
  font-weight: 700;
}

.manual-accession__header h2 {
  font-size: 0.98rem;
}

.manual-accession__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.manual-accession .primary-button {
  min-width: 92px;
  padding: 0 14px;
}

.manual-accession .primary-button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.manual-accession input:disabled {
  opacity: 0.74;
}

.manual-accession__hint {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.scanner {
  position: relative;
  overflow: hidden;
  min-height: 260px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #101218;
}

.scanner__video {
  display: block;
  width: 100%;
  min-height: 260px;
  object-fit: cover;
}

.scanner__html5,
.scanner__html5 video {
  width: 100% !important;
  min-height: 260px;
  object-fit: cover;
}

.scanner__html5 {
  color: #ffffff;
}

.scanner__html5 img,
.scanner__html5 button,
.scanner__html5 select {
  display: none !important;
}

.scanner__frame {
  position: absolute;
  inset: 22%;
  border: 2px solid var(--uitm-gold);
  border-radius: var(--radius);
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.34);
  pointer-events: none;
}

.scan-status {
  font-size: 0.86rem;
}

.scan-value {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.scan-value strong {
  overflow-wrap: anywhere;
  color: var(--uitm-purple);
  font-size: 1rem;
}

.scan-value .secondary-button {
  justify-self: start;
  margin-top: 6px;
}

.scan-result {
  display: grid;
  gap: 12px;
}

.scan-book {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.scan-book__cover {
  display: block;
  width: 92px;
  min-height: 138px;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: var(--radius);
  background: var(--uitm-purple-100);
}

.scan-book__cover--empty {
  display: grid;
  place-items: center;
  color: var(--uitm-purple);
  font-weight: 700;
}

.scan-book__body {
  display: grid;
  min-width: 0;
  gap: 8px;
}

.scan-book__body h3 {
  overflow-wrap: anywhere;
  font-size: 0.98rem;
  line-height: 1.25;
}

.scan-book__title {
  display: grid;
  gap: 5px;
}

.scan-book__due {
  width: max-content;
  max-width: 100%;
  padding: 5px 8px;
  border-radius: 6px;
  color: var(--success);
  background: #e7f4ef;
  font-size: 0.78rem;
  font-weight: 600;
}

.scan-book__due strong {
  font-weight: 800;
}

.scan-book__body p {
  color: var(--muted);
  font-size: 0.86rem;
}

.scan-book__body dl {
  display: grid;
  gap: 6px;
  margin: 0;
}

.scan-book__body dt {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
  text-transform: uppercase;
}

.scan-book__body dd {
  margin: 0;
  font-weight: 700;
}

.scan-book__status {
  justify-self: start;
}

table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
}

td {
  font-size: 0.92rem;
}

.chart-placeholder {
  display: flex;
  align-items: end;
  gap: 10px;
  min-height: 190px;
  padding: 14px;
  border: 1px dashed #cabed5;
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.chart-placeholder span {
  flex: 1;
  min-width: 22px;
  border-radius: 6px 6px 0 0;
  background: var(--uitm-purple);
}

.chart-placeholder span:nth-child(even) {
  background: var(--uitm-gold);
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 10px;
  min-height: 220px;
  text-align: center;
}

.empty-state__icon {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 50%;
  color: var(--uitm-purple);
  background: var(--uitm-purple-100);
  font-size: 1.5rem;
  font-weight: 400;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  width: min(100%, 430px);
  transform: translateX(-50%);
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: 4px;
  padding: 8px 10px calc(8px + var(--safe-bottom));
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
}

/* Safe-area padding prevents mobile browser controls from covering navigation. */
.bottom-nav__link {
  display: grid;
  min-height: 44px;
  place-items: center;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.bottom-nav__link--active {
  color: var(--uitm-purple);
  background: var(--uitm-purple-100);
}

.offline-body {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 18px;
}

.offline-card {
  display: grid;
  width: min(440px, 100%);
  gap: 16px;
}

@media (min-width: 640px) {
  .user-chip__text {
    display: inline;
  }

  .dashboard-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .profile-card {
    grid-column: 1 / -1;
  }

  .content-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .span-2 {
    grid-column: span 2;
  }
}

@media (min-width: 980px) {
  .app-shell {
    display: grid;
    grid-template-columns: 260px 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    display: flex;
    height: 100vh;
    flex-direction: column;
    padding: 22px;
    border-right: 1px solid var(--border);
    background: var(--surface);
  }

  .side-nav {
    display: grid;
    gap: 8px;
    margin-top: 28px;
  }

  .side-nav__link {
    padding: 11px 12px;
    border-radius: var(--radius);
    color: var(--muted);
    font-weight: 600;
  }

  .side-nav__link--active,
  .side-nav__link:hover {
    color: var(--uitm-purple);
    background: var(--uitm-purple-100);
  }

  .sidebar__footer {
    margin-top: auto;
    padding: 14px;
    border-radius: var(--radius);
    background: var(--surface-soft);
  }

  .main {
    padding: 24px;
  }

  .bottom-nav {
    display: none;
  }
}

/* Final mobile-frame override: desktop browsers still see the app as a phone-sized PWA. */
@media (min-width: 640px) {
  body {
    background: #e9e3ee;
  }

  .app-shell {
    display: block;
    width: min(100%, 430px);
    min-height: calc(100vh - 36px);
    margin: 18px auto;
    border-radius: 18px;
    overflow: hidden;
    background: var(--bg);
  }

  .sidebar {
    display: none;
  }

  .main {
    width: 100%;
    padding: calc(18px + env(safe-area-inset-top, 0px)) 16px calc(84px + var(--safe-bottom));
  }

  .user-chip__text {
    display: none;
  }

  .dashboard-grid,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .profile-card,
  .span-2 {
    grid-column: auto;
  }

  .bottom-nav {
    bottom: 18px;
    left: 50%;
    display: grid;
    width: min(100%, 430px);
    transform: translateX(-50%);
    border-right: 1px solid var(--border);
    border-left: 1px solid var(--border);
    border-radius: 0 0 18px 18px;
  }
}


[data-theme="dark"] {
  --bg: #111318;
  --surface: #191c23;
  --surface-soft: #222630;
  --border: #303542;
  --text: #f4f2f7;
  --muted: #b6afc1;
  --uitm-purple: #b78ae7;
  --uitm-purple-700: #8f5ed0;
  --uitm-purple-100: #2b2336;
  --uitm-gold: #f0c84b;
  --uitm-gold-100: #3c3420;
  --shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
  color-scheme: dark;
}

[data-theme="dark"] body,
[data-theme="dark"] .app-shell {
  background: var(--bg);
}

[data-theme="dark"] body {
  background: #07080b;
}

[data-theme="dark"] .bottom-nav {
  background: rgba(25, 28, 35, 0.96);
}

[data-theme="dark"] .status--ok {
  background: #16372d;
}

[data-theme="dark"] .status--due {
  background: #3d1c23;
}

[hidden] {
  display: none !important;
}

.hero-panel {
  display: grid;
  gap: 18px;
  margin-bottom: 14px;
  padding: 20px;
  border: 1px solid rgba(75, 31, 115, 0.18);
  border-radius: var(--radius);
  color: #ffffff;
  background:
    linear-gradient(145deg, rgba(75, 31, 115, 0.94), rgba(35, 100, 170, 0.88)),
    url("../icons/icon-512.png") right -72px top -58px / 210px 210px no-repeat;
  box-shadow: var(--shadow);
}

.hero-panel .eyebrow,
.hero-panel .muted {
  color: rgba(255, 255, 255, 0.82);
}

.hero-panel h1 {
  max-width: 12ch;
  margin-bottom: 10px;
  font-size: 2rem;
}

.hero-panel .primary-button {
  width: 100%;
  color: var(--uitm-purple-700);
  background: #ffffff;
}

.auth-message {
  padding: 10px 12px;
  border: 1px solid #f0c7cc;
  border-radius: var(--radius);
  color: var(--danger);
  background: #fff1f3;
  font-size: 0.84rem;
  font-weight: 600;
}

[data-theme="dark"] .auth-message {
  border-color: #63303a;
  background: #2a171c;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.quick-action {
  display: grid;
  min-width: 0;
  gap: 4px;
  padding: 12px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 10px 24px rgba(45, 28, 66, 0.05);
}

.quick-action > span {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: var(--radius);
  color: var(--uitm-purple);
  background: var(--uitm-purple-100);
  font-size: 1.05rem;
}

.quick-action strong,
.quick-action small {
  overflow-wrap: anywhere;
}

.quick-action strong {
  color: var(--text);
  font-size: 0.86rem;
}

.quick-action small {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.25;
}

.event-list,
.library-event-list {
  display: grid;
  gap: 10px;
}

.event-item {
  display: grid;
  grid-template-columns: 68px 1fr;
  gap: 12px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.event-item time {
  display: grid;
  min-height: 46px;
  place-items: center;
  border-radius: var(--radius);
  color: var(--uitm-purple);
  background: var(--uitm-purple-100);
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
}

.library-event-item {
  grid-template-columns: 86px 1fr;
}

.library-event-item time {
  font-size: 0.7rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.event-item h3 {
  margin: 0 0 3px;
  font-size: 0.94rem;
  line-height: 1.25;
}

.event-item h3 a {
  color: inherit;
  text-decoration: none;
}

.event-item h3 a:focus,
.event-item h3 a:hover {
  color: var(--uitm-purple);
  text-decoration: underline;
}

.social-grid {
  display: grid;
  gap: 10px;
}

.social-link {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 2px 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.social-link > span {
  display: grid;
  width: 42px;
  height: 42px;
  grid-row: span 2;
  place-items: center;
  border-radius: var(--radius);
  color: #ffffff;
  font-weight: 800;
}

.social-link strong {
  line-height: 1.2;
}

.social-link small {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.3;
}

.social-link--facebook > span {
  background: #1877f2;
}

.social-link--youtube > span {
  background: #d71920;
}

.social-link--tiktok > span {
  background: #111111;
}


.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.permata-search {
  display: grid;
  gap: 14px;
  overflow: hidden;
  padding: 0;
  border-color: rgba(75, 31, 115, 0.14);
  margin-bottom: 18px;
}

.permata-search__header {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: 0;
  padding: 16px;
  color: inherit;
  background:
    linear-gradient(90deg, rgba(75, 31, 115, 0.13), rgba(201, 162, 39, 0.14)),
    var(--surface);
  cursor: pointer;
  text-align: left;
}

.permata-search__header > div:nth-child(2) {
  flex: 1 1 auto;
  min-width: 0;
}

.permata-search__icon {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: var(--radius);
  color: #ffffff;
  background: var(--uitm-purple);
  box-shadow: inset 0 -3px 0 rgba(201, 162, 39, 0.86);
  font-size: 1.35rem;
  line-height: 1;
}

.permata-search__copy {
  padding: 0 16px;
  color: var(--muted);
  font-size: 0.88rem;
}

.permata-search__panel {
  display: grid;
  gap: 14px;
}

.permata-search__panel[hidden] {
  display: none;
}

.accordion-indicator {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
  border: 2px solid var(--uitm-purple);
  border-radius: var(--radius);
  color: #ffffff;
  background: var(--uitm-purple);
  box-shadow: inset 0 -3px 0 rgba(201, 162, 39, 0.86);
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1;
  transition: transform 160ms ease;
}

[data-accordion-open] .accordion-indicator {
  transform: rotate(180deg);
}

.permata-search__form {
  display: grid;
  gap: 12px;
  padding: 0 16px 16px;
}

.permata-search__mode {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.permata-search__mode legend,
.permata-search__filters span {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
}

.permata-search__mode label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 600;
}

.permata-search__mode input {
  width: 16px;
  height: 16px;
  accent-color: var(--uitm-purple);
}

.permata-search__bar {
  display: grid;
  grid-template-columns: 1fr auto;
  overflow: hidden;
  border: 2px solid var(--uitm-purple);
  border-radius: var(--radius);
  background: var(--surface);
}

.permata-search__bar input {
  min-width: 0;
  min-height: 48px;
  border: 0;
  padding: 0 12px;
  color: var(--text);
  background: transparent;
  outline: 0;
}

.permata-search__bar input::placeholder {
  color: var(--muted);
}

.permata-search__bar .primary-button {
  min-height: 48px;
  border-radius: 0;
  padding: 0 14px;
  background: var(--uitm-purple);
  letter-spacing: 0;
}

.permata-search__filters {
  display: grid;
  gap: 10px;
}

.permata-search__filters label {
  display: grid;
  gap: 6px;
}

.permata-search__filters select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 12px;
  color: var(--text);
  background: var(--surface-soft);
}

.permata-search__tip {
  padding: 10px 12px;
  border-left: 3px solid var(--uitm-gold);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--muted);
  background: var(--uitm-gold-100);
  font-size: 0.8rem;
  line-height: 1.35;
}

.member-area {
  display: grid;
  gap: 14px;
}

.member-events {
  scroll-margin-top: 18px;
}

.member-area > .section-header {
  margin-bottom: 0;
}

.bottom-nav__link {
  gap: 2px;
  line-height: 1.1;
}

.bottom-nav__icon {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  font-size: 1rem;
  line-height: 1;
}

.is-logged-in .hero-panel {
  margin-bottom: 14px;
}

.is-logged-in .hero-panel h1,
.is-logged-in .hero-panel .muted {
  max-width: none;
}

@media (max-width: 360px) {
  .quick-actions {
    grid-template-columns: 1fr;
  }

  .hero-panel h1 {
    font-size: 1.75rem;
  }
}
