/* Automation module — phase 0 shell */
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Vazirmatn', sans-serif;
  background: var(--ui-bg);
  color: var(--ui-text);
}

.automation-loading {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.spinner {
  width: 42px;
  height: 42px;
  border: 3px solid var(--ui-border);
  border-top-color: var(--ui-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.automation-app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.automation-page-header {
  flex-shrink: 0;
}

.automation-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  background: var(--ui-surface);
  border-bottom: 1px solid var(--ui-border);
}
.automation-topbar h1 { margin: 0; font-size: 1.25rem; color: var(--ui-text); }
.automation-user-label { font-size: 0.85rem; color: var(--ui-text-muted); margin-right: 8px; }
.automation-build-label { font-size: 0.72rem; color: #94a3b8; margin-right: 6px; font-family: monospace; direction: ltr; }
.automation-topbar-left, .automation-topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.automation-search-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}
.automation-search-wrap input {
  min-width: 180px;
  padding: 6px 10px;
  border: 1px solid var(--ui-border-strong);
  border-radius: 6px;
  background: var(--ui-surface);
  color: var(--ui-text);
}
.automation-search-wrap select {
  padding: 6px;
  border-radius: 6px;
  border: 1px solid var(--ui-border-strong);
  background: var(--ui-surface);
  color: var(--ui-text);
}

.btn {
  border: none;
  border-radius: 6px;
  padding: 8px 14px;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-sm { padding: 6px 10px; font-size: 0.88rem; }
.btn-primary { background: var(--ui-accent); color: #fff; }
.btn-primary:hover { background: var(--ui-accent-hover); }
.btn-secondary { background: #64748b; color: #fff; }

.automation-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 20px;
  background: var(--ui-surface-muted);
  border-bottom: 1px solid var(--ui-border);
}
.stat-card {
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  padding: 10px 14px;
  min-width: 100px;
  cursor: pointer;
  text-align: center;
  font: inherit;
  color: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.stat-card:hover,
.stat-card:focus-visible {
  border-color: var(--ui-accent);
  box-shadow: 0 0 0 3px var(--ui-accent-soft);
  background: var(--ui-surface-muted);
  outline: none;
}
.stat-card.has-count {
  border-color: var(--ui-accent);
}
.stat-card strong { display: block; font-size: 1.2rem; color: var(--ui-accent); }
.stat-card.has-count strong { color: var(--ui-accent-hover); }
.stat-card span { font-size: 0.78rem; color: var(--ui-text-muted); }

.dashboard-loading { padding: 16px; text-align: center; }
.dashboard-empty { padding: 24px 16px; text-align: center; color: #64748b; }
.dashboard-section {
  margin-bottom: 28px;
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: 10px;
  overflow: hidden;
}
.dashboard-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}
.dashboard-section-head h3 {
  margin: 0;
  font-size: 1rem;
  color: #0f172a;
}
.dashboard-section-table { margin: 0; }
.dashboard-section-table tbody tr { cursor: pointer; }
.dashboard-section-table tbody tr:hover { background: var(--ui-row-hover); }
.badge-dashboard-highlight {
  display: inline-block;
  margin-right: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  background: #fef3c7;
  color: #92400e;
  vertical-align: middle;
}
.dashboard-section[data-section="approvals"] .badge-dashboard-highlight {
  background: #fee2e2;
  color: #b91c1c;
}
.dashboard-section[data-section="action"] .badge-dashboard-highlight {
  background: #ffedd5;
  color: #c2410c;
}

.automation-layout {
  flex: 1;
  display: flex;
  min-height: 0;
  position: relative;
}

.panel-rail-toggle {
  flex-shrink: 0;
  width: 18px;
  align-self: stretch;
  border: none;
  padding: 0;
  margin: 0;
  background: #e2e8f0;
  color: #475569;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.panel-rail-toggle:hover {
  background: #cbd5e1;
  color: #1e293b;
}
.nav-rail-toggle {
  background: #334155;
  color: #cbd5e1;
}
.nav-rail-toggle:hover {
  background: #475569;
  color: #fff;
}

.automation-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--ui-sidebar-bg);
  color: var(--ui-sidebar-text);
  padding: 10px 8px 14px;
  transition: width 0.18s ease;
}

.sidebar-section {
  --section-accent: #2563eb;
  border-right: 3px solid var(--section-accent);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.28);
  margin: 0 0 8px;
  overflow: hidden;
}
.sidebar-section--dash { --section-accent: #3b82f6; }
.sidebar-section--letters { --section-accent: #2563eb; }
.sidebar-section--events { --section-accent: #7c3aed; }
.sidebar-section--personnel {
  --section-accent: #059669;
  background: #1a2e28;
  box-shadow: inset 0 0 0 1px rgba(5, 150, 105, 0.35);
}
.sidebar-section--admin { --section-accent: #64748b; }
.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--section-accent);
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 8px 10px;
  cursor: pointer;
  text-align: right;
}
.sidebar-section-header.static { cursor: default; }
.sidebar-section-title {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.sidebar-section-arrow {
  font-size: 0.75rem;
  opacity: 0.95;
  transition: transform 0.18s ease;
}
.sidebar-section-arrow.open { transform: rotate(180deg); }
.sidebar-section-content { padding: 4px 0 6px; }
.sidebar-section-content.collapsed { display: none; }
.sidebar-subheader {
  padding: 7px 12px 5px;
  font-size: 0.72rem;
  color: #9ca3af;
  font-weight: 700;
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  background: transparent;
  color: inherit;
  font-family: inherit;
  font-size: 0.92rem;
  cursor: pointer;
  text-align: right;
  position: relative;
}
.sidebar-item:hover { background: rgba(255,255,255,0.08); }
.sidebar-item.active { background: var(--section-accent); color: #fff; }
.sidebar-item i { width: 20px; text-align: center; }
.sidebar-badge {
  margin-right: auto;
  margin-left: 6px;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.4;
}
.sidebar-item.active .sidebar-badge {
  background: #fff;
  color: var(--section-accent);
}

.sidebar-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 14px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.sidebar-profile-text { min-width: 0; flex: 1; }
.sidebar-profile-name {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.3;
  word-break: break-word;
}
.sidebar-profile-title {
  font-size: 0.72rem;
  color: #94a3b8;
  margin-top: 2px;
}
.user-avatar {
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #334155;
  color: #e2e8f0;
  font-weight: 700;
}
.user-avatar-sm { width: 24px; height: 24px; font-size: 0.7rem; }
.user-avatar-md { width: 48px; height: 48px; font-size: 1rem; }
.user-avatar-lg { width: 48px; height: 48px; font-size: 1.1rem; }
.user-avatar-fallback { border: 1px solid rgba(255, 255, 255, 0.15); }
img.user-avatar { object-fit: cover; display: block; }
.user-with-avatar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.user-avatar-wrap {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  line-height: 0;
}
.user-avatar-wrap > img.user-avatar:only-child {
  display: block;
}

.automation-layout.nav-rail-collapsed .automation-sidebar {
  width: 64px;
  padding: 8px 4px 12px;
}
.automation-layout.nav-rail-collapsed .automation-sidebar-nav {
  padding: 0;
}
.automation-layout.nav-rail-collapsed .sidebar-profile {
  justify-content: center;
  padding: 8px 4px 12px;
  gap: 0;
}
.automation-layout.nav-rail-collapsed .sidebar-profile-text,
.automation-layout.nav-rail-collapsed .sidebar-item > span:not(.sidebar-badge),
.automation-layout.nav-rail-collapsed .sidebar-section-title span,
.automation-layout.nav-rail-collapsed .sidebar-section-arrow,
.automation-layout.nav-rail-collapsed .sidebar-subheader {
  display: none;
}
.automation-layout.nav-rail-collapsed .sidebar-section-header {
  justify-content: center;
  padding: 8px 4px;
}
.automation-layout.nav-rail-collapsed .sidebar-section-title {
  gap: 0;
}
.automation-layout.nav-rail-collapsed .sidebar-item {
  justify-content: center;
  padding: 9px 4px;
}
.automation-layout.nav-rail-collapsed .sidebar-item i {
  margin: 0;
}
.automation-layout.nav-rail-collapsed .sidebar-badge {
  position: absolute;
  top: 2px;
  left: 2px;
  margin: 0;
  min-width: 16px;
  padding: 0 4px;
  font-size: 0.65rem;
}
.automation-layout.nav-rail-collapsed .sidebar-profile .user-avatar-lg {
  width: 36px;
  height: 36px;
  font-size: 0.9rem;
}
.approval-step-name .user-with-avatar {
  vertical-align: middle;
}
.ud-panel-wrap,
.ud-registry-wrap { padding: 4px 0; }
.ud-table { margin-top: 12px; }
.ud-registry-picker { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ud-registry-avatar { min-width: 0; }
.ud-registry-select { width: 100%; max-width: 420px; flex: 1; }
.ud-registry-user-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ud-profile-row label { display: flex; align-items: center; gap: 8px; font-weight: 500; }

.automation-main {
  flex: 1;
  padding: 16px 20px;
  overflow: auto;
  min-width: 0;
}

.automation-org-chart-panel-cell,
.org-chart-panel-cell {
  padding: 16px !important;
  vertical-align: top;
}
.org-chart-layout {
  display: flex;
  flex-wrap: nowrap;
  gap: 16px;
  align-items: flex-start;
  min-width: 0;
  max-width: 100%;
}
.org-chart-view {
  flex: 1;
  min-width: 0;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 16px;
  overflow: hidden;
}
.org-chart-view h4,
.org-chart-admin h4 {
  margin: 0 0 12px;
  font-size: 1rem;
}
.org-chart-admin {
  flex: 1;
  min-width: 260px;
  max-width: 360px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 16px;
  position: relative;
}
.org-chart-admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.org-chart-admin-head h4 {
  margin: 0;
}
.org-chart-admin .org-admin-toggle {
  width: 28px;
  height: 28px;
  align-self: center;
  border-radius: 6px;
  background: #f1f5f9;
}
.org-chart-admin-rail-label {
  display: none;
}
.org-chart-admin.is-collapsed {
  flex: 0 0 44px;
  min-width: 44px;
  max-width: 44px;
  padding: 8px 4px;
  overflow: hidden;
}
.org-chart-admin.is-collapsed .org-chart-admin-head h4,
.org-chart-admin.is-collapsed .org-chart-admin-body {
  display: none;
}
.org-chart-admin.is-collapsed .org-chart-admin-head {
  margin: 0;
  justify-content: center;
}
.org-chart-admin.is-collapsed .org-chart-admin-rail-label {
  display: block;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 0.82rem;
  font-weight: 700;
  color: #475569;
  text-align: center;
  margin: 10px auto 0;
  letter-spacing: 0.04em;
  cursor: pointer;
}
.org-chart-tree { font-size: 0.9rem; line-height: 1.8; }
.org-chart-node { padding: 2px 0; color: #1e293b; }
.org-chart-position { font-weight: 600; margin-top: 4px; }
.org-chart-holder { font-weight: 400; color: #334155; font-size: 0.86rem; }
.org-chart-holder i { color: #94a3b8; margin-left: 6px; font-size: 0.78rem; }
.org-holder-meta { color: #64748b; font-size: 0.82rem; margin-right: 6px; }
.org-chart-extra { margin-top: 20px; padding-top: 16px; border-top: 1px dashed #cbd5e1; }
.org-chart-extra h5 { margin: 0 0 8px; font-size: 0.92rem; color: #475569; }
.org-unassigned-list { list-style: none; margin: 8px 0 0; padding: 0; font-size: 0.86rem; }
.org-unassigned-list li { padding: 4px 0; color: #64748b; }
.org-unassigned-list i { margin-left: 6px; color: #94a3b8; }
.org-chart-orphaned h5 { color: #b45309; }
.org-chart-orphaned i { color: #d97706 !important; }
.org-chart-node i { color: #64748b; margin-left: 6px; }
.org-ceo-badge { color: #2563eb; }
.org-chart-empty { font-size: 0.88rem; color: #64748b; }

.org-chart-view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.org-chart-view-header h4 { margin: 0; }
.org-chart-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.org-chart-view-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.org-chart-vacant-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: #475569;
  cursor: pointer;
  user-select: none;
}
.org-chart-vacant-toggle input { cursor: pointer; }
.org-chart-view-toggle-label {
  font-size: 0.82rem;
  color: #64748b;
}

.org-position-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: #e0f2fe;
  color: #0c4a6e;
  font-weight: 600;
  font-size: 0.86rem;
  border: 1px solid #bae6fd;
}
.org-position-badge-vacant {
  background: #f1f5f9;
  color: #94a3b8;
  border-color: #e2e8f0;
  opacity: 0.75;
}
.org-vacant-label,
.org-hierarchy-vacant {
  font-size: 0.78rem;
  color: #94a3b8;
  font-style: italic;
}
.org-chart-vacant { padding: 2px 0 6px; }

.org-chart-holder-self,
.org-hierarchy-holder-self {
  background: #fef9c3;
  border: 1px solid #fde047;
  border-radius: 6px;
  padding: 4px 8px !important;
  color: #854d0e;
  font-weight: 600;
}
.org-self-badge {
  display: inline-block;
  margin-right: 6px;
  padding: 0 6px;
  border-radius: 4px;
  background: #eab308;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  vertical-align: middle;
}

.org-chart-export-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}
.org-chart-scroll-x {
  overflow-x: auto;
  overflow-y: visible;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  padding-bottom: 6px;
  scrollbar-gutter: stable;
}
.org-chart-scroll-x::-webkit-scrollbar {
  height: 10px;
}
.org-chart-scroll-x::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}
.org-chart-scroll-x::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 999px;
}
.org-chart-scroll-hint {
  margin: 0 0 8px;
  font-size: 0.78rem;
  color: #64748b;
  text-align: center;
}
.org-chart-scroll-hint i {
  margin-left: 4px;
  color: #94a3b8;
}

.org-forests-wrap {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: min-content;
}
.org-forest-block {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px 16px 16px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.org-forest-title {
  margin: 0 0 12px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #1e293b;
  padding-bottom: 8px;
  border-bottom: 1px dashed #cbd5e1;
}
.org-forest-multi-hint { margin: 0 0 10px; }
.org-forest-orphan-hint { color: #d97706; font-size: 0.85rem; }
.org-forest-body { min-width: min-content; }
.org-forest-pyramid .org-pyramid-root {
  margin: 0 auto;
  padding-right: 0;
}
.org-pos-table-wrap { overflow-x: auto; margin-bottom: 12px; }
.org-pos-admin-table { font-size: 0.85rem; }
.org-pos-admin-table th:last-child,
.org-pos-admin-table td.org-pos-actions-cell { width: 1%; white-space: nowrap; }
.org-pos-fields {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.org-pos-admin-table select,
.org-pos-admin-table input[type="text"] {
  width: 100%;
  min-width: 0;
  font-size: 0.85rem;
}
.org-pos-actions-cell { white-space: nowrap; }
.org-pos-admin-hint { margin-top: 8px; }

.org-pyramid-wrap {
  width: 100%;
  min-width: 0;
  padding: 0 0 8px;
}
.org-pyramid-wrap .org-chart-extra {
  direction: rtl;
  text-align: right;
}
.org-pyramid-tree {
  display: inline-block;
  width: max-content;
  min-width: 100%;
  text-align: center;
  padding: 8px 16px 4px;
  box-sizing: border-box;
}
.org-pyramid-tree ul {
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
}
.org-pyramid-root {
  display: flex;
  justify-content: center;
}
.org-pyramid-children {
  display: flex;
  justify-content: center;
  padding-top: 24px;
  position: relative;
}
.org-pyramid-children::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 24px;
  background: #94a3b8;
}
.org-pyramid-item {
  position: relative;
  padding: 24px 10px 0;
  text-align: center;
}
.org-pyramid-item::before,
.org-pyramid-item::after {
  content: '';
  position: absolute;
  top: 0;
  width: 50%;
  height: 24px;
  border-top: 2px solid #94a3b8;
}
.org-pyramid-item::before {
  right: 50%;
  border-right: 2px solid #94a3b8;
  border-radius: 0 4px 0 0;
}
.org-pyramid-item::after {
  left: 50%;
  border-left: 2px solid #94a3b8;
  border-radius: 4px 0 0 0;
}
.org-pyramid-root > .org-pyramid-item::before,
.org-pyramid-root > .org-pyramid-item::after {
  display: none;
}
.org-pyramid-children > .org-pyramid-item:only-child::before,
.org-pyramid-children > .org-pyramid-item:only-child::after {
  display: none;
}
.org-pyramid-children > .org-pyramid-item:first-child:not(:only-child)::before {
  border: none;
}
.org-pyramid-children > .org-pyramid-item:last-child:not(:only-child)::after {
  border: none;
}
.org-pyramid-card {
  direction: rtl;
  display: inline-block;
  min-width: 132px;
  max-width: 210px;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 10px 12px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  position: relative;
  z-index: 1;
}
.org-pyramid-card-vacant {
  background: #f8fafc;
  border-color: #e2e8f0;
  opacity: 0.72;
}
.org-hierarchy-position {
  margin-bottom: 8px;
}
.org-hierarchy-holder {
  font-size: 0.84rem;
  color: #334155;
  padding: 4px 0;
  border-top: 1px dashed #e2e8f0;
  margin-top: 4px;
}
.org-hierarchy-holder i {
  color: #94a3b8;
  margin-left: 4px;
  font-size: 0.75rem;
}

.approval-preview {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 10px 12px;
  margin: 8px 0 12px;
  font-size: 0.88rem;
}
.approval-preview ol { margin: 6px 20px 0 0; padding: 0; }
.approval-chain {
  margin: 14px 0;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}
.approval-chain-list {
  margin: 8px 20px 0 0;
  padding: 0;
  list-style: decimal;
}
.approval-step {
  margin-bottom: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  background: #fff;
  border: 1px solid #e2e8f0;
}
.approval-step-current {
  border-color: #2563eb;
  background: #eff6ff;
}
.approval-step-approved {
  border-color: #86efac;
  background: #f0fdf4;
}
.approval-step-rejected {
  border-color: #fca5a5;
  background: #fef2f2;
}
.approval-step-name {
  display: block;
  font-weight: 600;
}
.approval-step-status {
  display: block;
  font-size: 0.85rem;
  color: #64748b;
  margin-top: 2px;
}
.approval-action-hint {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
}
.approval-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-bottom: 12px;
}
.approval-filter-seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}
.automation-table .col-check {
  width: 2.25rem;
  text-align: center;
  vertical-align: middle;
}
.automation-table .col-check input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
}
#automationMainActions .approval-filter-bar {
  width: 100%;
  margin-bottom: 0;
}
.badge-approval-step {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #dbeafe;
  color: #1e40af;
  font-size: 0.78rem;
  font-weight: 600;
}
.badge-approval-outcome {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}
.badge-approval-pending {
  background: #fef3c7;
  color: #92400e;
}
.badge-approval-approved {
  background: #dcfce7;
  color: #166534;
}
.badge-approval-submitted {
  background: #e0e7ff;
  color: #3730a3;
}
.badge-approval-completed {
  background: #cffafe;
  color: #0e7490;
}
.badge-official-num {
  display: inline-block;
  margin-right: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  background: #f1f5f9;
  font-size: 0.75rem;
  color: #475569;
}
.badge-approval-rejected {
  background: #fee2e2;
  color: #991b1b;
}
.badge-template-visibility {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}
.badge-template-public {
  background: #dbeafe;
  color: #1e40af;
}
.badge-template-personal {
  background: #f3e8ff;
  color: #6b21a8;
}
.template-actions {
  white-space: nowrap;
}
.template-actions .btn {
  margin-left: 4px;
}
.draft-word-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.draft-word-options select {
  min-width: 160px;
}
.draft-main-document {
  margin-bottom: 16px;
}
.draft-doc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}
.draft-doc-name {
  flex: 1;
  font-size: 0.92rem;
  color: #334155;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.draft-doc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex-shrink: 0;
}
.btn.btn-icon {
  background: transparent;
  border: none;
  color: #475569;
  cursor: pointer;
  padding: 6px 8px;
  font-size: 16px;
  border-radius: 6px;
}
.btn.btn-icon:hover:not(:disabled) {
  background: #e2e8f0;
  color: #1e293b;
}
.btn.btn-icon:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.btn.btn-icon.danger {
  color: #dc2626;
}
.btn.btn-icon.danger:hover:not(:disabled) {
  background: #fee2e2;
  color: #b91c1c;
}
.draft-attachments-section {
  margin-top: 4px;
}
.draft-attachments-list {
  list-style: none;
  margin: 8px 0 10px;
  padding: 0;
}
.draft-attach-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  margin-bottom: 6px;
  background: #fff;
}
.draft-attach-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
}
.draft-attach-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.draft-attach-input {
  margin-top: 6px;
}
.draft-doc-ready {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 8px;
  color: #065f46;
}
.form-hint-warn {
  color: #b45309;
  margin-top: 6px;
}
.letter-row-pending-approval td {
  background: var(--ui-row-pending);
  color: var(--ui-text);
}
.letter-row-pending-approval:hover td {
  background: var(--ui-row-pending-hover);
}
.letter-row-approval-done td {
  background: var(--ui-row-done);
  color: var(--ui-row-done-text);
}
.letter-row-approval-done:hover td {
  background: var(--ui-row-done-hover);
}
.att-pr-row-pending td {
  background: var(--ui-row-pending);
  color: var(--ui-text);
}
.att-pr-row-pending:hover td {
  background: var(--ui-row-pending-hover);
}
.att-pr-row-done td {
  background: var(--ui-row-done);
  color: var(--ui-row-done-text);
}
.att-pr-row-done:hover td {
  background: var(--ui-row-done-hover);
}
.org-pos-list { list-style: none; padding: 0; margin: 0 0 12px; }
.org-pos-list li { padding: 4px 0; border-bottom: 1px solid #eee; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.org-pos-del-btn { flex-shrink: 0; cursor: pointer; }
.org-pos-del-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.automation-main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.automation-main-header h2 { margin: 0; font-size: 1.1rem; }

.automation-table-wrap {
  background: var(--ui-surface);
  border-radius: 8px;
  border: 1px solid var(--ui-border);
  overflow: auto;
}
.automation-panel-host {
  padding: 16px;
  min-height: 120px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
.automation-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.automation-table th, .automation-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--ui-border);
  text-align: right;
  color: var(--ui-text);
}
.automation-table th { background: var(--ui-table-head); font-weight: 600; color: var(--ui-text); }
.letter-row { cursor: pointer; }
.letter-row:hover { background: var(--ui-row-hover); }
.letter-row:not(.letter-row-pending-approval):not(.letter-row-approval-done):hover td {
  background: var(--ui-row-hover);
  color: var(--ui-text);
}
.letter-unread td { font-weight: 600; }
.badge-action {
  font-size: 0.72rem;
  background: #fef3c7;
  color: #92400e;
  padding: 2px 6px;
  border-radius: 4px;
  margin-right: 4px;
}
.badge-urgency {
  font-size: 0.72rem;
  padding: 2px 6px;
  border-radius: 4px;
  margin-right: 4px;
}
.badge-urgency-urgent {
  background: #ffedd5;
  color: #c2410c;
}
.badge-urgency-immediate {
  background: #fee2e2;
  color: #b91c1c;
}
.recipient-action-panel {
  margin: 8px 0 12px;
}
.recipient-action-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.recipient-action-list li {
  padding: 4px 0;
}
.recipient-action-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  flex-wrap: wrap;
}
.recipient-action-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  flex-wrap: wrap;
}
.readonly-person-field {
  padding: 8px 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
}
.urgency-select {
  max-width: 200px;
}
.letter-meta-header {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
  padding: 10px 14px;
  margin-bottom: 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.92rem;
}
.letter-metadata-edit {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  background: #fffbeb;
}
.letter-metadata-edit .form-group {
  margin-bottom: 10px;
}
.letter-flag { font-size: 0.78rem; margin-right: 4px; }
.letter-flag-reply { color: #2563eb; }
.letter-flag-forward { color: #7c3aed; }
.letter-flag-thread { color: #64748b; }
.badge-thread-count {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  background: #e0e7ff;
  color: #3730a3;
  padding: 2px 7px;
  border-radius: 999px;
  margin-right: 4px;
}
.letter-thread-timeline {
  margin-bottom: 16px;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
}
.letter-thread-title {
  margin: 0 0 10px;
  font-size: 0.95rem;
  color: #334155;
  display: flex;
  align-items: center;
  gap: 8px;
}
.letter-thread-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
}
.letter-thread-item {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 12px;
}
.letter-thread-item.is-active {
  border-color: #93c5fd;
  box-shadow: inset 0 0 0 1px #93c5fd;
  background: #f8fbff;
}
.letter-thread-item[data-thread-letter] {
  cursor: pointer;
}
.letter-thread-item[data-thread-letter]:hover {
  border-color: #bfdbfe;
  background: #f1f5f9;
}
.letter-thread-item-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
  font-size: 0.8rem;
}
.letter-thread-kind {
  background: #e2e8f0;
  color: #334155;
  padding: 1px 8px;
  border-radius: 999px;
  font-weight: 600;
}
.letter-thread-item.is-active .letter-thread-kind {
  background: #dbeafe;
  color: #1d4ed8;
}
.letter-thread-meta { color: #64748b; direction: ltr; }
.letter-thread-time { color: #94a3b8; margin-right: auto; }
.letter-thread-who { margin-bottom: 4px; }
.letter-thread-subject { font-weight: 600; font-size: 0.9rem; margin-bottom: 4px; }
.letter-thread-body {
  margin: 0;
  white-space: pre-wrap;
  font: inherit;
  font-size: 0.82rem;
  color: #475569;
  background: transparent;
  border: none;
  padding: 0;
}

.automation-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.automation-modal {
  background: #fff;
  border-radius: 10px;
  width: min(560px, 100%);
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}
.automation-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #e2e8f0;
}
.automation-modal-header h3 { margin: 0; font-size: 1rem; }
.modal-close {
  border: none;
  background: transparent;
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
}
.automation-modal-body { padding: 16px; }
.form-group { margin-bottom: 12px; }
.form-group label { display: block; margin-bottom: 4px; font-size: 0.88rem; }
.form-group input, .form-group textarea, .form-group select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-family: inherit;
}
.field-hint {
  display: block;
  font-size: 0.78rem;
  color: #64748b;
  margin-bottom: 4px;
}
.automation-select-multi { min-height: 160px; }

.recipient-picker {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.recipient-picker .lookup-container {
  position: relative;
}
.recipient-picker .lookup-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  left: 0;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 0 0 8px 8px;
  z-index: 40;
  max-height: 240px;
  overflow-y: auto;
  display: none;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
}
.recipient-picker .lookup-item {
  padding: 8px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.recipient-picker .lookup-item:hover {
  background: #f1f5f9;
}
.recipient-picker .lookup-item.muted {
  color: #64748b;
  cursor: default;
}
.recipient-search-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font: inherit;
}
.recipient-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 0;
}
.recipient-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 6px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  font-size: 0.88rem;
  max-width: 100%;
}
.recipient-chip .user-with-avatar {
  max-width: 260px;
}
.recipient-chip-remove {
  border: none;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 2px;
}
.recipient-chip-remove:hover {
  color: #b91c1c;
}
.recipient-hidden-select {
  display: none !important;
}

.external-party-logo-thumb {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: 6px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}
.external-party-logo-empty {
  color: #94a3b8;
}
.external-party-logo-preview {
  width: 96px;
  height: 96px;
  margin-bottom: 8px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: #94a3b8;
  font-size: 0.85rem;
}
.external-party-logo-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 0.9rem;
}
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
.form-hint {
  font-size: 0.85rem;
  color: #64748b;
  margin: 0 0 12px;
  line-height: 1.5;
}
.btn-link {
  background: transparent;
  color: #2563eb;
  padding: 4px 0;
  margin-top: 4px;
}
.letter-detail pre {
  white-space: pre-wrap;
  background: #f8fafc;
  padding: 12px;
  border-radius: 6px;
  font-family: inherit;
}
.letter-flow ul {
  margin: 8px 0 0;
  padding-right: 20px;
  font-size: 0.85rem;
  color: #475569;
}
.letter-detail-actions {
  flex-wrap: wrap;
}
.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
}

.automation-empty {
  padding: 24px;
  text-align: center;
  color: #64748b;
}

.toast-container {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 2147483000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 10px 16px;
  border-radius: 6px;
  color: #fff;
  background: #334155;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  pointer-events: auto;
}
.toast.error { background: #dc2626; }
.toast.success { background: #16a34a; }

.letter-attachments {
  margin: 12px 0;
  padding: 10px 12px;
  background: #f8fafc;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
}
.letter-attachments ul { margin: 8px 0 0; padding-right: 20px; }
.letter-body pre {
  white-space: pre-wrap;
  background: #f1f5f9;
  padding: 12px;
  border-radius: 6px;
  font-family: inherit;
  margin: 0;
}
.letter-body.letter-body-html {
  background: #f8fafc;
  padding: 12px 14px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  line-height: 1.75;
}
.letter-body.letter-body-html p { margin: 0 0 0.75em; }
.letter-body.letter-body-html p:last-child { margin-bottom: 0; }
.letter-body.letter-body-html ul,
.letter-body.letter-body-html ol {
  margin: 0.5em 0 0.75em;
  padding-right: 1.4em;
}
.letter-body blockquote.letter-quote,
.letter-quote-block blockquote.letter-quote {
  margin: 12px 0 0;
  padding: 12px 14px;
  background: #eef2f6;
  border-right: 3px solid #94a3b8;
  border-radius: 6px;
  color: #334155;
  font-size: 0.95em;
}
.letter-quote-meta {
  margin: 0 0 8px;
  font-weight: 600;
  color: #475569;
}
.letter-quote-content { margin: 0; }
.letter-new-body { margin-bottom: 4px; }
.letter-quote-block {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-right: 3px solid #64748b;
  border-radius: 8px;
  padding: 12px 14px;
  max-height: 220px;
  overflow: auto;
  color: #334155;
  line-height: 1.7;
  font-size: 0.95rem;
}
.letter-quote-block pre {
  margin: 0;
  white-space: pre-wrap;
  font-family: inherit;
  background: transparent;
  padding: 0;
}
.letter-body-editor-host {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}
.letter-editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 8px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}
.letter-editor-toolbar button {
  min-width: 32px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: #1e293b;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
}
.letter-editor-toolbar button:hover {
  background: #e2e8f0;
}
.letter-body-editor {
  min-height: 140px;
  max-height: 320px;
  overflow: auto;
  padding: 10px 12px;
  line-height: 1.7;
  outline: none;
}
.letter-body-editor:focus {
  box-shadow: inset 0 0 0 2px rgba(37, 99, 235, 0.15);
}
.letter-body-editor ul,
.letter-body-editor ol {
  margin: 0.4em 0;
  padding-right: 1.4em;
}
.letter-body-editor p { margin: 0 0 0.6em; }
.letter-body-editor[contenteditable="false"] {
  background: #f8fafc;
  color: #475569;
}
.letter-flow ul { margin: 8px 0; padding-right: 0; font-size: 0.9rem; list-style: none; }
.letter-flow-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #f1f5f9;
}
.letter-flow-item:last-child { border-bottom: none; }
.letter-flow-user {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 120px;
  flex-shrink: 0;
  font-size: 0.85rem;
  color: #334155;
}
.letter-flow-body {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  flex: 1;
}
.letter-flow-action { font-weight: 600; color: #1e293b; }
.letter-flow-time { color: #64748b; font-size: 0.82rem; }
.letter-flow-note { color: #475569; font-size: 0.85rem; }
.org-person-with-avatar { font-size: inherit; }
.org-chart-holder .user-with-avatar,
.org-hierarchy-holder .user-with-avatar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.org-unassigned-list li {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 0;
}
.letter-detail-actions { flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.automation-settings-form { max-width: 480px; }
.automation-settings-form .form-group { margin: 10px 0; }
.checkbox-inline { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }

.doc-editor-overlay { z-index: 20000; }
.doc-editor-modal {
  width: min(96vw, 1200px);
  max-width: none;
  height: 90vh;
  display: flex;
  flex-direction: column;
}
.doc-editor-frame {
  flex: 1;
  min-height: 70vh;
  height: calc(90vh - 64px);
  width: 100%;
  position: relative;
}
.doc-editor-frame iframe { width: 100%; height: 100%; border: 0; }

.automation-notif-btn { position: relative; }

.staff-status-wrap { position: relative; }
.staff-status-btn.staff-status-btn-active {
  background: #dbeafe;
  border: 1px solid #2563eb;
  color: #1d4ed8;
}
.staff-status-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: auto;
  z-index: 1200;
  min-width: min(420px, 92vw);
  max-width: 480px;
  max-height: min(420px, 70vh);
  overflow: auto;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
  padding: 8px 0;
}
.staff-status-panel-head {
  padding: 8px 14px 10px;
  border-bottom: 1px solid #e2e8f0;
  font-size: 0.85rem;
  font-weight: 600;
  color: #334155;
}
.staff-status-loading,
.staff-status-empty {
  padding: 16px 14px;
  text-align: center;
  color: #64748b;
  font-size: 0.88rem;
}
.staff-status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid #f1f5f9;
}
.staff-status-row:last-child { border-bottom: none; }
.staff-status-person {
  flex: 1;
  min-width: 0;
}
.staff-status-person .user-with-avatar { font-size: 0.9rem; }
.staff-status-position {
  display: block;
  font-size: 0.75rem;
  color: #64748b;
  margin-top: 2px;
}
.staff-status-dot {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #cbd5e1;
}
.staff-status-dot.online { background: #22c55e; box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.25); }
.staff-status-dot.offline { background: #94a3b8; }
.staff-status-times {
  flex-shrink: 0;
  font-size: 0.78rem;
  color: #475569;
  text-align: left;
  direction: rtl;
  white-space: nowrap;
}

.notif-badge {
  position: absolute;
  top: -4px;
  left: -4px;
  background: #dc2626;
  color: #fff;
  font-size: 10px;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  border-radius: 8px;
  padding: 0 4px;
}
.event-filter-wrap { display: inline-flex; margin-left: 8px; }
.event-filter-wrap select { padding: 4px 8px; border-radius: 4px; }
.notif-list { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow-y: auto; }
.notif-list li { padding: 10px 12px; border-bottom: 1px solid #e2e8f0; cursor: pointer; display: flex; align-items: flex-start; gap: 10px; }
.notif-list li.notif-unread { background: #eff6ff; }
.notif-list li.notif-read { opacity: 0.62; background: #fff; }
.notif-list li.notif-empty { cursor: default; opacity: 1; color: #64748b; }
.notif-list li[data-id]:hover { background: var(--ui-row-hover); }
.notif-list li.notif-unread:hover { background: #dbeafe; }
.notif-list li p { margin: 4px 0; font-size: 0.9rem; color: #475569; }
.notif-body { flex: 1; min-width: 0; }
.event-row { cursor: pointer; }
.event-row:hover { background: var(--ui-row-hover); }

.events-calendar-wrap {
  width: 100%;
  min-width: 0;
}
.cal-view-all-hint {
  margin: 0 0 12px;
  text-align: center;
}
.events-calendar-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 14px;
}
.events-calendar-title {
  margin: 0;
  font-size: 1.05rem;
  min-width: 140px;
  text-align: center;
}
.events-calendar-month-heading {
  margin: 0 0 12px;
  text-align: center;
  font-size: 1.25rem;
  font-weight: 700;
  color: #0f172a;
}
.cal-day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-bottom: 4px;
  min-height: 22px;
}
.cal-day-add {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  background: #f8fafc;
  color: #2563eb;
  cursor: pointer;
  padding: 0;
  font-size: 0.72rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.cal-day-add:hover {
  background: #dbeafe;
  border-color: #93c5fd;
}
.events-calendar-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.events-calendar {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  table-layout: fixed;
}
.events-calendar th {
  background: #1e293b;
  color: #f8fafc;
  padding: 10px 6px;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
}
.events-calendar td {
  vertical-align: top;
  border: 1px solid #e2e8f0;
  min-height: 88px;
  height: 96px;
  padding: 6px;
  background: #fff;
}
.cal-day-empty {
  background: #f8fafc;
}
.cal-day-has-events {
  background: #fffbeb;
}
.events-calendar td.cal-day-today,
.att-calendar-wrap td.cal-day-today {
  background: #fce7f3;
  box-shadow: inset 0 0 0 2px #f9a8d4;
}
.events-calendar td.cal-day-today .cal-day-num,
.att-calendar-wrap td.cal-day-today .cal-day-num {
  color: #9d174d;
  font-weight: 700;
}
.cal-day-num {
  font-weight: 600;
  font-size: 0.88rem;
  color: #334155;
}
.cal-day-events {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cal-event-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  width: 100%;
  text-align: right;
  border: none;
  border-radius: 4px;
  padding: 4px 6px;
  font-family: inherit;
  font-size: 0.72rem;
  line-height: 1.35;
  cursor: pointer;
  background: #dbeafe;
  color: #1e3a8a;
}
.cal-event-chip-main {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cal-event-comments {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 0.68rem;
  color: #475569;
  background: rgba(255, 255, 255, 0.65);
  border-radius: 999px;
  padding: 1px 5px;
}
.cal-event-comments i {
  font-size: 0.62rem;
}
.cal-event-chip:hover {
  background: #bfdbfe;
}
.cal-event-high {
  background: #fee2e2;
  color: #991b1b;
}
.cal-event-high:hover {
  background: #fecaca;
}
.cal-event-low {
  background: #f1f5f9;
  color: #475569;
}
.cal-event-time {
  opacity: 0.85;
  margin-right: 4px;
}
.event-comments {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
}
.event-participants-roster {
  margin: 12px 0 16px;
}
.event-participants-roster > strong {
  display: block;
  margin-bottom: 8px;
  color: #1e293b;
}
.event-participants-roster-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.event-participant-roster-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}
.event-participant-roster-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.event-participant-name {
  font-size: 0.92rem;
  color: #1e293b;
  font-weight: 600;
}
.event-participant-position {
  font-size: 0.8rem;
  color: #64748b;
}
.event-comments-section {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
}
.event-comments-section h3 {
  margin: 0 0 12px;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.event-comment-compose-wrap {
  margin-bottom: 16px;
}
.event-comment-compose-wrap > .btn-primary {
  min-width: 120px;
}
.event-comment-compose {
  margin-top: 10px;
  padding: 12px;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 10px;
}
.event-comment-compose-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #0c4a6e;
}
.event-comment-compose textarea {
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 10px;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-family: inherit;
  resize: vertical;
}
.event-comments-feed {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.event-comment-feed-item {
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}
.event-comment-feed-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.event-comment-feed-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.event-comment-feed-meta strong {
  font-size: 0.9rem;
  color: #1e293b;
}
.event-attendees-section {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
}
.event-attendees-section h3 {
  margin: 0 0 8px;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.event-attendees-hint {
  margin: 0 0 12px;
}
.event-attendees-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.event-attendee-row {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}
.event-attendee-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}
.event-attendee-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.event-attendee-info strong {
  font-size: 0.95rem;
  color: #1e293b;
}
.event-attendee-position {
  font-size: 0.82rem;
  color: #64748b;
}
.event-attendee-actions {
  flex-shrink: 0;
}
.event-attendee-comments {
  padding: 10px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.event-attendee-comment {
  padding: 8px 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}
.event-attendee-no-comment {
  margin: 0;
  font-size: 0.85rem;
}
.event-attendee-comment-form {
  padding: 0 14px 14px;
}
.event-attendee-comment-form textarea {
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 8px;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-family: inherit;
  resize: vertical;
}
.event-attendee-form-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.event-attendee-empty {
  margin: 0;
}
.event-comments h3 {
  margin: 0 0 12px;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.event-comment-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  font-size: 0.8rem;
  font-weight: 600;
}
.event-comments-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.event-comment-item {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 12px;
}
.event-comment-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.event-comment-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.event-comment-meta strong {
  font-size: 0.9rem;
  color: #1e293b;
}
.event-comment-time {
  font-size: 0.78rem;
  color: #64748b;
}
.event-comment-text {
  margin: 0;
  white-space: pre-wrap;
  font-size: 0.9rem;
  line-height: 1.6;
  color: #334155;
}
.event-comment-empty {
  padding: 8px 0;
  color: #64748b;
}
.event-comment-form textarea {
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 8px;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-family: inherit;
  resize: vertical;
}
  display: block;
  font-size: 0.68rem;
  opacity: 0.85;
  direction: ltr;
  text-align: left;
}
.cal-empty-month {
  text-align: center;
  color: #64748b;
  padding: 24px !important;
}

.event-detail-export { background: #fff; }
.event-detail-print-header h1 { margin: 0 0 8px; }
.event-detail-desc pre { white-space: pre-wrap; background: #f8fafc; padding: 10px; border-radius: 6px; }

/* حضور و غیاب */
.att-calendar-wrap .att-cal-day { cursor: pointer; vertical-align: top; min-height: 88px; }
.att-calendar-wrap .att-day-off { background: #f8fafc; }
.att-calendar-wrap .att-day-leave {
  background: #fff7ed;
  box-shadow: inset 0 0 0 2px #fdba74;
}
.att-calendar-wrap .att-day-mission {
  background: #eef2ff;
  box-shadow: inset 0 0 0 2px #a5b4fc;
}
.att-calendar-wrap .att-day-remote {
  background: #ecfdf5;
  box-shadow: inset 0 0 0 2px #6ee7b7;
}
.att-day-body { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.att-chip { display: inline-block; font-size: 0.68rem; padding: 2px 6px; border-radius: 4px; line-height: 1.3; }
.att-chip-work { background: #dbeafe; color: #1e40af; }
.att-chip-off, .att-chip-holiday { background: #f1f5f9; color: #64748b; }
.att-chip-leave { background: #fef3c7; color: #92400e; font-weight: 600; }
.att-chip-mission { background: #e0e7ff; color: #3730a3; font-weight: 600; }
.att-chip-remote { background: #d1fae5; color: #065f46; font-weight: 600; }
.att-chip-note { background: #fce7f3; color: #9d174d; font-weight: 600; }
.att-personal-note-block {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #e2e8f0;
}
.att-personal-note-editor-host { margin-top: 6px; }
.att-note-editor-toolbar { margin-bottom: 0; }
.att-note-editor { min-height: 120px; }
.att-sum-leave { color: #92400e; }
.att-sum-mission { color: #3730a3; }
.att-sum-remote { color: #065f46; }
.att-mini-slots { font-size: 0.68rem; color: #334155; direction: ltr; text-align: right; }
.att-lock { color: #16a34a; font-size: 0.75rem; }
.att-month-summary { margin: 12px 0; padding: 12px; background: #f8fafc; border-radius: 8px; border: 1px solid #e2e8f0; }
.att-month-summary h4 { margin: 0 0 8px; font-size: 0.95rem; }
.att-summary-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; font-size: 0.85rem; }
.att-note-report-wrap { display: flex; flex-direction: column; gap: 12px; }
.att-note-report-header {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px 16px;
  background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
}
.att-note-report-brand {
  font-size: 0.78rem;
  color: #64748b;
  margin-bottom: 4px;
}
.att-note-report-title {
  margin: 0 0 10px;
  font-size: 1.05rem;
  color: #0f172a;
  border-bottom: 2px solid #0f766e;
  padding-bottom: 8px;
}
.att-note-report-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: 0.88rem;
  color: #334155;
}
.att-note-report-meta em {
  font-style: normal;
  color: #64748b;
  margin-left: 4px;
}
.att-note-report-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.att-note-report-list {
  max-height: 60vh;
  overflow: auto;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px;
  background: #f8fafc;
}
.att-note-report-item {
  margin: 0 0 12px;
  padding: 12px 12px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
}
.att-note-report-item:last-child { margin-bottom: 0; }
.att-note-report-item-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px dashed #cbd5e1;
}
.att-note-report-idx {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #0f766e;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
}
.att-note-report-item h5 { margin: 0; color: #134e4a; }
.att-note-report-body {
  line-height: 1.8;
  color: #334155;
  word-break: break-word;
  background: transparent !important;
  border: 0 !important;
  padding: 0 !important;
}
.att-note-report-body pre {
  white-space: pre-wrap;
  margin: 0;
  font-family: inherit;
  background: transparent;
  padding: 0;
}
.att-settings-panel, .att-timesheet-wrap { padding: 4px 0; }
.att-inline-form { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; align-items: center; }
.att-inline-form input { flex: 1; min-width: 120px; padding: 8px; border: 1px solid #cbd5e1; border-radius: 6px; }
.att-emp-picker { max-width: 640px; margin-bottom: 12px; }
.att-emp-picker-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.att-emp-picker-row select { flex: 1; min-width: 180px; }
.att-staff-report-form { display: flex; flex-direction: column; gap: 0.75rem; }
.att-staff-report-scope { display: flex; flex-wrap: wrap; gap: 1rem; }
.att-staff-report-scope .att-radio { display: inline-flex; align-items: center; gap: 0.35rem; font-weight: 500; }
.att-ym-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.att-ym-row select { min-width: 7rem; }
.att-staff-report-preview {
  margin-top: 0.5rem;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.75rem;
  background: #f8fafc;
}
.att-staff-report-actions { margin-bottom: 0.75rem; }
.att-staff-report-preview-frame {
  max-height: 55vh;
  overflow: auto;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 0.75rem;
}
.att-staff-report-preview-person { margin-bottom: 1.25rem; }
.att-staff-report-preview-person h4 {
  margin: 0 0 0.5rem;
  color: #134e4a;
  border-bottom: 1px solid #cbd5e1;
  padding-bottom: 0.35rem;
}
.att-report-calendar { margin-bottom: 1rem; }
.att-report-month-title { margin: 0 0 0.5rem; font-size: 0.95rem; text-align: center; }
.att-calendar-slim-report .att-report-nonwork { background: #f8fafc; }
.att-calendar-slim-report .att-mini-slots.muted { color: #94a3b8; }

@media print {
  .att-staff-report-actions { display: none !important; }
}
.att-tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.att-slot-row { display: grid; grid-template-columns: auto 1fr auto 1fr; gap: 8px; align-items: center; margin-bottom: 8px; }
.att-ts-row { cursor: pointer; }
.att-ts-row:hover { background: #f8fafc; }
.att-ts-row.att-day-leave { background: #fff7ed; }
.att-ts-row.att-day-mission { background: #eef2ff; }
.att-ts-row.att-day-remote { background: #ecfdf5; }
.badge-ok { background: #dcfce7; color: #166534; padding: 2px 8px; border-radius: 4px; font-size: 0.75rem; }
.att-punch-panel {
  margin-bottom: 16px;
  padding: 16px;
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 1px solid #bae6fd;
  border-radius: 10px;
}
.att-punch-info { margin-bottom: 12px; }
.att-punch-slots { display: block; font-size: 0.9rem; color: #334155; margin-top: 4px; }
.att-punch-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.att-pr-type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.att-pr-type-btn { padding: 14px 12px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.att-prev-slots { background: #f8fafc; padding: 8px 12px; border-radius: 6px; direction: ltr; text-align: right; }
.att-ts-pending { color: #94a3b8; font-size: 0.85rem; }
.att-day-view p { margin: 8px 0; }
.punch-btn-active {
  background: #2563eb !important;
  color: #fff !important;
  border-color: #1d4ed8 !important;
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.35);
}
.punch-btn-idle {
  background: #e2e8f0 !important;
  color: #94a3b8 !important;
  border-color: #cbd5e1 !important;
  cursor: not-allowed;
  opacity: 0.85;
}
.punch-btn-active:not(:disabled):hover {
  background: #1d4ed8 !important;
}
.automation-punch-clock {
  font-size: 1.05rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: #0f172a;
  min-width: 5.5rem;
  text-align: center;
  padding: 4px 8px;
  background: #fff;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
}
.automation-punch-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-right: 8px;
  padding: 4px 10px;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 8px;
}
.automation-punch-hint {
  font-size: 0.78rem;
  color: #475569;
  max-width: 240px;
  line-height: 1.3;
}
.att-timesheet-hint { margin-bottom: 12px; }

/* Emergency group SMS */
.ems-panel h3 { margin-bottom: 0.35rem; }
.ems-table-wrap { overflow-x: auto; margin-top: 1rem; }
.ems-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.ems-table th,
.ems-table td {
  border-bottom: 1px solid #e2e8f0;
  padding: 0.55rem 0.45rem;
  text-align: right;
  vertical-align: top;
}
.ems-table th { color: #64748b; font-weight: 600; font-size: 0.8rem; }
.ems-preview { max-width: 16rem; }
.ems-counts small { color: #64748b; display: block; }
.ems-actions { white-space: nowrap; }
.ems-del { color: #b91c1c !important; }
.ems-status {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: #e2e8f0;
  color: #334155;
}
.ems-status-scheduled { background: #dbeafe; color: #1d4ed8; }
.ems-status-sending { background: #fef3c7; color: #b45309; }
.ems-status-sent { background: #d1fae5; color: #047857; }
.ems-status-partial { background: #ffedd5; color: #c2410c; }
.ems-status-cancelled { background: #f1f5f9; color: #64748b; }
.ems-picker-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.35rem;
}
.ems-picker-head label { margin: 0; flex: 1; }
.ems-picker-block { margin-bottom: 1rem; }
.ems-no-mobile { color: #b45309; }
.ems-body-pre {
  white-space: pre-wrap;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.75rem;
  font-family: inherit;
  font-size: 0.9rem;
}
.ems-form .form-actions { margin-top: 1rem; display: flex; gap: 0.5rem; justify-content: flex-end; }
.ems-detail h4 { margin: 1rem 0 0.5rem; }

/* Regulations (کتابخانه) */
.reg-panel-wrap { display: flex; flex-direction: column; gap: 0.75rem; }
.reg-controls { margin-bottom: 0.25rem; }
.reg-att-list { list-style: none; margin: 0.35rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.reg-att-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.35rem 0.5rem;
  background: rgba(15, 23, 42, 0.04);
  border-radius: 6px;
}
.reg-att-item a { color: inherit; text-decoration: none; }
.reg-att-item a:hover { text-decoration: underline; }
.reg-att-size { color: #64748b; font-size: 0.85em; }
.reg-att-cell { min-width: 10rem; }
.reg-inline-att {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-inline-end: 0.5rem;
  margin-bottom: 0.25rem;
  white-space: nowrap;
}
.reg-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}
.reg-desc { margin-top: 0.35rem; white-space: pre-wrap; }
.reg-comment-cell { white-space: nowrap; text-align: center; }
.reg-comment-count-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 600;
}
.reg-commenters-cell { min-width: 6rem; }
.reg-commenter-stack {
  display: inline-flex;
  align-items: center;
  flex-direction: row-reverse;
  padding-inline-end: 0.25rem;
}
.reg-commenter-avatar {
  display: inline-flex;
  margin-inline-end: -0.4rem;
  border-radius: 50%;
  box-shadow: 0 0 0 2px #fff;
}
.reg-commenter-avatar .user-avatar,
.reg-commenter-avatar .user-avatar-wrap {
  width: 28px;
  height: 28px;
}
.reg-commenter-avatar .user-avatar-sm {
  width: 28px;
  height: 28px;
  font-size: 0.7rem;
}
.reg-commenter-more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  margin-inline-end: -0.4rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  font-size: 0.75rem;
  font-weight: 700;
  box-shadow: 0 0 0 2px #fff;
  z-index: 1;
}
.reg-comments-section {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid #e2e8f0;
}
.reg-comments-title {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.reg-comment-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4rem;
  height: 1.4rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  font-size: 0.8rem;
}
.reg-comment-compose-wrap { margin-bottom: 0.85rem; }
.reg-comment-compose {
  margin-top: 0.6rem;
  padding: 0.75rem;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 10px;
}
.reg-comment-compose textarea {
  width: 100%;
  margin: 0.35rem 0 0.6rem;
  resize: vertical;
}
.reg-comment-form-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.reg-comments-feed {
  list-style: none;
  margin: 0;
  padding: 0;
}
.reg-comment-item {
  padding: 0.65rem 0.75rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  margin-bottom: 0.55rem;
}
.reg-comment-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.4rem;
}
.reg-comment-meta {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}
.reg-comment-time {
  font-size: 0.8rem;
  color: #64748b;
}
.reg-comment-text {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.6;
}
.reg-comment-empty {
  padding: 0.5rem 0;
  color: #64748b;
}

/* Desktop only: fixed top shell + independent scroll regions */
@media (min-width: 1024px) {
  .automation-app {
    height: 100vh;
    overflow: hidden;
  }
  .automation-page-header {
    position: sticky;
    top: 0;
    z-index: 120;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  }
  .automation-layout {
    overflow: hidden;
  }
  .automation-sidebar {
    align-self: stretch;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 0;
    overflow: hidden;
  }
  .automation-sidebar-nav {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 8px 14px;
  }
  .sidebar-profile {
    flex-shrink: 0;
    margin-bottom: 0;
    background: var(--ui-sidebar-bg);
  }
  .automation-layout.nav-rail-collapsed .automation-sidebar {
    padding: 0;
  }
  .automation-layout.nav-rail-collapsed .automation-sidebar-nav {
    padding: 8px 4px 12px;
  }
}

@media (max-width: 768px) {
  .automation-layout { flex-direction: column; }
  .nav-rail-toggle { display: none; }
  .automation-layout.nav-rail-collapsed .automation-sidebar {
    width: 100%;
    padding: 8px;
  }
  .automation-layout.nav-rail-collapsed .sidebar-profile-text,
  .automation-layout.nav-rail-collapsed .sidebar-item span,
  .automation-layout.nav-rail-collapsed .sidebar-section-title span,
  .automation-layout.nav-rail-collapsed .sidebar-section-arrow,
  .automation-layout.nav-rail-collapsed .sidebar-subheader {
    display: unset;
  }
  .automation-layout.nav-rail-collapsed .sidebar-profile-text { display: block; }
  .automation-layout.nav-rail-collapsed .sidebar-item span,
  .automation-layout.nav-rail-collapsed .sidebar-section-title span { display: inline; }
  .automation-layout.nav-rail-collapsed .sidebar-section-arrow { display: inline-block; }
  .automation-layout.nav-rail-collapsed .sidebar-subheader { display: block; }
  .automation-layout.nav-rail-collapsed .sidebar-item,
  .automation-layout.nav-rail-collapsed .sidebar-section-header,
  .automation-layout.nav-rail-collapsed .sidebar-profile {
    justify-content: unset;
  }
  .automation-sidebar {
    width: 100%;
  }
  .automation-sidebar-nav {
    padding: 0 8px 8px;
  }
  .sidebar-profile {
    padding: 8px 8px 10px;
  }
  .sidebar-section { margin-bottom: 10px; }
  .sidebar-section-header { width: 100%; }
  .sidebar-section-content {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    padding: 6px;
  }
  .sidebar-section-content.collapsed { display: none; }
  .sidebar-subheader {
    grid-column: 1 / -1;
    padding: 6px 2px 0;
  }
  .sidebar-item {
    width: 100%;
    border-radius: 6px;
    font-size: 0.86rem;
    padding: 8px 10px;
  }
  .org-chart-layout { flex-wrap: wrap; }
  .org-chart-admin,
  .org-chart-admin.is-collapsed {
    flex: 1 1 100%;
    max-width: 100%;
    min-width: 0;
  }
  .org-chart-admin.is-collapsed {
    min-height: 44px;
    padding: 8px 10px;
  }
  .org-chart-admin.is-collapsed .org-chart-admin-head {
    justify-content: space-between;
  }
  .org-chart-admin.is-collapsed .org-chart-admin-rail-label {
    writing-mode: horizontal-tb;
    transform: none;
    margin: 0;
  }
}
