:root {
  --dtu-blue-900: #073b74;
  --dtu-blue-800: #0a4f96;
  --dtu-blue-700: #0d63b7;
  --dtu-blue-100: #e8f2fd;
  --dtu-gold: #f3c51b;
  --dtu-gold-dark: #d79b08;
  --ink: #102033;
  --muted: #65758b;
  --line: #d9e3ef;
  --surface: #ffffff;
  --surface-soft: #f5f8fc;
  --danger: #be123c;
  --success: #047857;
  --warning: #a16207;
  --shadow: 0 18px 45px rgba(13, 51, 87, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background-color: #edf4fb;
  background-image:
    linear-gradient(180deg, rgba(5, 22, 42, 0.82) 0%, rgba(237, 244, 251, 0.95) 48%, rgba(237, 244, 251, 0.98) 100%),
    url('../assets/images/faculty-background.jpg'),
    url('../assets/images/campus-placeholder.svg');
  background-position: center top;
  background-size: cover;
  background-attachment: fixed;
  font-family: Inter, Arial, sans-serif;
  overflow-x: hidden;
}

body.rtl {
  direction: rtl;
  font-family: Cairo, Inter, Arial, sans-serif;
}

.auth-pending .admin-shell {
  visibility: hidden;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none !important;
  box-shadow: none !important;
}

.admin-shell {
  width: min(1260px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 44px;
}

.topbar,
.card {
  border: 1px solid rgba(217, 227, 239, 0.9);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 16px;
  margin-bottom: 20px;
  background: linear-gradient(135deg, rgba(6, 30, 58, 0.96), rgba(7, 59, 116, 0.92));
  backdrop-filter: blur(16px);
  border-radius: 8px;
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: 0 18px 45px rgba(5, 22, 42, 0.22);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand-logo {
  width: 62px;
  height: 62px;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
  border: 2px solid rgba(243, 197, 27, 0.72);
}

.brand strong,
.brand small {
  display: block;
  overflow-wrap: anywhere;
}

.brand strong {
  color: #fff;
  font-size: 1.18rem;
}

.brand small {
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.86rem;
}

.top-actions,
.button-row,
.filter-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.ghost-link,
.language-toggle,
.primary-button,
.secondary-button {
  min-width: 0;
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 16px;
  font-weight: 800;
  text-decoration: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.ghost-link,
.language-toggle,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--dtu-blue-800);
  background: #fff;
  border-color: var(--line);
}

.language-toggle {
  flex: 0 0 auto;
  gap: 7px;
  min-width: 58px;
  padding: 0 12px;
  text-transform: uppercase;
}

.language-toggle::before {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-radius: 50%;
  background:
    linear-gradient(currentColor, currentColor) center / 2px 100% no-repeat,
    linear-gradient(currentColor, currentColor) center / 100% 2px no-repeat;
  opacity: 0.9;
}

.topbar .ghost-link,
.topbar .language-toggle {
  color: #fff;
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.26);
}

.topbar .ghost-link:hover,
.topbar .language-toggle:hover {
  background: rgba(243, 197, 27, 0.18);
  border-color: rgba(243, 197, 27, 0.58);
}

.primary-button {
  color: #fff;
  background: linear-gradient(135deg, var(--dtu-blue-900), var(--dtu-blue-700));
  box-shadow: 0 12px 24px rgba(13, 99, 183, 0.25);
}

.ghost-link:hover,
.language-toggle:hover,
.primary-button:hover,
.secondary-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(13, 51, 87, 0.12);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(320px, 0.92fr);
  gap: 22px;
}

.dashboard-grid > * {
  min-width: 0;
}

.card {
  min-width: 0;
  padding: 24px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  border-top: 4px solid var(--dtu-gold);
  box-shadow: 0 18px 48px rgba(13, 51, 87, 0.14);
}

.attendance-panel {
  grid-column: 1 / -1;
}

.login-shell {
  min-height: 100vh;
}

.login-layout {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 130px);
}

.login-card {
  width: min(100%, 480px);
}

.section-heading,
.table-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  min-width: 0;
}

.section-heading > div,
.table-toolbar > div {
  min-width: 0;
}

.section-heading.compact {
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--dtu-blue-700);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

body.rtl .eyebrow {
  letter-spacing: 0;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  color: var(--dtu-blue-900);
  font-size: 3rem;
  line-height: 1.04;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

h2 {
  margin-bottom: 0;
  color: var(--ink);
  font-size: 1.48rem;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--warning);
  background: #fef9c3;
  font-size: 0.82rem;
  font-weight: 800;
}

.status-pill.is-active {
  color: var(--success);
  background: #dcfce7;
}

.status-pill.is-error {
  color: var(--danger);
  background: #ffe4e6;
}

.scanner-box {
  width: 100%;
  min-height: 324px;
  display: grid;
  place-items: center;
  padding: 14px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(7, 59, 116, 0.12), rgba(243, 197, 27, 0.14)),
    var(--surface-soft);
}

#reader {
  width: min(100%, 460px);
  overflow: hidden;
  border-radius: 8px;
}

#reader video {
  border-radius: 8px;
}

.field-group {
  margin-bottom: 18px;
}

label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 0.93rem;
  font-weight: 800;
}

input[type='text'],
input[type='password'] {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 13px;
  color: var(--ink);
  background: #fbfdff;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

input[type='text']:focus,
input[type='password']:focus {
  border-color: var(--dtu-blue-700);
  box-shadow: 0 0 0 4px rgba(13, 99, 183, 0.12);
}

.field-error {
  display: none;
  margin-top: 7px;
  color: var(--danger);
  font-size: 0.82rem;
  font-weight: 700;
}

.field-group.has-error input {
  border-color: var(--danger);
}

.field-group.has-error .field-error {
  display: block;
}

.login-card .primary-button {
  width: 100%;
}

.notice {
  display: none;
  margin-top: 14px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 8px;
  font-weight: 800;
}

.notice.is-success {
  display: block;
  color: var(--success);
  background: #ecfdf5;
  border: 1px solid #bbf7d0;
}

.notice.is-error {
  display: block;
  color: var(--danger);
  background: #fff1f2;
  border: 1px solid #fecdd3;
}

.notice.is-info {
  display: block;
  color: var(--dtu-blue-800);
  background: var(--dtu-blue-100);
  border: 1px solid #bfdbfe;
}

.empty-state {
  display: grid;
  min-height: 306px;
  place-items: center;
  padding: 20px;
  border-radius: 8px;
  color: var(--muted);
  background:
    linear-gradient(135deg, rgba(232, 242, 253, 0.86), rgba(255, 248, 219, 0.78)),
    var(--surface-soft);
  text-align: center;
}

.scan-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 14px;
  background: rgba(7, 25, 45, 0.58);
  backdrop-filter: blur(10px);
  overflow-y: auto;
}

.student-panel {
  position: relative;
  width: min(100%, 420px);
  max-height: calc(100svh - 28px);
  overflow-y: auto;
  padding: 18px;
}

.scan-close {
  position: absolute;
  inset-inline-end: 10px;
  top: 10px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  color: var(--dtu-blue-900);
  background: var(--surface-soft);
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1;
}

.scan-close:hover {
  box-shadow: 0 10px 20px rgba(13, 51, 87, 0.12);
}

.student-panel .section-heading {
  padding-inline-end: 38px;
  margin-bottom: 14px;
}

.student-result {
  display: grid;
  gap: 14px;
}

.attendance-action {
  width: 100%;
  min-height: 52px;
}

.attendance-action.is-checkout {
  background: linear-gradient(135deg, var(--warning), var(--dtu-gold-dark));
  box-shadow: 0 12px 24px rgba(161, 98, 7, 0.18);
}

dl {
  display: grid;
  gap: 0;
  margin: 0;
}

dl div {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

dl div:first-child {
  padding-top: 0;
}

dt {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

dd {
  margin: 0;
  color: var(--ink);
  font-size: 0.98rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.date-filter {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

input[type='date'] {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

input[type='date']:focus {
  border-color: var(--dtu-blue-700);
  box-shadow: 0 0 0 4px rgba(13, 99, 183, 0.12);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
  background: #fff;
}

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

th {
  color: var(--dtu-blue-900);
  background: var(--surface-soft);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

td {
  color: var(--ink);
  font-size: 0.92rem;
}

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

.table-empty {
  color: var(--muted);
  text-align: center;
}

.code-cell {
  color: var(--dtu-blue-800);
  font-family: Consolas, Monaco, monospace;
  font-weight: 800;
}

.is-hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .dashboard-grid,
  .table-toolbar {
    grid-template-columns: 1fr;
  }

  .dashboard-grid {
    display: grid;
  }

  .table-toolbar {
    display: grid;
  }

  .filter-actions {
    align-items: stretch;
  }

  .date-filter,
  .filter-actions button {
    flex: 1 1 180px;
  }

  h1 {
    font-size: 2.35rem;
  }
}

@media (max-width: 620px) {
  body {
    background-attachment: scroll;
  }

  .admin-shell {
    width: min(100% - 20px, 1220px);
    padding-top: 10px;
  }

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

  .top-actions,
  .button-row,
  .filter-actions {
    display: grid;
    width: 100%;
  }

  .top-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .button-row,
  .filter-actions {
    grid-template-columns: 1fr;
  }

  .ghost-link,
  .button-row button,
  .filter-actions button,
  .date-filter {
    width: 100%;
  }

  .login-page .language-toggle {
    grid-column: 1 / -1;
  }

  .language-toggle {
    justify-self: end;
    width: auto;
  }

  .card {
    padding: 18px;
  }

  .section-heading {
    display: grid;
    grid-template-columns: 1fr;
  }

  .student-panel .section-heading {
    padding-inline-end: 38px;
  }

  .status-pill {
    justify-self: start;
  }

  .brand-logo {
    width: 50px;
    height: 50px;
  }

  h1 {
    font-size: 2rem;
  }

  h2 {
    font-size: 1.28rem;
  }

  .scanner-box {
    min-height: 280px;
  }
}
