/* ═══════════════════════════════════════════
   Design Tokens — ГК МДМ Document Platform
   ═══════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root, [data-theme="light"] {
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  --text-xs:   clamp(0.75rem, 0.7rem + 0.25vw, 0.8125rem);
  --text-sm:   clamp(0.8125rem, 0.78rem + 0.2vw, 0.875rem);
  --text-base: clamp(0.875rem, 0.85rem + 0.15vw, 0.9375rem);
  --text-lg:   clamp(1rem, 0.95rem + 0.3vw, 1.125rem);
  --text-xl:   clamp(1.25rem, 1.1rem + 0.5vw, 1.5rem);

  --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;

  /* Corporate MDM red palette */
  --color-bg:             #f5f6f8;
  --color-surface:        #ffffff;
  --color-surface-2:      #fafbfc;
  --color-surface-offset: #eef0f4;
  --color-divider:        #e2e5ea;
  --color-border:         #d0d4db;
  --color-text:           #1a1d23;
  --color-text-muted:     #6b7280;
  --color-text-faint:     #9ca3af;
  --color-text-inverse:   #ffffff;
  --color-primary:        #D42020;
  --color-primary-hover:  #B01A1A;
  --color-primary-light:  #fde8e8;
  --color-primary-bg:     #fef0f0;
  --color-success:        #15803d;
  --color-success-light:  #dcfce7;
  --color-warning:        #b45309;
  --color-warning-light:  #fef3c7;
  --color-error:          #b91c1c;
  --color-error-light:    #fee2e2;
  --color-info:           #0369a1;
  --color-info-light:     #e0f2fe;

  --radius-sm: 0.25rem;
  --radius-md: 0.375rem;
  --radius-lg: 0.5rem;
  --radius-xl: 0.75rem;
  --radius-full: 9999px;
  --transition-interactive: 150ms ease;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);

  --sidebar-width: 260px;
  --sidebar-collapsed: 60px;
  --header-height: 56px;
}

[data-theme="dark"] {
  --color-bg:             #111318;
  --color-surface:        #1a1d24;
  --color-surface-2:      #21242c;
  --color-surface-offset: #161922;
  --color-divider:        #2a2d36;
  --color-border:         #363a44;
  --color-text:           #d1d5db;
  --color-text-muted:     #9ca3af;
  --color-text-faint:     #6b7280;
  --color-text-inverse:   #111318;
  --color-primary:        #F06060;
  --color-primary-hover:  #FF7A7A;
  --color-primary-light:  #3b1e1e;
  --color-primary-bg:     #331720;
  --color-success:        #4ade80;
  --color-success-light:  #14332a;
  --color-warning:        #fbbf24;
  --color-warning-light:  #332d14;
  --color-error:          #f87171;
  --color-error-light:    #331414;
  --color-info:           #38bdf8;
  --color-info-light:     #142533;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg:             #111318;
    --color-surface:        #1a1d24;
    --color-surface-2:      #21242c;
    --color-surface-offset: #161922;
    --color-divider:        #2a2d36;
    --color-border:         #363a44;
    --color-text:           #d1d5db;
    --color-text-muted:     #9ca3af;
    --color-text-faint:     #6b7280;
    --color-text-inverse:   #111318;
    --color-primary:        #F06060;
    --color-primary-hover:  #FF7A7A;
    --color-primary-light:  #3b1e1e;
    --color-primary-bg:     #331720;
    --color-success:        #4ade80;
    --color-success-light:  #14332a;
    --color-warning:        #fbbf24;
    --color-warning-light:  #332d14;
    --color-error:          #f87171;
    --color-error-light:    #331414;
    --color-info:           #38bdf8;
    --color-info-light:     #142533;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
  }
}
/* ═════════════════════════════════════════════
   Theme: Кураторг (Kuratorg)
   ═════════════════════════════════════════════ */

[data-project="kuratorg"],
[data-project="kuratorg"][data-theme="light"] {
  --color-primary:        #1B7D2E;
  --color-primary-hover:  #156324;
  --color-primary-light:  #E6F4EA;
  --color-primary-bg:     #F0F9F2;
  --color-bg:             #F5FAF6;
  --color-surface:        #FFFFFF;
  --color-surface-2:      #F0F9F2;
  --color-surface-offset: #E2F0E5;
  --color-divider:        #C8DECC;
  --color-border:         #B0CEB4;
}

[data-project="kuratorg"][data-theme="dark"] {
  --color-primary:        #4ADE80;
  --color-primary-hover:  #6AE89A;
  --color-primary-light:  #0F2918;
  --color-primary-bg:     #143D20;
  --color-bg:             #0F1A12;
  --color-surface:        #152218;
  --color-surface-2:      #1A2C1E;
  --color-surface-offset: #121E14;
  --color-divider:        #283D2C;
  --color-border:         #3A5240;
  --color-text:           #D0E8D4;
  --color-text-muted:     #98B8A0;
  --color-text-faint:     #687868;
  --color-text-inverse:   #0F1A12;
}

@media (prefers-color-scheme: dark) {
  [data-project="kuratorg"]:not([data-theme]) {
    --color-primary:        #4ADE80;
    --color-primary-hover:  #6AE89A;
    --color-primary-light:  #0F2918;
    --color-primary-bg:     #143D20;
    --color-bg:             #0F1A12;
    --color-surface:        #152218;
    --color-surface-2:      #1A2C1E;
    --color-surface-offset: #121E14;
    --color-divider:        #283D2C;
    --color-border:         #3A5240;
    --color-text:           #D0E8D4;
    --color-text-muted:     #98B8A0;
    --color-text-faint:     #687868;
    --color-text-inverse:   #0F1A12;
  }
}

/* ═════════════════════════════════════════════
   Theme: Brewsell Brewery
   ═════════════════════════════════════════════ */

[data-project="brewsell"], 
[data-project="brewsell"][data-theme="light"] {
  --color-primary:        #A75417;
  --color-primary-hover:  #8B4513;
  --color-primary-light:  #FFF4E0;
  --color-primary-bg:     #FFF8EF;
  --color-bg:             #FBF7F0;
  --color-surface:        #FFFFFF;
  --color-surface-2:      #FFF8EF;
  --color-surface-offset: #F5EDE0;
  --color-divider:        #E8DFD0;
  --color-border:         #D4C9B8;
}

[data-project="brewsell"][data-theme="dark"] {
  --color-primary:        #DFB454;
  --color-primary-hover:  #E8C76A;
  --color-primary-light:  #2E2518;
  --color-primary-bg:     #3B2C14;
  --color-bg:             #1A1510;
  --color-surface:        #231D15;
  --color-surface-2:      #2C241A;
  --color-surface-offset: #1E1812;
  --color-divider:        #3A3028;
  --color-border:         #4A3E32;
  --color-text:           #E8DFD0;
  --color-text-muted:     #B0A898;
  --color-text-faint:     #7A7068;
  --color-text-inverse:   #1A1510;
}

@media (prefers-color-scheme: dark) {
  [data-project="brewsell"]:not([data-theme]) {
    --color-primary:        #DFB454;
    --color-primary-hover:  #E8C76A;
    --color-primary-light:  #2E2518;
    --color-primary-bg:     #3B2C14;
    --color-bg:             #1A1510;
    --color-surface:        #231D15;
    --color-surface-2:      #2C241A;
    --color-surface-offset: #1E1812;
    --color-divider:        #3A3028;
    --color-border:         #4A3E32;
    --color-text:           #E8DFD0;
    --color-text-muted:     #B0A898;
    --color-text-faint:     #7A7068;
    --color-text-inverse:   #1A1510;
  }
}

/* Project Switcher */
.project-switcher {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 8px 0 4px;
  padding: 3px;
  background: var(--color-surface-offset);
  border-radius: 10px;
}
.project-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 8px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  background: transparent;
  transition: all 0.2s;
  opacity: 0.5;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
}
.project-btn:hover {
  opacity: 0.8;
  background: rgba(255,255,255,0.05);
}
.project-btn.active {
  opacity: 1;
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
  color: var(--color-primary);
}
.project-btn .project-logo {
  width: 24px;
  height: 24px;
  object-fit: contain;
  border-radius: 4px;
}
.project-btn .project-name {
  font-size: 11px;
  white-space: nowrap;
}


/* ═══ Layout ═══ */

body {
  min-height: 100dvh;
  overflow: hidden;
}

#app {
  display: flex;
  min-height: 100dvh;
}

/* ═══ Sidebar ═══ */

.sidebar {
  width: var(--sidebar-width);
  height: 100dvh;
  background: var(--color-surface);
  border-right: 1px solid var(--color-divider);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 200ms ease, transform 200ms ease;
  z-index: 100;
  overflow: hidden;
}

.sidebar-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-3) var(--space-4) var(--space-3);
  border-bottom: 1px solid var(--color-divider);
  gap: 0;
  flex-shrink: 0;
}

.sidebar-logo svg {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}
.sidebar-logo img {
  width: 95px;
  height: 95px;
  flex-shrink: 0;
  object-fit: contain;
}

.sidebar-logo > div:last-child {
  text-align: center;
}

.sidebar-logo .logo-text {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-primary);
  white-space: nowrap;
}

.sidebar-logo .logo-sub {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3) var(--space-2);
}

.nav-section {
  margin-bottom: var(--space-4);
}

.nav-section-title {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: var(--space-1) var(--space-3);
  margin-bottom: var(--space-1);
  white-space: nowrap;
  overflow: hidden;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-decoration: none;
  border: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: var(--color-surface-offset);
  color: var(--color-text);
}

.nav-item.active {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 600;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--color-error);
  color: white;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.125rem 0.4375rem;
  border-radius: var(--radius-full);
  min-width: 1.25rem;
  text-align: center;
  line-height: 1.4;
}

.sidebar-footer {
  border-top: 1px solid var(--color-divider);
  padding: var(--space-3) var(--space-4);
  flex-shrink: 0;
}

.user-panel {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: 600;
  flex-shrink: 0;
}

.user-info {
  overflow: hidden;
}

.user-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ═══ Main Content ═══ */

.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100dvh;
}

.header {
  height: var(--header-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-divider);
  display: flex;
  align-items: center;
  padding: 0 var(--space-6);
  gap: var(--space-4);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: 1;
}

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-2);
  border-radius: var(--radius-md);
  color: var(--color-text);
  width: 44px;
  height: 44px;
  min-width: 44px;
  flex-shrink: 0;
  background: var(--color-surface-offset);
  border: 1px solid var(--color-divider);
}
.menu-toggle svg {
  width: 24px;
  height: 24px;
}

.menu-toggle:hover {
  background: var(--color-surface-offset);
}

.page-title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--color-text);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.header-btn {
  position: relative;
  padding: var(--space-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
  transition: background var(--transition-interactive), color var(--transition-interactive), border-color var(--transition-interactive), box-shadow var(--transition-interactive), transform var(--transition-interactive);
}

.header-btn:hover {
  background: var(--color-primary-bg);
  border-color: var(--color-primary);
  color: var(--color-primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.header-btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.header-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  color: inherit;
  display: block;
  flex-shrink: 0;
}

[data-theme="dark"] .header-btn {
  background: var(--color-surface-2);
  border-color: var(--color-border);
  color: #f8fafc;
}

[data-theme="dark"] .header-btn:hover {
  background: var(--color-primary-bg);
  border-color: var(--color-primary);
  color: var(--color-primary-hover);
}

.header-btn .badge-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background: var(--color-error);
  border-radius: 50%;
  border: 2px solid var(--color-surface);
}

.content-area {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6);
  background: var(--color-bg);
}

/* ═══ KPI Cards ═══ */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.kpi-card {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.kpi-card .kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.kpi-card .kpi-icon.blue { background: var(--color-info-light); color: var(--color-info); }
.kpi-card .kpi-icon.green { background: var(--color-success-light); color: var(--color-success); }
.kpi-card .kpi-icon.orange { background: var(--color-warning-light); color: var(--color-warning); }
.kpi-card .kpi-icon.red { background: var(--color-error-light); color: var(--color-error); }

.kpi-value {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text);
  font-variant-numeric: tabular-nums lining-nums;
}

.kpi-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-weight: 500;
}

.kpi-sub {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}

/* ═══ Cards & Panels ═══ */

.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-divider);
}

.panel-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
}

.panel-body {
  padding: var(--space-4) var(--space-5);
}

.panel-body.no-pad {
  padding: 0;
}

/* ═══ Tables ═══ */

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

.data-table th {
  text-align: left;
  font-weight: 600;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-2);
  border-bottom: 1px solid var(--color-divider);
  white-space: nowrap;
}

.data-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-divider);
  vertical-align: middle;
}

.data-table tbody tr {
  cursor: pointer;
  transition: background 100ms ease;
}

.data-table tbody tr:hover {
  background: var(--color-surface-offset);
}

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

/* ═══ Status Badges ═══ */

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.1875rem 0.625rem;
  border-radius: var(--radius-full);
  font-size: 0.6875rem;
  font-weight: 600;
  white-space: nowrap;
}

.status-badge.draft { background: var(--color-surface-offset); color: var(--color-text-muted); }
.status-badge.on_review { background: var(--color-info-light); color: var(--color-info); }
.status-badge.approved { background: var(--color-success-light); color: var(--color-success); }
.status-badge.rejected { background: var(--color-error-light); color: var(--color-error); }
.status-badge.new { background: var(--color-info-light); color: var(--color-info); }
.status-badge.analysis { background: var(--color-warning-light); color: var(--color-warning); }
.status-badge.in_progress { background: var(--color-primary-light); color: var(--color-primary); }
.status-badge.planning { background: #f0e6ff; color: #7c3aed; }
.status-badge.implementation { background: #e0f2fe; color: #0284c7; }
.status-badge.evaluation { background: #fef3c7; color: #d97706; }
.status-badge.completed { background: var(--color-success-light); color: var(--color-success); }
.status-badge.on_hold { background: var(--color-surface-offset); color: var(--color-text-muted); }
.status-badge.signing { background: #ede9fe; color: #7c3aed; }
.status-badge.edo_awaiting { background: #fff3e0; color: #e65100; }
.status-badge.edo_signed { background: #e8f5e9; color: #2e7d32; }
.status-badge.signed { background: #e3f2fd; color: #1565c0; }
.status-badge.registered { background: #d1fae5; color: #059669; }
.status-badge.archived { background: var(--color-surface-offset); color: var(--color-text-muted); }
.status-badge.trash { background: var(--color-error-light); color: var(--color-error); }
.status-badge.withdrawn { background: var(--color-surface-offset); color: var(--color-text-muted); }
.status-badge.expired { background: var(--color-surface-offset); color: var(--color-text-muted); }
.status-badge.terminated { background: var(--color-error-light); color: var(--color-error); }
.status-badge.paused { background: #fff3e0; color: #ff9800; }
.status-badge.blocked { background: #fee2e2; color: #dc2626; }
.status-badge.block_request { background: #fff3e0; color: #ff9800; }

.category-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 4px;
  font-size: var(--text-xs); font-weight: 600; white-space: nowrap;
}
.category-badge.cat-operational { background: #dbeafe; color: #2563eb; }
.category-badge.cat-tactical { background: #f3e8ff; color: #7c3aed; }
.category-badge.cat-strategic { background: #fce7f3; color: #db2777; }

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ═══ Level Badges ═══ */

.level-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  font-size: 0.6875rem;
  font-weight: 700;
  flex-shrink: 0;
}

.level-badge.l0 { background: var(--color-error-light); color: var(--color-error); }
.level-badge.l1 { background: var(--color-warning-light); color: var(--color-warning); }
.level-badge.l2 { background: var(--color-info-light); color: var(--color-info); }

/* ═══ Priority ═══ */

.priority-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: var(--text-xs);
  font-weight: 600;
}

.priority-badge.high { color: var(--color-error); }
.priority-badge.medium { color: var(--color-warning); }
.priority-badge.low { color: var(--color-success); }

/* ═══ Buttons ═══ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}

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

.btn-outline {
  background: transparent;
  border-color: var(--color-border);
  color: var(--color-text);
}

.btn-outline:hover {
  background: var(--color-surface-offset);
}

.btn-sm {
  padding: 0.25rem 0.625rem;
  font-size: var(--text-xs);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn-icon svg {
  width: 16px;
  height: 16px;
}

.btn-icon:hover {
  background: var(--color-surface-offset);
  color: var(--color-text);
}

.btn-icon-danger:hover {
  background: rgba(220, 38, 38, 0.1);
  color: #dc2626;
}

.btn-danger {
  background: #dc2626;
  color: #fff;
  border: none;
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn svg {
  width: 16px;
  height: 16px;
}

/* ═══ Filters bar ═══ */

.filters-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.filter-select {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  font-size: var(--text-sm);
  color: var(--color-text);
  min-width: 140px;
}

.search-input {
  padding: var(--space-2) var(--space-3);
  padding-left: 2.25rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  font-size: var(--text-sm);
  color: var(--color-text);
  width: 240px;
}

.search-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px oklch(from var(--color-primary) l c h / 0.15);
}

.search-wrap {
  position: relative;
}

.search-wrap svg {
  position: absolute;
  left: 0.625rem;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--color-text-faint);
}

/* ═══ Detail View ═══ */

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  gap: var(--space-4);
}

.detail-title-group {
  flex: 1;
}

.detail-breadcrumb {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.detail-breadcrumb a,
.detail-breadcrumb button {
  color: var(--color-primary);
  text-decoration: none;
  cursor: pointer;
}

.detail-number {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-bottom: var(--space-1);
}

.detail-title {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.detail-meta {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.meta-item svg {
  width: 14px;
  height: 14px;
}

.detail-actions {
  display: flex;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* ═══ Info Grid ═══ */

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.info-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-weight: 500;
}

.info-value {
  font-size: var(--text-sm);
  color: var(--color-text);
  font-weight: 500;
}

/* ═══ Approval Steps ═══ */

.approval-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.approval-step {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  position: relative;
}

.approval-step:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 13px;
  top: 38px;
  bottom: -4px;
  width: 2px;
  background: var(--color-divider);
}

.step-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  z-index: 1;
}

.step-icon.approved { background: var(--color-success-light); color: var(--color-success); }
.step-icon.pending { background: var(--color-surface-offset); color: var(--color-text-faint); }
.step-icon.rejected { background: var(--color-error-light); color: var(--color-error); }

.step-content {
  flex: 1;
  min-width: 0;
}

.step-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
}

.step-role {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.step-comment {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
  font-style: italic;
}

.step-date {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  font-variant-numeric: tabular-nums;
}

/* ═══ Activity Feed ═══ */

.activity-feed {
  display: flex;
  flex-direction: column;
}

.activity-item {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-divider);
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-primary-light);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6875rem;
  font-weight: 600;
  flex-shrink: 0;
}

.activity-content {
  flex: 1;
  min-width: 0;
}

.activity-text {
  font-size: var(--text-sm);
  color: var(--color-text);
}

.activity-text strong {
  font-weight: 600;
}

.activity-time {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  margin-top: 2px;
}

/* ═══ Grid layouts ═══ */

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

.three-col {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-6);
}

/* ═══ Notification panel ═══ */

.notif-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 380px;
  max-width: 100vw;
  height: 100dvh;
  background: var(--color-surface);
  border-left: 1px solid var(--color-divider);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 200ms ease;
}

.notif-panel.open {
  transform: translateX(0);
}

.notif-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-divider);
}

.notif-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2);
}

.notif-item {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.notif-item:hover {
  background: var(--color-surface-offset);
}

.notif-item.unread {
  background: var(--color-primary-bg);
}

.notif-item-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
}

.notif-item-msg {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.notif-item-time {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}

/* ═══ Modal ═══ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 560px;
  max-height: 80dvh;
  overflow: auto;
  box-shadow: var(--shadow-lg);
}
.modal.modal-lg {
  max-width: 780px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5);
  border-bottom: 1px solid var(--color-divider);
}

.modal-title {
  font-size: var(--text-lg);
  font-weight: 600;
}

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

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--color-divider);
}

/* ═══ Forms ═══ */

.form-group {
  margin-bottom: var(--space-4);
}

.form-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: var(--space-1);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  font-size: var(--text-sm);
  color: var(--color-text);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--color-primary);
  outline: none;
  box-shadow: 0 0 0 2px oklch(from var(--color-primary) l c h / 0.15);
}

.form-textarea {
  min-height: 100px;
  resize: vertical;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

/* ═══ Empty State ═══ */

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

.empty-state svg {
  width: 48px;
  height: 48px;
  margin: 0 auto var(--space-3);
  color: var(--color-text-faint);
}

.empty-state p {
  font-size: var(--text-sm);
  max-width: none;
}

/* ═══ Toast ═══ */

.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.toast {
  background: var(--color-text);
  color: var(--color-text-inverse);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  box-shadow: var(--shadow-lg);
  animation: slideIn 200ms ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ═══ Login ═══ */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  width: 100vw;
  background: var(--color-bg);
}

.login-card {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-xl);
  padding: var(--space-10);
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-md);
}

.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-8);
}

.login-logo svg, .login-logo img {
  width: 210px;
  height: auto;
}

.login-logo h1 {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-primary);
}

.login-logo p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-align: center;
  max-width: none;
}

.login-error {
  background: var(--color-error-light);
  color: var(--color-error);
  font-size: var(--text-sm);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
  display: none;
}

.login-btn {
  width: 100%;
  padding: var(--space-3);
  justify-content: center;
  font-weight: 600;
}

/* ═══ Tabs ═══ */

.tabs {
  display: flex;
  border-bottom: 2px solid var(--color-divider);
  margin-bottom: var(--space-5);
  gap: 0;
}

.tab {
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
}

.tab:hover {
  color: var(--color-text);
}

.tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: 600;
}

/* ═══ Mobile overlay ═══ */

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 99;
  display: none;
  -webkit-tap-highlight-color: transparent;
}

.sidebar-overlay.show {
  display: block;
}

/* ═══ Table scroll wrapper ═══ */

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0;
  padding: 0;
}

/* ═══ Responsive ═══ */


/* Fallback text when SVG doesn't render */
.sr-fallback {
  display: none;
  font-size: 1.5rem;
  line-height: 1;
}
.menu-toggle:not(:has(svg)) .sr-fallback,
.menu-toggle svg:empty + .sr-fallback {
  display: inline;
}

@media (max-width: 1024px) {
  /* — Sidebar — */
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 85vw;
    max-width: 320px;
    transform: translateX(-100%);
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.12);
  }

  /* — Menu toggle — */
  .menu-toggle {
    display: flex;
  }

  /* — Prevent horizontal overflow — */
  html, body {
    overflow-x: hidden;
  }
  #app {
    max-width: 100vw;
    overflow-x: hidden;
  }
  .main-wrapper {
    width: 100vw;
    max-width: 100vw;
    overflow-x: hidden;
  }

  /* — Header — */
  .header {
    padding: 0 var(--space-3);
    gap: var(--space-2);
  }
  .page-title {
    font-size: var(--text-base);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* — Content — */
  .content-area {
    padding: var(--space-3);
  }

  /* — KPI grid — */
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-2);
  }
  .kpi-card {
    padding: var(--space-3);
  }
  .kpi-value {
    font-size: var(--text-lg);
  }

  /* — Grid layouts — */
  .two-col, .three-col {
    grid-template-columns: 1fr;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .detail-header {
    flex-direction: column;
    gap: var(--space-3);
  }

  /* — Notifications — */
  .notif-panel {
    width: 100vw;
  }

  /* — Filters bar — */
  .filters-bar {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-2);
  }
  .filter-select {
    width: 100%;
    min-width: 0;
  }
  .search-input {
    width: 100%;
  }
  .search-wrap {
    width: 100%;
  }
  .filters-bar .btn {
    width: 100%;
    justify-content: center;
  }

  /* — Tables — */
  .table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0;
    padding: 0;
  }
  .panel > .table-scroll,
  .panel-body > .table-scroll {
    overflow-x: auto;
  }
  .data-table {
    min-width: 600px;
  }
  .data-table th,
  .data-table td {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-xs);
  }

  /* — Section titles — */
  .section-title {
    font-size: var(--text-lg);
  }

  /* — Cards — */
  .card {
    padding: var(--space-3);
  }

  /* — Login page — */
  .login-card {
    margin: var(--space-4);
    padding: var(--space-6);
  }

  /* — Tabs — */
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-bottom: 2px;
  }
  .tabs::-webkit-scrollbar {
    display: none;
  }
  .tab {
    white-space: nowrap;
    flex-shrink: 0;
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-xs);
  }

  /* — Footer — */
  .app-footer {
    padding: var(--space-3);
    font-size: 0.625rem;
  }

  /* — Modals — */
  .modal-content {
    width: 95vw;
    max-width: 95vw;
    margin: var(--space-3);
    max-height: 90vh;
  }

  /* — Menu access checkboxes — */
  .menu-matrix {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* — Status badges more compact — */
  .project-badge {
    font-size: 0.5625rem;
    padding: 0.0625rem 0.375rem;
  }

  /* ═══ AI Cabinet Mobile ═══ */

  /* Hide certain table columns on mobile */
  .ai-col-pos,
  .ai-col-status {
    display: none;
  }

  /* Show position as subtitle under name */
  .ai-mob-subtitle {
    display: block !important;
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
    margin-top: 2px;
    font-weight: 400;
  }

  /* Make participants table scrollable with smaller min-width */
  .ai-participants-table .table-scroll {
    margin: 0;
    padding: 0;
  }
  .ai-participants-table .data-table {
    min-width: 480px;
  }

  /* Action buttons wrap on mobile */
  .ai-action-btns {
    width: 100%;
  }
  .ai-action-btns .btn {
    flex: 1 1 auto;
    min-width: 0;
    justify-content: center;
    font-size: 0.6875rem !important;
    padding: 0.375rem 0.625rem !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Test header mobile */
  .ai-test-header h3 {
    font-size: var(--text-sm) !important;
    flex: 1;
    min-width: 0;
  }

  /* Module row mobile */
  .ai-module-row {
    padding: 0.75rem 1rem !important;
    gap: 0.5rem !important;
  }
}

/* AI mobile subtitle hidden by default on desktop */
.ai-mob-subtitle {
  display: none;
}

/* ═══ Footer ═══ */

.app-footer {
  padding: var(--space-4) var(--space-6);
  text-align: center;
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  border-top: 1px solid var(--color-divider);
  background: var(--color-bg);
}

.app-footer a {
  color: var(--color-text-muted);
  text-decoration: none;
}

.app-footer a:hover {
  color: var(--color-primary);
}

/* ═══ Scrollbar ═══ */

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

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

::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-faint);
}

/* ═══ Project badge ═══ */

.project-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.6875rem;
  font-weight: 600;
  white-space: nowrap;
}

.project-badge.uk { background: var(--color-primary-light); color: var(--color-primary); }
.project-badge.brewsell { background: #fef3e2; color: #b45309; }
.project-badge.kuratorg { background: #ecfdf5; color: #15803d; }
.project-badge.mdm { background: #fef2f2; color: #b91c1c; }

[data-theme="dark"] .project-badge.brewsell { background: #332d14; color: #fbbf24; }
[data-theme="dark"] .project-badge.kuratorg { background: #14332a; color: #4ade80; }
[data-theme="dark"] .project-badge.mdm { background: #331414; color: #f87171; }


/* ── Collapsible nav groups ── */
.nav-group { position: relative; }
.nav-submenu {
  display: none;
  padding-left: 0;
}
.nav-group.expanded > .nav-submenu {
  display: block;
}
.nav-item .nav-chevron {
  margin-left: auto;
  flex-shrink: 0;
  transition: transform 0.2s ease;
  opacity: 0.5;
}
.nav-group.expanded > .nav-item > .nav-chevron {
  transform: rotate(180deg);
}
.nav-item.nav-sub {
  padding-left: 2.5rem;
  font-size: 0.8125rem;
}
.nav-item.nav-sub::before {
  content: '';
  position: absolute;
  left: 1.25rem;
  top: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--color-text-muted);
  opacity: 0.4;
}

/* ── Flowchart Modal ── */
.fc-overlay { position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.5);z-index:10000;display:flex;align-items:center;justify-content:center; }
.fc-modal { background:#fff;border-radius:12px;width:90%;max-width:700px;max-height:90vh;display:flex;flex-direction:column;box-shadow:0 20px 60px rgba(0,0,0,0.3); }
.fc-modal-header { display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid #eee; }
.fc-modal-body { overflow-y:auto;padding:20px; }
.fc-print-header { text-align:center;margin-bottom:20px;padding-bottom:12px;border-bottom:2px solid #D42020; }
.fc-chart { display:flex;flex-direction:column;align-items:center;gap:0; }
.fc-block { border:2px solid #ddd;border-radius:10px;padding:12px 20px;min-width:320px;max-width:500px;text-align:center;position:relative; }
.fc-start { background:#e8f5e9;border-color:#4caf50; }
.fc-end { background:#e8f5e9;border-color:#4caf50; }
.fc-equipment { background:#fff;border-color:#D42020;text-align:left; }
.fc-pause { background:#fff8e1;border:2px dashed #f0ad4e; }
.fc-block-title { font-weight:700;font-size:1rem; }
.fc-block-sub { font-size:0.85rem;color:#666;margin-top:2px; }
.fc-block-detail { font-size:0.8rem;color:#555;margin-top:3px; }
.fc-blocking { color:#D42020; }
.fc-nonblocking { color:#4caf50; }
.fc-warning { color:#e65100; }
.fc-step-num { position:absolute;left:-14px;top:50%;transform:translateY(-50%);width:28px;height:28px;border-radius:50%;background:#D42020;color:#fff;font-weight:700;font-size:0.8rem;display:flex;align-items:center;justify-content:center; }
.fc-arrow { text-align:center;color:#D42020;font-size:1.2rem;margin:2px 0; }
.fc-summary { margin-bottom:20px;padding:12px;background:#f8f9fa;border-radius:8px; }
.fc-summary-title { font-weight:700;font-size:0.9rem;color:#D42020;margin-bottom:8px; }
.fc-summary-grid { display:grid;grid-template-columns:repeat(3,1fr);gap:4px 16px; }
.fc-param { font-size:0.8rem; }
.fc-param-label { color:#666; }
