:root {
  --background: 222 47% 99%;
  --foreground: 222 47% 11%;
  --card: 0 0% 100%;
  --card-foreground: 222 47% 11%;
  --muted: 215 16% 92%;
  --muted-foreground: 215 16% 35%;
  --border: 214 32% 91%;
  --ring: 221 83% 53%;
  --radius: 16px;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --gutter: clamp(1rem, 2vw, 1.75rem);
  --card-padding: clamp(1rem, 2vw, 1.5rem);
  --sidebar-width: 280px;
  --sidebar-width-xl: 320px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 20%, rgba(99,102,241,0.16), transparent 35%),
    radial-gradient(circle at 90% 5%, rgba(14,165,233,0.16), transparent 32%),
    #f6f8fb;
  color: hsl(var(--foreground));
  font-family: 'Space Grotesk','Inter',system-ui,sans-serif;
  line-height: 1.5;
}

img,
svg,
video {
  max-width: 100%;
  height: auto;
}

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

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

.glass-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 18px;
  box-shadow: 0 20px 80px -40px rgba(15,23,42,0.55), 0 12px 32px -20px rgba(14,165,233,0.35);
  min-width: 0;
}

.soft-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 9999px;
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.02em;
}

.panel {
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(244,246,255,0.94));
  border: 1px solid hsl(var(--border));
  border-radius: 16px;
  box-shadow: 0 24px 60px -34px rgba(15,23,42,0.35);
  min-width: 0;
}

/* Flip calendar animation for stat digits */
.flip-slot { perspective: 600px; }
.flip-digit { display:inline-block; transform-origin: top; will-change: transform; }
.animate-flip { animation: flipTick 450ms ease-in-out; }
@keyframes flipTick {
  0% { transform: rotateX(0deg); }
  50% { transform: rotateX(-90deg); }
  100% { transform: rotateX(0deg); }
}

/* Layout + spacing */
.app-shell {
  min-height: 100vh;
  position: relative;
  transition: grid-template-columns 200ms ease;
}

.app-shell.sidebar-open {
  --sidebar-size: var(--sidebar-width);
}

.app-shell.sidebar-closed {
  --sidebar-size: 0px;
}

.app-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.45);
  backdrop-filter: blur(2px);
  z-index: 25;
}

.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: min(85vw, 320px);
  transform: translateX(-100%);
  transition: transform 200ms ease;
  z-index: 30;
  padding: var(--gutter);
  overflow-y: auto;
  overflow-x: hidden;
}

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

.app-main {
  min-width: 0;
  padding: var(--gutter);
  overflow-x: hidden;
}

@media (min-width: 768px) {
  .app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-size, 0px) minmax(0, 1fr);
  }

  .app-shell.sidebar-open {
    --sidebar-size: var(--sidebar-width);
  }

  .app-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    transform: translateX(0);
    width: var(--sidebar-size, 0px);
    padding: var(--gutter);
  }

  .app-shell.sidebar-closed .app-sidebar {
    width: 0;
    padding: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
  }
}

@media (min-width: 1280px) {
  .app-shell.sidebar-open {
    --sidebar-size: var(--sidebar-width-xl);
  }
}

.ui-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.ui-stack--sm {
  gap: var(--space-2);
}

.ui-stack--lg {
  gap: var(--space-6);
}

.ui-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  min-width: 0;
}

.ui-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.75rem;
  border: 1px solid hsl(var(--border));
  background: rgba(255,255,255,0.92);
  color: #475569;
  transition: background 150ms ease, color 150ms ease;
}

.ui-icon-button:hover {
  background: rgba(255,255,255,1);
  color: #0f172a;
}

.ui-modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: var(--gutter);
  background: rgba(15,23,42,0.45);
}

.ui-modal__content {
  width: 100%;
  max-height: 85vh;
  overflow: hidden;
  background: #fff;
  border-radius: 1rem;
  padding: var(--card-padding);
  box-shadow: 0 24px 60px -34px rgba(15,23,42,0.35);
  min-width: 0;
}

.ui-modal__content--md { max-width: 32rem; }
.ui-modal__content--lg { max-width: 42rem; }
.ui-modal__content--xl { max-width: 72rem; }
.ui-modal__content--flush { padding: 0; }
.ui-modal__content--tall { max-height: 90vh; }
.ui-modal__content--scroll { overflow-y: auto; }

.detail-modal {
  max-width: min(1100px, 100%);
  max-height: 90vh;
}

.menu-drawer {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  grid-template-columns: minmax(0, 280px) 1fr;
  pointer-events: none;
}

.menu-drawer__panel {
  height: 100%;
  background: #fff;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  box-shadow: 12px 0 40px -24px rgba(15,23,42,0.5);
  pointer-events: auto;
}

.menu-drawer__backdrop {
  background: rgba(15,23,42,0.45);
  pointer-events: auto;
}

.menu-drawer__section {
  display: grid;
  gap: 0.35rem;
}

.menu-drawer__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.75rem;
  border-radius: 0.75rem;
  border: 1px solid hsl(var(--border));
  background: #f8fafc;
  color: #334155;
  font-size: 0.9rem;
  transition: background 150ms ease, color 150ms ease, border 150ms ease;
}

.menu-drawer__item:hover {
  background: #eef2ff;
  border-color: #c7d2fe;
  color: #1e1b4b;
}

.menu-drawer__item--danger {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}

.menu-drawer__item--danger:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #991b1b;
}

.sprint-accordion-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 0.6rem 0.75rem;
  border-radius: 0.9rem;
  border: 1px solid hsl(var(--border));
  background: #f8fafc;
  cursor: pointer;
  text-align: left;
  transition: background 150ms ease, border 150ms ease, color 150ms ease;
}

.sprint-accordion-header:hover {
  background: #eef2ff;
  border-color: #c7d2fe;
}

.accordion-caret {
  height: 2rem;
  width: 2rem;
  border-radius: 999px;
  border: 1px solid hsl(var(--border));
  display: grid;
  place-items: center;
  color: #64748b;
  transition: transform 150ms ease, background 150ms ease, color 150ms ease;
  background: #fff;
}

.accordion-caret--open {
  transform: rotate(180deg);
  background: #eef2ff;
  color: #4f46e5;
  border-color: #c7d2fe;
}

.detail-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-5);
  padding: var(--card-padding);
  align-items: start;
}

@media (min-width: 900px) {
  .detail-body {
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.9fr);
  }
}

.detail-main,
.detail-side {
  display: grid;
  gap: var(--space-4);
  min-width: 0;
  align-content: start;
}

.detail-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 14px;
  padding: var(--space-4);
  box-shadow: 0 18px 40px -32px rgba(15,23,42,0.35);
  min-width: 0;
}

.detail-card--stack {
  display: grid;
  gap: var(--space-3);
}

.detail-card__title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #94a3b8;
}

.detail-card__value {
  font-size: 0.95rem;
  font-weight: 600;
  color: #0f172a;
}

.detail-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.detail-meta-card--wide {
  grid-column: span 2;
}

@media (max-width: 640px) {
  .detail-meta-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .detail-meta-card--wide {
    grid-column: span 1;
  }
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.status-total-card {
  padding: 0.75rem;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--space-2);
  min-height: 76px;
}

.status-total__title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #1f2937;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-total__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.status-total__label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #94a3b8;
}

.status-total__value {
  width: clamp(2.25rem, 40%, 3rem);
  aspect-ratio: 1 / 1;
  height: auto;
  border-radius: 0.6rem;
  background: #0f172a;
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
}

.status-total__digit {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1;
}

.board-grid {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  align-items: start;
}

@media (min-width: 768px) {
  .board-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1280px) {
  .board-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

.status-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.status-column-title {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.2;
  min-width: 0;
}

.status-count-badge {
  font-size: 11px;
  padding: 4px 8px;
  white-space: nowrap;
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
}

.task-card {
  border: 1px solid hsl(var(--border));
  border-radius: 0.75rem;
  padding: var(--space-3);
  background: rgba(255,255,255,0.92);
  box-shadow: 0 12px 32px -20px rgba(15,23,42,0.35);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  cursor: pointer;
  min-width: 0;
}

.task-card--disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.task-card__title {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.backlog-order-controls {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.backlog-order-controls button {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: #f8fafc;
  color: #475569;
  font-size: 12px;
  line-height: 1;
  display: grid;
  place-items: center;
}

.backlog-order-controls button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
