:root {
  --bg: #f4f1ea;
  --bg-accent: #e5edf7;
  --panel: rgba(255, 255, 255, 0.86);
  --panel-strong: #ffffff;
  --text: #172033;
  --muted: #5d6a7f;
  --line: #d7dee8;
  --shadow: 0 18px 45px rgba(19, 29, 48, 0.12);
  --primary: #1d4ed8;
  --primary-dark: #12379d;
  --secondary: #334155;
  --danger: #b91c1c;
  --success: #166534;
  --radius-xl: 24px;
  --radius-lg: 16px;
  --radius-md: 12px;
}

* {
  box-sizing: border-box;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

html,
body {
  width: 100%;
}

html {
  background:
    radial-gradient(circle at top left, rgba(29, 78, 216, 0.14), transparent 34%),
    radial-gradient(circle at bottom right, rgba(244, 114, 182, 0.14), transparent 30%),
    linear-gradient(180deg, #f8fafc 0%, var(--bg) 100%);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: transparent;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(255, 255, 255, 0.16) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.16) 1px, transparent 1px);
  background-size: 38px 38px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.35), transparent 85%);
}

header {
  background: rgba(15, 23, 42, 0.9);
  color: white;
  padding: 16px 20px;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.22);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}

header h1 {
  margin: 0;
  font-size: 1.2rem;
  letter-spacing: 0.02em;
}

header nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

header a {
  color: white;
  text-decoration: none;
  font-weight: 700;
  opacity: 0.92;
}

header a:hover {
  opacity: 1;
}

.center-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}

.home-page {
  min-height: 100vh;
  padding: 28px 20px 48px;
  display: grid;
  gap: 24px;
  justify-items: center;
  align-content: start;
}

.home-page > * {
  width: min(1100px, 100%);
}

.department-page {
  min-height: 100vh;
}

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 16px 36px;
  display: grid;
  gap: 16px;
}

.page-header {
  padding-top: calc(env(safe-area-inset-top) + 8px);
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.1;
}

.app-container {
  box-sizing: border-box;
}

.card {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: var(--radius-xl);
  padding: 16px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.hero {
  max-width: 760px;
  text-align: center;
}

.hero-shell {
  padding: 18px;
}

.hero-shell h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  margin: 10px 0;
  line-height: 1.02;
}

.hero-shell p {
  max-width: 56ch;
  margin: 0 auto;
  color: var(--muted);
  font-size: 1.05rem;
}

.hero-actions {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.status-board {
  margin-top: 0;
  padding-top: 0;
}

.card-lite {
  background: rgba(248, 250, 252, 0.72);
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-top: 16px;
}

.status-board-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.inline-stat {
  min-width: 210px;
}

.status-board-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.department-results {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.department-summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.department-page .card {
  max-width: 980px;
  margin: 16px auto 0;
}

.department-page select {
  max-width: 380px;
}

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

.status-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #334155;
  font-size: 0.86rem;
  font-weight: 700;
}

.login-card {
  width: 100%;
  max-width: 440px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--primary-dark);
  background: rgba(29, 78, 216, 0.08);
  border-radius: 999px;
  padding: 7px 12px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
}

.section-head h2,
.card h2 {
  margin: 10px 0 4px;
  font-size: 1.4rem;
}

label {
  display: block;
  margin-top: 14px;
  font-weight: 700;
}

input,
select,
textarea,
button,
.btn {
  width: 100%;
  padding: 12px 14px;
  margin-top: 7px;
  border-radius: 12px;
  border: 1px solid var(--line);
  font-size: 15px;
  color: var(--text);
  background: #fff;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

button,
.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  background: linear-gradient(180deg, #2d6bff, var(--primary));
  color: white;
  border: none;
  text-decoration: none;
  text-align: center;
  font-weight: 800;
  cursor: pointer;
  margin-top: 16px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  box-shadow: 0 10px 18px rgba(29, 78, 216, 0.18);
}

button:hover,
.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 24px rgba(29, 78, 216, 0.22);
}

button.secondary,
.btn.secondary {
  background: linear-gradient(180deg, #475569, var(--secondary));
  box-shadow: 0 10px 18px rgba(51, 65, 85, 0.18);
}

button.secondary:hover,
.btn.secondary:hover {
  box-shadow: 0 14px 24px rgba(51, 65, 85, 0.22);
}

button.danger,
.danger {
  background: linear-gradient(180deg, #e54848, var(--danger));
  box-shadow: 0 10px 18px rgba(185, 28, 28, 0.16);
}

button.success,
.success {
  background: linear-gradient(180deg, #1f9d4c, var(--success));
  box-shadow: 0 10px 18px rgba(22, 101, 52, 0.16);
}

.small-btn {
  width: auto;
  padding: 8px 14px;
  margin: 0;
  border-radius: 10px;
  box-shadow: none;
}

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

.hint,
.meta {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.stats-grid,
.flow-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.stat-card,
.flow-card,
.queue-card,
.admin-flow-row {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.stat-card strong {
  display: block;
  font-size: 2rem;
  margin-top: 10px;
}

.stat-label {
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
}

.flow-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 100%;
}

.flow-card-head,
.request-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
}

.flow-count {
  min-width: 56px;
  min-height: 56px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: #111827;
  color: white;
  font-size: 1.4rem;
  font-weight: 800;
}

.flow-preview {
  display: grid;
  gap: 10px;
}

.preview-item {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: inherit;
  text-decoration: none;
}

.preview-item:hover {
  border-color: #cbd5e1;
}

.preview-item span {
  color: var(--muted);
  font-size: 0.9rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.flow-blue { background: #dbeafe; color: #1d4ed8; }
.flow-amber { background: #fef3c7; color: #b45309; }
.flow-green { background: #dcfce7; color: #15803d; }
.flow-indigo { background: #e0e7ff; color: #4338ca; }
.flow-pink { background: #fce7f3; color: #be185d; }
.flow-emerald { background: #d1fae5; color: #047857; }
.flow-slate { background: #e2e8f0; color: #475569; }
.flow-rose { background: #ffe4e6; color: #be123c; }
.flow-orange { background: #ffedd5; color: #c2410c; }
.flow-violet { background: #ede9fe; color: #6d28d9; }

.request,
.queue-card {
  border: 1px solid #e5e7eb;
  padding: 16px;
  border-radius: var(--radius-lg);
  margin-top: 14px;
  background: rgba(255, 255, 255, 0.82);
}

.request h3,
.queue-card h3,
.admin-flow-row h3 {
  margin: 0 0 8px;
}

.workflow {
  margin-top: 12px;
  padding: 12px;
  background: #f8fafc;
  border-radius: 14px;
  border: 1px solid #e2e8f0;
}

.step {
  padding: 5px 0;
  color: #334155;
}

.actions,
.queue-actions,
.admin-flow-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.queue-actions {
  margin-bottom: 8px;
}

.admin-layout {
  grid-template-columns: 380px minmax(0, 1fr);
  align-items: start;
}

.inline-form {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.inline-form button {
  width: 100%;
}

.department-admin-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.department-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #f8fafc;
}

.admin-flow-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 14px;
}

.admin-flow-main {
  max-width: 58ch;
}

.empty-state {
  padding: 28px;
  border-radius: var(--radius-lg);
  border: 1px dashed #cbd5e1;
  background: #f8fafc;
  margin-top: 18px;
}

@media (max-width: 900px) {
  header,
  .flow-card-head,
  .request-head,
  .section-head,
  .admin-flow-row,
  .status-board-head,
  .department-summary {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-layout {
    grid-template-columns: 1fr;
  }

  .hero-actions {
    grid-template-columns: 1fr;
  }

  .home-page {
    padding-inline: 14px;
  }

  .page {
    padding-inline: 14px;
  }

  .department-page .card {
    margin-inline: 14px;
  }
}

@media (max-width: 768px) {
  .app-container {
    max-width: 480px;
    margin: 0 auto;
    padding-top: calc(env(safe-area-inset-top) + 12px);
    padding-left: 16px;
    padding-right: 16px;
    padding-bottom: calc(env(safe-area-inset-bottom) + 12px);
    width: 100%;
  }

  @supports not (padding-top: env(safe-area-inset-top)) {
    .app-container {
      padding-top: 20px;
      padding-bottom: 20px;
    }
  }

  .app-container > header,
  .app-container > .page {
    width: 100%;
  }

  .btn,
  button,
  a.btn {
    min-height: 48px;
    max-height: 54px;
    padding: 0 16px;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 100%;
    box-sizing: border-box;
    white-space: nowrap;
  }

  .btn,
  button {
    margin-top: 12px;
  }

  .small-btn {
    width: auto;
    min-height: 40px;
    max-height: 44px;
    padding: 0 12px;
    margin: 0;
  }

  .card {
    padding: 16px;
    border-radius: 16px;
  }

  .hero-shell {
    padding: 18px 16px;
  }

  .hero-actions {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .button-stack,
  .admin-actions,
  .action-buttons,
  .actions,
  .queue-actions,
  .admin-flow-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .department-row {
    flex-direction: column;
    align-items: stretch;
  }

  .status-board-head,
  .department-summary,
  .section-head,
  .flow-card-head,
  .request-head,
  .admin-flow-row {
    gap: 10px;
  }

  .page-title {
    font-size: 22px;
  }

  .status-board-grid,
  .stats-grid,
  .flow-grid {
    gap: 12px;
  }
}
