@font-face {
  font-family: "Space Grotesk";
  src: url("/admin/static/fonts/SpaceGrotesk-var.woff2") format("woff2");
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("/admin/static/fonts/JetBrainsMono-Regular.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("/admin/static/fonts/JetBrainsMono-Medium.woff2") format("woff2");
  font-style: normal;
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Sans Arabic";
  src: url("/admin/static/fonts/IBMPlexSansArabic-Regular.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Sans Arabic";
  src: url("/admin/static/fonts/IBMPlexSansArabic-Bold.woff2") format("woff2");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

:root {
  --void: #000000;
  --abyss: #05080a;
  --deep: #080c0f;
  --undertow: #0e161a;
  --petrol: #131e22;
  --slate: #294048;
  --signal: #49707f;
  --ash: #608490;
  --haze: #7798a1;
  --mist: #a1b9bd;
  --frost: #c2d4d4;
  --first-light: #dcebe6;
  --nominal: #49707f;
  --elevated: #d69a3c;
  --critical: #c2611f;
  --motion: cubic-bezier(0.2, 0, 0, 1);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--deep);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--frost);
  background: var(--deep);
  font-family: "Space Grotesk", sans-serif;
  line-height: 1.5;
}

html[lang="ar"] body,
html[lang="ar"] input,
html[lang="ar"] button {
  font-family: "IBM Plex Sans Arabic", "Space Grotesk", sans-serif;
}

button,
input {
  font: inherit;
}

button,
a,
input {
  transition: transform 120ms var(--motion), opacity 120ms var(--motion);
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--first-light);
  outline-offset: 3px;
}

a {
  color: var(--first-light);
  text-underline-offset: 4px;
}

a:hover {
  color: var(--frost);
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.skip-link {
  position: fixed;
  inset-block-start: 8px;
  inset-inline-start: 8px;
  z-index: 100;
  padding: 10px 16px;
  color: var(--deep);
  background: var(--first-light);
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--first-light);
  text-decoration: none;
}

.brand img {
  width: 34px;
  height: 30px;
  object-fit: contain;
}

.brand p {
  margin: 0;
  line-height: 1.15;
}

.brand-name {
  font-weight: 700;
  letter-spacing: 0.12em;
}

.brand-section {
  margin-block-start: 4px !important;
  color: var(--mist);
  font-size: 0.75rem;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--haze);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

html[lang="ar"] .eyebrow {
  letter-spacing: 0;
}

h1 {
  margin: 0;
  color: var(--first-light);
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 1.08;
}

.alert {
  padding: 12px 16px;
  border-inline-start: 3px solid var(--critical);
  color: var(--first-light);
  background: var(--petrol);
}

.primary-button,
.secondary-button,
.text-button {
  min-height: 44px;
  border-radius: 2px;
  font-weight: 600;
}

.primary-button {
  width: 100%;
  border: 1px solid var(--first-light);
  color: var(--deep);
  background: var(--first-light);
}

.primary-button:hover {
  transform: translateY(-1px);
}

.secondary-button {
  padding-inline: 16px;
  border: 1px solid var(--haze);
  color: var(--first-light);
  background: var(--petrol);
}

.secondary-button:hover {
  border-color: var(--first-light);
}

.text-button {
  padding-inline: 8px;
  border: 0;
  color: var(--first-light);
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 4px;
}

input[type="text"],
input[type="password"],
input[type="search"] {
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--slate);
  border-radius: 2px;
  color: var(--first-light);
  background: var(--abyss);
  caret-color: var(--first-light);
}

input::placeholder {
  color: var(--haze);
  opacity: 1;
}

label {
  color: var(--frost);
  font-size: 0.875rem;
  font-weight: 600;
}

/* Login */
.login-shell {
  background-color: var(--deep);
  background-image:
    linear-gradient(var(--slate) 1px, transparent 1px),
    linear-gradient(90deg, var(--slate) 1px, transparent 1px);
  background-size: 64px 64px;
  background-position: center;
}

.login-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  background: linear-gradient(to bottom, var(--deep), transparent 35%, var(--deep));
  pointer-events: none;
}

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

.login-card {
  width: min(100%, 440px);
  border: 1px solid var(--slate);
  border-radius: 4px;
  background: var(--undertow);
}

.brand-login {
  width: 100%;
  padding: 20px 24px;
  border-block-end: 1px solid var(--slate);
}

.login-intro,
.login-form,
.login-card > .alert {
  margin-inline: 32px;
}

.login-intro {
  margin-block-start: 36px;
}

.login-intro p:last-child {
  margin: 16px 0 0;
  color: var(--mist);
}

.login-card > .alert {
  margin-block-start: 24px;
}

.login-form {
  display: grid;
  gap: 8px;
  margin-block: 28px 36px;
}

.login-form label:not(:first-of-type) {
  margin-block-start: 12px;
}

.password-field {
  position: relative;
  display: grid;
}

.password-field input {
  padding-inline-end: 76px;
}

.password-toggle {
  position: absolute;
  inset-block: 2px;
  inset-inline-end: 2px;
  min-height: 44px;
}

.login-form .primary-button {
  margin-block-start: 20px;
}

.login-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 56px;
  padding: 12px 24px;
  border-block-start: 1px solid var(--slate);
  color: var(--mist);
  font-size: 0.75rem;
}

/* Application shell */
.topbar {
  position: sticky;
  inset-block-start: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 72px;
  padding-inline: clamp(20px, 4vw, 64px);
  border-block-end: 1px solid var(--slate);
  background: var(--abyss);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 20px;
}

.topbar-actions form {
  margin: 0;
}

.language-link {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.admin-name {
  color: var(--mist);
  font-size: 0.875rem;
}

.panel-main {
  width: min(100%, 1440px);
  margin-inline: auto;
  padding: clamp(32px, 5vw, 72px) clamp(20px, 4vw, 64px);
}

.page-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 32px;
  margin-block-end: 32px;
}

.page-heading p:last-child {
  max-width: 660px;
  margin: 14px 0 0;
  color: var(--mist);
}

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: max-content;
  padding: 8px 12px;
  border: 1px solid var(--slate);
  border-radius: 2px;
  color: var(--frost);
  font-size: 0.75rem;
}

.live-dot,
.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--nominal);
}

.codes-panel {
  border: 1px solid var(--slate);
  border-radius: 4px;
  background: var(--undertow);
}

.search-form {
  display: grid;
  gap: 8px;
  padding: 20px 24px;
  border-block-end: 1px solid var(--slate);
}

.search-row {
  display: flex;
  gap: 8px;
}

.search-row input {
  width: min(100%, 480px);
}

.clear-search {
  display: inline-flex;
  align-items: center;
}

.table-wrap {
  min-height: 260px;
}

.codes-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.codes-table th {
  padding: 12px 16px;
  border-block-end: 1px solid var(--slate);
  color: var(--haze);
  background: var(--petrol);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-align: start;
  text-transform: uppercase;
}

html[lang="ar"] .codes-table th {
  letter-spacing: 0;
}

.codes-table th:nth-child(1) { width: 19%; }
.codes-table th:nth-child(2) { width: 18%; }
.codes-table th:nth-child(3) { width: 14%; }
.codes-table th:nth-child(4) { width: 13%; }
.codes-table th:nth-child(5) { width: 14%; }
.codes-table th:nth-child(6) { width: 22%; }

.codes-table td {
  height: 80px;
  padding: 14px 16px;
  border-block-end: 1px solid var(--slate);
  color: var(--frost);
  font-size: 0.875rem;
  vertical-align: middle;
}

.codes-table tbody tr:last-child td {
  border-block-end: 0;
}

.codes-table tbody tr:hover td {
  background: var(--petrol);
}

.phone,
.masked-code,
.revealed-code,
.countdown {
  font-family: "JetBrains Mono", monospace;
  font-variant-numeric: tabular-nums;
  unicode-bidi: isolate;
}

.phone {
  color: var(--first-light);
  white-space: nowrap;
}

.code-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
}

.masked-code {
  color: var(--mist);
  font-size: 1rem;
  letter-spacing: 0.12em;
}

.revealed-code {
  color: var(--first-light);
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: 0.14em;
}

.reveal-button {
  min-height: 36px;
  padding-inline: 12px;
  font-size: 0.8125rem;
}

.copy-button {
  min-height: 36px;
  font-size: 0.8125rem;
}

.relative-time {
  color: var(--frost);
}

.countdown {
  color: var(--frost);
}

.countdown.elevated {
  color: var(--elevated);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.status-elevated .status-dot {
  background: var(--elevated);
}

.status-critical .status-dot {
  background: var(--critical);
}

.status-muted .status-dot {
  background: var(--haze);
}

.reveal-history {
  display: grid;
}

.reveal-history time,
.unavailable {
  color: var(--haze);
  font-size: 0.75rem;
}

.empty-state {
  display: grid;
  min-height: 220px;
  place-content: center;
  text-align: center;
}

.empty-state p {
  margin: 4px;
  color: var(--mist);
}

.empty-state .empty-title {
  color: var(--first-light);
  font-size: 1.125rem;
  font-weight: 600;
}

.dynamic-alert {
  margin: 16px 24px;
}

.panel-footer {
  margin-block-start: 20px;
  color: var(--mist);
  font-size: 0.8125rem;
  text-align: center;
}

@media (max-width: 760px) {
  .topbar {
    position: static;
    align-items: flex-start;
    gap: 12px;
    padding-block: 16px;
  }

  .admin-name {
    display: none;
  }

  .topbar-actions {
    gap: 4px;
  }

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

  .codes-panel {
    border: 0;
    background: transparent;
  }

  .search-form {
    padding: 16px;
    border: 1px solid var(--slate);
    border-radius: 4px;
    background: var(--undertow);
  }

  .search-row {
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .clear-search {
    grid-column: 1 / -1;
  }

  .codes-table,
  .codes-table tbody {
    display: block;
  }

  .codes-table thead {
    display: none;
  }

  .codes-table tr {
    display: grid;
    margin-block-start: 12px;
    border: 1px solid var(--slate);
    border-radius: 4px;
    background: var(--undertow);
  }

  .codes-table td {
    display: grid;
    grid-template-columns: minmax(104px, 34%) 1fr;
    align-items: center;
    gap: 12px;
    height: auto;
    min-height: 56px;
    padding: 10px 14px;
    text-align: start;
  }

  .codes-table td::before {
    content: attr(data-label);
    color: var(--haze);
    font-size: 0.75rem;
    font-weight: 600;
  }

  .codes-table .empty-row {
    display: block;
  }

  .codes-table .empty-row td {
    display: block;
  }

  .codes-table .empty-row td::before {
    display: none;
  }

  .code-cell {
    flex-wrap: wrap;
  }
}

@media (max-width: 430px) {
  .login-main {
    padding: 12px;
  }

  .login-intro,
  .login-form,
  .login-card > .alert {
    margin-inline: 20px;
  }

  .topbar {
    padding-inline: 16px;
  }

  .brand-section {
    display: none;
  }

  .panel-main {
    padding-inline: 12px;
  }

  .search-row {
    grid-template-columns: 1fr;
  }

  .search-row .secondary-button {
    width: 100%;
  }

  .codes-table td {
    grid-template-columns: 96px 1fr;
    padding-inline: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0ms !important;
    animation-duration: 0ms !important;
  }
}
