.admin-page {
  min-height: 100vh;
  overflow-x: hidden;
  background: #f2f2f3;
}

.admin-login-shell {
  display: grid;
  grid-template-columns: minmax(420px, 1.05fr) minmax(480px, 0.95fr);
  min-height: 100vh;
}

.login-media {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
  padding: 54px max(54px, calc((100vw - 1240px) / 2));
  overflow: hidden;
  background: var(--black);
  color: var(--white);
}

.login-media::before,
.login-media::after {
  position: absolute;
  inset: 0;
  content: "";
}

.login-media::before {
  background: url('/assets/audi-r26.jpg') center / cover;
  filter: saturate(0.6) brightness(0.58);
}

.login-media::after {
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.25), rgba(0, 0, 0, 0.86));
}

.login-media > * {
  position: relative;
  z-index: 1;
}

.login-media h1 {
  max-width: 600px;
  margin: 0;
  font-size: 60px;
  font-weight: 500;
  line-height: 1;
}

.login-media div > p:last-child {
  max-width: 560px;
  margin: 26px 0 0;
  color: #d0d0d2;
  line-height: 1.7;
}

.login-disclosure {
  color: #98989c;
  font-size: 10px;
  text-transform: uppercase;
}

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  background: var(--white);
}

.login-form-wrap {
  width: min(420px, 100%);
}

.login-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin-bottom: 28px;
  background: var(--ink);
  color: var(--white);
}

.login-mark svg {
  width: 21px;
}

.login-form-wrap h2 {
  margin: 0;
  font-size: 31px;
  font-weight: 500;
  line-height: 1.15;
}

.login-form-wrap > p:not(.form-kicker) {
  margin: 16px 0 30px;
  color: #66666a;
  line-height: 1.6;
}

.login-form-wrap form {
  display: grid;
  gap: 18px;
}

.login-form-wrap .field {
  display: grid;
  gap: 7px;
}

.login-form-wrap .field > span {
  font-size: 12px;
  font-weight: 700;
}

.login-form-wrap .field input {
  width: 100%;
  height: 50px;
  padding: 0 13px;
  background: var(--white);
  border: 1px solid #b7b7ba;
  border-radius: 2px;
  outline: none;
}

.login-form-wrap .field input:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px rgba(23, 23, 25, 0.08);
}

.login-form-wrap .button {
  min-height: 50px;
}

.dark-back-link {
  margin-top: 28px;
  color: #66666a;
}

.admin-app[hidden],
.admin-login-shell[hidden] {
  display: none;
}

.admin-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 0 32px;
  background: var(--black);
  color: var(--white);
  border-bottom: 1px solid #303034;
}

.admin-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-header .button-secondary {
  border-color: #5a5a5e;
  background: transparent;
  color: var(--white);
}

.copy-link-button svg,
.drawer-actions .button-secondary svg {
  margin-right: 10px;
  margin-left: 0;
}

.admin-icon-button {
  border-color: #4d4d51;
  color: var(--white);
}

.admin-main {
  width: min(1360px, calc(100% - 64px));
  margin: 0 auto;
  padding: 54px 0 80px;
}

.admin-title-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
}

.admin-title-row h1 {
  margin: 0;
  font-size: 40px;
  font-weight: 500;
  line-height: 1.1;
}

.admin-title-row > div:first-child > p:last-child {
  margin: 10px 0 0;
  color: #6f6f73;
  font-size: 13px;
}

.mail-mode {
  display: grid;
  grid-template-columns: 9px auto;
  align-items: center;
  gap: 8px;
  min-width: 190px;
  padding: 12px 14px;
  background: #fff5df;
  border: 1px solid #efd9ad;
  color: #704300;
}

.mail-mode > span {
  width: 9px;
  height: 9px;
  background: var(--amber);
  border-radius: 50%;
}

.mail-mode strong {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.mail-mode.is-live {
  background: #eaf6f2;
  border-color: #b8ddd1;
  color: #155e4c;
}

.mail-mode.is-live > span {
  background: var(--green);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 34px;
  background: var(--white);
  border: 1px solid #dedee0;
}

.metrics > div {
  min-width: 0;
  padding: 22px 24px;
  border-right: 1px solid #dedee0;
}

.metrics > div:last-child {
  border-right: 0;
}

.metrics span,
.metrics strong {
  display: block;
}

.metrics span {
  margin-bottom: 8px;
  color: #747478;
  font-size: 11px;
}

.metrics strong {
  font-size: 30px;
  font-weight: 500;
}

.active-allocation {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 18px;
  margin-top: 16px;
  padding: 20px 22px;
  background: var(--ink);
  color: var(--white);
}

.allocation-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: #303034;
  color: #85858a;
}

.active-allocation.has-guest .allocation-icon {
  background: var(--green);
  color: var(--white);
}

.allocation-icon svg {
  width: 23px;
}

.allocation-copy span,
.allocation-copy strong,
.allocation-copy small {
  display: block;
}

.allocation-copy span {
  color: #8f8f94;
  font-size: 10px;
  text-transform: uppercase;
}

.allocation-copy strong {
  margin-top: 3px;
  font-size: 17px;
  font-weight: 500;
}

.allocation-copy small {
  margin-top: 3px;
  color: #a8a8ac;
}

.active-allocation .button-secondary {
  border-color: #66666a;
  background: transparent;
  color: var(--white);
}

.workspace-tabs {
  display: flex;
  align-items: flex-end;
  gap: 28px;
  margin-top: 42px;
  border-bottom: 1px solid #cfcfd1;
}

.workspace-tabs button {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 2px 15px;
  background: transparent;
  border: 0;
  color: #757579;
  cursor: pointer;
  font-size: 13px;
}

.workspace-tabs button::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  background: var(--red);
  content: "";
  opacity: 0;
}

.workspace-tabs button.is-active {
  color: var(--ink);
  font-weight: 700;
}

.workspace-tabs button.is-active::after {
  opacity: 1;
}

.workspace-tabs svg {
  width: 17px;
}

.applications-workspace,
.email-workspace {
  min-width: 0;
  max-width: 100%;
  margin-top: 24px;
}

.applications-workspace[hidden],
.email-workspace[hidden] {
  display: none;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.status-filters {
  display: flex;
  min-width: 0;
  overflow-x: auto;
  background: #e5e5e7;
  padding: 3px;
}

.status-filters button {
  min-height: 34px;
  padding: 0 14px;
  background: transparent;
  border: 0;
  color: #6c6c70;
  cursor: pointer;
  font-size: 11px;
  white-space: nowrap;
}

.status-filters button.is-active {
  background: var(--white);
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  font-weight: 700;
}

.search-control {
  display: flex;
  align-items: center;
  width: min(340px, 100%);
  height: 42px;
  padding-left: 13px;
  background: var(--white);
  border: 1px solid #d0d0d2;
}

.search-control svg {
  flex: 0 0 auto;
  width: 17px;
  color: #79797d;
}

.search-control input {
  width: 100%;
  min-width: 0;
  height: 40px;
  padding: 0 12px;
  background: transparent;
  border: 0;
  outline: none;
  font-size: 12px;
}

.admin-alert {
  margin-bottom: 14px;
  padding: 12px 14px;
  background: #fff0f1;
  border-left: 3px solid var(--red);
  color: #7f0011;
  font-size: 12px;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  background: var(--white);
  border: 1px solid #dcdcdf;
}

.applications-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  table-layout: fixed;
}

.applications-table th,
.applications-table td {
  padding: 16px 18px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid #e2e2e4;
}

.applications-table th {
  background: #f6f6f7;
  color: #717176;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.applications-table th:first-child { width: 34%; }
.applications-table th:nth-child(2) { width: 18%; }
.applications-table th:nth-child(3) { width: 18%; }
.applications-table th:nth-child(4) { width: 17%; }
.applications-table th:last-child { width: 70px; }

.applications-table tbody tr:last-child td {
  border-bottom: 0;
}

.applications-table tbody tr:hover {
  background: #fafafa;
}

.applicant-cell {
  display: grid;
  grid-template-columns: 38px 1fr;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.applicant-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: #e5e5e7;
  color: #555559;
  font-size: 11px;
  font-weight: 700;
}

.applicant-cell strong,
.applicant-cell span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.applicant-cell strong {
  font-size: 13px;
  font-weight: 700;
}

.applicant-cell span,
.table-secondary {
  margin-top: 3px;
  color: #77777b;
  font-size: 11px;
}

.table-reference {
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 0 9px;
  border-radius: 2px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.status-pending { background: #fff1d6; color: #784900; }
.status-approved { background: #dff3ec; color: #0e624e; }
.status-declined { background: #ececef; color: #59595e; }
.status-cancelled { background: #fde4e7; color: #8f0013; }

.row-action {
  border-color: #d0d0d3;
  color: var(--ink);
}

.table-empty {
  display: grid;
  place-items: center;
  min-height: 250px;
  padding: 40px;
  text-align: center;
}

.table-empty[hidden] {
  display: none;
}

.table-empty svg {
  width: 28px;
  height: 28px;
  margin-bottom: 14px;
  color: #9a9a9e;
}

.table-empty strong {
  font-size: 14px;
}

.table-empty span {
  margin-top: 5px;
  color: #858589;
  font-size: 12px;
}

.email-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 16px;
}

.email-heading h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 500;
}

.email-heading p {
  margin: 6px 0 0;
  color: #76767a;
  font-size: 12px;
}

.email-heading > span {
  color: #76767a;
  font-size: 11px;
}

.email-list {
  background: var(--white);
  border: 1px solid #dcdcdf;
}

.email-row {
  display: grid;
  grid-template-columns: 42px minmax(220px, 1.2fr) minmax(180px, 0.8fr) 120px 130px;
  align-items: center;
  gap: 14px;
  min-height: 70px;
  padding: 12px 16px;
  border-bottom: 1px solid #e2e2e4;
}

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

.email-type-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: #f0f0f1;
}

.email-type-icon svg {
  width: 17px;
}

.email-row strong,
.email-row span,
.email-row small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.email-row strong {
  display: block;
  font-size: 12px;
}

.email-row small,
.email-row span {
  color: #737377;
  font-size: 10px;
}

.delivery-status {
  display: inline-flex;
  justify-self: start;
  min-height: 24px;
  align-items: center;
  padding: 0 8px;
  background: #ececef;
  color: #55555a;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.delivery-sent { background: #dff3ec; color: #0e624e; }
.delivery-failed { background: #fde4e7; color: #8f0013; }

.drawer-backdrop,
.confirmation-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.48);
}

.drawer-backdrop[hidden],
.confirmation-backdrop[hidden] {
  display: none;
}

.application-drawer {
  position: fixed;
  z-index: 41;
  top: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  width: min(620px, 94vw);
  background: var(--white);
  box-shadow: -24px 0 60px rgba(0, 0, 0, 0.2);
  animation: drawer-in 220ms ease both;
}

.application-drawer[hidden] {
  display: none;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 88px;
  padding: 22px 26px;
  background: var(--ink);
  color: var(--white);
}

.drawer-header h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 500;
}

.drawer-header .form-kicker {
  color: #d68791;
}

.drawer-body {
  overflow-y: auto;
  padding: 26px;
}

.detail-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.detail-status-row small {
  color: #77777b;
  font-family: Consolas, "Courier New", monospace;
}

.detail-section {
  padding: 24px 0;
  border-bottom: 1px solid var(--line);
}

.detail-section h3 {
  margin: 0 0 16px;
  font-size: 11px;
  text-transform: uppercase;
}

.detail-section dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px 24px;
  margin: 0;
}

.detail-section dl.long-details {
  grid-template-columns: 1fr;
}

.detail-section dt {
  margin-bottom: 5px;
  color: #77777b;
  font-size: 10px;
}

.detail-section dd {
  margin: 0;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.sensitive-value {
  display: flex;
  align-items: center;
  gap: 8px;
}

.reveal-button {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-color: #d0d0d3;
  color: var(--ink);
}

.reveal-button svg {
  width: 15px;
  height: 15px;
}

.drawer-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 9px;
  padding: 18px 22px;
  background: #f5f5f6;
  border-top: 1px solid #dddde0;
}

.button-danger {
  background: #a50016;
  color: var(--white);
}

.button-danger:hover {
  background: #7e0011;
}

.decline-button {
  border-color: #99999d;
}

.confirmation-backdrop {
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
}

.confirmation-dialog {
  width: min(440px, 100%);
  padding: 30px;
  background: var(--white);
  box-shadow: var(--shadow);
}

.confirmation-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-bottom: 22px;
  background: #fde4e7;
  color: var(--red-dark);
}

.confirmation-icon svg {
  width: 21px;
}

.confirmation-dialog h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 500;
}

.confirmation-dialog p {
  margin: 14px 0 26px;
  color: #66666a;
  line-height: 1.6;
}

.confirmation-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.toast {
  position: fixed;
  z-index: 60;
  right: 24px;
  bottom: 24px;
  max-width: min(380px, calc(100% - 48px));
  padding: 14px 17px;
  background: var(--ink);
  color: var(--white);
  box-shadow: var(--shadow);
  font-size: 12px;
  line-height: 1.5;
}

.toast[hidden] {
  display: none;
}

@keyframes drawer-in {
  from { transform: translateX(30px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@media (max-width: 900px) {
  .admin-login-shell {
    grid-template-columns: 1fr;
  }

  .login-media {
    min-height: 470px;
    padding: 40px;
  }

  .login-media h1 {
    font-size: 48px;
  }

  .login-panel {
    padding: 70px 32px;
  }

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

  .metrics > div:nth-child(2) {
    border-right: 0;
  }

  .metrics > div:nth-child(-n + 2) {
    border-bottom: 1px solid #dedee0;
  }

  .email-row {
    grid-template-columns: 42px minmax(200px, 1fr) 120px 120px;
  }

  .email-row > span:nth-child(3) {
    display: none;
  }
}

@media (max-width: 680px) {
  .admin-header {
    min-height: 66px;
    padding: 0 16px;
  }

  .copy-link-button span {
    display: none;
  }

  .copy-link-button {
    width: 42px;
    padding: 0;
  }

  .copy-link-button svg {
    margin: 0;
  }

  .admin-main {
    width: calc(100% - 32px);
    padding-top: 38px;
  }

  .admin-title-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-title-row h1 {
    font-size: 34px;
  }

  .mail-mode {
    min-width: 0;
  }

  .metrics > div {
    padding: 18px 16px;
  }

  .metrics span {
    min-height: 32px;
  }

  .active-allocation {
    grid-template-columns: 42px 1fr;
    padding: 18px 16px;
  }

  .allocation-icon {
    width: 42px;
    height: 42px;
  }

  .active-allocation .button {
    grid-column: 1 / -1;
    width: 100%;
  }

  .table-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .status-filters,
  .search-control {
    width: 100%;
  }

  .email-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .email-row {
    grid-template-columns: 38px minmax(0, 1fr) auto;
  }

  .email-row > span:nth-child(3),
  .email-row > span:last-child {
    display: none;
  }

  .application-drawer {
    width: 100%;
  }

  .drawer-header,
  .drawer-body {
    padding-right: 18px;
    padding-left: 18px;
  }

  .detail-section dl {
    grid-template-columns: 1fr;
  }

  .drawer-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    padding-right: 14px;
    padding-left: 14px;
  }

  .drawer-actions .button {
    min-width: 0;
    padding-right: 12px;
    padding-left: 12px;
  }

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