*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --purple: #1B3A6B;
  --purple-light: #E6EEF7;
  --purple-dark: #142D52;
  --bg: #F9FAFB;
  --white: #FFFFFF;
  --border: #E5E7EB;
  --border-light: #F3F4F6;
  --text: #111827;
  --text-secondary: #6B7280;
  --text-muted: #9CA3AF;
  --yellow: #F59E0B;
  --yellow-bg: #FEF3C7;
  --pink: #EC4899;
  --pink-bg: #FCE7F3;
  --gray-dot: #D1D5DB;
  --sidebar-width: 260px;
  --radius: 6px;
  --radius-sm: 4px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
}

.hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html.nav-access-pending [data-nav-group="admin"] {
  display: none !important;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app {
  display: flex;
  min-height: 100vh;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  transition: width 0.25s ease, min-width 0.25s ease;
}

.sidebar.collapsed {
  width: 72px;
  min-width: 72px;
  overflow: hidden;
}

.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-text,
.sidebar.collapsed .nav-item .chevron,
.sidebar.collapsed .nav-group-header .add-btn,
.sidebar.collapsed .account-info,
.sidebar.collapsed .chevron-updown {
  display: none;
}

.sidebar.collapsed .sidebar-header {
  flex-direction: column;
  align-items: center;
  padding: 16px 8px 8px;
  gap: 8px;
}

.sidebar.collapsed .logo {
  justify-content: center;
}

.sidebar.collapsed .sidebar-nav {
  padding: 0 8px;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 10px;
  gap: 0;
}

.sidebar.collapsed .nav-group-header {
  justify-content: center;
  padding: 0;
  min-height: 0;
}

.sidebar.collapsed .sidebar-footer {
  padding: 8px;
}

.sidebar.collapsed .account-switcher {
  justify-content: center;
  padding: 8px;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 16px 12px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.logo-text {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

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

.icon-btn:hover {
  background: var(--border-light);
  color: var(--text);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px;
}

.nav-group {
  margin-bottom: 20px;
}

.nav-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
}

.nav-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 8px 8px;
}

.nav-group-header .nav-label {
  padding-bottom: 8px;
}

.add-btn {
  width: 24px;
  height: 24px;
  color: var(--text-muted);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 2px;
  transition: background 0.15s, color 0.15s;
  position: relative;
}

.nav-item svg:first-child {
  flex-shrink: 0;
}

.nav-text {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--purple);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav-badge.hidden {
  display: none;
}

.nav-item.active .nav-badge {
  background: var(--purple);
  color: #fff;
}

.sidebar.collapsed .nav-badge {
  display: none;
}

.nav-item:hover {
  background: var(--border-light);
  color: var(--text);
}

.nav-item.active {
  background: var(--purple-light);
  color: var(--purple);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--purple);
  border-radius: 0 3px 3px 0;
}

.nav-item-expandable .chevron {
  margin-left: auto;
  color: var(--text-muted);
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  position: relative;
}

.account-switcher {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}

.account-switcher:hover {
  background: var(--bg);
}

.account-icon {
  width: 32px;
  height: 32px;
  background: var(--purple);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.account-icon--photo {
  background: var(--border-light);
  padding: 0;
}

.account-icon--initial {
  background: var(--purple);
}

.org-avatar-img {
  display: block;
  object-fit: cover;
}

.org-avatar-img--md {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
}

.org-avatar-img--sm {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
}

.org-avatar-initial {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: #fff;
}

.org-avatar-initial--md {
  width: 32px;
  height: 32px;
  font-size: 13px;
}

.org-avatar-initial--sm {
  width: 28px;
  height: 28px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  background: var(--purple);
}

.account-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.account-name {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chevron-updown {
  color: var(--text-muted);
  flex-shrink: 0;
  margin-left: auto;
}

.org-switcher-popover {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(100% + 8px);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 8px;
  z-index: 20;
}

.org-switcher-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 4px 8px 8px;
}

.org-switcher-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 240px;
  overflow-y: auto;
}

.org-switcher-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.org-switcher-item-avatar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.org-switcher-item-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
}

.org-switcher-item:hover {
  background: var(--bg);
}

.org-switcher-item.is-active {
  background: var(--purple-light);
}

.org-switcher-item-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.org-switcher-item-slug {
  font-size: 11px;
  color: var(--text-muted);
}

.org-switcher-empty {
  padding: 12px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* Main */
.main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
}

.breadcrumb {
  font-size: 14px;
  color: var(--text-secondary);
}

.breadcrumb .sep {
  margin: 0 6px;
  color: var(--text-muted);
}

.breadcrumb .current {
  color: var(--text);
  font-weight: 500;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-logout {
  font-size: 13px;
  padding: 6px 12px;
}

.notification-btn {
  position: relative;
}

.notification-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background: #EF4444;
  border-radius: 50%;
  border: 2px solid var(--white);
}

.btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--purple);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--purple);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-outline:hover {
  background: var(--purple-light);
}

.avatar-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
}

.avatar-btn:hover {
  background: var(--border-light);
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.content {
  padding: 24px 28px;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#app-content > .page {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

#app-content > .page.page-scroll {
  overflow-y: auto;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.page.page-table.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.page.page-editor.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.page.page-scroll.active {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.table-error {
  text-align: center;
  padding: 32px;
  color: var(--text-secondary);
}

.table-error code {
  background: var(--border-light);
  padding: 2px 6px;
  border-radius: 3px;
}

.table-error a {
  color: var(--purple);
}

.table-empty-row td {
  border: none;
}

.table-empty-cell {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
}

.table-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  padding: 32px 24px;
  text-align: center;
}

.table-empty-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  margin-bottom: 16px;
  border-radius: 16px;
  background: var(--purple-light);
  color: var(--purple);
}

.table-empty-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.table-empty-desc {
  font-size: 14px;
  color: var(--text-secondary);
  max-width: 360px;
  margin-bottom: 20px;
  line-height: 1.5;
}

.table-empty-action {
  margin-top: 4px;
}

.avatar-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--purple-light);
  color: var(--purple);
}

.records-cell {
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.email-cell {
  color: var(--text-secondary);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.user-avatar.avatar-placeholder {
  font-size: 11px;
  font-weight: 600;
}

/* Analytics */
.analytics-loading,
.analytics-error {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.analytics-error a {
  color: var(--purple);
}

.analytics-error code {
  background: var(--border-light);
  padding: 2px 6px;
  border-radius: 3px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 14px;
  min-width: 0;
  box-shadow: var(--shadow);
}

.stat-label {
  display: block;
  font-size: 12px;
  line-height: 1.35;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.stat-value {
  display: block;
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.2;
  white-space: nowrap;
}

.stat-change {
  display: inline-block;
  margin-top: 8px;
  font-size: 12px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 20px;
}

.stat-change.positive {
  color: #059669;
  background: #D1FAE5;
}

.stat-change.negative {
  color: #DC2626;
  background: #FEE2E2;
}

.analytics-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.analytics-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.analytics-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
}

.analytics-card-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.analytics-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.bar-chart-analytics {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  height: 180px;
  padding-top: 8px;
}

.bar-chart-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  height: 100%;
}

.bar-chart-bar-wrap {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.bar-chart-bar {
  width: 100%;
  max-width: 40px;
  height: var(--h);
  min-height: 8px;
  background: linear-gradient(180deg, #3B5998 0%, var(--purple) 100%);
  border-radius: 4px 4px 2px 2px;
}

.bar-chart-label {
  font-size: 12px;
  color: var(--text-secondary);
}

.status-bars {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.status-bar-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.status-bar-meta {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-secondary);
}

.status-bar-meta strong {
  color: var(--text);
  font-weight: 600;
}

.status-bar-track {
  height: 8px;
  background: var(--border-light);
  border-radius: 4px;
  overflow: hidden;
}

.status-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}

.analytics-table {
  table-layout: fixed;
  width: 100%;
}

.analytics-table .analytics-col-number {
  width: 112px;
}

.analytics-table .analytics-col-duration {
  width: 120px;
}

.analytics-table .analytics-duration-cell {
  white-space: nowrap;
}

.analytics-table th.col-number,
.analytics-table td.col-number {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.reports-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.report-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.report-item:hover {
  background: var(--bg);
}

.report-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.report-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.report-download {
  flex-shrink: 0;
}

.analytics-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 16px;
  margin-bottom: 20px;
  padding: 16px 20px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.analytics-filter {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 140px;
}

.analytics-filter-user {
  min-width: 180px;
  flex: 1;
  max-width: 240px;
}

.analytics-filter-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.analytics-filter input,
.analytics-filter select {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--white);
  color: var(--text);
}

.analytics-card-full {
  margin-bottom: 20px;
}

.analytics-grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.analytics-empty-cell {
  text-align: center;
  color: var(--text-muted);
  padding: 24px 16px !important;
}

.team-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.team-emoji {
  font-size: 16px;
  line-height: 1;
}

@media (max-width: 1100px) {
  .stats-grid:not(.home-stats) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .analytics-grid,
  .analytics-grid-3 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .stats-grid:not(.home-stats) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

/* Table Section */
.table-section {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
}

.tabs {
  display: flex;
  gap: 0;
}

.tab {
  padding: 16px 20px;
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  position: relative;
  transition: color 0.15s;
}

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

.tab.active {
  color: var(--purple);
}

.tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 20px;
  right: 20px;
  height: 2px;
  background: var(--purple);
  border-radius: 2px 2px 0 0;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
  flex-wrap: wrap;
}

.toolbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--text-muted);
}

.toolbar-filter select {
  padding: 7px 28px 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  min-width: 160px;
}

.toolbar-filter select:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 3px var(--purple-light);
}

.toolbar-search input {
  border: none;
  outline: none;
  font-size: 13px;
  width: 160px;
  color: var(--text);
}

.toolbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
}

.toolbar-btn:hover {
  background: var(--bg);
}

.toolbar-btn.icon-only {
  padding: 7px 10px;
}

.selected-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px 6px 14px;
  background: var(--purple);
  color: var(--white);
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.selected-badge.hidden {
  display: none;
}

.selected-badge button {
  background: none;
  border: none;
  color: var(--white);
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
  opacity: 0.8;
  padding: 0 2px;
}

.selected-badge button:hover {
  opacity: 1;
}

/* Table */
.table-wrapper {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table thead {
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 1;
}

.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 14px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background 0.15s;
}

.data-table tbody tr:hover {
  background: #FAFAFA;
}

.data-table tbody tr.selected {
  background: #E6EEF7;
}

.col-check {
  width: 48px;
}

/* Seleção em massa oculta — remover regra abaixo e selectable: true em app.js para reativar */
.col-check,
.selected-badge {
  display: none !important;
}

.data-table th.col-actions,
.data-table td.col-actions {
  text-align: center;
  width: 120px;
  white-space: nowrap;
}

.data-table td.col-actions .action-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

/* Checkbox */
.checkbox {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  position: relative;
}

.checkbox input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.checkmark {
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--border);
  border-radius: 3px;
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.checkbox input:checked + .checkmark {
  background: var(--purple);
  border-color: var(--purple);
}

.checkbox input:checked + .checkmark::after {
  content: '';
  width: 5px;
  height: 9px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  margin-top: -2px;
}

/* Project cell */
.project-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.project-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 12px;
}

.project-icon.purple { background: var(--purple-light); color: var(--purple); }
.project-icon.blue { background: #DBEAFE; color: #2563EB; }
.project-icon.green { background: #D1FAE5; color: #059669; }
.project-icon.orange { background: #FFEDD5; color: #EA580C; }
.project-icon.pink { background: var(--pink-bg); color: var(--pink); }

.workflow-name {
  font-weight: 600;
  color: var(--text);
}

/* Status badge */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-dot.active { background: var(--purple); }
.status-dot.draft { background: var(--gray-dot); }
.status-dot.paused { background: var(--yellow); }

/* Action cell */
.action-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

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

.action-btn:hover {
  background: var(--border-light);
  color: var(--text);
}

.action-run:hover {
  color: var(--purple);
  background: var(--purple-light);
}

.action-edit:hover {
  color: #2563EB;
  background: #DBEAFE;
}

.action-delete:hover {
  color: #DC2626;
  background: #FEE2E2;
}

.desc-cell {
  max-width: 320px;
  color: var(--text-secondary);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.45);
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 48px);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.15);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

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

.modal-header h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 22px;
  line-height: 1;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.modal-close:hover {
  background: var(--border-light);
  color: var(--text-primary);
}

.modal-form {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-intro {
  margin: 0;
}

.modal-run .modal-form {
  padding: 0;
  gap: 0;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.form-label-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.form-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--border-light);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  cursor: help;
  flex-shrink: 0;
}

.form-field-desc {
  display: block;
  margin-top: -2px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-secondary);
  font-weight: 400;
}

.form-field-readonly {
  margin: 0;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text-secondary);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.form-label-optional {
  font-weight: 400;
  color: var(--text-secondary);
}

.credential-auth-intro {
  margin-bottom: 4px;
}

.credential-secret-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-field-checkbox-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.form-field-checkbox-text .form-field-desc {
  margin-top: 0;
}

.form-field input,
.form-field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--white);
  transition: border-color 0.15s;
}

.form-field input:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 3px var(--purple-light);
}

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

.form-field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--white);
  cursor: pointer;
}

.form-field select:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 3px var(--purple-light);
}

.form-field-checkbox {
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
}

.form-field-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--purple);
  cursor: pointer;
}

.form-field-checkbox .form-label {
  margin: 0;
}

.form-field-radio .form-radio-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-field-radio--horizontal .form-radio-group {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 12px 20px;
}

.form-radio-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
}

.form-radio-option input[type="radio"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--purple);
  cursor: pointer;
  flex-shrink: 0;
}

.modal-desc {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.form-empty {
  margin: 0;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
}

.modal-desc-danger {
  color: var(--text-primary);
  font-weight: 500;
}

.modal-delete-warning {
  margin: 0;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.5;
  color: #991B1B;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: var(--radius-sm);
}

.modal-delete-warning.hidden {
  display: none;
}

.modal-footer .modal-btn-danger {
  background: #DC2626;
  color: var(--white);
  border-color: #DC2626;
}

.modal-footer .modal-btn-danger:hover:not(:disabled) {
  background: #B91C1C;
  border-color: #B91C1C;
}

.modal-footer .modal-btn-danger:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.app-name-field {
  display: flex;
  align-items: stretch;
  gap: 10px;
}

.app-name-field > input[type="text"] {
  flex: 1;
  min-width: 0;
}

.app-name-with-icon {
  position: relative;
  flex-shrink: 0;
}

.app-icon-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.app-icon-trigger:hover {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px var(--purple-light);
}

.app-icon-trigger-icon {
  width: 32px;
  height: 32px;
  font-size: 16px;
  border-radius: var(--radius-sm);
  pointer-events: none;
}

.app-icon-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 20;
  width: 260px;
  padding: 14px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.app-icon-popover-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.app-icon-option-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.app-icon-swatches,
.app-icon-emojis {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.app-icon-swatch {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}

.app-icon-swatch.is-selected {
  border-color: var(--text);
  transform: scale(1.05);
}

.app-icon-emoji {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.app-icon-emoji:hover {
  border-color: var(--purple);
  background: var(--purple-light);
}

.app-icon-emoji.is-selected {
  border-color: var(--purple);
  background: var(--purple-light);
  box-shadow: 0 0 0 1px var(--purple);
}

.home-page {
  max-width: 960px;
}

.home-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.home-header h1 {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 4px;
  letter-spacing: -0.02em;
}

.home-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
}

.home-stats {
  margin-bottom: 24px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.stat-card-negative .stat-value {
  color: #DC2626;
}

.home-panel {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.home-panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.home-panel-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.home-panel-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--purple);
  text-decoration: none;
}

.home-panel-link:hover {
  text-decoration: underline;
}

.home-panel-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.home-activity-app {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.home-activity-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--purple);
  text-decoration: none;
}

.home-activity-title:hover {
  text-decoration: underline;
}

.home-activity-subtitle {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted, #64748b);
  line-height: 1.3;
}

.home-app-link {
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
}

.home-app-link:hover {
  color: var(--purple);
}

.home-exec-table .builder-badge {
  font-size: 11px;
  padding: 3px 8px;
}

.home-loading,
.home-error,
.home-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
}

.home-page h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
}

.home-lead {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

.home-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.home-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.home-card:hover {
  border-color: var(--purple);
  box-shadow: 0 4px 12px rgba(27, 58, 107, 0.12);
}

.home-card-title {
  font-size: 15px;
  font-weight: 600;
}

.home-card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 8px;
}

.modal-footer .modal-btn-primary {
  background: var(--purple);
  color: var(--white);
  border-color: var(--purple);
}

.modal-footer .modal-btn-primary:hover {
  background: var(--purple-dark);
  border-color: var(--purple-dark);
}

/* App editor */
.page-editor {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.editor-section {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
  flex: 1;
}

.editor-header {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 20px;
}

.editor-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  width: fit-content;
}

.editor-back:hover {
  color: var(--purple);
}

.editor-title-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
}

.editor-app-icon .project-icon {
  width: 44px;
  height: 44px;
  font-size: 20px;
}

.editor-title {
  font-size: 22px;
  font-weight: 600;
  margin: 0;
}

.editor-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 4px 0 0;
}

.editor-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}

.editor-tab {
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

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

.editor-tab.active {
  color: var(--purple);
  border-bottom-color: var(--purple);
}

.editor-panels {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.editor-panel {
  display: none;
  flex: 1;
  min-height: 0;
  padding-top: 20px;
}

.editor-panel.active {
  display: flex;
  flex-direction: column;
}

.builder-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  flex: 1;
  min-height: 0;
}

.builder-sidebar,
.builder-canvas {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  overflow: auto;
}

.builder-heading {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 6px;
}

.builder-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 16px;
}

.builder-form-preview {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-empty {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
}

.builder-canvas-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.builder-badge {
  font-size: 12px;
  padding: 4px 10px;
  background: var(--bg-secondary);
  border-radius: 999px;
  color: var(--text-secondary);
}

.task-result {
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 999px;
}

.task-result-approved {
  background: rgba(34, 197, 94, 0.12);
  color: #16a34a;
}

.task-result-rejected {
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
}

.task-result-neutral {
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

.task-expires-soon {
  color: #b45309;
  font-weight: 500;
}

.task-expires-overdue {
  color: #dc2626;
  font-weight: 600;
}

.task-expires-none {
  color: var(--text-muted, #9ca3af);
}

.task-expires-na {
  color: var(--text-muted, #9ca3af);
}

.task-notify-message {
  white-space: pre-wrap;
  line-height: 1.5;
  padding: 14px 16px;
  border-radius: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text);
  overflow-wrap: anywhere;
  word-break: break-word;
  max-height: min(50vh, 360px);
  overflow-x: hidden;
  overflow-y: auto;
  flex-shrink: 1;
  min-height: 0;
}

.builder-steps {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 420px;
  margin: 0 auto;
}

.builder-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
}

.builder-step-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.builder-step-icon.start {
  background: rgba(27, 58, 107, 0.1);
  color: var(--purple);
}

.builder-step-icon.process {
  background: var(--bg-secondary);
}

.builder-step-icon.end {
  background: rgba(34, 197, 94, 0.12);
  color: #16a34a;
}

.builder-step-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 6px;
}

.builder-step-body strong {
  font-size: 14px;
}

.builder-step-body span {
  font-size: 12px;
  color: var(--text-secondary);
}

.builder-step-line {
  width: 2px;
  height: 24px;
  background: var(--border);
  margin-left: 17px;
}

.executions-section {
  flex: 1;
  min-height: 0;
}

.executions-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-secondary);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.exec-status {
  display: inline-block;
  font-size: 12px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 999px;
}

.exec-status-success {
  background: rgba(34, 197, 94, 0.12);
  color: #16a34a;
}

.exec-status-error {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
}

.exec-status-running {
  background: rgba(59, 130, 246, 0.12);
  color: #2563eb;
}

.exec-status-pending {
  background: rgba(245, 158, 11, 0.14);
  color: #b45309;
}

@media (max-width: 900px) {
  .builder-layout {
    grid-template-columns: 1fr;
  }
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    z-index: 100;
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .content {
    padding: 16px;
  }

  .table-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-actions {
    justify-content: flex-start;
  }
}

.audit-table .audit-user-cell {
  vertical-align: top;
}

.audit-user-name {
  display: block;
  font-weight: 600;
  line-height: 1.35;
}

.audit-user-email {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.35;
}

.audit-action-cell {
  line-height: 1.5;
}

.audit-table th.audit-col-module,
.audit-table td.audit-col-module {
  width: 140px;
  white-space: nowrap;
  vertical-align: top;
}

.audit-table th.audit-col-date,
.audit-date-cell {
  text-align: right;
  white-space: nowrap;
  width: 220px;
  padding-right: 24px;
}
