/* =========================================================
   ЕЦМП Design System — «Sky Mist»
   Soft sky blue · calm · Manrope
   ========================================================= */

:root {
  /* Soft sky / mist */
  --ink-950: #0f1729;
  --ink-900: #1a2740;
  --ink-800: #243552;
  --ink-700: #334866;
  --mist-50: #f5f8fc;
  --mist-100: #eaf1f8;
  --mist-200: #d7e5f2;
  --mist-300: #b8cde3;

  /* Compat aliases */
  --navy-900: #0f1729;
  --navy-800: #1a2740;
  --navy-700: #243552;
  --slate-50: #f5f8fc;
  --slate-100: #eaf1f8;
  --slate-200: #d7e5f2;
  --slate-300: #b8cde3;
  --slate-400: #7f9bb8;
  --slate-500: #5c7896;
  --slate-600: #445e7a;
  --slate-700: #334866;
  --slate-800: #243552;
  --slate-900: #1a2740;

  --primary: #5b9fd4;
  --primary-dark: #3d7eb8;
  --primary-light: #8bbfe6;
  --primary-bg: rgba(91, 159, 212, 0.12);
  --primary-glow: rgba(91, 159, 212, 0.16);
  --accent: #6b9fd6;
  --accent-dark: #4a86c0;
  --success: #3d9a78;
  --danger: #d46565;
  --warning: #d4a35b;

  --bg-main: #eef4fa;
  --bg-card: #ffffff;
  --bg-card-solid: #ffffff;
  --bg-muted: #f5f8fc;
  --bg-sidebar: #1a2740;
  --border: #c9d9ea;
  --border-light: rgba(26, 39, 64, 0.1);
  --text-primary: #1a2740;
  --text-secondary: #445e7a;
  --text-muted: #5c7896;
  --text-on-dark: #eaf1f8;

  --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;
  --space-10: 2.5rem;
  --space-12: 3rem;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px rgba(26, 39, 64, 0.05);
  --shadow-md: 0 4px 14px rgba(26, 39, 64, 0.07);
  --shadow-lg: 0 12px 28px rgba(26, 39, 64, 0.09);
  --shadow-xl: 0 20px 40px rgba(26, 39, 64, 0.11);
  --shadow-focus: 0 0 0 3px rgba(91, 159, 212, 0.25);

  --transition: 0.18s ease;
  --transition-slow: 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  --glass-blur: blur(0px);

  --font-sans: "Manrope", "Segoe UI", sans-serif;
  --font-display: "Manrope", "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --text-xs: 0.72rem;
  --text-sm: 0.8125rem;
  --text-base: 0.9375rem;
  --text-lg: 1.0625rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --leading-tight: 1.2;
  --leading-normal: 1.55;
}

[data-theme="dark"] {
  --bg-main: #0f1729;
  --bg-card: #162033;
  --bg-card-solid: #162033;
  --bg-muted: #1a2740;
  --bg-sidebar: #0b1220;
  --border: #2a3d5c;
  --border-light: rgba(234, 241, 248, 0.1);
  --text-primary: #eaf1f8;
  --text-secondary: #b8cde3;
  --text-muted: #7f9bb8;
  --primary: #7eb8e8;
  --primary-dark: #5b9fd4;
  --primary-light: #a8d4f5;
  --primary-bg: rgba(126, 184, 232, 0.14);
  --primary-glow: rgba(126, 184, 232, 0.18);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.45);
  --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.5);
  --shadow-focus: 0 0 0 3px rgba(126, 184, 232, 0.28);
}

/* ---------- Shared primitives ---------- */

.ui-page {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-4);
}

.ui-card {
  background: var(--bg-card-solid);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.ui-card:hover {
  border-color: rgba(91, 159, 212, 0.35);
  box-shadow: var(--shadow-md);
}

.ui-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-light);
  background: linear-gradient(180deg, var(--mist-50), transparent);
}

[data-theme="dark"] .ui-card-header {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent);
}

.ui-card-body {
  padding: var(--space-5);
}

.ui-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  line-height: var(--leading-tight);
}

.ui-subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

.ui-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 650;
  background: var(--primary-bg);
  color: var(--primary-dark);
  border: 1px solid rgba(91, 159, 212, 0.2);
  white-space: nowrap;
}

[data-theme="dark"] .ui-badge {
  color: var(--primary-light);
}

.ui-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.62rem 1.1rem;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 650;
  letter-spacing: -0.01em;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition), color var(--transition), border-color var(--transition),
    box-shadow var(--transition), transform var(--transition);
}

.ui-btn:active {
  transform: translateY(1px);
}

.ui-btn:disabled,
.ui-btn.loading {
  opacity: 0.6;
  pointer-events: none;
}

.ui-btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.ui-btn-primary:hover {
  background: var(--primary-dark);
}

.ui-btn-secondary {
  background: var(--bg-muted);
  color: var(--text-primary);
  border-color: var(--border);
}

.ui-btn-secondary:hover {
  background: var(--mist-100);
  border-color: var(--mist-300);
}

[data-theme="dark"] .ui-btn-secondary:hover {
  background: var(--ink-700);
}

.ui-btn-danger {
  background: var(--danger);
  color: #fff;
}

.ui-btn-danger:hover {
  filter: brightness(1.05);
}

.ui-btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.ui-btn-ghost:hover {
  background: var(--primary-bg);
  color: var(--primary);
}

.ui-input,
.ui-select,
.ui-textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-card-solid);
  color: var(--text-primary);
  font-family: inherit;
  font-size: var(--text-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.ui-input:focus,
.ui-select:focus,
.ui-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--shadow-focus);
}

.ui-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.ui-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  background: var(--bg-card-solid);
  box-shadow: var(--shadow-sm);
}

.ui-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.ui-table th {
  text-align: left;
  padding: 0.85rem 1rem;
  background: var(--bg-muted);
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

.ui-table td {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
  vertical-align: middle;
}

.ui-table tr:last-child td {
  border-bottom: none;
}

.ui-table tbody tr {
  transition: background var(--transition);
}

.ui-table tbody tr:hover {
  background: var(--primary-bg);
}

.ui-empty {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  color: var(--text-muted);
}

.ui-empty-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto var(--space-4);
  opacity: 0.4;
}

.ui-empty-title {
  font-size: var(--text-lg);
  font-weight: 650;
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

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

.ui-fade-up {
  animation: ui-fade-up 0.4s var(--transition-slow) both;
}

@media (prefers-reduced-motion: reduce) {
  .ui-fade-up {
    animation: none !important;
  }
}

@media (max-width: 768px) {
  .ui-page {
    padding: var(--space-4) var(--space-3);
  }

  .ui-card-body {
    padding: var(--space-4);
  }

  .ui-title {
    font-size: var(--text-xl);
  }
}
