:root {
  --bg: #000000;
  --bg-alt: #111111;
  --surface: rgba(26, 26, 26, 0.9);
  --surface-strong: rgba(38, 38, 38, 0.96);
  --text: #ffffff;
  --muted: rgba(125, 211, 252, 0.86);
  --primary: #7dd3fc;
  --primary-strong: #a78bfa;
  --accent: #ffd166;
  --danger: #fca5a5;
  --success: #86efac;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
  --border: rgba(148, 163, 184, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

html {
  font-size: calc(100% - 2px);
}

body {
  margin: 0;
  font-family: "Manrope", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(64, 64, 64, 0.35), transparent 28%),
    radial-gradient(circle at top right, rgba(96, 96, 96, 0.2), transparent 28%),
    linear-gradient(180deg, #000000 0%, #101010 40%, #050505 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(128, 128, 128, 0.12) 1px, transparent 1px), linear-gradient(90deg, rgba(128, 128, 128, 0.12) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.85), transparent 80%);
}

.app-shell,
.app-layout {
  min-height: 100vh;
}

#staffView {
  position: relative;
}

.staff-access-state {
  min-height: calc(100vh - 180px);
  display: grid;
  place-items: center;
  padding: 4rem 1rem;
}

.staff-access-message {
  width: min(720px, 100%);
  padding: 2.5rem 2rem;
  border: 1px solid var(--border);
  border-radius: 28px;
  background: rgba(16, 16, 16, 0.92);
  backdrop-filter: blur(22px);
  box-shadow: var(--shadow);
  text-align: center;
}

.staff-access-message h2 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.auth-backdrop {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 20% 20%, rgba(64, 64, 64, 0.45), transparent 30%), radial-gradient(circle at 80% 30%, rgba(96, 96, 96, 0.28), transparent 28%);
}

.auth-card {
  position: relative;
  width: min(560px, calc(100vw - 2rem));
  margin: 6vh auto;
  padding: 2rem;
  border: 1px solid var(--border);
  border-radius: 28px;
  background: rgba(16, 16, 16, 0.92);
  backdrop-filter: blur(22px);
  box-shadow: var(--shadow);
}

.brand-badge,
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.brand-name,
.page-title,
.auth-title,
.panel-header h3 {
  font-family: "Space Grotesk", sans-serif;
}

.auth-title {
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.05;
  margin-bottom: 0.75rem;
}

.auth-copy {
  color: var(--muted);
  margin-bottom: 1.5rem;
}

.auth-form .form-control,
.stack-form .form-control,
.stack-form .form-select,
.search-wrap .form-control,
.filter-select {
  color: var(--text);
  background: rgba(24, 24, 24, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.22);
}

.auth-form .form-control::placeholder,
.stack-form .form-control::placeholder,
.search-wrap .form-control::placeholder {
  color: rgba(125, 211, 252, 0.7);
}

.auth-form .form-control:focus,
.stack-form .form-control:focus,
.stack-form .form-select:focus,
.search-wrap .form-control:focus,
.filter-select:focus {
  border-color: rgba(125, 211, 252, 0.55);
  box-shadow: 0 0 0 0.2rem rgba(125, 211, 252, 0.14);
  background: rgba(34, 34, 34, 0.98);
  color: var(--text);
}

.auth-hint {
  color: var(--muted);
  font-size: 0.9rem;
}

.app-layout {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  min-height: 100vh;
  padding: 1.5rem;
  border-right: 1px solid var(--border);
  background: rgba(10, 10, 10, 0.92);
  backdrop-filter: blur(24px);
}

.sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  width: 100%;
  padding: 0.9rem 1rem;
  border: 1px solid transparent;
  border-radius: 16px;
  color: var(--text);
  background: transparent;
  text-align: left;
}

.sidebar .nav-link.active,
.sidebar .nav-link:hover {
  color: #ffd166;
  background: rgba(34, 34, 34, 0.95);
}

.sidebar-footer {
  position: absolute;
  left: 1.5rem;
  right: 1.5rem;
  bottom: 1.5rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: rgba(24, 24, 24, 0.9);
}

.main-content {
  padding: 1.5rem;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: rgba(24, 24, 24, 0.9);
  backdrop-filter: blur(20px);
}

.eyebrow {
  color: var(--primary);
  font-size: 0.8rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.page-title {
  font-size: clamp(1.35rem, 2vw, 2rem);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-primary {
  border: none;
  color: #ffffff;
  font-weight: 700;
  background: linear-gradient(135deg, #1f1f1f, #2d2d2d);
}

.btn-primary:hover,
.btn-primary:focus {
  color: #ffd166;
}

.btn-soft,
.btn-outline-secondary {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(24, 24, 24, 0.86);
}

.btn-soft:hover,
.btn-outline-secondary:hover {
  color: var(--text);
  background: rgba(40, 40, 40, 0.96);
}

.text-bg-light,
.bg-light,
.bg-white,
.table-light,
.alert-light,
.badge.text-bg-light {
  color: #7dd3fc !important;
  background-color: rgba(24, 24, 24, 0.96) !important;
}

.text-bg-light *,
.bg-light *,
.bg-white *,
.table-light *,
.alert-light * {
  color: #7dd3fc !important;
}

.text-muted,
.text-white-50 {
  color: rgba(125, 211, 252, 0.82) !important;
}

.view-panel {
  display: none;
}

.view-panel.active {
  display: block;
}

.summary-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.summary-card,
.panel-card,
.mini-metric,
.budget-card {
  border: 1px solid var(--border);
  border-radius: 24px;
  background: rgba(24, 24, 24, 0.9);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.summary-card {
  padding: 1rem 1.1rem;
}

.summary-card span,
.mini-metric span,
.budget-card span {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
}

.summary-card strong,
.mini-metric strong,
.budget-card strong {
  display: block;
  margin-top: 0.4rem;
  font-size: 1.35rem;
  font-weight: 800;
}

.panel-card {
  padding: 1.25rem;
}

.panel-card .form-control,
.panel-card .form-select {
  color: #ffffff;
  background: rgba(18, 18, 18, 0.98);
  border-color: rgba(148, 163, 184, 0.22);
}

.panel-card .form-control::placeholder {
  color: rgba(125, 211, 252, 0.7);
}

.panel-card .form-control:focus,
.panel-card .form-select:focus {
  color: #ffffff;
  background: rgba(30, 30, 30, 0.98);
}

.compact-chart-card {
  padding: 0.85rem 1.05rem 0.95rem;
}

.compact-chart-card .panel-header {
  margin-bottom: 0.5rem;
}

.compact-chart-card .panel-header h3 {
  font-size: 1.15rem;
}

.compact-chart-card .panel-header p {
  font-size: 0.85rem;
}

.compact-chart-wrap {
  height: 322px;
}

.compact-chart-wrap canvas {
  display: block;
  width: 100% !important;
  height: 322px !important;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.panel-header h3 {
  margin: 0;
  font-size: 1.35rem;
}

.panel-header p {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

.stack-form {
  display: grid;
  gap: 1rem;
}

.stack-form .form-label {
  margin-bottom: 0.4rem;
  font-weight: 600;
}

.data-table {
  margin-bottom: 0;
  color: #22c55e;
}

.data-table thead th {
  color: #000000;
  background: rgba(74, 222, 128, 0.96);
  border-bottom-color: rgba(74, 222, 128, 0.9);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.data-table tbody td {
  border-top-color: rgba(148, 163, 184, 0.12);
  vertical-align: middle;
  color: #22c55e;
}

.data-table tbody tr:hover {
  background: rgba(34, 34, 34, 0.95);
}

.table {
  color: #22c55e;
}

.table thead th {
  color: #000000;
  background: rgba(74, 222, 128, 0.96);
}

.table tbody td {
  color: #22c55e;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  background: rgba(24, 24, 24, 0.95);
  border: 1px solid currentColor;
}

.chip-success {
  color: #86efac;
}

.chip-warning {
  color: #ffd166;
}

.chip-danger {
  color: #fca5a5;
}

.chip-neutral {
  color: #7dd3fc;
}

.search-wrap {
  min-width: min(320px, 100%);
}

.filter-select {
  min-width: 170px;
}

.mini-metric,
.budget-card {
  padding: 1rem;
}

.budget-grid {
  align-items: stretch;
}

.budget-card small {
  display: block;
  margin-top: 0.4rem;
  color: var(--muted);
}

.alert-stack {
  display: grid;
  gap: 0.75rem;
}

.alert-item {
  padding: 0.9rem 1rem;
  border-radius: 18px;
  background: rgba(24, 24, 24, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.22);
  color: #fca5a5;
}

.toast {
  color: var(--text);
  background: rgba(24, 24, 24, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(18px);
}

canvas {
  max-width: 100%;
}

@media (max-width: 1200px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .app-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    z-index: 1040;
    inset: 0 auto 0 0;
    width: min(300px, 84vw);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-footer {
    position: static;
    margin-top: 2rem;
  }

  .main-content {
    padding: 1rem;
  }
}

@media (max-width: 768px) {
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-actions {
    justify-content: space-between;
  }

  .search-wrap {
    min-width: 100%;
  }
}

/* ── Task Deadline Countdown ── */
.countdown-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.countdown-tile {
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 16px;
  padding: 1rem;
  background: rgba(18, 18, 18, 0.95);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  transition: border-color 0.2s;
}

.countdown-tile.countdown-overdue {
  border-color: rgba(252, 165, 165, 0.5);
  background: rgba(40, 10, 10, 0.95);
}

.countdown-employee {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.countdown-task {
  font-size: 0.95rem;
  font-weight: 700;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.countdown-deadline {
  font-size: 0.78rem;
  color: var(--muted);
}

.countdown-timer {
  font-size: 1.15rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
  margin: 0.2rem 0;
}

.countdown-timer.time-ok    { color: #86efac; }
.countdown-timer.time-soon  { color: #ffd166; }
.countdown-timer.time-urgent { color: #fb923c; }
.countdown-timer.time-overdue { color: #fca5a5; }

.countdown-bar-wrap {
  height: 4px;
  border-radius: 99px;
  background: rgba(148, 163, 184, 0.15);
  overflow: hidden;
}

.countdown-bar {
  height: 100%;
  border-radius: 99px;
  background: #22c55e;
  transition: width 0.3s;
}

.countdown-completion {
  font-size: 0.75rem;
  color: var(--muted);
}