: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;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 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; }
.page { width: min(1120px, calc(100% - 32px)); margin: 32px auto; }
.message { padding: 12px 14px; background: #eaf6ee; border: 1px solid #b6e0c2; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
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; }
.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; }
.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;
}
.digital-card {
  aspect-ratio: 1.58 / 1;
  padding: clamp(18px, 4vw, 28px);
  background: linear-gradient(90deg, var(--accent) 0 7%, #f9f9f5 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); }
.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;
}
.status-panel, .verify-panel {
  background: white;
  border: 1px solid var(--line);
  padding: 24px;
}
.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; }

@media (max-width: 760px) {
  .topbar { align-items: flex-start; }
  .page { margin: 22px auto; }
  .section-head, .personal-grid { display: grid; }
  .filters { grid-template-columns: 1fr; }
  h1 { font-size: 2.4rem; }
  .digital-card h2 { margin-right: 0; }
  .digital-card .qr { width: 72px; height: 72px; }
}
