:root, :root.theme-light {
  /* Светлая тема по умолчанию */
  --bg: #f5f7f9;
  --card: #ffffff;
  --muted: #6b7280;
  --text: #1f2937;
  --accent: #f59e0b;
  --accent-2: #10b981;
  --danger: #ef4444;
  --radius: 18px;
  --shadow: 0 4px 20px rgba(0,0,0,.08);
  --border: #e5e7eb;
  --scrollbar-track: #f1f5f9;
  --scrollbar-thumb: #cbd5e1;
  --scrollbar-thumb-hover: #94a3b8;
  --progress-bg: #f1f5f9;
  --kpi-bg: #f8fafc;
  --task-bg: #f8fafc;
  --modal-field-bg: #f8fafc;
  --card-header-bg: #f8fafc;
}

:root.theme-dark {
  --bg: #111316;
  --card: #1a1d22;
  --muted: #9aa3af;
  --text: #e6e8eb;
  --accent: #f59e0b;
  --accent-2: #2ecc71;
  --danger: #ef4444;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --border: #23262d;
  --scrollbar-track: #1a1d22;
  --scrollbar-thumb: #3a404a;
  --scrollbar-thumb-hover: #4e5561;
  --progress-bg: #1b1f26;
  --kpi-bg: #171a1f;
  --task-bg: #171a1f;
  --modal-field-bg: #1e2229;
  --card-header-bg: transparent;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  margin: 0; 
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg); 
  color: var(--text);
  -webkit-font-smoothing: antialiased; 
  text-rendering: optimizeLegibility;
  line-height: 1.5;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Кастомный скролл */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
  border-radius: 4px;
  transition: background-color 0.3s ease;
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 4px;
  transition: background 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

/* Специальные стили для скролла модального окна */
.modal-content {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

.modal-content::-webkit-scrollbar {
  width: 6px;
}

.modal-content::-webkit-scrollbar-thumb {
  background: var(--accent);
}

.container {
  max-width: 800px;
  margin: 40px auto;
  padding: 0 20px;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  margin-top: 8vh;
  background: var(--card);
  border-radius: var(--radius);
  width: 90%;
  max-width: 700px;
  max-height: 83vh;
  overflow-y: auto;
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transform: translateY(20px);
  transition: all 0.3s ease;
  scrollbar-gutter: stable;
}

.modal-overlay.active .modal-content {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
}

.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 24px;
  cursor: pointer;
  transition: color 0.3s ease;
}

.modal-close:hover {
  color: var(--text);
}

.modal-body {
  margin-bottom: 20px;
}

.modal-field {
  margin-bottom: 15px;
}

.modal-field-title {
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 5px;
  font-size: 14px;
}

.modal-field-value {
  background: var(--modal-field-bg);
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  word-break: break-word;
  max-height: 300px;
  overflow-y: auto;
  padding-right: 8px;
  transition: all 0.3s ease;
}

.description-content {
  line-height: 1.6;
  padding: 8px 0;
}

.description-content p {
  margin-bottom: 12px;
}

.description-content a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.3s ease;
}

.description-content a:hover {
  color: var(--accent-2);
  text-decoration: underline;
}

.description-content br {
  display: block;
  content: "";
  margin-bottom: 12px;
}

.no-description {
  color: var(--muted);
  font-style: italic;
}

.mention {
  color: var(--accent-2);
  font-weight: 500;
}

.modal-field-value ul,
.modal-field-value ol {
  margin-left: 20px;
  margin-bottom: 12px;
}

.modal-field-value li {
  margin-bottom: 6px;
}

.modal-footer {
  display: flex;
  justify-content: space-between;
  padding-top: 15px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}

.link {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.3s ease;
}

.link:hover {
  color: var(--accent-2);
  text-decoration: underline;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.title {
  margin-top: 50px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: .2px;
  color: var(--text);
}

.chart-current-day {
  background-color: rgba(253, 181, 21, 0.1);
  border-left: 2px dashed var(--accent);
}

.subtitle {
  color: var(--muted);
  font-size: 14px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 999px;
  position: relative;
  overflow: hidden;
  z-index: 1;
  box-shadow: var(--shadow);
  transition: all 0.3s ease;
}

.chip svg {
  opacity: .9;
}

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 14px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: all .3s ease;
  font-family: inherit;
  font-size: 14px;
}

.btn:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  background: var(--bg);
}

.grid {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: fadeIn 0.3s ease-out forwards;
  opacity: 0;
  transition: all 0.3s ease;
}

.card-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--card-header-bg);
  border-radius: var(--radius) var(--radius) 0 0;
  transition: all 0.3s ease;
}

.card-h h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.card-c {
  padding: 18px;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
  transition: all 0.3s ease;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 16px 0;
}

.kpi {
  background: var(--kpi-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  box-shadow: var(--shadow);
  transition: all 0.3s ease;
}

.kpi .v {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
}

.kpi .l {
  font-size: 12px;
  color: var(--muted);
}

.progress-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
}

.progress {
  height: 12px;
  background: var(--progress-bg);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
  transition: all 0.3s ease;
}

.progress>span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 80%, white));
  width: 0;
  transition: background 0.3s ease;
}

.legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.legend .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  transition: background-color 0.3s ease;
}

.legend .item {
  display: flex;
  gap: 6px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  transition: color 0.3s ease;
}

.tasks {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.task {
  background: var(--task-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.task:hover {
  transform: translateY(-4px);
  background: var(--card);
  border-color: var(--accent);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.task:hover::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--accent) 15%, transparent) 0%,
    transparent 60%
  );
  z-index: 0;
}

.task .t {
  font-weight: 700;
  transition: color 0.3s ease;
  position: relative;
  z-index: 1;
  color: var(--text);
}

.task:hover .t {
  color: var(--accent);
}

.task .meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
  position: relative;
  z-index: 1;
}

.task:hover .pill {
  transform: scale(1.03);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.pill {
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 12px;
  transition: all 0.3s ease;
}

.pill.good {
  
  background: var(--accent-2);
  color: white;
}

.pill.warn {
  background: #3b82f6;
  color: white;
}

.pill.neutral {
  background: var(--muted);
  color: white;
}

.pill.danger {
  background: var(--danger);
  color: white;
}

.footer {
  color: var(--muted);
  text-align: center;
  margin: 28px 0 14px;
  transition: color 0.3s ease;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-top: 16px;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  transition: border-color 0.3s ease;
}

.stat-value {
  font-weight: 700;
  color: var(--text);
  transition: color 0.3s ease;
}

.diff-positive {
  color: var(--accent-2);
}

.diff-negative {
  color: var(--danger);
}

.achievement-item {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--border);
  transition: border-color 0.3s ease;
}

.achievement-title {
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--accent);
  transition: color 0.3s ease;
}

@keyframes fadeIn {
  from { 
    opacity: 0; 
    transform: translateY(10px); 
  }
  to { 
    opacity: 1; 
    transform: translateY(0); 
  }
}

.card:nth-child(1) { 
  animation-delay: 0.1s; 
}

.card:nth-child(2) { 
  animation-delay: 0.2s; 
}

.card:nth-child(3) { 
  animation-delay: 0.3s; 
}

.chart-container {
  position: relative;
  height: 200px;
  width: 100%;
}

.update-info {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  transition: color 0.3s ease;
}

/* Специфичные цвета для легенды */
#l-done { background-color: var(--accent-2); }
#l-inprog { background-color: var(--accent); }
#l-todo { background-color: var(--muted); }

@media (max-width: 980px) { 
  .grid {
    grid-template-columns: 1fr;
  }
  
  .tasks {
    grid-template-columns: 1fr 1fr;
  } 
}

@media (max-width: 640px) { 
  .tasks {
    grid-template-columns: 1fr;
  } 
  
  .header {
    flex-direction: column;
    align-items: flex-start;
  } 
  
  .stat-grid {
    grid-template-columns: 1fr;
  } 
}

@media print {
  @page {
    size: A4; 
    margin: 15mm;
  }
  
  body {
    background: #ffffff !important; 
    color: #1f2937 !important; 
    padding: 0 !important; 
    margin: 0 !important; 
    width: 100%; 
    height: 100%;
  }
  
  body, .container, .card, .task, .kpi, .chip {
    background-color: #ffffff !important; 
    color: #1f2937 !important;
  }
  
  .container {
    max-width: 100% !important; 
    margin: 0 !important; 
    padding: 15mm !important; 
    background: #ffffff !important;
  }
  
  .card {
    background: #ffffff !important; 
    border: 1px solid #e5e7eb !important; 
    box-shadow: 0 4px 20px rgba(0,0,0,.08) !important; 
    color: #1f2937 !important; 
    break-inside: avoid;
  }
  
  .chip, .btn, .kpi, .task {
    background: #f8fafc !important; 
    border: 1px solid #e5e7eb !important; 
    color: #374151 !important;
  }
  
  .progress {
    background: #f1f5f9 !important; 
    border: 1px solid #e5e7eb !important;
  }
  
  .progress>span {
    background: linear-gradient(90deg, #f59e0b, #fbbf24) !important;
  }
  
  .pill.good {
    background: #10b981 !important; 
    color: #ffffff !important; 
    border-color: #a7f3d0 !important;
  }
  
  .pill.warn {
    background: #3b82f6 !important; 
    color: #ffffff !important; 
    border-color: #93c5fd !important;
  }
  
  .pill.neutral {
    background: #6b7280 !important; 
    color: #ffffff !important; 
    border-color: #d1d5db !important;
  }
  
  .pill.danger {
    background: #ef4444 !important; 
    color: #ffffff !important; 
    border-color: #fca5a5 !important;
  }
  
  .btn {
    display: none !important;
  }
  
  .legend .dot {
    border: 1px solid #e5e7eb !important;
  }
  
  html {
    background: #ffffff !important;
  }
  
  * {
    -webkit-print-color-adjust: exact !important; 
    print-color-adjust: exact !important;
  }
}