:root {
  --canvas: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --primary: #0f172a;
  --primary-teal: #0d9488;
  --primary-teal-dark: #0f766e;
  --text: #1e293b;
  --text-muted: #64748b;
  --text-faint: #94a3b8;
  --success-bg: #ecfdf5;
  --success-text: #047857;
  --success-border: #a7f3d0;
  --warn-bg: #fffbeb;
  --warn-text: #b45309;
  --warn-border: #fde68a;
  --danger-bg: #fff1f2;
  --danger-text: #be123c;
  --danger-border: #fecdd3;
  --ms-blue: #2f5ea8;
  --brand-navy: #2a3268;
  --brand-navy-dark: #1f2650;
  --ict-accent: #0d9488;
  --ict-accent-dark: #0f766e;
  --ict-bg: #f0fdfa;
  --procurement-accent: #7c3aed;
  --procurement-accent-dark: #6d28d9;
  --procurement-bg: #f5f3ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--canvas);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a {
  color: inherit;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.container-wide {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

@media (max-width: 480px) {
  .container,
  .container-wide {
    padding: 1.25rem 1rem;
  }
}

/* --- Two-column detail layouts (ICT/Procurement review screens) --- */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 2rem;
  align-items: start;
}

@media (max-width: 900px) {
  .detail-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
}

/* --- Site-wide brand bar (identical on every page) --- */
.site-header {
  width: 100%;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

.site-header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
}

/* --- Thin strip directly under the header, just for a back action — kept off
   the header row itself so it never competes with the brand/nav for space --- */
.sub-nav {
  width: 100%;
  background: var(--canvas);
  border-bottom: 1px solid var(--border);
}

.sub-nav-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0.6rem 1.5rem;
}

.brand-logo-col {
  justify-self: start;
}

.brand-logo {
  height: 64px;
  width: auto;
  display: block;
  margin-left: 0.5rem;
}

.brand-title-col {
  justify-self: center;
  min-width: 0;
}

.brand-title {
  display: block;
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--brand-navy);
  letter-spacing: -0.01em;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
}

.nav-col {
  justify-self: end;
}

@media (max-width: 860px) {
  .site-header-inner {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }
  .brand-logo-col,
  .brand-title-col,
  .nav-col {
    justify-self: center;
  }
  .brand-title {
    font-size: 1.4rem;
    white-space: normal;
  }
}

.brand-subtitle {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin-top: 0.1rem;
}

/* --- Per-page heading (sits below the brand bar, inside the content container) --- */
.page-heading-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.eyebrow {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary-teal);
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0.15rem 0 0;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  font-size: 0.8rem;
  font-weight: 600;
}

.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
}

.nav-links a:hover {
  color: var(--primary);
}

.nav-links button {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  font-size: 0.78rem;
  cursor: pointer;
  padding: 0.4rem 0.85rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.nav-links button:hover {
  border-color: var(--danger-border);
  color: var(--danger-text);
  background: var(--danger-bg);
}

/* --- User menu: avatar + dropdown, replacing plain "Name (email) [Sign out]" text --- */
.user-menu {
  position: relative;
}

.user-avatar-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  border-radius: 999px;
}
.user-avatar-btn:hover .user-avatar {
  box-shadow: 0 0 0 3px var(--ict-bg);
}
.theme-procurement .user-avatar-btn:hover .user-avatar {
  box-shadow: 0 0 0 3px var(--procurement-bg);
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-navy);
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}
.theme-ict .user-avatar {
  background: var(--ict-accent);
}
.theme-procurement .user-avatar {
  background: var(--procurement-accent);
}

.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 0.6rem);
  right: 0;
  min-width: 230px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.14);
  padding: 0.75rem;
  z-index: 50;
}

.user-menu-info {
  padding: 0.1rem 0.4rem 0.65rem;
  margin-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.user-menu-name {
  display: block;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text);
}

.user-menu-email {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
  word-break: break-all;
}

.user-menu-dropdown .nav-links-signout {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 0.55rem 0.4rem;
  font: inherit;
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--danger-text);
  cursor: pointer;
  border-radius: 0.45rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.user-menu-dropdown .nav-links-signout:hover {
  background: var(--danger-bg);
}

/* --- Compact button variant for nav bars, back-links, and inline actions --- */
.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.78rem;
}

/* --- Cards --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.5rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

@media (max-width: 480px) {
  .card {
    padding: 1.1rem;
  }
  .question-card {
    padding: 1.75rem 1.1rem;
  }
}

.card h2 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--primary);
  margin: 0 0 1rem;
}

.card h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary);
  margin: 0 0 0.75rem;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

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

/* --- Forms --- */
label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

input[type='text'],
input[type='email'],
input[type='number'],
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  padding: 0.55rem 0.7rem;
  font-size: 0.85rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--primary-teal);
  outline-offset: 1px;
}

select:disabled {
  background: var(--surface-muted, #f1f5f9);
  color: var(--text-muted);
  cursor: not-allowed;
}

.field {
  margin-bottom: 1rem;
}

.field:last-child {
  margin-bottom: 0;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: none;
  border-radius: 0.5rem;
  padding: 0.65rem 1.25rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

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

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: #1e293b;
}

.btn-teal {
  background: var(--primary-teal);
  color: #fff;
}
.btn-teal:hover:not(:disabled) {
  background: var(--primary-teal-dark);
}

.btn-danger {
  background: #e11d48;
  color: #fff;
}
.btn-danger:hover:not(:disabled) {
  background: #be123c;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover:not(:disabled) {
  border-color: var(--primary);
}

.btn-block {
  width: 100%;
}

.btn-ms {
  background: var(--ms-blue);
  color: #fff;
}
.btn-ms:hover:not(:disabled) {
  background: #244a86;
}

.btn-lg {
  padding: 0.9rem 1.5rem;
  font-size: 0.95rem;
}

/* --- Alerts --- */
.alert {
  border-radius: 0.5rem;
  padding: 0.65rem 0.85rem;
  font-size: 0.78rem;
}

.alert-error {
  background: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid var(--danger-border);
}

.alert-success {
  background: var(--success-bg);
  color: var(--success-text);
  border: 1px solid var(--success-border);
}

.alert-info {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

/* --- Badges --- */
.badge {
  display: inline-block;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-pending {
  background: var(--warn-bg);
  color: var(--warn-text);
}
.badge-approved {
  background: var(--success-bg);
  color: var(--success-text);
}
.badge-rejected {
  background: var(--danger-bg);
  color: var(--danger-text);
}
.badge-neutral {
  background: #f1f5f9;
  color: #475569;
}

/* --- Table --- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead th {
  text-align: left;
  font-size: 0.7rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
  padding-right: 1rem;
}

tbody td {
  padding: 0.6rem 1rem 0.6rem 0;
  border-bottom: 1px solid var(--border);
}

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

.table-scroll {
  overflow-x: auto;
}

/* --- Questionnaire wizard --- */
.wizard-progress {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.wizard-progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.wizard-progress-fill {
  height: 100%;
  background: var(--primary-teal);
  transition: width 0.25s ease;
}

.question-card {
  text-align: center;
  padding: 2.5rem 1.5rem;
}

.question-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0 0 0.75rem;
}

.question-description {
  color: var(--text-muted);
  font-size: 0.9rem;
  max-width: 32rem;
  margin: 0 auto 2rem;
}

.question-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
}

.answer-btn {
  min-width: 8rem;
  padding: 0.9rem 1.5rem;
  border-radius: 0.6rem;
  font-size: 1rem;
  font-weight: 700;
  border: 2px solid var(--border);
  background: var(--surface);
  cursor: pointer;
}

.answer-btn.yes:hover {
  border-color: var(--success-text);
  color: var(--success-text);
  background: var(--success-bg);
}

.answer-btn.no:hover {
  border-color: var(--danger-text);
  color: var(--danger-text);
  background: var(--danger-bg);
}

/* --- Level selector (e.g. Regular / High / Advanced usage) --- */
.level-options {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 26rem;
  margin: 1.5rem auto 0;
  text-align: left;
}

.level-option {
  display: block;
  width: 100%;
  padding: 0.9rem 1.1rem;
  border-radius: 0.6rem;
  border: 2px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
}

.level-option:hover {
  border-color: var(--primary-teal);
  background: #f0fdfa;
}

.level-option .level-label {
  display: block;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
}

.level-option .level-desc {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* --- Recommendation detail --- */
.spec-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  padding: 1rem;
  margin-bottom: 1rem;
}

.spec-item .label {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.spec-item .value {
  font-weight: 700;
  color: var(--text);
}

.feature-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.pill {
  background: #f1f5f9;
  border: 1px solid var(--border);
  color: #334155;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-size: 0.72rem;
}

.justification-list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.85rem;
  color: var(--text);
}

.justification-list li {
  margin-bottom: 0.35rem;
}

.text-muted {
  color: var(--text-muted);
}

.text-xs {
  font-size: 0.75rem;
}

.center {
  text-align: center;
}

.hidden {
  display: none !important;
}

.mt-1 {
  margin-top: 0.5rem;
}
.mt-2 {
  margin-top: 1rem;
}
.mb-1 {
  margin-bottom: 0.5rem;
}

.link {
  color: var(--primary-teal);
  font-weight: 600;
  text-decoration: none;
}
.link:hover {
  text-decoration: underline;
}

.login-shell {
  min-height: calc(100vh - 100px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.login-wrap {
  width: 100%;
  max-width: 26rem;
}

.login-card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  padding: 2rem;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-faint);
  font-size: 0.72rem;
  margin: 1.5rem 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.dev-box {
  border: 1px dashed var(--warn-border);
  background: var(--warn-bg);
  border-radius: 0.6rem;
  padding: 1rem;
}

.dev-box .dev-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--warn-text);
  display: block;
  margin-bottom: 0.75rem;
}

.loading-shell {
  min-height: 40vh;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* --- Staff-portal access footer (bottom of the public request page) --- */
.staff-portal-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.portal-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid transparent;
}

.portal-chip.ict {
  background: var(--ict-bg);
  color: var(--ict-accent-dark);
  border-color: #99f6e4;
}
.portal-chip.ict:hover {
  background: #ccfbf1;
}

.portal-chip.procurement {
  background: var(--procurement-bg);
  color: var(--procurement-accent-dark);
  border-color: #ddd6fe;
}
.portal-chip.procurement:hover {
  background: #ede9fe;
}

/* --- Portal theming: ICT (teal) vs Procurement (purple) --- */
.theme-ict .eyebrow {
  color: var(--ict-accent);
}
.theme-ict .btn-teal,
.theme-ict .btn-approve {
  background: var(--ict-accent);
}
.theme-ict .btn-teal:hover,
.theme-ict .btn-approve:hover {
  background: var(--ict-accent-dark);
}

.theme-procurement .eyebrow {
  color: var(--procurement-accent);
}
.theme-procurement .btn-primary-action {
  background: var(--procurement-accent);
}
.theme-procurement .btn-primary-action:hover {
  background: var(--procurement-accent-dark);
}
.theme-procurement .badge-pending {
  background: var(--procurement-bg);
  color: var(--procurement-accent-dark);
}

/* --- ICT override picker --- */
.override-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
}

.override-note {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin: 0.5rem 0 1.25rem;
}

/* --- Section tabs (Procurement Active / Completed) --- */
.section-heading-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

/* --- Device photo gallery --- */
.device-gallery {
  position: relative;
  max-width: 260px;
  margin-bottom: 1rem;
}

.device-gallery-img-btn {
  display: block;
  position: relative;
  width: 100%;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  overflow: hidden;
  background: var(--surface);
  cursor: zoom-in;
}

.device-gallery-img {
  display: block;
  width: 100%;
  height: 150px;
  object-fit: cover;
}

.device-gallery-counter {
  position: absolute;
  right: 0.4rem;
  bottom: 0.4rem;
  background: rgba(15, 23, 42, 0.75);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
}

.device-gallery-controls {
  display: flex;
  justify-content: space-between;
  margin-top: 0.35rem;
}

.device-gallery-nav {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 0.4rem;
  width: 2rem;
  height: 1.75rem;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text);
}

.device-gallery-nav:hover {
  background: var(--canvas);
}

.gallery-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.gallery-lightbox.hidden {
  display: none;
}

.gallery-lightbox-img {
  max-width: min(90vw, 900px);
  max-height: 85vh;
  border-radius: 0.5rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.gallery-lightbox-close {
  position: absolute;
  top: 1.25rem;
  right: 1.5rem;
  background: none;
  border: none;
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
}

.gallery-lightbox-nav {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  font-size: 2rem;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  cursor: pointer;
  margin: 0 1rem;
}

.gallery-lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.2);
}

.gallery-lightbox-counter {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
}

@media (max-width: 640px) {
  .device-gallery {
    max-width: 100%;
  }
}

.count-chip {
  background: #f1f5f9;
  color: #475569;
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  font-size: 0.7rem;
  font-weight: 700;
}
