/* RASI Process Manager — Custom CSS */
/* Přepisuje a rozšiřuje Bootstrap 5 */

:root {
  --rasi-primary:    #1e3a5f;
  --rasi-secondary:  #2d5a9e;
  --rasi-accent:     #4a7fd4;
  --rasi-managing:   #1e3a5f;
  --rasi-core:       #2d5a9e;
  --rasi-supporting: #3b6cb5;
  --rasi-r:          #dc2626;
  --rasi-a:          #d97706;
  --rasi-s:          #2563eb;
  --rasi-i:          #6b7280;
  --rasi-gate:       #f59e0b;
  --rasi-bg:         #f8fafc;
  --sidebar-width:   260px;
}

/* ─── BODY & LAYOUT ─────────────────────────────────────── */
html {
  overflow-x: hidden;
  max-width: 100%;
}

body {
  background: var(--rasi-bg);
  font-size: 0.9rem;
  overflow-x: hidden;
  max-width: 100%;
}

.app-wrapper {
  display: flex;
  min-height: 100vh;
  max-width: 100%;
  overflow-x: hidden;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ─── SIDEBAR ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--rasi-primary);
  color: white;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* children handle their own scroll */
  transition: width 0.22s ease, transform 0.22s ease;
}

/* ── Collapsed state ── */
.sidebar.collapsed {
  width: 56px;
}
.sidebar.collapsed .brand-sub,
.sidebar.collapsed .sidebar-section,
.sidebar.collapsed .sidebar-link span,
.sidebar.collapsed .sidebar-footer .text-truncate,
.sidebar.collapsed .sidebar-footer .text-opacity-50,
.sidebar.collapsed .sidebar-footer a span {
  display: none;
}
.sidebar.collapsed .sidebar-brand {
  padding: 1.25rem 0;
  text-align: center;
}
.sidebar.collapsed .brand-title {
  font-size: 0.8rem;
  letter-spacing: 0;
}
.sidebar.collapsed .sidebar-link {
  justify-content: center;
  padding: 0.55rem 0;
  border-left: none;
  border-bottom: 2px solid transparent;
}
.sidebar.collapsed .sidebar-link:hover,
.sidebar.collapsed .sidebar-link.active {
  background: rgba(255,255,255,0.1);
  border-left-color: transparent;
  border-bottom-color: var(--rasi-accent);
}
.sidebar.collapsed .sidebar-link i { width: auto; font-size: 1.1rem; }
.sidebar.collapsed .sidebar-footer {
  padding: 0.75rem 0;
  text-align: center;
}
.sidebar.collapsed .sidebar-footer a { justify-content: center; padding: 0.4rem 0; }

/* Main content shift when collapsed */
.sidebar.collapsed ~ .main-content {
  margin-left: 56px;
}

/* Collapse toggle button */
.sidebar-collapse-btn {
  position: absolute;
  top: 12px;
  right: -12px;
  width: 24px;
  height: 24px;
  background: white;
  border: 1px solid var(--c-border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--rasi-primary);
  font-size: 0.7rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
  z-index: 10;
  transition: transform 0.22s;
}
.sidebar.collapsed .sidebar-collapse-btn { transform: rotate(180deg); }

/* Mobile close button inside sidebar */
.sidebar-mobile-close {
  display: none;
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 8px;
  color: #fff;
  font-size: 1rem;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: background .15s;
}
.sidebar-mobile-close:hover { background: rgba(255,255,255,.25); }
@media (max-width: 991px) {
  .sidebar.show .sidebar-mobile-close { display: flex; }
}

.sidebar-brand {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  text-decoration: none;
  color: white;
  display: block;
}

.sidebar-brand:hover { color: rgba(255,255,255,0.85); }

.sidebar-brand .brand-title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.sidebar-brand .brand-sub {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.6);
  margin-top: 2px;
}

.sidebar-nav {
  padding: 0.5rem 0;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch; /* iOS smooth scroll */
}

.sidebar-section {
  padding: 0.75rem 1rem 0.25rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.45);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 1rem;
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  font-size: 0.85rem;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}

.sidebar-link:hover,
.sidebar-link.active {
  color: white;
  background: rgba(255,255,255,0.1);
  border-left-color: var(--rasi-accent);
}

.sidebar-link i {
  width: 18px;
  text-align: center;
  font-size: 0.9rem;
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 0.75rem;
  color: rgba(255,255,255,0.5);
}

/* ─── TOPBAR ─────────────────────────────────────────────── */
.topbar {
  background: white;
  border-bottom: 1px solid #e2e8f0;
  padding: 0.5rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  position: sticky;
  top: 0;
  z-index: 1095;
}

.topbar-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--rasi-primary);
}

/* ─── PAGE CONTENT ───────────────────────────────────────── */
.page-body {
  padding: 1.75rem 1.5rem 1.5rem;
  flex: 1;
}

/* ─── TYPOGRAPHY ─────────────────────────────────────────── */
.process-code {
  font-family: 'Courier New', monospace;
  font-weight: 700;
  letter-spacing: 0.05em;
}

/* ─── RASI BADGES ────────────────────────────────────────── */
.badge-r { background-color: var(--rasi-r) !important; }
.badge-a { background-color: var(--rasi-a) !important; }
.badge-s { background-color: var(--rasi-s) !important; }
.badge-i { background-color: var(--rasi-i) !important; }

.rasi-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  color: white;
  cursor: pointer;
  transition: transform 0.1s;
  user-select: none;
}
.rasi-badge:hover { transform: scale(1.15); }
.rasi-badge.inactive { background-color: #e2e8f0 !important; color: #94a3b8; }

/* ─── PROCESS MAP LEVEL 1 ────────────────────────────────── */
.process-section-banner {
  background: var(--rasi-primary);
  color: white;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 8px 16px;
  font-size: 0.75rem;
}

.process-section-banner.managing   { background: var(--rasi-managing); }
.process-section-banner.core       { background: var(--rasi-core); }
.process-section-banner.supporting { background: var(--rasi-supporting); }

.process-card {
  background: var(--rasi-secondary);
  color: white;
  border: none;
  cursor: pointer;
  transition: transform 0.15s, background-color 0.15s;
  min-height: 90px;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.process-card:hover {
  background: var(--rasi-accent);
  color: white;
  transform: translateY(-2px);
}

.process-card .card-body {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0.75rem;
}

/* ─── VERTICAL TEXT (Level 1 sides) ─────────────────────── */
.vertical-text {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.8);
  white-space: nowrap;
}

/* ─── STEP HEADER TABLE ──────────────────────────────────── */
.step-header-table th,
.step-header-table td {
  font-size: 0.8rem;
  padding: 0.4rem 0.75rem;
  white-space: nowrap;
}

/* ─── RASI MATRIX TABLE ──────────────────────────────────── */
.rasi-table {
  font-size: 0.85rem;
}

.rasi-table th {
  background: var(--rasi-primary);
  color: white;
  text-align: center;
  font-weight: 600;
  font-size: 0.75rem;
  position: sticky;
  top: 0;
  z-index: 1;
}

.rasi-table td { text-align: center; vertical-align: middle; }
.rasi-table td:first-child { text-align: left; font-weight: 500; }

/* ─── STATS CARDS ────────────────────────────────────────── */
.stat-card {
  border: none;
  border-radius: 12px;
  transition: transform 0.15s;
}
.stat-card:hover { transform: translateY(-2px); }

.stat-card .stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  color: white;
}

/* ─── ALERTS & FLASH ─────────────────────────────────────── */
.flash-container {
  position: sticky;
  top: 56px;
  z-index: 99;
}

/* ─── BUG REPORT BUTTON ──────────────────────────────────── */
#bugReportBtn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-size: 1.2rem;
  line-height: 1;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* ─── BREADCRUMB ─────────────────────────────────────────── */
.breadcrumb {
  font-size: 0.8rem;
  margin-bottom: 0;
}

/* ─── TOAST ──────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 80px;
  right: 24px;
  z-index: 9998;
}

/* ═══════════════════════════════════════════════════════════
   RASI DOKUMENT — tabulka 1:1 dle vzorového dokumentu
   ═══════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════
   DESIGN TOKENS
   ═══════════════════════════════════════════════════════════ */
:root {
  --c-navy:    #0f172a;
  --c-navy2:   #1e3a5f;
  --c-blue:    #2563eb;
  --c-surf:    #f8fafc;
  --c-surf2:   #f1f5f9;
  --c-border:  #e2e8f0;
  --c-text:    #0f172a;
  --c-muted:   #64748b;
  --c-R:       #dc2626;
  --c-A:       #d97706;
  --c-S:       #2563eb;
  --c-I:       #64748b;
}

/* ═══════════════════════════════════════════════════════════
   SLIM ACTION BAR (replaces old page-header + identity card)
   ═══════════════════════════════════════════════════════════ */
.rd-slim-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0 12px;
  flex-wrap: wrap;
}
.rd-slim-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}
.rd-slim-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: 6px;
  color: var(--c-text);
  font-size: 0.74rem;
  font-weight: 500;
  text-decoration: none;
  transition: border-color .15s, background .15s;
  white-space: nowrap;
}
.rd-slim-back:hover { background: var(--c-surf); border-color: #94a3b8; color: var(--c-text); }
.rd-slim-sep { color: #cbd5e1; font-size: 0.9rem; }
.rd-slim-code {
  background: var(--c-navy);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 5px;
  letter-spacing: .05em;
  white-space: nowrap;
}
.rd-slim-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--c-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 400px;
}
.rd-slim-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.rd-slim-tag {
  font-size: 0.7rem;
  color: var(--c-muted);
  background: var(--c-surf2);
  border: 1px solid var(--c-border);
  border-radius: 4px;
  padding: 2px 7px;
  white-space: nowrap;
}
.rd-slim-print-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 13px;
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: 6px;
  font-size: 0.74rem;
  font-weight: 500;
  color: var(--c-text);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.rd-slim-print-btn:hover { background: var(--c-surf); border-color: #94a3b8; }

/* Print-only header — hidden on screen */
.rd-print-header { display: none; }

/* ═══════════════════════════════════════════════════════════
   RASI MATRIX CARD
   ═══════════════════════════════════════════════════════════ */
.rd-matrix-card {
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.05);
  overflow: clip; /* ořezává bez vytvoření scroll containeru → sticky funguje */
  margin-bottom: 16px;
}
.rd-matrix-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--c-border);
  background: var(--c-surf);
  flex-wrap: wrap;
  gap: 10px;
}
.rd-matrix-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--c-text);
  display: flex;
  align-items: center;
  gap: 7px;
}
.rd-matrix-title .bi { color: var(--c-muted); }
.rd-legend-inline { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rd-legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.68rem;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 20px;
  border: 1px solid;
  white-space: nowrap;
}
.rd-legend-chip strong { font-weight: 700; font-size: 0.75rem; }
.rd-legend-chip.rd-R { background: #fef2f2; border-color: #fca5a5; color: #991b1b; }
.rd-legend-chip.rd-A { background: #fffbeb; border-color: #fcd34d; color: #92400e; }
.rd-legend-chip.rd-S { background: #eff6ff; border-color: #93c5fd; color: #1e40af; }
.rd-legend-chip.rd-I { background: #f8fafc; border-color: #cbd5e1; color: #475569; }

/* ── Scroll wrapper ─ */
.rd-matrix-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  /* subtle hint that content scrolls */
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}
.rd-matrix-scroll::-webkit-scrollbar { height: 6px; }
.rd-matrix-scroll::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

/* ── Table ─ */
.rd-matrix-table {
  width: 100%;
  border-collapse: collapse;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  font-size: 0.78rem;
  table-layout: auto;
  min-width: 0;
}
.rd-matrix-table th,
.rd-matrix-table td { border: 1px solid var(--c-border); }

/* Activity header row */
.rd-th-pos {
  width: 140px;
  min-width: 120px;
  text-align: left;
  padding: 11px 12px;
  font-size: 0.67rem;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--c-muted);
  background: var(--c-surf);
  border-color: var(--c-border);
  /* Sticky first column */
  position: sticky;
  left: 0;
  z-index: 3;
}
.rd-th-act {
  text-align: left;
  vertical-align: top;
  padding: 10px 12px 8px;
  background: var(--c-navy);
  border-color: #1e3a6e !important;
  min-width: 150px;
  width: 150px;
  position: relative;
}
.rd-act-index {
  display: block;
  font-size: 0.56rem;
  font-weight: 600;
  color: rgba(255,255,255,.45);
  letter-spacing: .08em;
  margin-bottom: 4px;
}
.rd-act-name {
  display: block;
  writing-mode: horizontal-tb;
  transform: none;
  white-space: normal;
  word-break: break-word;
  font-size: 0.78rem;
  font-weight: 600;
  color: #fff;
  line-height: 1.3;
}

/* Position rows */
.rd-td-pos {
  padding: 0 12px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--c-text);
  background: var(--c-surf);
  border-right: 2px solid var(--c-border);
  height: 52px;
  vertical-align: middle;
  white-space: nowrap;
  /* Sticky first column */
  position: sticky;
  left: 0;
  z-index: 2;
  /* Shadow on right side to indicate scrollable content */
  box-shadow: 2px 0 4px rgba(0,0,0,.06);
}
.rd-row-alt .rd-td-pos { background: #eef2f8; }
.rd-row-alt .rd-td-cell { background: #f9fafc; }
/* Alt rows need explicit bg on sticky col to avoid transparency bleed */
.rd-row-alt .rd-td-pos { background: #eef2f8; }

/* RASI value cells */
.rd-td-cell {
  text-align: center;
  vertical-align: middle;
  height: 52px;
  width: 58px;
  min-width: 58px;
  background: #fff;
  transition: background .1s;
}

/* Row hover — highlight entire row clearly */
.rd-matrix-row { cursor: default; }
.rd-matrix-row:hover .rd-td-cell {
  background: #eef3ff;
}
.rd-matrix-row:hover .rd-td-pos {
  background: #dce6f5;
  color: var(--c-navy);
}

/* RASI letter badges */
.rd-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-weight: 800;
  font-size: 0.85rem;
  cursor: default;
  transition: transform .12s, box-shadow .12s;
}
.rd-letter:hover {
  transform: scale(1.15);
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.rd-R { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.rd-A { background: #fef3c7; color: #b45309; border: 1px solid #fcd34d; }
.rd-S { background: #dbeafe; color: #1d4ed8; border: 1px solid #93c5fd; }
.rd-I { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }

/* ═══════════════════════════════════════════════════════════
   ACTIVITY DETAIL CARDS (below RASI matrix)
   ═══════════════════════════════════════════════════════════ */
.rd-act-details-section {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.rd-act-detail-card {
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: 6px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rd-act-detail-hdr {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 8px;
}
.rd-act-idx-badge {
  width: 22px; height: 22px;
  background: var(--c-navy);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  font-weight: 700;
  flex-shrink: 0;
}
.rd-act-detail-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: #1e293b;
  flex: 1;
}
.rd-act-detail-desc-wrap {
  font-size: 0.75rem;
  color: #475569;
  min-height: 20px;
  flex: 1;
}
.rd-act-detail-docs { font-size: 0.73rem; }
.rd-act-detail-linked { font-size: 0.73rem; }

/* Section label above docs/linked in detail cards */
.rd-act-detail-sublabel {
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #94a3b8;
  margin-bottom: 4px;
}

/* ═══════════════════════════════════════════════════════════
   TRIGGER / INPUT / OUTPUT / KPI — 4-column row
   ═══════════════════════════════════════════════════════════ */
.rd-tio-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr minmax(80px, 0.5fr);
  gap: 16px;
  margin-bottom: 16px;
  align-items: stretch;
}
.rd-io-card {
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.rd-io-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--c-border);
  flex-shrink: 0;
}
.rd-io-trigger .rd-io-head { background: #fefce8; border-bottom-color: #fde68a; }
.rd-io-in      .rd-io-head { background: #eff6ff; }
.rd-io-out     .rd-io-head { background: #f0fdf4; }
.rd-io-icon { font-size: 0.95rem; }
.rd-io-trigger .rd-io-icon { color: #b45309; }
.rd-io-in      .rd-io-icon { color: var(--c-S); }
.rd-io-out     .rd-io-icon { color: #16a34a; }
.rd-io-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.rd-io-trigger .rd-io-label { color: #92400e; }
.rd-io-in      .rd-io-label { color: #1e40af; }
.rd-io-out     .rd-io-label { color: #15803d; }
.rd-io-kpi     .rd-io-head  { background: #fdf4ff; }
.rd-io-kpi     .rd-io-icon  { color: #9333ea; }
.rd-io-kpi     .rd-io-label { color: #7e22ce; }
.rd-kpi-input {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 0.8rem;
  color: #1e293b;
  outline: none;
  padding: 0;
}
.rd-kpi-input:focus { border-bottom: 1px solid #a78bfa; }
.rd-io-body {
  padding: 14px 16px;
  font-size: 0.8rem;
  line-height: 1.7;
  color: #1e293b;
  flex: 1;
}

/* ═══════════════════════════════════════════════════════════
   MATRIX SECTION ROWS — Description, Documents, Processes
   ═══════════════════════════════════════════════════════════ */

/* Separator line between RASI rows and section rows */
.rd-section-row:first-of-type td { border-top: 2px solid var(--c-border); }

.rd-section-label {
  padding: 10px 14px;
  font-size: 0.67rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--c-muted);
  background: var(--c-surf2);
  vertical-align: top;
  white-space: nowrap;
  border-right: 1px solid var(--c-border);
}
.rd-section-label .bi { margin-right: 4px; }

.rd-section-cell {
  padding: 10px 12px;
  font-size: 0.73rem;
  line-height: 1.55;
  color: #334155;
  vertical-align: top;
  border: 1px solid var(--c-border);
}

/* Description — subtle warm bg */
.rd-desc-cell { background: #fafafa; color: #475569; }

/* Documents cell */
.rd-docs-cell { background: #fff; }

/* Processes cell (spans all) */
.rd-procs-cell { background: #fafffe; }

/* Inline doc list inside table cell */
.rd-inline-doc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.rd-inline-doc-list li { line-height: 1.4; }
.rd-inline-doc-list a,
.rd-inline-doc-list span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--c-blue);
  text-decoration: none;
  font-size: 0.72rem;
}
.rd-inline-doc-list a:hover { text-decoration: underline; }
.rd-inline-doc-list span { color: var(--c-text); }

/* Inline processes list */
.rd-inline-proc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
}
.rd-inline-proc-list a,
.rd-inline-proc-list span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--c-blue);
  text-decoration: none;
  font-size: 0.72rem;
}
.rd-inline-proc-list a:hover { text-decoration: underline; }
.rd-inline-proc-list span { color: var(--c-text); }
.rd-inline-proc-list code,
.rd-inline-doc-list code {
  background: var(--c-surf2);
  border: 1px solid var(--c-border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.67rem;
  color: var(--c-navy);
}

/* Confidentiality — pouze při tisku */
.rd-legal-print { display: none; }

/* ═══════════════════════════════════════════════════════════
   PRINT — A4 landscape, vždy jedna stránka
   ═══════════════════════════════════════════════════════════ */
@media print {
  @page {
    size: A4 landscape;
    margin: 7mm 8mm;
  }

  /* Hide all non-content elements */
  .sidebar, .topbar, #bugReportBtn, .no-print,
  .breadcrumb-nav, .rd-slim-bar,
  .flash-container { display: none !important; }

  .main-content { margin-left: 0 !important; }
  .page-body    { padding: 0 !important; }
  body          { background: #fff !important; font-size: 8pt; }

  /* Show print-only header */
  .rd-print-header {
    display: flex !important;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 0 0 4pt;
    border-bottom: 1.5pt solid #0f172a;
    margin-bottom: 5pt;
  }
  .rd-print-title {
    font-size: 9pt;
    font-weight: 700;
    color: #0f172a;
  }
  .rd-print-kpi { font-weight: 400; color: #475569; }
  .rd-print-meta {
    font-size: 7pt;
    color: #64748b;
    white-space: nowrap;
  }

  /* Fit all RASI content on one page — scale down */
  .rd-rasi-content {
    display: block;
    width: 100%;
  }

  /* Cards: flat, no shadow, no radius */
  .rd-matrix-card, .rd-io-card {
    box-shadow: none !important;
    border-radius: 0 !important;
    border: 1pt solid #e2e8f0 !important;
    margin-bottom: 4pt !important;
    overflow: visible !important;
  }

  /* Matrix header compact */
  .rd-matrix-header {
    padding: 4pt 6pt !important;
    background: #f8fafc !important;
  }
  .rd-matrix-title { font-size: 7pt !important; }
  .rd-legend-chip  { font-size: 6pt !important; padding: 1pt 4pt !important; }

  /* Scrollable wrapper must not scroll in print */
  .rd-matrix-scroll { overflow: visible !important; }

  /* Table: small, dense, auto layout in print */
  .rd-matrix-table {
    font-size: 6.5pt !important;
    min-width: unset !important;
    width: 100% !important;
    table-layout: auto !important;
  }

  /* Activity headers */
  .rd-th-act {
    padding: 3pt 1pt !important;
    width: 44pt !important; min-width: 44pt !important;
    height: 80pt !important;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
  .rd-act-index { font-size: 4pt !important; margin-bottom: 1pt !important; }
  .rd-act-name  { font-size: 5pt !important; max-height: 70pt !important; }

  /* Position column */
  .rd-th-pos  { padding: 4pt 6pt !important; font-size: 6pt !important; width: 80pt !important; }
  .rd-td-pos  { padding: 2pt 6pt !important; font-size: 7pt !important; height: auto !important; }
  .rd-td-cell { height: auto !important; padding: 3pt !important; }

  /* RASI letter badges */
  .rd-letter {
    width: 14pt !important; height: 14pt !important;
    font-size: 6pt !important; border-radius: 2pt !important;
    print-color-adjust: exact; -webkit-print-color-adjust: exact;
  }

  /* Section rows */
  .rd-section-label {
    padding: 3pt 5pt !important; font-size: 5.5pt !important;
    print-color-adjust: exact; -webkit-print-color-adjust: exact;
  }
  .rd-section-cell { padding: 3pt 5pt !important; font-size: 6pt !important; }

  /* TIO row: 3 columns, compact */
  .rd-tio-row {
    grid-template-columns: 1fr 1fr 1fr !important;
    gap: 4pt !important;
    margin-bottom: 0 !important;
  }
  .rd-io-head { padding: 3pt 6pt !important; }
  .rd-io-label { font-size: 6pt !important; }
  .rd-io-icon  { font-size: 7pt !important; }
  .rd-io-body  { padding: 4pt 6pt !important; font-size: 6.5pt !important; line-height: 1.4 !important; }
  .rd-io-in .rd-io-head, .rd-io-out .rd-io-head, .rd-io-trigger .rd-io-head {
    print-color-adjust: exact; -webkit-print-color-adjust: exact;
  }

  /* Legal notice in print */
  .rd-legal-print {
    display: block !important;
    margin-top: 4pt;
    font-size: 5.5pt;
    color: #94a3b8;
    font-style: italic;
    border-top: 0.5pt solid #e2e8f0;
    padding-top: 3pt;
  }
}

/* ─── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 991px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s;
    width: var(--sidebar-width) !important;
  }
  .sidebar.show { transform: translateX(0) !important; }
  .sidebar.collapsed { transform: translateX(-100%); }
  .main-content { margin-left: 0 !important; }
  .sidebar-collapse-btn { display: none; }
  /* Na mobilu/tabletu: logo je v topbaru, v sidebaru ho skryjeme */
  .sidebar-brand { display: none; }
  /* Uvolní místo pro zavírací tlačítko (absolute top:10px, výška 32px) */
  .sidebar-nav { padding-top: 64px; }
  .rd-tio-row { grid-template-columns: 1fr; }
  /* Process map: reduce padding so map fills the viewport */
  .page-body { padding: 0.75rem; }
  .iatf-process-map { width: 100%; box-sizing: border-box; }
  /* Prevent iOS auto-zoom on contenteditable elements */
  [contenteditable="true"] { font-size: max(16px, 1em) !important; }
}

/* ── RASI matrix responsive ────────────────────────────── */
@media (max-width: 767px) {
  /* Slim bar: stack on small screens */
  .rd-slim-bar { flex-direction: column; align-items: flex-start; gap: 8px; }
  .rd-slim-meta { flex-wrap: wrap; gap: 6px; }

  /* Meta panel: stack fields vertically */
  .rd-meta-fields { flex-direction: column; gap: 6px; }
  .rd-meta-fields label { width: 100%; }
  .rd-meta-input { width: 100% !important; }

  /* Matrix: smaller font + narrower position column */
  .rd-matrix-table { font-size: 0.72rem; min-width: 0; }
  .rd-th-pos { width: 110px; min-width: 100px; padding: 8px 8px; font-size: 0.62rem; }
  .rd-td-pos { padding: 0 8px; font-size: 0.72rem; height: 44px; }
  .rd-td-cell { height: 44px; min-width: 100px; }
  .rd-th-act { padding: 8px 10px 6px; min-width: 100px; width: 100px; }
  .rd-act-name { font-size: 0.7rem; }
  .rd-act-index { font-size: 0.5rem; }

  /* Slim tag: tighter */
  .rd-slim-tag { font-size: 0.68rem; padding: 2px 6px; }

  /* Matrix header: stack title and legend */
  .rd-matrix-header { flex-direction: column; align-items: flex-start; padding: 10px 14px; }
  .rd-matrix-header-right { flex-wrap: wrap; gap: 6px; }
  .rd-legend-inline { flex-wrap: wrap; gap: 4px; }
  .rd-legend-chip { font-size: 0.62rem; padding: 2px 6px; }

  /* On mobile: hide table + desktop detail cards, show accordion */
  .rd-matrix-card { display: none !important; }
  #rd-activity-details { display: none !important; }
  .rd-mob-accordion { display: block !important; }
}

/* Hide the old separate activity-detail cards — now inline in the table */
#rd-activity-details { display: none !important; }

/* ── Inline detail rows (Popis / Dokumenty / Procesy) ────── */
.rd-detail-sep-row td {
  height: 6px;
  background: #f0f4f8;
  border: none;
  padding: 0;
}
.rd-detail-label {
  background: #f1f5f9;
  padding: 8px 12px;
  font-size: 0.68rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
  vertical-align: top;
  position: sticky;
  left: 0;
  z-index: 2;
  box-shadow: 2px 0 4px rgba(0,0,0,.05);
}
.rd-detail-cell {
  vertical-align: top;
  padding: 8px 12px;
  font-size: 0.8rem;
  color: #374151;
  background: #fafbfc;
  min-width: 0;
}
.rd-detail-cell-end { background: #fafbfc; padding: 0; min-width: 32px; }
.rd-detail-row:hover .rd-detail-cell { background: #f5f7fa; }

/* Hide empty-value role rows in view mode; show them in edit mode */
.rd-mob-rasi-row:not(.rd-mob-has-value) { display: none; }
.rasi-edit-mode .rd-mob-rasi-row:not(.rd-mob-has-value) { display: flex; }

/* ── Mobile accordion styles (always defined, shown via media query) ── */
.rd-mob-accordion {
  display: none;
  margin-bottom: 1rem;
}
.rd-mob-act-card {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  margin-bottom: 8px;
  overflow: hidden;
  background: #fff;
}
/* Edit-mode header row: collapse button + delete button side by side */
.rd-mob-act-hdr-row {
  display: flex;
  align-items: stretch;
  background: #f8fafc;
}
.rd-mob-act-hdr {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  padding: 10px 12px;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  font-size: .85rem;
  font-weight: 600;
  color: #1e293b;
}
.rd-mob-act-hdr:not(.collapsed) { background: #eff6ff; }
.rd-mob-act-del {
  background: transparent;
  border: none;
  border-left: 1px solid #e2e8f0;
  padding: 0 12px;
  color: #94a3b8;
  cursor: pointer;
  font-size: .85rem;
  flex-shrink: 0;
}
.rd-mob-act-del:hover { background: #fee2e2; color: #dc2626; }
.rd-mob-act-title { flex: 1; line-height: 1.3; }
.rd-mob-chevron { transition: transform .2s; font-size: .7rem; color: #64748b; }
.rd-mob-act-hdr:not(.collapsed) .rd-mob-chevron { transform: rotate(180deg); }
.rd-mob-act-body { padding: 0 12px 12px; }
.rd-mob-rasi-list { margin: 8px 0; }
.rd-mob-rasi-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: .82rem;
}
.rd-mob-rasi-row:last-child { border-bottom: none; }
.rd-mob-role-name { color: #475569; flex: 1; }
/* In edit mode, role name is clickable to replace */
.rasi-edit-mode .rd-mob-role-name { cursor: pointer; }
.rasi-edit-mode .rd-mob-role-name:hover { color: var(--rasi-secondary); text-decoration: underline; }
.rd-mob-role-del {
  background: transparent;
  border: none;
  padding: 2px 4px;
  color: #94a3b8;
  cursor: pointer;
  font-size: .75rem;
  flex-shrink: 0;
  align-items: center;
}
.rd-mob-role-del:hover { color: #dc2626; }
.rd-mob-rasi-val { display: flex; align-items: center; min-width: 28px; justify-content: flex-end; }
.rd-mob-rasi-row[data-cell] { cursor: pointer; }
.rd-mob-rasi-row[data-cell]:hover { background: #f8fafc; border-radius: 4px; }
/* Add-controls strip below accordion */
.rd-mob-add-controls {
  display: flex;
  gap: 8px;
  padding: 6px 0;
  flex-wrap: wrap;
}
.rd-mob-add-btn {
  background: #f1f5f9;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  padding: 7px 14px;
  font-size: .82rem;
  color: #475569;
  cursor: pointer;
  flex: 1;
  min-width: 140px;
}
.rd-mob-add-btn:hover { background: #e0f2fe; border-color: var(--rasi-secondary); color: var(--rasi-secondary); }
/* Inline input card for mobile add-activity */
.rd-mob-act-input-card {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  background: #fff;
  border: 2px dashed var(--rasi-secondary);
  border-radius: 8px;
  margin-bottom: 8px;
}
.rd-mob-act-input-card .rd-inline-input { flex: 1; }
.rd-mob-section {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #f1f5f9;
  font-size: .82rem;
  color: #374151;
}
.rd-mob-section-label {
  font-size: .72rem;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 4px;
}

/* ─── RASI EDIT MODE ─────────────────────────────────────── */
/* Controls hidden by default, revealed when body.rasi-edit-mode */
.rd-edit-only { display: none !important; }
.rasi-edit-mode .rd-edit-only { display: inline-flex !important; }
.rasi-edit-mode .rd-edit-only.d-flex { display: flex !important; }

/* Editable cells */
.rasi-edit-mode [data-cell] {
  cursor: pointer;
  transition: background 0.15s;
}
.rasi-edit-mode [data-cell]:hover { background: #e0eaff !important; }
.rd-cell-saving { opacity: .45; pointer-events: none; }

/* Empty cell placeholder */
.rd-cell-empty {
  color: #cbd5e1;
  font-size: 1rem;
  line-height: 1;
  user-select: none;
}
.rasi-edit-mode .rd-cell-empty { color: #94a3b8; }

/* Activity header edit controls — top-right corner of header cell */
.rd-act-hdr-btns {
  display: none;
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0,0,0,.22);
  border-radius: 4px;
  overflow: hidden;
  z-index: 6;
  white-space: nowrap;
}
.rasi-edit-mode .rd-th-act:hover .rd-act-hdr-btns { display: flex; }
.rd-act-hdr-btn {
  border: none;
  background: transparent;
  color: rgba(255,255,255,.8);
  font-size: .6rem;
  padding: 3px 6px;
  cursor: pointer;
  line-height: 1;
  display: flex;
  align-items: center;
}
.rd-act-hdr-btn:hover { background: rgba(255,255,255,.2); color: #fff; }
.rd-act-hdr-del:hover { background: rgba(220,38,38,.35) !important; color: #fca5a5 !important; }
.rd-act-hdr-btn + .rd-act-hdr-btn { border-left: 1px solid rgba(255,255,255,.2); }

/* Position remove button */
.rd-pos-remove {
  border: none;
  background: transparent;
  color: #f87171;
  padding: 0 3px;
  font-size: .7rem;
  cursor: pointer;
  border-radius: 3px;
  line-height: 1;
  flex-shrink: 0;
}
.rd-pos-remove:hover { background: #fee2e2; color: #dc2626; }

/* Add row for position */
.rd-add-pos-row td {
  border-top: 2px dashed #e2e8f0 !important;
}
#rd-add-position-btn {
  font-size: .72rem;
  padding: 2px 8px;
}

/* Document add / delete controls */
.rd-doc-add {
  font-size: .65rem;
  padding: 1px 6px;
  border-radius: 3px;
  color: #2563eb;
  border: 1px dashed #93c5fd;
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
}
.rd-doc-add:hover { background: #eff6ff; }
.rd-doc-del {
  font-size: .6rem;
  padding: 1px 4px;
  border: none;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  border-radius: 3px;
}
.rd-doc-del:hover { background: #fee2e2; color: #dc2626; }

/* Download icon link (separate from editable name) */
.rd-doc-dl-icon {
  color: inherit;
  text-decoration: none;
  margin-right: 4px;
  opacity: 0.65;
}
.rd-doc-dl-icon:hover { opacity: 1; color: var(--rasi-secondary); }

/* Edit mode: both icon and name wrapped in link */
.rd-doc-dl-link {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  opacity: 0.85;
}
.rd-doc-dl-link:hover { opacity: 1; color: var(--rasi-secondary); text-decoration: underline; }
.rd-doc-dl-link .bi { opacity: 0.75; flex-shrink: 0; }

/* Expand button for truncated text */
.rd-expand-btn {
  background: none;
  border: none;
  padding: 0 2px;
  margin-left: 1px;
  font-size: 1em;
  color: var(--rasi-secondary);
  cursor: pointer;
  line-height: 1;
  vertical-align: baseline;
  font-weight: 600;
  letter-spacing: -1px;
}
.rd-expand-btn:hover { color: var(--rasi-primary); text-decoration: underline; }

/* TIO / Meta edit icon buttons */
.rd-tio-edit-btn, .rd-meta-edit-btn {
  font-size: .7rem;
  padding: 1px 5px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  color: #94a3b8;
  transition: color .15s, border-color .15s;
}
.rd-tio-edit-btn:hover, .rd-meta-edit-btn:hover {
  color: #2563eb;
  border-color: #93c5fd;
}

/* Edit mode visual indicator on matrix card */
.rasi-edit-mode .rd-matrix-card {
  outline: 2px solid #3b82f6;
  outline-offset: 1px;
}

/* Slim bar edit / done buttons */
.rd-slim-edit-btn {
  font-size: .72rem;
  padding: 3px 10px;
  border-radius: 6px;
  background: #f0f9ff;
  border: 1px solid #7dd3fc;
  color: #0369a1;
  cursor: pointer;
  font-weight: 500;
  transition: background .15s;
}
.rd-slim-edit-btn:hover { background: #e0f2fe; }
.rd-slim-done-btn {
  font-size: .72rem;
  padding: 3px 10px;
  border-radius: 6px;
  background: #dcfce7;
  border: 1px solid #86efac;
  color: #16a34a;
  cursor: pointer;
  font-weight: 500;
  transition: background .15s;
}
.rd-slim-done-btn:hover { background: #bbf7d0; }

/* Linked-process delete control */
.rd-lp-del {
  font-size: .65rem;
  padding: 1px 5px;
  border: none;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  border-radius: 3px;
}
.rd-lp-del:hover { background: #fee2e2; color: #dc2626; }

/* ─── INLINE EDITING UI ──────────────────────────────────── */

/* Editable hint — subtle underline dashes in edit mode */
.rasi-edit-mode [data-editable] {
  display: block;
  min-height: 1.5em;
  cursor: text;
  border-radius: 3px;
  transition: background .15s;
  user-select: text;
}
.rasi-edit-mode [data-editable]:hover {
  background: rgba(59,130,246,.08) !important;
  box-shadow: 0 1px 0 0 #93c5fd;
}
/* Pending unsaved change indicator */
.rd-pending {
  background: rgba(234,179,8,.12) !important;
  border-left: 2px solid #f59e0b !important;
  border-radius: 2px;
  padding-left: 4px !important;
}
.rd-pending:hover {
  background: rgba(234,179,8,.2) !important;
}

/* Click-to-edit: wrap + input/textarea injected by JS */
.rd-field-wrap {
  display: block;
  width: 100%;
}
.rd-field-input {
  display: block;
  width: 100%;
  padding: 3px 6px;
  border: 2px solid #3b82f6;
  border-radius: 4px;
  background: #fff;
  color: #1e293b;
  font: inherit;
  font-size: inherit;
  line-height: inherit;
  resize: vertical;
  outline: none;
  box-shadow: 0 0 0 3px rgba(59,130,246,.2);
}
.rd-field-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,.25);
}

/* Inline form / input base */
.rd-inline-input {
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  padding: 3px 7px;
  font-size: .78rem;
  outline: none;
  background: #fff;
  color: #1e293b;
  transition: border-color .15s;
}
.rd-inline-input:focus { border-color: #3b82f6; box-shadow: 0 0 0 2px #bfdbfe; }
.rd-inline-input.w-100 { width: 100%; box-sizing: border-box; }

.rd-inline-form {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
  padding: 4px 2px;
}

/* Inline save / cancel buttons */
.rd-inline-save {
  border: 1px solid #86efac;
  background: #dcfce7;
  color: #16a34a;
  border-radius: 4px;
  padding: 2px 7px;
  font-size: .8rem;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.4;
  flex-shrink: 0;
}
.rd-inline-save:hover { background: #bbf7d0; }
.rd-inline-cancel {
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #64748b;
  border-radius: 4px;
  padding: 2px 7px;
  font-size: .8rem;
  cursor: pointer;
  line-height: 1.4;
  flex-shrink: 0;
}
.rd-inline-cancel:hover { background: #fee2e2; color: #dc2626; border-color: #fca5a5; }

/* Inline add-activity th */
.rd-inline-act-input-th {
  min-width: 160px;
  vertical-align: middle !important;
  background: #f0f9ff !important;
  border: 2px dashed #7dd3fc !important;
}

/* Meta panel (below slim bar, edit mode only) */
.rd-meta-panel {
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  padding: 6px 16px;
  animation: slideDown .15s ease;
}
.rd-meta-panel-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.rd-meta-panel-label {
  font-size: .72rem;
  font-weight: 600;
  color: #64748b;
  white-space: nowrap;
}
.rd-meta-fields {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
}
.rd-meta-fields label {
  display: flex;
  flex-direction: column;
  font-size: .65rem;
  color: #94a3b8;
  gap: 1px;
}
.rd-meta-input {
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: .78rem;
  outline: none;
  background: #fff;
}
.rd-meta-input:focus { border-color: #3b82f6; }
@keyframes slideDown {
  from { transform: translateY(-6px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* Position picker inline panel */
.rd-pos-picker {
  position: fixed;
  z-index: 9999;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,.12);
  padding: 8px;
  min-width: 260px;
  margin-top: 4px;
}
.rd-pos-picker-list {
  margin-top: 6px;
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rd-pos-pick-item {
  display: flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  padding: 5px 8px;
  border-radius: 5px;
  font-size: .78rem;
  cursor: pointer;
  text-align: left;
  color: #1e293b;
}
.rd-pos-pick-item:hover { background: #eff6ff; }
.rd-pos-pick-item code { font-size: .65rem; background: #f1f5f9; padding: 1px 4px; border-radius: 3px; }
.rd-pos-pick-item small { margin-left: auto; color: #94a3b8; font-size: .65rem; }
.rd-pos-pick-create { color: #2563eb !important; border-top: 1px solid #e2e8f0 !important; margin-top: 2px !important; }
.rd-pos-pick-create:hover { background: #eff6ff !important; }

/* Add-position row (relative for picker) */
.rd-add-pos-row td { position: relative; }

/* Drag handle */
.rd-drag-handle {
  display: none;
  cursor: grab;
  color: #94a3b8;
  font-size: .9rem;
  padding: 0 4px 0 0;
  flex-shrink: 0;
}
.rasi-edit-mode .rd-td-pos:hover .rd-drag-handle { display: inline-flex; align-items: center; }
.rd-drag-handle:active { cursor: grabbing; }
.rd-row-dragging { opacity: 0.4; }
.rd-row-drag-over td { box-shadow: inset 0 -2px 0 #3b82f6; }
/* Always show drag handle on touch devices; fix insert spacer height */
@media (hover: none) {
  .rasi-edit-mode .rd-td-pos .rd-drag-handle { display: inline-flex; align-items: center; }

  /* Give the spacer row real height so the '+' sits in the gap, not behind a row */
  .rasi-edit-mode .rd-row-insert-spacer { height: 20px; }
  .rasi-edit-mode .rd-row-insert-spacer td {
    padding: 3px 4px !important;
    border: none !important;
    position: relative;
    z-index: 4; /* paint above sticky position column */
  }
  .rasi-edit-mode .rd-row-insert-spacer .rd-row-insert-btn {
    display: flex;
    height: 14px;
    border-radius: 7px;
  }
}

/* Insert-between row spacer */
.rd-row-insert-spacer { height: 0; }
.rd-row-insert-spacer td { padding: 0 !important; border: none !important; }
.rd-row-insert-btn {
  display: none;
  width: 100%;
  height: 14px;
  border: none;
  background: #dbeafe;
  color: #3b82f6;
  font-size: .65rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.rasi-edit-mode .rd-row-insert-spacer:hover .rd-row-insert-btn { display: flex; }
/* Always show insert button on touch devices */
@media (hover: none) {
  .rasi-edit-mode .rd-row-insert-spacer .rd-row-insert-btn { display: flex; }
}

/* Inline doc-add form */
.rd-doc-add-form {
  padding: 5px 0 3px;
  border-top: 1px dashed #e2e8f0;
  margin-top: 4px;
}

/* Mini upload button inside doc-add form */
.rd-upload-mini-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: .75rem;
  cursor: pointer;
  color: #475569;
  white-space: nowrap;
  flex-shrink: 0;
}
.rd-upload-mini-btn:hover { background: #eff6ff; border-color: #93c5fd; color: #2563eb; }
.rd-hidden-file { position: absolute; opacity: 0; width: 0; height: 0; }

/* File picker button in doc add form */
.rd-file-pick-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  border-radius: 4px;
  padding: 3px 10px;
  font-size: .78rem;
  cursor: pointer;
  color: #475569;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.rd-file-pick-btn:hover { background: #eff6ff; border-color: #93c5fd; color: #2563eb; }
.rd-file-pick-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* Linked process add form */
.rd-lp-add-form {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed #e2e8f0;
}

/* Step search suggestions dropdown */
.rd-step-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,.1);
  z-index: 300;
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.rd-step-suggest-item {
  display: flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  padding: 6px 10px;
  font-size: .78rem;
  cursor: pointer;
  text-align: left;
  color: #1e293b;
  border-bottom: 1px solid #f1f5f9;
}
.rd-step-suggest-item:last-child { border-bottom: none; }
.rd-step-suggest-item:hover { background: #eff6ff; }
.rd-step-suggest-item code { font-size: .65rem; background: #f1f5f9; padding: 1px 4px; border-radius: 3px; flex-shrink: 0; }

/* Drag-drop upload zone */
.rd-upload-zone {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 18px 16px;
  border: 2px dashed #cbd5e1;
  border-radius: 0 0 8px 8px;
  background: #f8fafc;
  color: #64748b;
  font-size: .82rem;
  cursor: default;
  transition: background .15s, border-color .15s;
  text-align: center;
}
.rasi-edit-mode .rd-upload-zone { display: flex; }
.rd-upload-zone.rd-drop-active {
  background: #eff6ff;
  border-color: #3b82f6;
  color: #1d4ed8;
}
.rd-upload-pick {
  border: none;
  background: none;
  color: #2563eb;
  cursor: pointer;
  padding: 0;
  font-size: inherit;
  text-decoration: underline;
}
.rd-upload-pick:hover { color: #1d4ed8; }


/* ═══════════════════════════════════════════════════════════
   IATF 16949 PROCESS MAP — index.php
   ═══════════════════════════════════════════════════════════ */

/* Override old dark process-card style — now handled per band */
.iatf-process-map .process-section-banner { display: none; }

/* ── Overall container — CSS Grid so customer boxes span all rows ── */
.iatf-process-map {
  display: grid;
  grid-template-columns: var(--pm-req-w, 110px) 1fr var(--pm-sat-w, 110px);
  grid-template-rows: 1fr;
  border: 2px solid #cbd5e1;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 2px 12px rgba(0,0,0,.07);
}

/* Center column: three bands stacked vertically */
.iatf-bands-column {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ── Row wrappers (inside bands column) ─────────────────── */
.iatf-top-row,
.iatf-middle-row,
.iatf-bottom-row {
  display: flex;
  align-items: stretch;
  min-height: 100px;
}
.iatf-middle-row { flex: 1; }

.iatf-top-row    { border-bottom: 2px solid #cbd5e1; }
.iatf-bottom-row { border-top:    2px solid #cbd5e1; }

/* ── Customer boxes (left/right) — fill full grid height ── */
.iatf-customer-box {
  display: flex;
  align-items: center;
  min-width: 80px;
  max-width: 300px;
  flex-shrink: 0;
  background: #1e3a5f;
  color: white;
  position: relative;
}

.iatf-customer-req {
  border-right: 2px solid #cbd5e1;
  justify-content: center;
}

.iatf-customer-sat {
  border-left: 2px solid #cbd5e1;
  justify-content: center;
}

.iatf-customer-label {
  text-align: center;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.3;
  padding: 12px 8px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Arrow shapes */
.iatf-arrow-right,
.iatf-arrow-left {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  z-index: 2;
}

.iatf-arrow-right {
  right: -14px;
  border-top: 14px solid transparent;
  border-bottom: 14px solid transparent;
  border-left: 14px solid #1e3a5f;
}

.iatf-arrow-left {
  left: -14px;
  border-top: 14px solid transparent;
  border-bottom: 14px solid transparent;
  border-right: 14px solid #1e3a5f;
}

.iatf-customer-spacer {
  width: 100px;
  flex-shrink: 0;
}

/* ── Band (managing / core / supporting) ───────────────── */
.iatf-band {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.iatf-band-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.2);
  flex-shrink: 0;
}

.iatf-band-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: white;
}

.iatf-band-subtitle {
  font-size: 0.65rem;
  color: rgba(255,255,255,0.6);
  font-style: italic;
}

.iatf-band-managing  { background: #1e3a5f; }
.iatf-band-core      { background: #2d5a9e; }
.iatf-band-supporting { background: #3b6cb5; }

.iatf-band-content {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  flex: 1;
}

/* ── Process chips (MANAGING / SUPPORTING) ─────────────── */
.iatf-process-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  position: relative;
}

.iatf-chip-link {
  display: inline-flex;
  flex-direction: column;
  padding: 5px 10px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 6px;
  text-decoration: none;
  color: white;
  font-size: 0.78rem;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.iatf-chip-link:hover {
  background: rgba(255,255,255,0.22);
  border-color: rgba(255,255,255,0.5);
  color: white;
}

.iatf-chip-code {
  font-family: 'Courier New', monospace;
  font-size: 0.66rem;
  color: rgba(255,255,255,0.55);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.iatf-chip-name {
  font-size: 0.78rem;
}

.iatf-chip-edit {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 4px;
  color: white;
  font-size: 0.7rem;
  padding: 2px 5px;
  cursor: pointer;
  transition: background 0.15s;
  line-height: 1;
  flex-shrink: 0;
}

.iatf-chip-edit:hover { background: rgba(255,255,255,0.3); }

.iatf-chip-del {
  background: rgba(239,68,68,0.25);
  border: 1px solid rgba(239,68,68,0.5);
  border-radius: 4px;
  color: white;
  font-size: 0.7rem;
  padding: 2px 5px;
  cursor: pointer;
  transition: background 0.15s;
  line-height: 1;
  flex-shrink: 0;
}
.iatf-chip-del:hover { background: rgba(239,68,68,0.55); }

/* ── Customer box: vertical layout + items ─────────────── */
.iatf-customer-box {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  max-width: none; /* width set via inline style */
}
.iatf-customer-req,
.iatf-customer-sat { justify-content: flex-start; }

.iatf-cust-items {
  list-style: none;
  margin: 0;
  padding: 0 6px 6px;
  flex: 1;
  overflow-y: auto;
}
.iatf-cust-item {
  display: flex;
  align-items: flex-start;
  gap: 3px;
  font-size: 0.65rem;
  line-height: 1.3;
  padding: 2px 0 2px 5px;
  border-left: 2px solid rgba(255,255,255,0.35);
  margin-bottom: 4px;
}
.iatf-cust-item-text {
  flex: 1;
  word-break: break-word;
}
.iatf-cust-item-text[contenteditable="true"] {
  outline: none;
  background: rgba(255,255,255,0.12);
  border-radius: 2px;
  padding: 1px 3px;
  min-width: 20px;
  cursor: text;
}
.iatf-cust-del-item {
  background: rgba(239,68,68,0.4);
  border: none;
  border-radius: 2px;
  color: white;
  font-size: 0.55rem;
  padding: 1px 4px;
  cursor: pointer;
  flex-shrink: 0;
  line-height: 1.4;
  margin-top: 1px;
}
.iatf-cust-del-item:hover { background: rgba(239,68,68,0.7); }
.iatf-cust-add-item {
  background: rgba(255,255,255,0.1);
  border: 1px dashed rgba(255,255,255,0.4);
  color: rgba(255,255,255,0.85);
  font-size: 0.63rem;
  padding: 2px 6px;
  cursor: pointer;
  margin: 0 6px 6px;
  border-radius: 3px;
  text-align: center;
  width: calc(100% - 12px);
  flex-shrink: 0;
  display: block;
}
.iatf-cust-add-item:hover { background: rgba(255,255,255,0.2); }
.iatf-cust-resize {
  position: absolute;
  top: 0; bottom: 0;
  width: 8px;
  cursor: ew-resize;
  background: rgba(255,255,255,0.15);
  z-index: 5;
  transition: background 0.15s;
  display: block;
}
.iatf-cust-resize-right { right: 0; }
.iatf-cust-resize-left  { left: 0; }
.iatf-cust-resize:hover { background: rgba(255,255,255,0.38); }
.iatf-cust-label-text[contenteditable="true"] {
  outline: none;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  padding: 1px 4px;
  cursor: text;
  display: inline-block;
  min-width: 30px;
}

/* ── Inline edit for box names ──────────────────────────── */
.pm-inline-edit { outline: none; border-bottom: 1px dashed rgba(255,255,255,0.6); cursor: text; min-width: 40px; }
.pm-inline-edit:focus { background: rgba(0,0,0,0.15); border-radius: 3px; padding: 0 2px; }
.pm-inline-edit-changed { border-bottom: 2px solid #ffc107 !important; }

/* ── Add button ────────────────────────────────────────── */
.iatf-add-btn {
  margin-left: auto;
  background: rgba(255,255,255,0.15);
  border: 1px dashed rgba(255,255,255,0.45);
  border-radius: 5px;
  color: white;
  font-size: 0.75rem;
  padding: 3px 8px;
  cursor: pointer;
  transition: background 0.15s;
}
.iatf-add-btn:hover { background: rgba(255,255,255,0.28); }

/* ── Core process cards (horizontal flow) ──────────────── */
.iatf-core-flow {
  flex-wrap: nowrap;
  overflow-x: auto;
  align-items: center;
}

.iatf-core-item {
  display: flex;
  align-items: center;
  gap: 0;
  flex-shrink: 0;
  position: relative;
}

.iatf-core-card {
  display: flex;
  flex-direction: column;
  padding: 10px 14px;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 8px;
  min-width: 130px;
  max-width: 170px;
  transition: background 0.15s;
}

.iatf-core-card:hover {
  background: rgba(255,255,255,0.26);
  color: white;
}

.iatf-core-code {
  font-family: 'Courier New', monospace;
  font-size: 0.65rem;
  color: rgba(255,255,255,0.5);
  font-weight: 700;
  margin-bottom: 2px;
}

.iatf-core-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: white;
  line-height: 1.3;
}

.iatf-core-subs {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 5px;
  padding-top: 5px;
  border-top: 1px solid rgba(255,255,255,0.2);
}

.iatf-core-sub-link {
  font-size: 0.65rem;
  padding: 1px 5px;
  background: rgba(255,255,255,0.15);
  border-radius: 3px;
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  font-family: 'Courier New', monospace;
  font-weight: 700;
}
.iatf-core-sub-link:hover { background: rgba(255,255,255,0.3); color: white; }

.iatf-core-sub-more {
  font-size: 0.65rem;
  color: rgba(255,255,255,0.5);
  align-self: center;
}

/* ── Flow arrow between core items ─────────────────────── */
.iatf-flow-arrow {
  color: rgba(255,255,255,0.7);
  font-size: 1.1rem;
  padding: 0 6px;
  flex-shrink: 0;
}

/* ── Side arrows (middle row visual) ───────────────────── */
.iatf-side-arrow {
  width: 100px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
  border-right: 2px solid #cbd5e1;
}

/* ── Empty hint ────────────────────────────────────────── */
.iatf-empty-hint {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.45);
  font-style: italic;
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 991px) {
  /* Wrap the process map in a scrollable container to prevent body overflow */
  .iatf-process-map-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
  }
  /* Give the map a sensible min-width so it scrolls internally, not the body */
  .iatf-process-map {
    min-width: 520px;
  }
}

@media (max-width: 640px) {
  /* On very small screens hide the customer boxes, show only the bands */
  .iatf-customer-box { display: none; }
  .iatf-process-map {
    grid-template-columns: 1fr;  /* only center column */
    min-width: 300px;
  }

  .iatf-core-flow { flex-wrap: wrap; overflow-x: visible; }
  .iatf-core-item { width: 100%; }
  .iatf-core-card { max-width: 100%; }
}


/* ═══════════════════════════════════════════════════════════
   SUBPROCESS — LIST VIEW (step list)
   ═══════════════════════════════════════════════════════════ */

.sp-step-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding-bottom: 8px;
}

.sp-step-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  position: relative;
}

.sp-step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: white;
  font-size: 0.78rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 14px;
  z-index: 1;
  position: relative;
}

/* Vertical connector line */
.sp-step-connector {
  position: absolute;
  left: 15px;
  top: 46px;
  width: 2px;
  background: #cbd5e1;
  bottom: -12px;
  z-index: 0;
}

.sp-step-card {
  flex: 1;
  margin-bottom: 12px;
  border-radius: 8px !important;
  transition: box-shadow 0.15s, transform 0.1s;
}

.sp-step-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.1) !important;
  transform: translateX(2px);
}

.text-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}


/* ═══════════════════════════════════════════════════════════
   SUBPROCESS — SVG FLOWCHART EDITOR (Visio-like)
   ═══════════════════════════════════════════════════════════ */

/* ── Visio-like Flowchart Editor ────────────────────────── */
#visualEditorContainer {
  display: flex;
  flex-direction: column;
  background: #fff;
  min-height: 560px;
  border-top: 1px solid #e2e8f0;
}

/* Ribbon toolbar */
.ve-ribbon {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: linear-gradient(to bottom, #f8fafc, #f1f5f9);
  border-bottom: 2px solid #e2e8f0;
  flex-wrap: wrap;
  user-select: none;
  min-height: 52px;
}
.ve-ribbon-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.ve-ribbon-label {
  font-size: 0.6rem;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}
.ve-tool-row {
  display: flex;
  gap: 3px;
}
.ve-ribbon-sep {
  width: 1px;
  background: #e2e8f0;
  align-self: stretch;
  margin: 2px 4px;
}
.ve-tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border: 1px solid #e2e8f0;
  background: #fff;
  border-radius: 5px;
  padding: 3px 7px;
  cursor: pointer;
  font-size: 0.8rem;
  color: #475569;
  transition: background .12s;
  min-width: 44px;
}
.ve-tool span { font-size: 0.6rem; color: #94a3b8; white-space: nowrap; }
.ve-tool i { font-size: 1rem; }
.ve-tool:hover:not(.active) { background: #eff6ff; border-color: #93c5fd; }
.ve-tool.active { background: #2563eb; color: #fff; border-color: #1d4ed8; }
.ve-tool.active span { color: rgba(255,255,255,.8); }
.ve-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  border: 1px solid #e2e8f0; background: #fff; color: #475569;
  border-radius: 5px; padding: 3px 7px; cursor: pointer; font-size: 0.8rem;
  min-width: 44px;
}
.ve-btn span { font-size: 0.6rem; color: #94a3b8; }
.ve-btn i { font-size: 1rem; }
.ve-btn:hover { background: #f1f5f9; }
.ve-btn-danger {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  border: 1px solid #fecaca; background: #fff; color: #dc2626;
  border-radius: 5px; padding: 3px 7px; cursor: pointer; font-size: 0.8rem;
  min-width: 44px;
}
.ve-btn-danger span { font-size: 0.6rem; color: #fca5a5; }
.ve-btn-danger i { font-size: 1rem; }
.ve-btn-danger:hover { background: #fee2e2; }
.ve-btn-primary {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  border: 1px solid #2563eb; background: #2563eb; color: #fff;
  border-radius: 5px; padding: 3px 10px; cursor: pointer; font-size: 0.8rem;
  min-width: 44px;
}
.ve-btn-primary span { font-size: 0.6rem; color: rgba(255,255,255,.8); }
.ve-btn-primary i { font-size: 1rem; }
.ve-btn-primary:hover { background: #1d4ed8; }

/* Editor body: stencil + canvas */
.ve-editor-body {
  display: flex;
  flex: 1;
  min-height: 480px;
  overflow: hidden;
}

/* Stencil pane */
.ve-stencil {
  width: 110px;
  flex-shrink: 0;
  border-right: 1px solid #e2e8f0;
  background: #f8fafc;
  overflow-y: auto;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ve-stencil-title {
  font-size: 0.65rem;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 2px 0 4px;
  border-bottom: 1px solid #e2e8f0;
  margin-bottom: 4px;
}
.ve-stencil-section {
  font-size: 0.6rem;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 4px 0 2px;
}
.ve-stencil-item {
  padding: 4px 6px;
  border-radius: 5px;
  cursor: pointer;
  touch-action: manipulation;
  transition: background .12s;
  border: 1px solid transparent;
  text-align: center;
}
.ve-tool, .ve-btn, .ve-btn-danger, .ve-btn-primary { touch-action: manipulation; }
.ve-stencil-item:hover { background: #eff6ff; border-color: #93c5fd; }
.ve-stencil-item svg { display: block; margin: 0 auto; }
/* 29.3.6 — stencil nested subprocess groups */
.ve-stencil-sp-group { border: none; margin: 0; padding: 0; }
.ve-stencil-sp-summary {
  font-size: 0.65rem;
  font-weight: 700;
  color: #1e3a5f;
  padding: 3px 4px;
  cursor: pointer;
  list-style: none;
  border-radius: 4px;
  user-select: none;
}
.ve-stencil-sp-summary::-webkit-details-marker { display: none; }
.ve-stencil-sp-summary::before { content: '▶ '; font-size: 0.55rem; color: #94a3b8; }
details.ve-stencil-sp-group[open] > .ve-stencil-sp-summary::before { content: '▼ '; }
.ve-stencil-sp-summary:hover { background: #f1f5f9; }

.ve-stencil-step {
  text-align: left;
  padding: 4px 6px;
}

/* Canvas wrapper */
.ve-canvas-wrap {
  flex: 1;
  overflow: auto;
  background: #fff;
  cursor: default;
  position: relative;
}
.ve-canvas-wrap.ve-connect-mode { cursor: crosshair; }
.ve-svg-canvas {
  display: block;
  touch-action: none; /* prevent iOS scroll/zoom during canvas interactions */
  overflow: visible;
  user-select: none;
}
/* 29.3.3 — view mode canvas: allow vertical finger scroll to pass through to page */
.ve-view-canvas { touch-action: pan-y; }

/* Status bar */
.ve-status-bar {
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  padding: 4px 12px;
}

/* SVG node group */
.ve-node-g { cursor: move; }
.ve-node-g.ve-selected > .ve-shape { filter: drop-shadow(0 0 6px #f59e0b); }

/* AutoConnect arrows — shown on hover */
.ve-autoconnect { display: none; cursor: pointer; }
.ve-node-g:hover .ve-autoconnect { display: block; }
.ve-node-g.ve-selected:hover .ve-autoconnect { display: block; }

/* Port circles */
.ve-port { display: none; cursor: crosshair; }
.ve-node-g:hover .ve-port,
.ve-connect-mode .ve-port { display: block; }

/* Edge paths */
.ve-edge { cursor: pointer; stroke: #4a7fd4; fill: none; stroke-width: 2; }
.ve-edge:hover { stroke: #f59e0b; }
.ve-edge.ve-selected { stroke: #f59e0b; stroke-width: 2.5; }

/* Labels in foreignObject */
.ve-label-fo { pointer-events: none; overflow: visible; }
.ve-label-fo.editing { pointer-events: all; }
.ve-label-div {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.68rem; font-weight: 600; color: #1e293b;
  text-align: center; overflow: hidden;
  word-break: break-word; line-height: 1.2; padding: 2px;
}
.ve-label-div[contenteditable="true"] {
  pointer-events: all; cursor: text; outline: 2px solid #f59e0b;
  background: rgba(255,255,255,.9); border-radius: 3px; font-size: 16px;
}

/* Edge label */
.ve-edge-lbl { font-size: 0.62rem; fill: #64748b; pointer-events: none; }

/* Status */
#veSaveStatus { min-height: 16px; }

/* Properties panel */
.ve-props-panel {
  width: 210px;
  flex-shrink: 0;
  background: #f8fafc;
  border-left: 1px solid #e2e8f0;
  padding: 12px 10px;
  flex-direction: column;
  overflow-y: auto;
  font-size: 0.82rem;
}
.ve-props-title {
  font-weight: 600;
  color: #1e3a5f;
  margin-bottom: 10px;
  font-size: 0.85rem;
}
.ve-props-label {
  display: block;
  font-size: 0.72rem;
  color: #64748b;
  font-weight: 600;
  margin-bottom: 3px;
  margin-top: 6px;
}
.ve-props-label:first-of-type { margin-top: 0; }
.ve-props-input {
  width: 100%;
  font-size: 0.78rem;
  padding: 4px 6px;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  background: #fff;
  outline: none;
}
.ve-props-input:focus { border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,.15); }
.ve-props-hint {
  font-size: 0.65rem;
  color: #94a3b8;
  line-height: 1.4;
}

/* 29.3.2 — Responsive flowchart editor */
@media (max-width: 767px) {
  /* Container: no hard min-height on small screens */
  #visualEditorContainer { max-width: 100vw; min-height: 0; overflow: hidden; }
  /* Ribbon: horizontal scroll so all controls reachable */
  .ve-ribbon {
    padding: 4px 6px;
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    min-height: 48px;
  }
  .ve-ribbon::-webkit-scrollbar { display: none; }
  .ve-ribbon-group { flex-shrink: 0; }
  .ve-ribbon-sep { flex-shrink: 0; }
  /* Hide text labels, keep icons only */
  .ve-tool span, .ve-btn span, .ve-btn-danger span, .ve-btn-primary span { display: none; }
  .ve-tool, .ve-btn, .ve-btn-danger, .ve-btn-primary { min-width: 32px; padding: 4px 5px; }
  /* Stencil narrower on mobile */
  .ve-stencil { width: 68px; font-size: 0.6rem; }
  .ve-stencil-title { display: none; }
  /* Editor body: fill remaining viewport height */
  .ve-editor-body { max-width: 100%; min-height: 320px; height: calc(100vh - 170px); overflow: hidden; }
  /* Canvas: full-height scrollable */
  .ve-canvas-wrap { overflow: auto; -webkit-overflow-scrolling: touch; min-height: 280px; }
  /* Props panel: bottom drawer */
  .ve-props-panel { width: 100%; max-height: 40vh; border-left: none; border-top: 2px solid #e2e8f0; overflow-y: auto; }
  /* Status bar: smaller */
  .ve-status-bar { font-size: 0.58rem; }
  /* View mode canvas: constrain height on phone */
  .card .ve-canvas-wrap { min-height: 260px !important; max-height: 50vh !important; }
}

/* ─── DASHBOARD SECTIONS ────────────────────────────────── */
.dash-section-header {
  display: flex;
  align-items: center;
  padding: .75rem 1rem;
  font-weight: 600;
  font-size: .875rem;
  color: #fff;
  border-radius: .5rem .5rem 0 0;
}
.dash-header-docs  { background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%); }
.dash-header-smed  { background: linear-gradient(135deg, #d97706 0%, #b45309 100%); }
.dash-header-admin { background: linear-gradient(135deg, #4b5563 0%, #374151 100%); }

/* Feature card (Dokumentace section) */
.dash-feature-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1rem .75rem;
  border-radius: .75rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  transition: background .12s, box-shadow .12s, transform .12s;
  cursor: pointer;
  color: inherit;
}
.dash-feature-card:hover {
  background: #eff6ff;
  border-color: #bfdbfe;
  box-shadow: 0 2px 8px rgba(37,99,235,.1);
  transform: translateY(-1px);
}
.dash-feature-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  margin-bottom: .5rem;
}
.dash-feature-name {
  font-size: .82rem;
  font-weight: 600;
  color: #1e293b;
  line-height: 1.2;
  margin-bottom: .2rem;
}
.dash-feature-meta {
  font-size: .72rem;
  color: #94a3b8;
  line-height: 1.3;
}

/* Menu item row (SMED, Admin sections) */
.dash-menu-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem .75rem;
  border-radius: .5rem;
  border: 1px solid #f1f5f9;
  background: #f8fafc;
  transition: background .1s, border-color .1s;
  color: inherit;
}
.dash-menu-item:hover {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: inherit;
}
.dash-menu-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.dash-menu-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
.dash-menu-text .fw-semibold { font-size: .875rem; }
.dash-menu-text .small { font-size: .72rem; line-height: 1.3; }

/* ─── TOPBAR SEARCH (trigger button) ────────────────────── */
.topbar-search-wrap {
  flex: 1;
  max-width: 600px;
  cursor: pointer;
}
.topbar-search-box {
  display: flex;
  align-items: center;
  background: #f1f5f9;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  padding: 0 0.75rem;
  gap: 0.5rem;
  height: 38px;
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
}
.topbar-search-box:hover {
  background: #e8f0fe;
  border-color: var(--rasi-accent);
}
.topbar-search-icon { color: #94a3b8; font-size: 0.9rem; flex-shrink: 0; }
.topbar-search-placeholder {
  flex: 1;
  font-size: 0.88rem;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-search-hint {
  font-size: 0.72rem;
  color: #cbd5e1;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 1px 5px;
  flex-shrink: 0;
}

/* ─── SEARCH DIALOG (HTML top-layer) ────────────────────── */
.search-dialog {
  border: none;
  padding: 0;
  margin: 0;
  width: 100%;
  max-width: 100%;
  max-height: 100%;
  background: transparent;
  overflow: visible;
  position: fixed;
  inset: 0;
}
/* Bílý poloprůhledný backdrop s mírným rozmazáním */
.search-dialog::backdrop {
  background: rgba(15,23,42,.25);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
/* Karta výsledků — zarovnaná nahoru, pod topbar */
.sd-inner {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 6px rgba(0,0,0,.04), 0 24px 64px rgba(0,0,0,.14);
  max-height: calc(100dvh - 80px);
  display: flex;
  flex-direction: column;
  width: calc(100% - 32px);
  max-width: 660px;
  margin: 62px auto 0;  /* 62px ≈ výška topbaru + malá mezera */
  overflow: hidden;
}
/* ── Input řádek ── */
.sd-input-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #f1f5f9;
  flex-shrink: 0;
}
.sd-icon {
  font-size: 1.15rem;
  color: var(--rasi-accent);
  flex-shrink: 0;
}
#searchDialogInput {
  flex: 1;
  border: none;
  outline: none;
  font-size: 1.05rem;
  font-weight: 400;
  color: #0f172a;
  background: transparent;
  min-width: 0;
  line-height: 1.4;
}
#searchDialogInput::placeholder { color: #94a3b8; }
.sd-close {
  background: #f1f5f9;
  border: none;
  color: #64748b;
  font-size: .8rem;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
  flex-shrink: 0;
  line-height: 1;
  transition: background .12s, color .12s;
}
.sd-close:hover { background: #e2e8f0; color: #1e293b; }
/* ── Výsledky ── */
.sd-results { overflow-y: auto; overflow-x: hidden; flex: 1; }

/* Sekce */
.tsd-section { padding-bottom: 4px; }
.tsd-section + .tsd-section { border-top: 1px solid #f1f5f9; }
.tsd-section-header {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .7rem 1.25rem .35rem;
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #94a3b8;
}
.tsd-section-count {
  margin-left: auto;
  background: #f1f5f9;
  color: #64748b;
  border-radius: 10px;
  font-size: .65rem;
  font-weight: 600;
  padding: 1px 7px;
}

/* Řádek výsledku */
.tsd-item {
  display: flex;
  align-items: center;
  gap: .9rem;
  padding: .6rem 1.25rem;
  text-decoration: none;
  color: #0f172a;
  transition: background .08s;
  border-radius: 0;
}
.tsd-item:hover,
.tsd-item.active { background: #f8faff; }

/* Čtvercová ikona s barevným pozadím */
.tsd-item-icon {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  background: var(--ic-bg, #eff6ff);
  color: var(--ic-color, #2563eb);
  transition: transform .1s;
}
.tsd-item:hover .tsd-item-icon,
.tsd-item.active .tsd-item-icon { transform: scale(1.06); }

.tsd-item-body { flex: 1; min-width: 0; }
.tsd-item-name {
  display: block;
  font-size: .9rem;
  font-weight: 500;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.tsd-item-code { color: #2563eb; font-weight: 700; }
.tsd-item-path {
  display: block;
  font-size: .73rem;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.tsd-item-arrow {
  flex-shrink: 0;
  font-size: 1rem;
  color: #e2e8f0;
  transition: color .08s, transform .08s;
}
.tsd-item:hover .tsd-item-arrow,
.tsd-item.active .tsd-item-arrow {
  color: #94a3b8;
  transform: translateX(2px);
}

/* Stav / empty / error */
.tsd-status {
  padding: 1.5rem 1.25rem;
  color: #94a3b8;
  font-size: .875rem;
  text-align: center;
}
.tsd-error { color: #ef4444; }

/* Tlačítko "Zobrazit vše" */
.tsd-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .8rem 1.25rem;
  font-size: .82rem;
  font-weight: 600;
  color: var(--rasi-accent);
  text-decoration: none;
  background: #f8fafc;
  border-top: 1px solid #f1f5f9;
  border-radius: 0 0 16px 16px;
  transition: background .1s, color .1s;
}
.tsd-footer:hover { background: #eff6ff; color: #1d4ed8; }

/* ─── TOPBAR BRAND (viditelné když sidebar skrytý) ────────── */
.topbar-brand {
  display: none;
  flex-direction: column;
  justify-content: center;
  line-height: 1.1;
  flex-shrink: 0;
  text-decoration: none;
  color: inherit;
}
.topbar-brand-title {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -.02em;
  color: #fff;
  background: var(--rasi-accent);
  border-radius: 6px;
  padding: 1px 6px;
  display: inline-block;
}
.topbar-brand-sub {
  font-size: 0.6rem;
  color: #94a3b8;
  letter-spacing: .02em;
  margin-top: 2px;
  white-space: nowrap;
}
/* Zobraz brand na tabletech a mobilu (kdy sidebar je overlay) */
@media (max-width: 991.98px) {
  .topbar-brand { display: flex; }
  .topbar { padding: 0.75rem 1rem; gap: 1rem; }
}

/* ─── SEARCH PAGE (pages/search.php) ─────────────────────── */
.search-page-wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 1.5rem 0 2rem;
}
.search-page-bar {
  display: flex;
  align-items: center;
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  padding: 0 1rem;
  gap: .75rem;
  height: 52px;
  margin-bottom: 1.5rem;
  transition: border-color .15s;
}
.search-page-bar:focus-within {
  border-color: var(--rasi-accent);
  background: #fff;
}
.sp-icon {
  color: #94a3b8;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.search-page-bar input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 1rem;
  color: #0f172a;
  outline: none;
}
.search-page-bar input::placeholder { color: #94a3b8; }
.sp-clear {
  background: none;
  border: none;
  padding: 0;
  color: #94a3b8;
  font-size: .9rem;
  cursor: pointer;
  line-height: 1;
  flex-shrink: 0;
  transition: color .1s;
}
.sp-clear:hover { color: #475569; }

.sp-results {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: #fff;
  border-radius: 14px;
  border: 1px solid #f1f5f9;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,.06);
}
.sp-results:empty { display: none; }
.sp-summary {
  padding: .75rem 1.25rem;
  font-size: .85rem;
  color: #475569;
  border-bottom: 1px solid #f1f5f9;
  background: #f8fafc;
}
.sp-results .tsd-section:last-child { padding-bottom: 8px; }
.sp-results .tsd-item { border-radius: 0; }

/* ─── SPS — Systematic Problem Solving ──────────────────── */

/* A3 toolbar: left | center (nav) | right */
.a3-toolbar {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: nowrap;
}
.a3-toolbar-left  { display: flex; align-items: center; gap: .4rem; flex-shrink: 0; }
.a3-toolbar-nav   { flex: 1 1 0; min-width: 0; }
.a3-toolbar-nav .form-select { font-size: .78rem; }
.a3-toolbar-right { display: flex; align-items: center; gap: .4rem; flex-shrink: 0; }
@media (max-width: 480px) {
  .a3-toolbar { flex-wrap: wrap; }
  .a3-toolbar-nav { order: 3; width: 100%; flex: 1 1 100%; }
}

.sps-section-nav {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}
.sps-section-nav a {
  font-size: .72rem;
  font-weight: 600;
  color: #475569;
  background: #f1f5f9;
  border-radius: 6px;
  padding: 3px 10px;
  text-decoration: none;
  white-space: nowrap;
  transition: background .1s, color .1s;
}
.sps-section-nav a:hover { background: #dc3545; color: #fff; }

.sps-card {
  background: #fff;
  border-radius: 14px;
  border: 1px solid #e8edf2;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
}
.sps-card-title {
  font-size: .82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: #64748b;
  margin-bottom: 1rem;
  padding-bottom: .5rem;
  border-bottom: 2px solid #f1f5f9;
}
.sps-sub-title {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #94a3b8;
}
.sps-label {
  font-size: .78rem;
  font-weight: 600;
  color: #475569;
  display: block;
  margin-bottom: 3px;
}

/* Generic SPS table */
.sps-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}
.sps-table th {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: .4rem .6rem;
  font-weight: 600;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #64748b;
  white-space: nowrap;
}
.sps-table td {
  border: 1px solid #e2e8f0;
  padding: 2px 4px;
  vertical-align: middle;
}
.sps-table tr:hover td { background: #f8faff; }
.sps-table .form-control,
.sps-table .form-select {
  min-width: 60px;
  font-size: .82rem;
}

/* iPad/touch: restore native select picker so it opens reliably */
@media (pointer: coarse) {
  .sps-table select,
  .sps-table .form-select,
  .a3-toolbar select,
  .a3-toolbar .form-select {
    -webkit-appearance: auto !important;
    appearance: auto !important;
    background-image: none !important;
    padding-right: .5rem !important;
  }
}

/* ── Fishbone (Ishikawa) diagram ─────────────────────────── */
.fb-row {
  display: flex;
  gap: .5rem;
}
.fb-top-row { margin-bottom: 0; }
.fb-bot-row { margin-top: 0; }
.fb-cat-col {
  flex: 1;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  min-width: 0;
}
.fb-cat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  padding: .35rem .6rem;
  letter-spacing: .03em;
}
.fb-add-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,.8);
  padding: 0;
  font-size: .85rem;
  cursor: pointer;
  line-height: 1;
  flex-shrink: 0;
}
.fb-add-btn:hover { color: #fff; }
.fb-items { background: #fff; }
.fb-item {
  display: flex;
  align-items: center;
  border-top: 1px solid #f1f5f9;
  padding: 2px 4px;
}
.fb-item:first-child { border-top: none; }
.fb-item-num {
  width: 18px;
  text-align: center;
  font-size: .68rem;
  color: #94a3b8;
  flex-shrink: 0;
}
.fb-item-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: .8rem;
  padding: 3px 4px;
  outline: none;
  min-width: 0;
}
.fb-item-input:focus { background: #f0f9ff; }
.fb-item-rm {
  background: none;
  border: none;
  color: #cbd5e1;
  padding: 0 2px;
  font-size: .8rem;
  cursor: pointer;
  flex-shrink: 0;
  line-height: 1;
}
.fb-item-rm:hover { color: #ef4444; }
.fb-item-empty { padding: 4px 8px; color: #cbd5e1; font-size: .75rem; }
.fb-spine-area { padding: 0; }
.fb-spine-svg {
  display: block;
  width: 100%;
  height: 64px;
}
@media (max-width: 767px) {
  .fb-row { flex-direction: column; }
  .fb-spine-svg { height: 40px; }
}

/* Root cause boxes */
.rc-box {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  height: 100%;
}
.rc-header {
  background: #0ea5e9;
  color: #fff;
  font-size: .75rem;
  font-weight: 700;
  padding: .5rem .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.rc-top { padding: .6rem .75rem; border-bottom: 1px solid #e2e8f0; }
.rc-why {
  display: flex;
  align-items: center;
  border-top: 1px solid #f1f5f9;
  background: #f8fafc;
  padding: 2px 6px;
}
.rc-why:nth-child(even) { background: #fff; }
.rc-why-num {
  width: 22px;
  font-size: .72rem;
  color: #94a3b8;
  flex-shrink: 0;
  font-weight: 700;
}

/* Corrective actions groups */
.ca-group-header {
  background: #0ea5e9;
  color: #fff;
  font-size: .75rem;
  font-weight: 700;
  padding: .4rem .75rem;
  border-radius: 6px 6px 0 0;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.ca-group { border: 1px solid #e2e8f0; border-radius: 8px; overflow: hidden; }

/* Method selector buttons in modal */
.btn-method:hover {
  border-color: #dc3545 !important;
  background: #fff5f5 !important;
}

/* Responsive */
@media (max-width: 767px) {
  .ishikawa-grid { grid-template-columns: 1fr 1fr; }
  .sps-card { padding: .85rem 1rem; }
}
@media (max-width: 480px) {
  .ishikawa-grid { grid-template-columns: 1fr; }
}
