:root {
  --brand: #208aef;
  --brand-dark: #1769c2;
  --ink: #1a2230;
  --muted: #5b6677;
  --bg: #f5f7fa;
  --card: #ffffff;
  --border: #e3e8ef;
  --danger: #dc2626;
}

* {
  box-sizing: border-box;
}

/* The hidden attribute must win over component `display` rules (grid/flex). */
[hidden] {
  display: none !important;
}

body.portal {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica,
    Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

body.portal-app {
  justify-content: flex-start;
  padding: 0;
}

/* ---- Footer links ---- */
.foot-heart {
  color: #e0245e;
}

.foot-links {
  margin-top: 6px;
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.foot-links a {
  color: #000;
  text-decoration: underline;
}

/* ---- Article (terms / privacy) ---- */
.article {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}

.article h1 {
  margin-bottom: 4px;
}

.article h2 {
  margin-top: 28px;
  font-size: 1.1rem;
}

.article ul {
  padding-left: 20px;
}

.article a {
  color: var(--brand);
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.875rem;
}

/* ---- Login card ---- */
.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.08);
  padding: 122px 32px 32px;
  margin-top: 105px;
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.card-head h1 {
  margin: 12px 0 4px;
  font-size: 1.6rem;
}

.card-head p {
  margin-top: 4px;
}

.brand-logo {
  width: 112px;
  height: 112px;
  border-radius: 24px;
}

/* Login logo: larger and floating half outside the top of the card. */
.card-head .brand-logo {
  position: absolute;
  top: -105px;
  left: 50%;
  transform: translateX(-50%);
  width: 210px;
  height: 210px;
}

.brand-logo.small {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.methods {
  display: grid;
  gap: 12px;
  margin-top: 24px;
}

.method-btn {
  appearance: none;
  border: 2px solid var(--border);
  background: #fff;
  border-radius: 14px;
  padding: 16px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.1s ease;
}

.method-btn:hover {
  border-color: var(--brand);
  transform: translateY(-1px);
}

.method-btn:active {
  transform: translateY(0);
}

/* ---- Auth panel ---- */
.auth {
  margin-top: 20px;
}

.auth-title {
  font-weight: 600;
  margin-bottom: 12px;
}

.qr-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
}

.qr {
  width: 220px;
  height: 220px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
}

.open-app {
  display: inline-block;
  margin: 8px 0;
  padding: 12px 18px;
  background: var(--brand);
  color: #fff;
  text-decoration: none;
  border-radius: 12px;
  font-weight: 600;
}

.open-app:hover {
  background: var(--brand-dark);
}

.link-btn {
  appearance: none;
  background: none;
  border: none;
  color: var(--brand);
  font: inherit;
  cursor: pointer;
  padding: 8px;
}

.link-btn:hover {
  text-decoration: underline;
}

.error {
  margin-top: 16px;
  color: var(--danger);
  font-size: 0.9rem;
}

/* ---- Dashboard ---- */
.topbar {
  width: 100%;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-user form {
  margin: 0;
}

.content {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

/* ---- Dashboard two-column layout + connected organisations ---- */
.dashboard-head {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px 0;
}

.dashboard-head h1 {
  margin: 0 0 6px;
}

.dashboard-grid {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  gap: 28px;
  align-items: flex-start;
  padding: 0 20px;
}

/* ---- Credential list tabs ---- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.tab {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 12px 8px;
  font-size: 0.98rem;
  line-height: 1.4;
  color: var(--muted);
  cursor: pointer;
}

.tab:hover {
  color: var(--ink);
}

.tab.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
  font-weight: 600;
}

/* The sidebar's heading tab is a static label, not interactive. */
.sidebar .tab {
  cursor: default;
}

.dashboard-grid .content {
  flex: 1;
  max-width: none;
  margin: 0;
  padding: 28px 0 60px;
}

.sidebar {
  width: 280px;
  flex-shrink: 0;
  padding-top: 28px;
}

.sidebar h2 {
  font-size: 1.1rem;
  margin: 0 0 12px;
}

.org-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.org-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
}

.org-logo {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

.org-logo.placeholder {
  display: inline-block;
  background: var(--bg);
}

.org-name {
  font-size: 0.92rem;
}

@media (max-width: 820px) {
  .dashboard-grid {
    flex-direction: column;
    gap: 0;
  }

  .sidebar {
    width: 100%;
    padding-top: 0;
    padding-bottom: 28px;
  }
}

.content h1 {
  margin: 0 0 6px;
}

.panel {
  margin-top: 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
}

/* ---- Dashboard sections / credential lists ---- */
.section {
  margin-top: 28px;
}

.section h2 {
  font-size: 1.1rem;
  margin: 0 0 12px;
}

.cred-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.cred-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
}

.cred-link {
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease;
}

.cred-link:hover {
  border-color: var(--brand);
}

.chev {
  flex: none;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
}

.cred-main {
  min-width: 0;
}

.cred-title {
  font-weight: 600;
}

.badge {
  flex: none;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.badge-active {
  background: #e7f6ec;
  color: #1a7f3c;
}

.badge-revoked {
  background: #fdeaea;
  color: var(--danger);
}

.badge-expired {
  background: #f1f3f6;
  color: var(--muted);
}

.btn {
  appearance: none;
  border: none;
  border-radius: 12px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  flex: none;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
}

.btn-primary:hover {
  background: var(--brand-dark);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-secondary {
  background: #eef2f7;
  color: var(--ink);
}

.btn-secondary:hover {
  background: #e3e8ef;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.tffo-foot {
  margin-top: 24px;
  padding: 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
}

.tffo-foot a {
  color: #000;
  text-decoration: underline;
}

/* ---- Enrollment modal ---- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.modal[hidden] {
  display: none;
}

.modal-card {
  position: relative;
  background: var(--card);
  border-radius: 18px;
  padding: 28px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.25);
}

.modal-card h3 {
  margin: 0 0 8px;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 14px;
  appearance: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}

.modal-card .qr {
  margin: 12px auto;
  display: block;
}

.modal-card .btn {
  margin-top: 8px;
}
