:root {
  color-scheme: light;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --brand: #2563eb;
  --brand-strong: #1d4ed8;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #dc2626;
  --radius: 14px;
  --shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
  --priority-critical: #ef4444;
  --priority-high: #f97316;
  --priority-medium: #2563eb;
  --priority-low: #6b7280;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top left, #eef3ff 0%, var(--bg) 55%);
  color: var(--text);
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  padding: 0.58rem 0.7rem;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #93c5fd;
  outline: 2px solid #dbeafe;
}

button {
  border: 0;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  padding: 0.6rem 0.85rem;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease, opacity 140ms ease;
}

button:hover {
  background: var(--brand-strong);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.hidden {
  display: none !important;
}

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

.row {
  display: flex;
  align-items: center;
}

.gap-sm {
  gap: 0.45rem;
}

.stack {
  display: grid;
  gap: 0.8rem;
}

.app-shell {
  min-height: 100vh;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.auth-card {
  width: min(460px, 100%);
}

.auth-logo-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 72px;
  margin-bottom: 1rem;
}

.auth-logo {
  width: min(220px, 64%);
  max-width: 100%;
  height: auto;
  object-fit: contain;
}

.workspace {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
  color: #f8fafc;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  border-right: 1px solid rgba(148, 163, 184, 0.25);
}

.brand {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.brand h2 {
  margin: 0 0 0.3rem;
  font-size: 1.1rem;
}

.brand .muted {
  margin: 0;
  font-size: 0.84rem;
  color: #cbd5e1;
}

.nav-list {
  display: grid;
  gap: 0.9rem;
  overflow-y: auto;
  padding-right: 0.2rem;
}

.nav-group {
  display: grid;
  gap: 0.42rem;
}

.nav-group-title {
  margin: 0.2rem 0;
  color: #94a3b8;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
}

.nav-list button {
  width: 100%;
  text-align: left;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid transparent;
  color: #e2e8f0;
  padding: 0.62rem 0.72rem;
}

.nav-list button:hover {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(147, 197, 253, 0.35);
}

.nav-list button.active {
  background: #1d4ed8;
  border-color: #60a5fa;
  color: #fff;
}

.danger {
  background: #991b1b;
}

.danger:hover {
  background: #7f1d1d;
}

.danger-subtle {
  background: #fee2e2;
  color: #991b1b;
}

.danger-subtle:hover {
  background: #fecaca;
}

.content {
  padding: 1rem 1.1rem 5rem;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 18;
  background: rgba(244, 246, 251, 0.95);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
  margin-bottom: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
}

.topbar h1 {
  margin: 0;
  font-size: 1.2rem;
}

.ghost {
  background: #e2e8f0;
  color: #0f172a;
}

.ghost:hover {
  background: #cbd5e1;
}

.mini-btn {
  padding: 0.38rem 0.58rem;
  font-size: 0.82rem;
}

.icon-btn {
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  padding: 0;
}

.mobile-only {
  display: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0.08rem 0.46rem;
  margin-left: 0.35rem;
  min-width: 1.2rem;
  font-size: 0.74rem;
  font-weight: 700;
}

.badge.unread {
  background: #ef4444;
  color: #fff;
}

.page {
  display: none;
  gap: 0.9rem;
}

.page.active {
  display: grid;
}

.module-panel {
  animation: fade-slide-in 180ms ease;
}

.grid {
  display: grid;
  gap: 0.9rem;
}

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

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

.card h3 {
  margin: 0 0 0.8rem;
  font-size: 1rem;
}

.card.tight {
  padding: 0.75rem;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  margin-bottom: 0.75rem;
}

.toolbar input {
  width: min(300px, 100%);
}

.form-grid {
  display: grid;
  gap: 0.65rem;
}

.form-grid label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.89rem;
}

.field-hint {
  margin: 0 0 0.4rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.checkbox {
  display: flex !important;
  align-items: center;
  gap: 0.5rem;
}

.checkbox input {
  margin: 0;
}

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

table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  padding: 0.52rem 0.45rem;
}

th {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 0.65rem;
}

.cards.compact {
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}

.mini-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.72rem;
  background: var(--surface-soft);
}

.mini-card h4 {
  margin: 0 0 0.3rem;
  font-size: 0.94rem;
}

.mini-card p {
  margin: 0.2rem 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.priority-chip,
.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.18rem 0.58rem;
  font-size: 0.76rem;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}

.priority-chip.priority-critical,
.pill.critical {
  color: #991b1b;
  border-color: #fecaca;
  background: #fee2e2;
}

.priority-chip.priority-high,
.pill.high {
  color: #9a3412;
  border-color: #fed7aa;
  background: #ffedd5;
}

.priority-chip.priority-medium,
.pill.medium {
  color: #1d4ed8;
  border-color: #bfdbfe;
  background: #dbeafe;
}

.priority-chip.priority-low,
.pill.low {
  color: #374151;
  border-color: #d1d5db;
  background: #f3f4f6;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.18rem 0.56rem;
  border: 1px solid transparent;
  font-size: 0.74rem;
  font-weight: 600;
  white-space: nowrap;
}

.status-chip.status-pending {
  color: #7c3aed;
  background: #ede9fe;
  border-color: #ddd6fe;
}

.status-chip.status-in-progress,
.status-chip.status-processing,
.status-chip.status-ordered,
.status-chip.status-in-transit {
  color: #b45309;
  background: #fef3c7;
  border-color: #fde68a;
}

.status-chip.status-completed,
.status-chip.status-approved,
.status-chip.status-delivered,
.status-chip.status-active {
  color: #166534;
  background: #dcfce7;
  border-color: #bbf7d0;
}

.status-chip.status-overdue,
.status-chip.status-cancelled,
.status-chip.status-failed {
  color: #991b1b;
  background: #fee2e2;
  border-color: #fecaca;
}

.status-chip.status-draft {
  color: #334155;
  background: #e2e8f0;
  border-color: #cbd5e1;
}

.overdue {
  color: #b91c1c;
  font-weight: 700;
}

.due-soon {
  color: #b45309;
  font-weight: 700;
}

.mini {
  background: #e2e8f0;
  color: #0f172a;
  border: 1px solid #cbd5e1;
  margin-right: 0.3rem;
  padding: 0.34rem 0.55rem;
  font-size: 0.82rem;
}

.mini:hover {
  background: #cbd5e1;
}

.empty {
  border: 1px dashed var(--line-strong);
  border-radius: 11px;
  background: #f8fafc;
  color: var(--muted);
  padding: 0.7rem;
}

.timeline {
  display: grid;
  gap: 0.62rem;
}

.timeline-item {
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  padding: 0.58rem 0.66rem;
}

.timeline-item p {
  margin: 0;
  font-size: 0.84rem;
}

.timeline-item small {
  color: var(--muted);
}

.admin-module {
  display: grid;
  gap: 0.9rem;
}

.segmented {
  display: inline-flex;
  gap: 0.35rem;
  background: #e2e8f0;
  border-radius: 12px;
  padding: 0.2rem;
}

.segmented button {
  background: transparent;
  color: #334155;
  border-radius: 9px;
}

.segmented button.active {
  background: #fff;
  color: #0f172a;
  border: 1px solid #cbd5e1;
}

.task-view {
  display: none;
}

.task-view.active {
  display: block;
}

.kanban-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(220px, 1fr));
  gap: 0.75rem;
  overflow-x: auto;
}

.kanban-column {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
  min-height: 220px;
  padding: 0.65rem;
}

.kanban-column h4 {
  margin: 0 0 0.55rem;
  font-size: 0.86rem;
}

.kanban-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.52rem;
  margin-bottom: 0.45rem;
}

.kanban-card h5 {
  margin: 0 0 0.3rem;
  font-size: 0.85rem;
}

.kanban-card p {
  margin: 0.15rem 0;
  color: var(--muted);
  font-size: 0.76rem;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.4rem;
}

.calendar-day {
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 94px;
  background: #fff;
  padding: 0.4rem;
}

.calendar-day-header {
  font-weight: 700;
  font-size: 0.78rem;
  margin-bottom: 0.3rem;
}

.calendar-events {
  display: grid;
  gap: 0.22rem;
}

.calendar-event {
  border-radius: 7px;
  padding: 0.18rem 0.34rem;
  font-size: 0.68rem;
  background: #eff6ff;
  color: #1e3a8a;
}

.bar-chart {
  display: grid;
  gap: 0.45rem;
  margin-bottom: 0.75rem;
}

.bar-row {
  display: grid;
  grid-template-columns: 180px 1fr auto;
  align-items: center;
  gap: 0.5rem;
}

.bar {
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #2563eb, #60a5fa);
}

.chip-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 0.2rem 0.56rem;
  font-size: 0.76rem;
  color: #334155;
  cursor: pointer;
}

.chip:hover {
  border-color: #93c5fd;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.46);
  z-index: 46;
  padding: 1rem;
  display: grid;
  place-items: center;
}

.overlay-card {
  width: min(920px, 96vw);
  max-height: 88vh;
  overflow: auto;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 1rem;
  box-shadow: 0 22px 40px rgba(15, 23, 42, 0.25);
}

.overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  margin-bottom: 0.7rem;
}

.overlay-header h3 {
  margin: 0;
}

.search-input-wrap input {
  width: 100%;
}

.split-panel {
  margin-top: 0.8rem;
  display: grid;
  grid-template-columns: 1.8fr 1fr;
  gap: 0.75rem;
}

.list-panel {
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  max-height: 48vh;
  overflow: auto;
  padding: 0.45rem;
}

.list-item {
  border-radius: 9px;
  border: 1px solid transparent;
  padding: 0.5rem;
  margin-bottom: 0.35rem;
  cursor: pointer;
}

.list-item.active,
.list-item:hover {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.list-item p {
  margin: 0;
}

.list-item small {
  color: var(--muted);
}

.notification-panel {
  position: fixed;
  top: 0.8rem;
  right: 0.8rem;
  width: min(420px, calc(100vw - 1.6rem));
  max-height: calc(100vh - 1.6rem);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  z-index: 55;
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.2);
  padding: 0.85rem;
}

.notification-list {
  display: grid;
  gap: 0.5rem;
}

.notification-item {
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 0.55rem 0.62rem;
  background: #fff;
}

.notification-item.unread {
  border-color: #93c5fd;
  background: #eff6ff;
}

.notification-item p {
  margin: 0;
}

.notification-item small {
  color: var(--muted);
}

.profile-drawer {
  position: fixed;
  top: 0.8rem;
  right: 0.8rem;
  width: min(560px, calc(100vw - 1.6rem));
  max-height: calc(100vh - 1.6rem);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  z-index: 54;
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.2);
  padding: 0.85rem;
}

.profile-summary {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.65rem;
  margin-bottom: 0.7rem;
  background: #f8fafc;
}

.profile-summary h4 {
  margin: 0 0 0.2rem;
}

.reward {
  color: #15803d;
}

.penalty {
  color: #b91c1c;
}

.hint {
  display: inline-grid;
  place-items: center;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  border: 1px solid currentColor;
  margin-left: 0.3rem;
  font-size: 0.68rem;
  font-weight: 700;
  cursor: help;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(15, 23, 42, 0.25);
  display: grid;
  place-items: center;
}

.loading-sheet {
  width: min(480px, 92vw);
}

.skeleton {
  border-radius: 9px;
  background: linear-gradient(90deg, #e2e8f0 0%, #f1f5f9 40%, #e2e8f0 90%);
  background-size: 300% 100%;
  animation: shimmer 1.2s infinite linear;
}

.skeleton-line {
  height: 12px;
  margin-bottom: 0.55rem;
}

.skeleton-grid {
  height: 110px;
}

.w-40 {
  width: 40%;
}

.w-70 {
  width: 70%;
}

.toast-container {
  position: fixed;
  top: 0.9rem;
  right: 0.9rem;
  z-index: 80;
  display: grid;
  gap: 0.4rem;
}

.toast {
  border-radius: 10px;
  padding: 0.56rem 0.72rem;
  color: #fff;
  background: #334155;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.22);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.toast.success {
  background: #15803d;
}

.toast.error {
  background: #b91c1c;
}

.toast button {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  padding: 0.22rem 0.55rem;
  border-radius: 8px;
  font-size: 0.74rem;
}

.quick-actions {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 62;
}

.quick-main-btn {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  font-size: 1.3rem;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.35);
}

.quick-menu {
  margin-top: 0.55rem;
  display: grid;
  gap: 0.35rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.45rem;
  box-shadow: var(--shadow);
}

.quick-menu button {
  text-align: left;
  background: #eff6ff;
  color: #1e3a8a;
}

.quick-menu button:hover {
  background: #dbeafe;
}

.mobile-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  background: rgba(15, 23, 42, 0.96);
  border-top: 1px solid rgba(148, 163, 184, 0.22);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.3rem;
  padding: 0.4rem;
}

.mobile-nav button {
  padding: 0.4rem 0.25rem;
  border-radius: 8px;
  font-size: 0.76rem;
  background: transparent;
  border: 1px solid transparent;
  color: #e2e8f0;
}

.mobile-nav button.active {
  background: rgba(59, 130, 246, 0.25);
  border-color: rgba(147, 197, 253, 0.55);
}

@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: 0 0;
  }
}

@keyframes fade-slide-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1260px) {
  .kanban-board {
    grid-template-columns: repeat(5, minmax(190px, 1fr));
  }
  .bar-row {
    grid-template-columns: 140px 1fr auto;
  }
}

@media (max-width: 1024px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(300px, 88vw);
    transform: translateX(-105%);
    transition: transform 180ms ease;
    z-index: 66;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-only {
    display: inline-grid;
  }

  .content {
    padding: 0.8rem 0.8rem 5.2rem;
  }

  .topbar {
    top: 0.35rem;
  }

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

  .split-panel {
    grid-template-columns: 1fr;
  }

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

  .mobile-nav {
    display: grid !important;
  }
}

@media (max-width: 740px) {
  .cards {
    grid-template-columns: 1fr;
  }

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

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

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

  .topbar .row {
    justify-content: space-between;
  }

  .bar-row {
    grid-template-columns: 1fr;
    gap: 0.2rem;
  }
}