:root {
  --bg: #f4f6fa;
  --bg-accent: #eaf0f8;
  --ink: #0f172a;
  --muted: #5b677a;
  --accent: #1f6feb;
  --accent-dark: #1a56c7;
  --accent-soft: #e6f0ff;
  --teal: #1b8b76;
  --card: #ffffff;
  --line: #e2e8f0;
  --shadow: 0 14px 36px rgba(15, 23, 42, 0.12);
  --shadow-soft: 0 4px 12px rgba(15, 23, 42, 0.08);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Tahoma", "Arial", sans-serif;
  color: var(--ink);
  background: linear-gradient(135deg, var(--bg-accent), var(--bg));
  direction: rtl;
  text-align: right;
  line-height: 1.6;
}

body.drawer-open {
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: radial-gradient(rgba(15, 23, 42, 0.06) 1px, transparent 1px);
  background-size: 26px 26px;
  opacity: 0.25;
  pointer-events: none;
  z-index: 0;
}

.app-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
  flex-wrap: wrap;
}

.drawer-toggle {
  display: none;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  cursor: pointer;
  font-size: 18px;
}

.app-body {
  flex: 1;
}

.app-layout.has-drawer .app-body {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.app-drawer {
  background: #fff;
  border-inline-end: 1px solid var(--line);
  padding: 24px 18px;
  position: relative;
}

.app-layout.has-drawer .app-drawer {
  grid-column: 1;
  grid-row: 1;
}

.app-layout.has-drawer .page {
  grid-column: 2;
  grid-row: 1;
}

.drawer-title {
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--muted);
}

.drawer-nav {
  display: grid;
  gap: 10px;
}

.drawer-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  background: #f7f9fc;
  transition: all 0.2s ease;
}

.drawer-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.drawer-link.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.drawer-count {
  font-size: 12px;
  font-weight: 700;
  background: rgba(15, 23, 42, 0.08);
  padding: 2px 8px;
  border-radius: 999px;
}

.drawer-link.active .drawer-count {
  background: rgba(255, 255, 255, 0.35);
  color: #fff;
}

.drawer-scrim {
  display: none;
}

.app-layout.has-drawer .drawer-scrim {
  grid-column: 1 / -1;
  grid-row: 1;
}

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

.brand-mark {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}

.brand-text {
  font-family: "Tahoma", "Arial", sans-serif;
  font-size: 18px;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 14px;
}

.nav-link {
  text-decoration: none;
  color: var(--ink);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.nav-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.nav-user {
  font-weight: 600;
}

.nav-role {
  font-size: 11px;
  letter-spacing: 0;
  color: var(--muted);
}

.page {
  position: relative;
  z-index: 1;
  padding: 24px 32px 80px;
}

.page-inner {
  max-width: 1100px;
  margin: 0 auto;
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 24px;
  background: var(--card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
  margin-bottom: 24px;
  animation: rise 0.45s ease both;
}

.hero h1 {
  margin: 0 0 8px;
  font-family: "Tahoma", "Arial", sans-serif;
  font-size: 30px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 24px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
  margin-bottom: 24px;
  animation: rise 0.5s ease both;
}

.card h1,
.card h2,
.card h3 {
  margin-top: 0;
  font-family: "Tahoma", "Arial", sans-serif;
}

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

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

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 24px 0;
}

.tab-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
  background: #fff;
  transition: all 0.2s ease;
}

.tab-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.tab-button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.tab-count {
  font-size: 12px;
  font-weight: 700;
  background: #eef2f7;
  color: var(--muted);
  padding: 2px 8px;
  border-radius: 999px;
}

.tab-button.active .tab-count {
  background: rgba(255, 255, 255, 0.35);
  color: #fff;
}

.stat {
  background: #f5f8ff;
  border-radius: var(--radius-md);
  padding: 18px;
  border: 1px solid #dce6ff;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat strong {
  font-size: 24px;
  color: var(--accent-dark);
}

.form-grid {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}

input,
select,
textarea,
button {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  font-family: inherit;
  font-size: 14px;
  text-align: right;
  background: #fff;
  color: var(--ink);
}

input[type="number"] {
  direction: ltr;
  text-align: left;
}

input[type="datetime-local"] {
  direction: ltr;
  text-align: left;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  padding: 10px 18px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s ease;
  font-family: inherit;
}

.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

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

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

.btn.danger {
  background: #d64545;
  color: #fff;
  border-color: #d64545;
}

.btn.danger:hover {
  background: #b93636;
  border-color: #b93636;
}

.btn.ghost {
  border-color: transparent;
  color: var(--muted);
  background: transparent;
}

.btn.ghost:hover {
  border-color: transparent;
  color: var(--accent);
  background: var(--accent-soft);
}

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

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th,
.table td {
  text-align: right;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
}

.table th {
  color: var(--muted);
  font-weight: 600;
  background: #f8fafc;
}

.table tbody tr:nth-child(even) {
  background: #fbfcfe;
}

.table tbody tr:hover {
  background: #f2f6ff;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: #e7f6f1;
  color: var(--teal);
}

.badge.off {
  background: #f1f3f8;
  color: #6c7280;
}

.badge.warn {
  background: #fff2d9;
  color: #9a5a00;
}

.list {
  margin: 0;
  padding-inline-start: 18px;
  color: var(--muted);
}

.inline {
  display: inline;
}

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 18px;
  font-size: 14px;
  border: 1px solid transparent;
}

.alert.info {
  background: #e7f6f1;
  color: var(--teal);
  border-color: #cdebe1;
}

.alert.success {
  background: #e8f6ec;
  color: #2f6c33;
  border-color: #cfead7;
}

.alert.error {
  background: #fff2f2;
  color: #b93636;
  border-color: #ffd8d8;
}

.camera-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 24px;
  margin: 18px 0;
  align-items: center;
}

#cameraPreview {
  width: 100%;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: #0f172a;
}

.camera-note {
  background: #f6faf9;
  border-radius: var(--radius-md);
  padding: 16px;
  border: 1px solid #cfe1da;
}

.exam-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.timer {
  background: #0f172a;
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  text-align: center;
  min-width: 120px;
  direction: ltr;
}

.timer strong {
  font-size: 22px;
  display: block;
}

.divider {
  height: 1px;
  background: var(--line);
  margin: 20px 0;
}

.question {
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px dashed var(--line);
}

.options {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: #fff;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.option input {
  margin: 0;
  accent-color: var(--accent);
}

.option input:checked + span {
  color: var(--accent-dark);
  font-weight: 600;
}

.save-status {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}

.record-status,
.live-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #eef2ff;
  color: var(--accent-dark);
  border: 1px solid #d7e4ff;
  margin-bottom: 12px;
}

.record-status.on,
.live-status.on {
  background: #e7f6f1;
  color: var(--teal);
  border-color: #cdebe1;
}

.record-status.off,
.live-status.off {
  background: #fff2f2;
  color: #b93636;
  border-color: #ffd8d8;
}

.video-player {
  width: 100%;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: #0f172a;
  margin: 16px 0;
}

.site-footer {
  text-align: center;
  padding: 20px;
  color: var(--muted);
  font-size: 13px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.6);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 960px) {
  .app-layout.has-drawer .app-body {
    grid-template-columns: 1fr;
  }

  .drawer-toggle {
    display: inline-flex;
  }

  .app-drawer {
    position: fixed;
    top: 64px;
    bottom: 0;
    right: 0;
    width: 260px;
    transform: translateX(100%);
    transition: transform 0.2s ease;
    z-index: 20;
    box-shadow: var(--shadow);
  }

  body.drawer-open .app-drawer {
    transform: translateX(0);
  }

  .drawer-scrim {
    display: block;
    position: fixed;
    inset: 64px 0 0 0;
    background: rgba(15, 23, 42, 0.2);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 15;
  }

  body.drawer-open .drawer-scrim {
    opacity: 1;
    pointer-events: auto;
  }

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

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

  .hero {
    flex-direction: column;
    gap: 16px;
  }

  .page {
    padding: 20px 18px 64px;
  }

  .card,
  .hero {
    padding: 20px;
  }

  .card {
    overflow-x: auto;
  }

  .table {
    min-width: 640px;
  }
}

@media (max-width: 640px) {
  .grid.two,
  .grid.four {
    grid-template-columns: 1fr;
  }

  .app-bar {
    flex-direction: column;
    gap: 10px;
    padding: 12px 16px;
  }

  .timer {
    width: 100%;
  }

  .page {
    padding: 18px 14px 56px;
  }

  .table {
    font-size: 13px;
  }
}
