:root {
  --ink: #161616;
  --muted: #666;
  --line: #d8d8d8;
  --paper: #f7f7f4;
  --accent: #f0cf31;
  --accent-student: #e03080;
  --accent-teacher: #00ffff;
  --accent-default: #f0cf31;
  --good: #127a3a;
  --bad: #ad1f2d;
  --warn: #946100;
}

@font-face {
  font-family: "Halis R";
  src: url("/static/cards/fonts/HalisR-Light.ee6825fc2d3a.ttf") format("truetype");
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Halis R";
  src: url("/static/cards/fonts/HalisR-Regular.cfd2a4ee0cc3.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Halis R";
  src: url("/static/cards/fonts/HalisR-Medium.ee8ef908c775.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Halis R", Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: var(--paper);
}
a { color: inherit; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 12px clamp(16px, 4vw, 48px);
  background: #111;
  color: white;
}
.brand img { width: 112px; height: auto; display: block; }
.topbar nav { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.topbar a, .inline-form button { color: white; background: transparent; border: 0; font: inherit; cursor: pointer; }
.admin-access { color: #bdbdbd !important; font-size: .78rem; text-decoration: none; }
.admin-access:hover { color: white !important; text-decoration: underline; }
.page { width: min(1120px, calc(100% - 32px)); margin: 32px auto; }
.message { padding: 12px 14px; background: #eaf6ee; border: 1px solid #b6e0c2; }
.message.warning { background: #fff8e5; border-color: #e8cf87; }
.site-footer {
  width: min(1120px, calc(100% - 32px));
  margin: 48px auto 24px;
  color: var(--muted);
  font-size: .85rem;
}
.legal-content { max-width: 760px; }
.legal-content h1 { margin-bottom: 32px; }
.legal-content h2 { margin-top: 28px; font-size: 1.25rem; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
h1 { font-size: clamp(2rem, 5vw, 4.5rem); line-height: 1; margin: 0; }
h2 { margin: 0 0 12px; }
.auth-panel { max-width: 420px; margin: 12vh auto; text-align: center; }
.auth-panel h1 { font-size: 2.6rem; line-height: 1.05; }
.auth-intro { color: var(--muted); margin: 18px 0 24px; }
.microsoft-signin { display: inline-block; line-height: 0; }
.microsoft-signin img { display: block; width: 215px; height: 41px; }
.local-auth-panel h1 { font-size: 2rem; }
.local-auth-panel .form { text-align: left; }
.form, .filters {
  display: grid;
  gap: 12px;
  max-width: 560px;
}
.filters {
  grid-template-columns: minmax(180px, 1fr) 150px 150px 150px 170px auto auto;
  max-width: none;
  margin-bottom: 28px;
}
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  font: inherit;
  background: white;
}
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 6px;
  padding: 10px 14px;
  background: var(--ink);
  color: white;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}
button.secondary, .button.secondary {
  background: #ececec;
  color: var(--ink);
}
button.danger { background: var(--bad); }
.data-section { margin-top: 28px; }
.confirm-import { margin-top: 16px; }
.count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #e8e8e4;
  font-size: .9rem;
  font-weight: 400;
}
.table-wrap { overflow-x: auto; background: white; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { text-align: left; padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: #efefeb; font-size: .86rem; text-transform: uppercase; }
td a + a { margin-left: 12px; }
.pagination {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}
.pagination a {
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: white;
  border-radius: 6px;
  text-decoration: none;
}
.status {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: .84rem;
  background: #ececec;
}
.status.active { color: var(--good); background: #e5f4ea; }
.status.expired { color: var(--warn); background: #fff2cf; }
.status.revoked { color: var(--bad); background: #fbe1e4; }
.personal-grid {
  display: grid;
  grid-template-columns: minmax(280px, 520px) minmax(240px, 1fr);
  gap: 24px;
  align-items: start;
}
.personal-grid > * { min-width: 0; max-width: 100%; }
.digital-card {
  width: 100%;
  min-width: 0;
  aspect-ratio: 1.58 / 1;
  padding: clamp(18px, 4vw, 28px);
  background: linear-gradient(90deg, var(--accent) 0 7%, #fff 7%);
  border: 1px solid var(--line);
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  overflow: hidden;
}
.digital-card.role-alumne { --accent: var(--accent-student); }
.digital-card.role-professorat { --accent: var(--accent-teacher); }
.digital-card.role-pas, .digital-card.role-visitant { --accent: var(--accent-default); }
.card-top {
  margin-left: 9%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  font-weight: 700;
  font-size: .9rem;
  min-height: 32px;
}
.card-logo-box {
  display: inline-flex;
  align-items: center;
  width: 92px;
  height: 28px;
  overflow: hidden;
  flex: 0 0 auto;
}
.card-logo {
  display: block;
  max-width: 92px;
  max-height: 28px;
  width: auto;
  height: auto;
  object-fit: contain;
}
.digital-card h2 { margin: 9% 92px 0 9%; font-size: clamp(1.4rem, 4vw, 2.1rem); overflow-wrap: anywhere; }
.digital-card p { margin-left: 9%; }
.digital-card .code { font-weight: 700; letter-spacing: 0; }
.digital-card .qr {
  position: absolute;
  right: 22px;
  bottom: 22px;
  width: 84px;
  height: 84px;
}
.digital-card.revoked,
.digital-card.expired {
  border-width: 2px;
}
.digital-card.revoked { border-color: var(--bad); --accent: var(--bad) !important; }
.digital-card.expired { border-color: var(--warn); --accent: var(--warn) !important; }
.digital-card.revoked > :not(.invalid-stamp),
.digital-card.expired > :not(.invalid-stamp) {
  opacity: .3;
  filter: grayscale(1);
}
.invalid-stamp {
  position: absolute;
  z-index: 3;
  top: 45%;
  left: -10%;
  width: 120%;
  padding: 12px;
  transform: rotate(-8deg);
  background: var(--bad);
  color: white;
  border: 3px solid white;
  outline: 3px solid var(--bad);
  text-align: center;
  font-size: clamp(1.15rem, 4vw, 1.75rem);
  letter-spacing: 0;
}
.invalid-stamp.expired { background: var(--warn); outline-color: var(--warn); }
.status-panel, .verify-panel {
  background: white;
  border: 1px solid var(--line);
  padding: 24px;
}
.status-panel h2 { margin-top: 16px; }
.status-panel.state-revoked {
  border: 2px solid var(--bad);
  background: #fff4f5;
}
.status-panel.state-expired {
  border: 2px solid var(--warn);
  background: #fffaf0;
}
.credential-actions { display: grid; justify-items: start; gap: 12px; margin-top: 20px; }
.credential-actions > .button { min-width: 215px; }
.credential-actions form { margin: 0; line-height: 0; }
.wallet-badge-button {
  display: block;
  width: auto;
  height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  line-height: 0;
}
.wallet-badge-button img,
.wallet-badge-link img {
  display: block;
  width: auto;
  height: 48px;
  max-width: 100%;
}
.wallet-badge-link { display: inline-block; line-height: 0; }
.verify-panel { max-width: 720px; margin: 10vh auto; }
.verify-panel.active { border-top: 8px solid var(--good); }
.verify-panel.expired { border-top: 8px solid var(--warn); }
.verify-panel.revoked, .verify-panel.not_found { border-top: 8px solid var(--bad); }
.kicker { color: var(--muted); text-transform: uppercase; font-size: .82rem; }
dl { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; }
dt { color: var(--muted); }
dd { margin: 0; font-weight: 700; }
.empty, .error { padding: 14px; border: 1px solid var(--line); background: white; }
.error { border-color: #f1b4bb; color: var(--bad); }
.hint { color: var(--muted); font-size: .9rem; }

/* Some Android browsers keep a desktop layout viewport in portrait mode.
   The touch/portrait branch keeps the personal card usable in that case. */
@media (max-width: 960px), (pointer: coarse) and (orientation: portrait) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
    padding: 14px 16px;
  }
  .brand { align-self: flex-start; }
  .brand img { width: 96px; }
  .topbar nav {
    width: 100%;
    gap: 12px 18px;
  }
  .page { margin: 22px auto; }
  .section-head { display: grid; }
  .personal-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }
  .actions { justify-content: start; }
  .filters { grid-template-columns: 1fr; }
  h1 { font-size: 2.4rem; }
  .digital-card {
    width: 100%;
    min-width: 0;
    aspect-ratio: auto;
    min-height: 320px;
    padding: 20px;
  }
  .digital-card h2 {
    margin: 40px 104px 0 11%;
    font-size: 1.65rem;
  }
  .digital-card p { margin-left: 11%; }
  .digital-card .qr {
    right: 20px;
    bottom: 20px;
    width: 88px;
    height: 88px;
  }
  .status-panel { padding: 20px; }
  .credential-actions,
  .credential-actions > .button,
  .credential-actions form,
  .wallet-badge-link { width: 100%; }
  .wallet-badge-button { margin: 0 auto; }
  .wallet-badge-link img { margin: 0 auto; }
}
