:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --bg-elevated: #ffffff;
  --bg-muted: #eef2f8;
  --bg-accent: #ecf4ff;
  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.14);
  --text: #0f172a;
  --text-soft: #526076;
  --text-faint: #7b8aa5;
  --primary: #2563eb;
  --primary-soft: rgba(37, 99, 235, 0.12);
  --success: #0f9f6e;
  --success-soft: rgba(15, 159, 110, 0.14);
  --warning: #d97706;
  --warning-soft: rgba(217, 119, 6, 0.14);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.14);
  --info: #0f766e;
  --info-soft: rgba(15, 118, 110, 0.14);
  --shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.08);
  --shadow-card: 0 10px 30px rgba(15, 23, 42, 0.05);
  --shadow-sidebar: 0 16px 50px rgba(15, 23, 42, 0.08);
  --ring: 0 0 0 4px rgba(37, 99, 235, 0.12);
  --radius-xl: 1.5rem;
  --radius-lg: 1rem;
  --radius-md: 0.875rem;
  --sidebar-width: 18rem;
  --sidebar-width-collapsed: 6rem;
}

.dark {
  color-scheme: dark;
  --bg: #0b1220;
  --bg-elevated: #111a2d;
  --bg-muted: #182234;
  --bg-accent: rgba(37, 99, 235, 0.18);
  --border: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.24);
  --text: #e7eefc;
  --text-soft: #a5b4cf;
  --text-faint: #7c8ca8;
  --primary: #60a5fa;
  --primary-soft: rgba(96, 165, 250, 0.16);
  --success: #22c55e;
  --success-soft: rgba(34, 197, 94, 0.16);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.16);
  --danger: #fb7185;
  --danger-soft: rgba(251, 113, 133, 0.16);
  --info: #2dd4bf;
  --info-soft: rgba(45, 212, 191, 0.16);
  --shadow-soft: 0 22px 50px rgba(2, 8, 23, 0.45);
  --shadow-card: 0 14px 34px rgba(2, 8, 23, 0.32);
  --shadow-sidebar: 0 18px 50px rgba(2, 8, 23, 0.55);
  --ring: 0 0 0 4px rgba(96, 165, 250, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: "Manrope", sans-serif;
  color: var(--text);
  overflow-x: hidden;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.08), transparent 28%),
    radial-gradient(circle at top right, rgba(15, 118, 110, 0.08), transparent 22%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), transparent 18%),
    var(--bg);
  transition: background-color 180ms ease, color 180ms ease;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.08) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.12), transparent 75%);
  pointer-events: none;
  z-index: -1;
}

[x-cloak] {
  display: none !important;
}

a {
  color: inherit;
  text-decoration: none;
}

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

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[role="button"]:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.panel {
  background: color-mix(in srgb, var(--bg-elevated) 94%, transparent);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  border-radius: var(--radius-xl);
  backdrop-filter: blur(12px);
}

.panel-muted {
  background: color-mix(in srgb, var(--bg-muted) 88%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.stat-card {
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: "";
  position: absolute;
  inset: auto -3rem -3rem auto;
  width: 8rem;
  height: 8rem;
  border-radius: 999px;
  background: linear-gradient(135deg, transparent, rgba(255, 255, 255, 0.28));
}

.shell-main {
  min-width: 0;
  padding-left: var(--sidebar-width);
  transition: padding-left 180ms ease;
}

.sidebar-shell {
  width: var(--sidebar-width);
  background: color-mix(in srgb, var(--bg-elevated) 92%, transparent);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow-sidebar);
  backdrop-filter: blur(16px);
  transition: width 180ms ease, transform 180ms ease;
}

.sidebar-collapsed .sidebar-shell {
  width: var(--sidebar-width-collapsed);
}

.sidebar-collapsed .shell-main {
  padding-left: var(--sidebar-width-collapsed);
}

.sidebar-collapsed .sidebar-group-toggle {
  display: none;
}

.sidebar-collapsed .sidebar-group-body {
  margin-top: 0;
}

.sidebar-collapsed .sidebar-brand-copy,
.sidebar-collapsed .sidebar-label,
.sidebar-collapsed .sidebar-section-title,
.sidebar-collapsed .sidebar-chevron,
.sidebar-collapsed .sidebar-footer-copy {
  display: none;
}

.sidebar-collapsed .sidebar-link {
  justify-content: center;
  padding-inline: 0.75rem;
}

.sidebar-collapsed .sidebar-link svg {
  margin-right: 0;
}

.sidebar-link {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 0.75rem;
  padding: 0.8rem 0.95rem;
  border-radius: 1rem;
  color: var(--text-soft);
  transition: background-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.sidebar-link:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--bg-muted) 84%, transparent);
  transform: translateX(2px);
}

.sidebar-link.active {
  background: linear-gradient(135deg, var(--primary-soft), transparent);
  color: var(--primary);
  border: 1px solid color-mix(in srgb, var(--primary) 16%, var(--border));
}

.header-shell {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
}

.header-context {
  min-width: 0;
}

.header-controls {
  min-width: 0;
  justify-content: flex-start;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.header-controls > * {
  flex: 0 0 auto;
}

.header-controls::-webkit-scrollbar {
  display: none;
}

.top-search {
  flex: 1 1 20rem;
  background: color-mix(in srgb, var(--bg-elevated) 85%, transparent);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.metric-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.78rem;
  font-weight: 700;
}

.metric-badge.primary {
  background: var(--primary-soft);
  color: var(--primary);
}

.metric-badge.success {
  background: var(--success-soft);
  color: var(--success);
}

.metric-badge.warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.metric-badge.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.metric-badge.info {
  background: var(--info-soft);
  color: var(--info);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.32rem 0.72rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  border: 1px solid transparent;
}

.status-badge::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 999px;
  background: currentColor;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.avatar-sm {
  width: 2rem;
  height: 2rem;
  font-size: 0.72rem;
}

.avatar-lg {
  width: 3.5rem;
  height: 3.5rem;
  font-size: 1rem;
}

.avatar.primary {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.16), rgba(15, 118, 110, 0.18));
  color: var(--primary);
}

.avatar.success {
  background: var(--success-soft);
  color: var(--success);
}

.avatar.warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.avatar.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.avatar.info {
  background: var(--info-soft);
  color: var(--info);
}

.data-table-shell table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.data-table-shell {
  overflow-x: auto;
}

.data-table-shell thead th {
  position: relative;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  background: color-mix(in srgb, var(--bg-muted) 78%, transparent);
  border-bottom: 1px solid var(--border);
}

.data-table-shell th,
.data-table-shell td {
  padding: 0.95rem 1rem;
  text-align: left;
}

.data-table-shell tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background-color 140ms ease;
}

.data-table-shell tbody tr:hover {
  background: color-mix(in srgb, var(--bg-muted) 72%, transparent);
}

.data-table-shell tbody tr.is-hidden {
  display: none;
}

.field,
.select-field,
.textarea-field {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 0.95rem;
  background: color-mix(in srgb, var(--bg-elevated) 88%, transparent);
  color: var(--text);
  padding: 0.82rem 0.95rem;
  transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

.field::placeholder,
.textarea-field::placeholder {
  color: var(--text-faint);
}

.field:focus,
.select-field:focus,
.textarea-field:focus {
  border-color: color-mix(in srgb, var(--primary) 28%, var(--border));
  box-shadow: var(--ring);
}

.textarea-field {
  min-height: 7rem;
  resize: vertical;
}

.toggle-switch {
  position: relative;
  width: 3.25rem;
  height: 1.9rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg-muted) 82%, transparent);
  border: 1px solid var(--border);
  transition: background-color 140ms ease;
}

.toggle-switch::after {
  content: "";
  position: absolute;
  top: 0.16rem;
  left: 0.2rem;
  width: 1.42rem;
  height: 1.42rem;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.12);
  transition: transform 140ms ease;
}

.toggle-input:checked + .toggle-switch {
  background: color-mix(in srgb, var(--primary) 40%, transparent);
}

.toggle-input:checked + .toggle-switch::after {
  transform: translateX(1.3rem);
}

.timeline {
  position: relative;
}

.timeline::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0.72rem;
  width: 1px;
  background: linear-gradient(180deg, var(--primary-soft), transparent);
}

.timeline-item {
  position: relative;
  padding-left: 2.5rem;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: 0.33rem;
  top: 0.2rem;
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 999px;
  background: var(--primary);
  border: 4px solid color-mix(in srgb, var(--bg-elevated) 92%, transparent);
}

.kanban-column {
  min-height: 22rem;
  background: color-mix(in srgb, var(--bg-elevated) 92%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
}

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

.calendar-cell {
  min-height: 9rem;
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--bg-elevated) 90%, transparent);
}

.message-bubble {
  max-width: 28rem;
  border-radius: 1.3rem;
  padding: 0.85rem 1rem;
}

.message-bubble.incoming {
  background: color-mix(in srgb, var(--bg-muted) 84%, transparent);
}

.message-bubble.outgoing {
  background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 78%, #ffffff 22%), color-mix(in srgb, var(--info) 52%, #ffffff 48%));
  color: #fff;
}

.upload-dropzone {
  border: 1.5px dashed color-mix(in srgb, var(--primary) 32%, var(--border));
  background: linear-gradient(135deg, var(--primary-soft), transparent);
  border-radius: var(--radius-xl);
}

.table-action-menu {
  min-width: 11rem;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-elevated) 94%, transparent);
  box-shadow: var(--shadow-card);
  border-radius: 1rem;
}

.toast-stack {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toast-item {
  min-width: 18rem;
  max-width: 24rem;
  border-radius: 1rem;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-elevated) 95%, transparent);
  box-shadow: var(--shadow-soft);
  padding: 0.95rem 1rem;
  animation: toast-in 180ms ease;
}

.mobile-sidebar-open {
  overflow: hidden;
}

.modal-backdrop,
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(6px);
}

.modal-shell,
.drawer-shell {
  position: fixed;
  z-index: 60;
  background: color-mix(in srgb, var(--bg-elevated) 96%, transparent);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
}

.modal-shell {
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  width: min(90vw, 42rem);
  border-radius: 1.5rem;
}

.drawer-shell {
  inset: 0 0 0 auto;
  width: min(92vw, 24rem);
  border-radius: 1.5rem 0 0 1.5rem;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
}

.auth-shell .auth-visual {
  background:
    radial-gradient(circle at top, rgba(37, 99, 235, 0.18), transparent 38%),
    radial-gradient(circle at bottom left, rgba(15, 118, 110, 0.16), transparent 32%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 48%),
    #0f172a;
}

.auth-grid-card {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 1.25rem;
  backdrop-filter: blur(18px);
}

.error-shell,
.maintenance-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
}

.reveal {
  animation: reveal-up 220ms ease;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--text-faint) 35%, transparent);
  border-radius: 999px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

@keyframes reveal-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 1023px) {
  .shell-main {
    padding-left: 0 !important;
  }

  .sidebar-shell {
    transform: translateX(-100%);
  }

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

  [data-mobile-overlay] {
    display: none;
  }

  .mobile-sidebar-open [data-mobile-overlay] {
    display: block;
  }

  .auth-shell {
    grid-template-columns: 1fr;
  }

  .auth-shell .auth-visual {
    display: none;
  }
}

@media (min-width: 1280px) {
  .header-context {
    flex: 1 1 26rem;
  }

  .header-controls {
    justify-content: flex-end;
    overflow: visible;
    padding-bottom: 0;
  }
}

@media (max-width: 767px) {
  .header-shell > div {
    gap: 0.75rem;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
  }

  .shell-main > main {
    padding-top: 1rem;
  }

  .header-controls {
    gap: 0.5rem;
  }

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

  .calendar-cell {
    min-height: auto;
  }

  .toast-stack {
    left: 1rem;
    right: 1rem;
  }

  .toast-item {
    min-width: 0;
    max-width: none;
  }
}


