:root {
  --brand: #3f5793;
  --brand-700: #2f4377;
  --accent: #98252c;
  --success: #5e984e;
  --ink: #1e2a32;
  --muted: #6f7c86;
  --line: #c7c6c6;
  --surface: #ffffff;
  --soft: #f3f6f7;
  --warning: #98252c;
  --shadow: 0 18px 50px rgba(21, 36, 48, 0.12);
  font-family: "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--soft);
  font-size: 15px;
  line-height: 1.45;
}

a {
  color: var(--brand);
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  padding: 9px 12px;
}

input[type="file"] {
  padding: 8px;
}

input[readonly] {
  background: #f8fafb;
}

label {
  display: grid;
  gap: 7px;
  color: #46545e;
  font-size: 13px;
  font-weight: 700;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: #63717c;
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
  background: #f8fafb;
}

td span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 68px;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 12px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-700));
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
}

.main-nav {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.main-nav a {
  border-radius: 8px;
  color: #4e5c66;
  padding: 9px 12px;
  font-weight: 700;
}

.main-nav a.active,
.main-nav a:hover {
  color: var(--brand);
  background: #eef2fb;
}

.logout-form {
  margin: 0;
}

.page {
  width: min(1180px, calc(100% - 32px));
  margin: 30px auto 56px;
}

.page-heading,
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.page-heading h1,
.section-heading h2 {
  margin: 0;
}

.page-heading h1 {
  font-size: 30px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.actions,
.form-actions,
.row-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.actions.left {
  justify-content: flex-start;
}

.primary-button,
.secondary-button,
.icon-button,
.row-actions button,
.row-actions a {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  padding: 9px 13px;
  cursor: pointer;
  font-weight: 800;
}

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

.primary-button:hover {
  background: var(--brand-700);
}

.secondary-button,
.icon-button,
.row-actions a,
.row-actions button {
  color: var(--brand);
  background: #eef2fb;
}

.row-actions button {
  color: var(--warning);
  background: #f8e8eb;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card,
.table-section,
.login-panel,
.qr-preview,
.qr-details,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(21, 36, 48, 0.06);
}

.stat-card {
  min-height: 118px;
  display: grid;
  align-content: space-between;
  padding: 18px;
}

.stat-card span {
  color: var(--muted);
  font-weight: 700;
}

.stat-card strong {
  color: var(--brand-700);
  font-size: 34px;
}

.table-section {
  overflow: hidden;
}

.section-heading {
  margin: 0;
  padding: 18px 18px 0;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.status {
  display: inline-flex;
  width: max-content;
  min-height: 28px;
  align-items: center;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 800;
}

.status.active {
  color: #2f6526;
  background: #e7f3e4;
}

.status.inactive {
  color: #84313d;
  background: #f7dfe4;
}

.filters,
.form-grid {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}

.filters {
  grid-template-columns: 180px minmax(220px, 1fr) auto;
  align-items: end;
}

.form-grid {
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 22px;
}

.wide {
  grid-column: 1 / -1;
}

.photo-uploader {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 112px;
  gap: 16px;
  align-items: end;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 16px;
}

.field-hint {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.photo-preview {
  width: 96px;
  height: 96px;
  justify-self: end;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  background: #fff;
  object-fit: cover;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.photo-preview.empty {
  padding: 12px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  align-self: end;
}

.checkbox-label input {
  width: 16px;
  min-height: 16px;
}

.flash {
  border-radius: 8px;
  margin-bottom: 18px;
  padding: 12px 14px;
  font-weight: 700;
}

.flash.success {
  color: #2f6526;
  background: #e7f3e4;
}

.flash.error {
  color: #84313d;
  background: #f7dfe4;
}

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

.login-shell {
  background:
    linear-gradient(160deg, rgba(63, 87, 147, 0.96), rgba(30, 42, 50, 0.94)),
    #1e2a32;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  padding: 28px;
}

.login-brand {
  margin-bottom: 24px;
}

.stack {
  display: grid;
  gap: 16px;
}

.qr-layout {
  display: grid;
  grid-template-columns: minmax(260px, 420px) minmax(320px, 1fr);
  gap: 18px;
}

.qr-preview {
  display: grid;
  place-items: center;
  min-height: 430px;
  padding: 24px;
}

.qr-preview img {
  width: min(340px, 100%);
  aspect-ratio: 1;
}

.qr-details {
  display: grid;
  align-content: start;
  gap: 16px;
  padding: 24px;
}

.empty-state {
  display: grid;
  justify-items: start;
  gap: 10px;
  padding: 28px;
}

.profile-shell {
  min-height: 100vh;
  background:
    linear-gradient(180deg, var(--brand) 0, var(--brand) 285px, #f4f5f6 285px),
    #f4f5f6;
}

.profile-page {
  width: min(560px, 100%);
  margin: 0 auto;
  padding: 30px 16px 60px;
}

.profile-card {
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow);
}

.profile-hero {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 10px;
  min-height: 250px;
  padding: 64px 28px 22px;
  color: #fff;
  text-align: center;
  background:
    linear-gradient(135deg, rgba(63, 87, 147, 0.96), rgba(94, 152, 78, 0.88)),
    var(--brand);
}

.profile-brandline {
  position: absolute;
  top: 18px;
  left: 22px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  font-weight: 800;
}

.profile-brandline > span:last-child {
  font-size: 11px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.profile-logo-badge {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #fff;
  padding: 2px;
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(20, 32, 48, 0.14);
}

.profile-logo-badge.small {
  width: 54px;
  height: 54px;
  padding: 4px;
}

.profile-logo-badge img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.avatar {
  width: 118px;
  height: 118px;
  border: 4px solid rgba(255, 255, 255, 0.86);
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
}

.avatar.initials {
  display: grid;
  place-items: center;
  color: var(--brand);
  font-size: 28px;
  font-weight: 900;
}

.profile-hero h1 {
  margin: 4px 0 0;
  font-size: 23px;
}

.profile-title,
.profile-department {
  margin: 0;
  opacity: 0.9;
}

.profile-department {
  max-width: 90%;
  color: rgba(255, 255, 255, 0.84);
  font-size: 14px;
}

.verified {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 5px 10px;
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
  font-size: 12px;
  font-weight: 800;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 18px 32px 8px;
  background: #fff;
}

.quick-actions a {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-radius: 999px;
  color: #fff;
  background: var(--brand);
  box-shadow: 0 10px 22px rgba(63, 87, 147, 0.18);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.quick-actions a:first-child {
  background: var(--success);
  box-shadow: 0 10px 22px rgba(94, 152, 78, 0.2);
}

.quick-actions i {
  font-size: 14px;
}

.quick-actions a + a {
  border-left: 0;
}

.contact-list {
  padding: 16px 32px 18px;
}

.contact-row {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 12px;
  align-items: center;
  min-height: 72px;
  border-bottom: 1px solid var(--line);
}

.contact-row:last-child {
  border-bottom: 0;
}

.contact-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--brand);
  background: #eef2fb;
  font-size: 16px;
}

.contact-row strong {
  display: block;
  overflow-wrap: anywhere;
}

.contact-row small {
  color: var(--muted);
}

.download-vcard {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 54px;
  margin: 18px 32px 32px;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  font-weight: 900;
  text-transform: uppercase;
  box-shadow: 0 12px 24px rgba(152, 37, 44, 0.28);
}

.profile-card.unavailable {
  display: grid;
  justify-items: center;
  gap: 12px;
  min-height: 320px;
  padding: 36px;
  text-align: center;
}

.profile-card.unavailable .verified {
  color: var(--brand);
  background: #eef2fb;
}

@media (max-width: 900px) {
  .topbar,
  .page-heading,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .main-nav {
    margin-left: 0;
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }

  .filters,
  .form-grid,
  .qr-layout,
  .photo-uploader {
    grid-template-columns: 1fr;
  }

  .photo-preview {
    justify-self: start;
  }
}

@media (max-width: 560px) {
  .page {
    width: min(100% - 20px, 1180px);
    margin-top: 18px;
  }

  .topbar {
    padding: 12px 16px;
  }

  .page-heading h1 {
    font-size: 24px;
  }

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

  .contact-list {
    padding: 20px 18px 14px;
  }

  .quick-actions {
    padding: 16px 18px 4px;
  }

  .download-vcard {
    margin: 16px 18px 24px;
  }

  .quick-actions a {
    min-height: 46px;
    padding: 0 12px;
    font-size: 11px;
  }

  .quick-actions a + a {
    border-left: 0;
    border-top: 0;
  }
}

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