:root {
  --app-bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --ink: #162033;
  --muted: #64748b;
  --line: #d8e0ea;
  --brand: #0b776b;
  --brand-dark: #07564d;
  --brand-soft: #e7f5f2;
  --accent: #2563eb;
  --success: #15803d;
  --warning: #b45309;
  --danger: #b91c1c;
  --sidebar-width: 270px;
  --radius: 8px;
  --shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--app-bg);
  color: var(--ink);
  font-family: Tahoma, Arial, sans-serif;
}

a {
  text-decoration: none;
}

/* Restore the original login styles; keep their theme scoped to this page. */
.login-screen {
  --ink: #172033;
  --muted: #667085;
  --brand: #087568;
  --brand-strong: #064e47;
  --amber: #b7791f;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 16px;
  background:
    linear-gradient(120deg, rgba(8, 117, 104, 0.11), transparent 34%),
    linear-gradient(245deg, rgba(183, 121, 31, 0.12), transparent 32%),
    linear-gradient(180deg, #f8fbfd 0%, #eef5f8 100%);
  font-family: "Cairo", "Segoe UI", Tahoma, Arial, sans-serif;
  font-size: 0.95rem;
}

.login-shell {
  width: min(430px, 100%);
}

.login-panel {
  position: relative;
  overflow: hidden;
  padding: 34px 30px 30px;
  border: 1px solid rgba(197, 215, 222, 0.95);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.14);
}

.login-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, var(--brand), var(--amber));
}

.login-brand {
  display: grid;
  align-items: center;
  justify-items: center;
  gap: 12px;
  margin-bottom: 24px;
  text-align: center;
}

.login-title span {
  display: block;
  margin-bottom: 5px;
  color: var(--brand-strong);
  font-size: 0.78rem;
  font-weight: 800;
}

.login-title h1 {
  margin: 0;
  color: var(--ink);
  font-size: 1.28rem;
  font-weight: 900;
  line-height: 1.55;
}

.brand-mark {
  width: 74px;
  height: 74px;
  display: block;
  flex: 0 0 74px;
  margin-bottom: 0;
  padding: 4px;
  border: 1px solid #d8e6df;
  border-radius: 8px;
  background: #fff;
  color: #fff;
  font-weight: 700;
  object-fit: contain;
}

.login-brand .brand-mark {
  width: 92px;
  height: 92px;
  flex: 0 0 92px;
  padding: 7px;
  border-color: #c9ded9;
  box-shadow: 0 10px 24px rgba(8, 117, 104, 0.12);
}

.login-intro {
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid #edf1f5;
  text-align: center;
}

.login-intro strong,
.login-intro small {
  display: block;
}

.login-intro strong {
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 900;
}

.login-intro small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.82rem;
}

.login-panel .form-label {
  margin-bottom: 6px;
  color: #344054;
  font-size: 0.83rem;
  font-weight: 800;
}

.login-panel .form-control {
  min-height: 46px;
  padding-inline: 13px;
  border-color: #cfd9e3;
  color: var(--ink);
  background-color: #fff;
}

.login-panel .form-control:focus {
  border-color: #41a99a;
  box-shadow: 0 0 0 4px rgba(8, 117, 104, 0.12);
}

.login-panel .btn-primary {
  min-height: 46px;
  font-weight: 800;
}

.login-panel .btn-primary:hover,
.login-panel .btn-primary:focus {
  border-color: var(--brand-strong);
  background: var(--brand-strong);
}

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

.app-main {
  min-width: 0;
  flex: 1;
  margin-inline-start: var(--sidebar-width);
}

.content {
  padding: 24px;
}

.sidebar {
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  width: var(--sidebar-width);
  z-index: 1040;
  overflow-y: auto;
  background: #0f172a;
  color: #e2e8f0;
  padding: 18px 16px;
  box-shadow: 2px 0 24px rgba(15, 23, 42, 0.18);
}

.sidebar-brand,
.mobile-sidebar-title {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #ffffff;
}

.sidebar-brand {
  padding: 6px 4px 22px;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.16);
}

.sidebar-brand:hover,
.mobile-sidebar-title:hover {
  color: #ffffff;
}

.brand-symbol,
.mobile-sidebar-title img,
.topbar-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
  flex: 0 0 auto;
}

.sidebar-brand strong,
.mobile-sidebar-title strong {
  display: block;
  line-height: 1.25;
  font-size: 0.95rem;
}

.sidebar-brand small,
.mobile-sidebar-title small {
  display: block;
  color: #9fb1c7;
  font-size: 0.75rem;
}

.mobile-sidebar-header {
  display: none;
}

.mobile-nav-toggle {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(226, 232, 240, 0.22);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.65);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.mobile-nav-toggle span {
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: #ffffff;
}

.sidebar .nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #cbd5e1;
  font-weight: 600;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
  background: rgba(11, 119, 107, 0.2);
  color: #ffffff;
}

.sidebar .nav-link::before {
  content: "";
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  border-radius: 6px;
  background: rgba(226, 232, 240, 0.2);
}

.sidebar .nav-link.active::before {
  background: var(--brand);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 24px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.topbar-title h1,
.topbar-title h2,
.topbar-title p {
  margin: 0;
}

.topbar-title h1,
.topbar-title h2 {
  font-size: 1.08rem;
  line-height: 1.25;
  font-weight: 800;
  color: var(--ink);
}

.topbar-title p,
.topbar-title small {
  color: var(--muted);
  font-size: 0.82rem;
}

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

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.panel + .panel {
  margin-top: 18px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-heading h2,
.panel-heading h3,
.panel-heading h4 {
  margin: 0;
  font-weight: 800;
}

.panel-heading p {
  margin: 4px 0 0;
  color: var(--muted);
}

.next-order-card {
  min-width: 132px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--brand-soft);
  color: var(--brand-dark);
  text-align: center;
}

.next-order-card span,
.next-order-card strong {
  display: block;
}

.next-order-card span {
  font-size: 0.82rem;
  font-weight: 800;
}

.next-order-card strong {
  margin-top: 2px;
  font-size: 2rem;
  line-height: 1;
  letter-spacing: 0;
  font-family: Arial, "Segoe UI", Tahoma, sans-serif;
}

.dashboard-kicker {
  display: inline-block;
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.dashboard-metrics,
.patient-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.metric {
  min-height: 112px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-weight: 800;
  font-size: 0.8rem;
}

.metric-value,
.metric strong {
  display: block;
  margin-top: 10px;
  color: var(--ink);
  font-size: 1.65rem;
  line-height: 1.1;
  font-weight: 800;
}

.metric-label,
.metric small,
.metric-hint {
  color: var(--muted);
  font-size: 0.88rem;
}

.metric-done .metric-icon,
.metric-success .metric-icon {
  background: #dcfce7;
  color: var(--success);
}

.metric-active .metric-icon,
.metric-primary .metric-icon {
  background: #dbeafe;
  color: var(--accent);
}

.metric-urgent .metric-icon,
.metric-danger .metric-icon {
  background: #fee2e2;
  color: var(--danger);
}

.metric-warning .metric-icon {
  background: #fef3c7;
  color: var(--warning);
}

.table {
  margin-bottom: 0;
  vertical-align: middle;
}

.table thead th {
  color: #475569;
  background: var(--surface-soft);
  border-bottom-color: var(--line);
  font-size: 0.86rem;
  white-space: nowrap;
}

.table td,
.table th {
  border-color: #e5eaf1;
}

.dashboard-empty {
  padding: 28px 16px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
  background: var(--surface-soft);
}

.btn {
  border-radius: 8px;
  font-weight: 700;
}

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
}

.btn-primary:hover,
.btn-primary:focus {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
}

.form-control,
.form-select {
  border-color: #cbd5e1;
  border-radius: 8px;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 0.2rem rgba(11, 119, 107, 0.15);
}

.list-group-item {
  border-color: #e5eaf1;
}

.badge,
.priority-pill,
.status-pill {
  border-radius: 999px;
  font-weight: 800;
}

.priority-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  background: #e2e8f0;
  color: #334155;
  font-size: 0.78rem;
}

.priority-pill.urgent {
  background: #fee2e2;
  color: var(--danger);
}

.device-card,
.test-option,
.selected-test-item,
.order-test-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.device-card,
.order-test-card {
  padding: 14px;
}

.test-option,
.selected-test-item {
  padding: 10px 12px;
}

.selected-tests-list,
.patient-visit-list {
  display: grid;
  gap: 10px;
}

.patient-profile-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px;
  border-radius: var(--radius);
  color: #ffffff;
  background: linear-gradient(135deg, #0b776b, #155e75);
}

.patient-profile-hero h2,
.patient-profile-hero p {
  margin: 0;
}

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

.patient-visit-item {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.patient-visit-date {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 68px;
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.patient-visit-date strong {
  font-size: 1.4rem;
  line-height: 1;
}

.patient-visit-meta,
.patient-history-values {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.86rem;
}

.flag-H,
.flag-HIGH,
.flag-CRITICAL_HIGH {
  color: var(--danger);
}

.flag-L,
.flag-LOW,
.flag-CRITICAL_LOW {
  color: #1d4ed8;
}

.flag-N,
.flag-NORMAL,
.flag-TEXT {
  color: var(--success);
}

.lab-stats-toolbar {
  box-shadow: none;
}

.lab-stat-chart,
.lab-stat-list {
  min-height: 250px;
}

.lab-stat-note {
  margin-top: 10px;
  color: var(--muted);
}

.english-workflow {
  direction: ltr;
  text-align: left;
  font-family: Arial, "Segoe UI", Tahoma, sans-serif;
}

.english-workflow .table,
.english-workflow .form-control,
.english-workflow .form-select,
.english-workflow .modal-content {
  direction: ltr;
  text-align: left;
}

.result-order-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.result-test-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  overflow: hidden;
  margin-bottom: 16px;
}

.result-test-title,
.test-section-title,
.test-subsection-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.result-test-title {
  margin: 0;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #f1f5f9;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 800;
}

.test-section-title {
  padding: 10px 14px;
  background: #e7f5f2;
  color: var(--brand-dark);
  font-weight: 800;
}

.test-subsection-title {
  padding: 8px 14px;
  background: #f8fafc;
  color: #334155;
  font-weight: 800;
  border-top: 1px solid #e5eaf1;
  border-bottom: 1px solid #e5eaf1;
}

.result-component-row {
  display: grid;
  grid-template-columns: minmax(190px, 1.2fr) minmax(180px, 1fr) minmax(90px, 0.45fr) minmax(130px, 0.7fr);
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid #eef2f7;
}

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

.result-component-name {
  font-weight: 800;
}

.result-component-meta,
.reference-range,
.unit-label {
  color: var(--muted);
  font-size: 0.84rem;
}

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

.remove-test-button {
  flex: 0 0 auto;
}

@media (max-width: 991.98px) {
  .app-layout {
    display: block;
  }

  .app-main {
    margin-inline-start: 0;
  }

  .content {
    padding: 16px;
  }

  .sidebar {
    position: sticky;
    top: 0;
    width: 100%;
    max-height: 100vh;
    padding: 10px 12px;
  }

  .mobile-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .sidebar-brand {
    display: none;
  }

  #sidebarNav {
    display: none;
    padding-top: 10px;
  }

  .sidebar.mobile-nav-open #sidebarNav {
    display: flex;
  }

  .topbar {
    position: static;
    padding: 12px 16px;
    flex-direction: column;
    align-items: stretch;
  }

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

  .panel-heading,
  .patient-profile-hero {
    flex-direction: column;
    align-items: stretch;
  }

  .result-component-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

@media (max-width: 575.98px) {
  .content {
    padding: 12px;
  }

  .panel {
    padding: 14px;
  }

  .dashboard-metrics,
  .patient-summary-grid {
    grid-template-columns: 1fr;
  }

  .patient-visit-item {
    grid-template-columns: 1fr;
  }
}

@media print {
  .sidebar,
  .topbar,
  .no-print,
  .btn,
  .modal {
    display: none !important;
  }

  .app-main {
    margin: 0;
  }

  .content,
  .panel {
    padding: 0;
    box-shadow: none;
    border: 0;
  }

  body {
    background: #ffffff;
  }
}
