/* ═══════════════════════════════════════════════════════════════════════
   Expat Payroll Admin Dashboard – Styles
   Brand colours:
     Primary blue   #5B9BD5 / #6DAEE0
     Green accent   #8DC63F / #78B52E
     Dark nav       #2B3A4C / #1F2D3D
     Light bg       #f4f6f9
   ═══════════════════════════════════════════════════════════════════════ */

:root {
  --blue:         #5B9BD5;
  --blue-light:   #6DAEE0;
  --blue-pale:    #EBF4FB;
  --green:        #8DC63F;
  --green-dark:   #78B52E;
  --green-pale:   #F0F9E6;
  --dark:         #2B3A4C;
  --darker:       #1F2D3D;
  --bg:           #f4f6f9;
  --white:        #ffffff;
  --text:         #2D3748;
  --text-mid:     #4A5568;
  --text-light:   #718096;
  --border:       #E2E8F0;
  --shadow:       0 2px 12px rgba(0, 0, 0, 0.06);
  --shadow-md:    0 4px 24px rgba(0, 0, 0, 0.10);
  --radius:       10px;
  --radius-sm:    6px;
  --sidebar-w:    260px;
  --sidebar-collapsed-w: 68px;
  --topbar-h:     64px;
  --content-w:    1140px;
  --orange:       #F0A500;
  --orange-pale:  #FFF8E6;
  --red:          #E05555;
  --red-pale:     #FDF0F0;
  --purple:       #7C5CBF;
  --purple-pale:  #F3F0FD;
  --font:         'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

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

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--dark) 0%, var(--darker) 100%);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width 0.28s ease, transform 0.28s ease;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  overflow-x: hidden;
}

/* ── Sidebar Collapse Toggle ─────────────────────────────────────────────── */
.sidebar-collapse-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.4);
  cursor: pointer;
  padding: 6px;
  border-radius: 4px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
}
.sidebar-collapse-btn:hover { color: #fff; background: rgba(255,255,255,0.08); }
.sidebar-collapse-btn .material-symbols-outlined { font-size: 20px; }

/* Collapsed sidebar state */
.sidebar.collapsed {
  width: var(--sidebar-collapsed-w);
}
.sidebar.collapsed ~ .main {
  margin-left: var(--sidebar-collapsed-w);
}
.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-item > span:not(.nav-icon),
.sidebar.collapsed .sidebar-footer {
  opacity: 0;
  width: 0;
  overflow: hidden;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.15s;
}
.sidebar.collapsed .sidebar-logo {
  padding: 22px 13px;
  gap: 0;
}
.sidebar.collapsed .sidebar-collapse-btn {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  margin-left: 0;
}
.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 11px 0;
  border-left-color: transparent;
}
.sidebar.collapsed .nav-item.active {
  border-left-color: transparent;
  background: rgba(141, 198, 63, 0.15);
}
.sidebar.collapsed .nav-icon {
  width: 100%;
  text-align: center;
}
.sidebar.collapsed .sidebar-collapse-btn .material-symbols-outlined {
  transform: rotate(180deg);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  position: relative;
}

.logo-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.logo-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.logo-text { display: flex; flex-direction: column; transition: opacity 0.2s; }
.logo-main { font-size: 14px; font-weight: 700; color: #fff; line-height: 1.2; }
.logo-sub  { font-size: 11px; color: rgba(255, 255, 255, 0.45); margin-top: 2px; }

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.58);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s;
  text-decoration: none;
  border-left: 3px solid transparent;
  white-space: nowrap;
  overflow: hidden;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
}

.nav-item.active {
  background: rgba(141, 198, 63, 0.15);
  color: #fff;
  border-left-color: var(--green);
  padding-left: 11px;
}

/* Hide Inspection nav on mobile/tablet */
.nav-item[data-section="inspection"].mobile-hidden { display: none; }
.nav-item[data-section="debug"].mobile-hidden { display: none; }

.nav-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-icon .material-symbols-outlined { font-size: 20px; }

.sidebar-footer {
  padding: 14px 20px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.22);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  transition: opacity 0.2s;
  white-space: nowrap;
}

/* ── Main ────────────────────────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.28s ease;
}

/* ── Topbar ──────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  z-index: 50;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.topbar-left  { display: flex; align-items: center; gap: 16px; }
.topbar-right { display: flex; align-items: center; gap: 20px; }

.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-light);
  padding: 4px 6px;
  border-radius: 4px;
  transition: background 0.2s;
}
.menu-toggle:hover { background: var(--bg); }

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

.topbar-date { font-size: 13px; color: var(--text-light); }

.topbar-bell {
  position: relative;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}

.alert-dot {
  position: absolute;
  top: 0;
  right: 0;
  width: 8px;
  height: 8px;
  background: var(--red);
  border-radius: 50%;
}

/* ── Notification Dropdown ─────────────────────────────────────────────── */
.notification-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  width: 360px;
  max-height: 420px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 210;
  display: none;
  overflow: hidden;
  margin-top: 8px;
}
.notification-dropdown.open { display: block; animation: modalIn 0.18s ease; }

.notification-dropdown-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  font-size: 14px; font-weight: 700; color: var(--text);
}

.notification-list {
  max-height: 320px; overflow-y: auto; padding: 8px 0;
}

.notification-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 16px; cursor: pointer; transition: background 0.15s;
  border-left: 3px solid transparent;
}
.notification-item:hover { background: var(--bg); }
.notification-item.priority-high   { border-left-color: var(--red); }
.notification-item.priority-medium { border-left-color: var(--orange); }
.notification-item.priority-low    { border-left-color: var(--blue); }
.notification-item.priority-info   { border-left-color: #ccc; }

.notification-icon { flex-shrink: 0; font-size: 18px; padding-top: 1px; }
.notification-item.priority-high   .notification-icon { color: var(--red); }
.notification-item.priority-medium .notification-icon { color: var(--orange); }
.notification-item.priority-low    .notification-icon { color: var(--blue); }
.notification-item.priority-info   .notification-icon { color: var(--text-light); }

.notification-body { flex: 1; min-width: 0; }
.notification-title { font-size: 13px; font-weight: 600; color: var(--text); line-height: 1.3; }
.notification-detail { font-size: 12px; color: var(--text-light); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notification-time { font-size: 11px; color: var(--text-light); margin-top: 3px; }

.notification-dropdown-footer {
  padding: 10px 16px; border-top: 1px solid var(--border);
  text-align: center;
}

/* ── Notification Badge (bell count) ─────────────────────────────────────── */
.notification-badge {
  position: absolute; top: -4px; right: -6px;
  background: var(--red); color: #fff; font-size: 10px; font-weight: 700;
  min-width: 18px; height: 18px; line-height: 18px;
  text-align: center; border-radius: 10px;
  padding: 0 4px; display: none;
}
.notification-badge.visible { display: block; }

/* ── Notification Modal (full list) ──────────────────────────────────────── */
.notification-modal-list {
  max-height: 60vh; overflow-y: auto;
}
.notification-modal-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 0; border-bottom: 1px solid #f1f3f5;
}
.notification-modal-item:last-child { border-bottom: none; }
.notification-modal-item .notification-icon { font-size: 22px; }
.notification-modal-item .notification-title { font-size: 14px; }
.notification-modal-item .notification-detail { font-size: 13px; white-space: normal; }

/* Priority filter tabs */
.notification-filter-tabs {
  display: flex; gap: 0; margin-bottom: 16px; border-bottom: 2px solid var(--border);
}
.notification-filter-tab {
  padding: 8px 16px; font-size: 12px; font-weight: 600; font-family: var(--font);
  color: var(--text-light); background: none; border: none;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  cursor: pointer; transition: all 0.2s;
}
.notification-filter-tab:hover { color: var(--blue); }
.notification-filter-tab.active { color: var(--blue); border-bottom-color: var(--blue); }

/* ── Debug Section ───────────────────────────────────────────────────────── */
.debug-error-list { max-height: 400px; overflow-y: auto; }

.debug-entry {
  padding: 14px 16px;
  border-bottom: 1px solid #f1f3f5;
  font-size: 13px;
}
.debug-entry:last-child { border-bottom: none; }

.debug-entry-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
}
.debug-entry-title { font-weight: 600; color: var(--text); }
.debug-entry-time  { font-size: 11px; color: var(--text-light); }

.debug-entry-message {
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 12px; line-height: 1.6; color: var(--red);
  background: #fff5f5; padding: 8px 10px;
  border-radius: var(--radius-sm); border: 1px solid #fed7d7;
  white-space: pre-wrap; word-break: break-word;
  max-height: 200px; overflow-y: auto;
}

.debug-entry-context {
  font-size: 11px; color: var(--text-light); margin-top: 6px;
}

.debug-entry.priority-high   { border-left: 3px solid var(--red); }
.debug-entry.priority-medium { border-left: 3px solid var(--orange); }
.debug-entry.priority-low    { border-left: 3px solid var(--blue); }

.topbar-employee {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.employee-avatar {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--green) 0%, var(--blue) 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

/* ── Content ─────────────────────────────────────────────────────────────── */
.content {
  flex: 1;
  padding: 28px;
  width: var(--content-w);
  max-width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.content > .section {
  width: 100%;
  max-width: var(--content-w);
}

.section { display: none; }
.section.active { display: block; }

.section-header { margin-bottom: 24px; }
.section-header h2 { font-size: 20px; font-weight: 700; color: var(--text); }
.section-desc { font-size: 14px; color: var(--text-light); margin-top: 5px; }

/* ── Stats Grid ──────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: box-shadow 0.2s;
}
.stat-card:hover { box-shadow: var(--shadow-md); }

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.stat-icon .material-symbols-outlined { font-size: 26px; }

.stat-icon.blue   { background: var(--blue-pale);   }
.stat-icon.green  { background: var(--green-pale);  }
.stat-icon.orange { background: var(--orange-pale); }
.stat-icon.purple { background: var(--purple-pale); }

.stat-value { font-size: 30px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-light); margin-top: 4px; }

/* ── Panel ───────────────────────────────────────────────────────────────── */
.panel {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 24px;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 10px;
}

.panel-title { font-size: 15px; font-weight: 700; color: var(--text); }

.panel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.panel-body { padding: 22px; }

/* ── Flow Cards ──────────────────────────────────────────────────────────── */
.flows-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.flow-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: box-shadow 0.2s, transform 0.2s;
}
.flow-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.flow-card-top { padding: 22px 22px 16px; }

.flow-icon-name {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.flow-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  color: #fff;
}
.flow-icon .material-symbols-outlined { font-size: 24px; }

.flow-name { font-size: 15px; font-weight: 700; color: var(--text); }
.flow-desc { font-size: 13px; color: var(--text-light); line-height: 1.55; }

.flow-card-bottom {
  padding: 14px 22px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.flow-meta { font-size: 11px; color: var(--text-light); margin-top: 5px; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
  font-family: var(--font);
  line-height: 1;
}

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-light) 100%);
  color: #fff;
  box-shadow: 0 3px 10px rgba(91, 155, 213, 0.3);
}
.btn-primary:hover:not(:disabled) {
  box-shadow: 0 4px 16px rgba(91, 155, 213, 0.45);
  transform: translateY(-1px);
}

.btn-green {
  background: linear-gradient(135deg, var(--green) 0%, var(--green-dark) 100%);
  color: #fff;
  box-shadow: 0 3px 10px rgba(140, 198, 63, 0.3);
}
.btn-green:hover:not(:disabled) {
  box-shadow: 0 4px 16px rgba(140, 198, 63, 0.45);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: var(--blue);
  border: 1.5px solid var(--blue);
}
.btn-outline:hover:not(:disabled) { background: var(--blue-pale); }

.btn-danger {
  background: transparent;
  color: var(--red);
  border: 1.5px solid var(--red);
}
.btn-danger:hover:not(:disabled) { background: var(--red-pale); }

.btn-reactivate {
  background: transparent;
  color: var(--green-dark);
  border: 1.5px solid var(--green);
}
.btn-reactivate:hover:not(:disabled) { background: var(--green-pale); }

.btn-sm  { padding: 7px 14px; font-size: 12px; }
.btn-xs  { padding: 4px 10px; font-size: 11px; border-radius: 4px; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  line-height: 1.6;
}

.badge-green  { background: var(--green-pale);  color: var(--green-dark); }
.badge-blue   { background: var(--blue-pale);   color: var(--blue);       }
.badge-orange { background: var(--orange-pale); color: #b07200;           }
.badge-red    { background: var(--red-pale);    color: var(--red);        }
.badge-grey   { background: #f0f0f0;            color: #888;              }
.badge-purple { background: var(--purple-pale); color: var(--purple);     }

/* ── Data Table ──────────────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th {
  background: #f8fafc;
  color: var(--text-light);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 13px 16px;
  border-bottom: 1px solid #f1f3f5;
  color: var(--text-mid);
  vertical-align: middle;
}

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

.td-name    { font-weight: 600; color: var(--text); }
.td-email   { color: var(--text-light); font-size: 13px; }
.td-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.loading-cell {
  text-align: center;
  color: var(--text-light);
  padding: 40px !important;
  font-style: italic;
}

/* ── Form Inputs ─────────────────────────────────────────────────────────── */
.search-input,
.filter-select {
  padding: 8px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font);
  color: var(--text);
  background: var(--white);
  outline: none;
  transition: border-color 0.2s;
}

.search-input { min-width: 200px; }
.search-input:focus,
.filter-select:focus { border-color: var(--blue); }

/* ── Activity Log ────────────────────────────────────────────────────────── */
.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid #f1f3f5;
}
.activity-item:last-child { border-bottom: none; }

.activity-icon-wrap {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.activity-body    { flex: 1; min-width: 0; }
.activity-title   { font-size: 14px; font-weight: 600; color: var(--text); }
.activity-detail  { font-size: 12px; color: var(--text-light); margin-top: 2px; }
.activity-time    { font-size: 11px; color: var(--text-light); margin-top: 4px; }
.activity-status  { flex-shrink: 0; }

/* ── Alerts ──────────────────────────────────────────────────────────────── */
.alert-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  font-size: 13px;
}
.alert-item:last-child { margin-bottom: 0; }

.alert-item.warning { background: var(--orange-pale); border-left: 4px solid var(--orange); }
.alert-item.error   { background: var(--red-pale);    border-left: 4px solid var(--red);    }
.alert-item.info    { background: var(--blue-pale);   border-left: 4px solid var(--blue);   }

.alert-icon { font-size: 16px; flex-shrink: 0; line-height: 1.5; }
.alert-text { color: var(--text-mid); line-height: 1.55; }
.alert-text strong { color: var(--text); }

/* ── Empty State ─────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  color: var(--text-light);
  padding: 36px 20px;
  font-size: 14px;
}

/* ── Link Button ─────────────────────────────────────────────────────────── */
.link-btn {
  font-size: 13px;
  color: var(--blue);
  font-weight: 600;
  cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(2px);
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--white);
  border-radius: 14px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.2);
  width: 480px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(10px); }
  to   { opacity: 1; transform: scale(1)    translateY(0);    }
}

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

.modal-title { font-size: 17px; font-weight: 700; color: var(--text); }

.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-light);
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.2s;
  line-height: 1;
}
.modal-close:hover { background: var(--bg); }

.modal-body   { padding: 22px 24px; }

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Form elements inside modal */
.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}
.form-input:focus { border-color: var(--blue); }

.modal-flow-desc {
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 22px;
  line-height: 1.6;
  padding: 14px 16px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

/* ── Toast Notifications ─────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 300;
}

.toast {
  background: var(--white);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.14);
  padding: 13px 18px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
  max-width: 360px;
  border-left: 4px solid var(--blue);
  animation: toastIn 0.25s ease;
}

.toast.success { border-left-color: var(--green); }
.toast.error   { border-left-color: var(--red);   }
.toast.warning { border-left-color: var(--orange); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0);    }
}

/* ── Spinner ─────────────────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

.spinner.dark {
  border-color: rgba(91, 155, 213, 0.25);
  border-top-color: var(--green);
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Demo Mode Banner ────────────────────────────────────────────────────── */
.demo-banner {
  background: linear-gradient(90deg, #fff8e6 0%, #fff3d0 100%);
  border-bottom: 1px solid #f0d080;
  padding: 8px 28px;
  font-size: 12px;
  color: #8a6200;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .content { width: 100%; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); width: var(--sidebar-w); }
  .sidebar.collapsed { width: var(--sidebar-w); } /* No collapse on mobile, full slide */
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-md); }
  .sidebar-collapse-btn { display: none; } /* hide collapse on mobile */
  .main { margin-left: 0; }
  .sidebar.collapsed ~ .main { margin-left: 0; }
  .menu-toggle { display: block; }
  .topbar-date { display: none; }
  .content { padding: 20px 16px; width: 100%; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .panel-header { flex-direction: column; align-items: flex-start; }
  .panel-actions { width: 100%; }
  .search-input { min-width: 100%; width: 100%; }
  .flows-grid { grid-template-columns: 1fr; }
  /* Hide Inspection + Debug on mobile */
  .nav-item[data-section="inspection"] { display: none !important; }
  .nav-item[data-section="debug"] { display: none !important; }
  #section-inspection { display: none !important; }
  #section-debug { display: none !important; }
  /* Notification dropdown full-width on mobile */
  .notification-dropdown { width: calc(100vw - 32px); right: -60px; }
  #user-name { display: none; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 24px; }
  .topbar { padding: 0 16px; }
  .topbar-user span:not(.material-symbols-outlined) { display: none; }
  .notification-dropdown { right: -100px; }
}
/* ── Login Overlay ───────────────────────────────────────────────────────── */
.login-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(145deg, #f4f6f9 0%, #EBF4FB 50%, #F0F9E6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 20px;
}

.login-card {
  background: var(--white);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.13);
  width: 420px;
  max-width: 100%;
  overflow: hidden;
  border: 1px solid var(--border);
}

.login-card-header {
  background: linear-gradient(135deg, var(--dark) 0%, var(--darker) 100%);
  padding: 36px 36px 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.login-logo-img {
  max-width: 220px;
  height: auto;
  margin-bottom: 8px;
}

.login-logo-tagline {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 2px;
  text-transform: uppercase;
  font-weight: 600;
}

.login-logo-icon {
  display: none;
}

.login-logo-text  { display: none; }
.login-logo-main  { display: none; }
.login-logo-sub   { display: none; }

.login-card-body {
  padding: 36px 36px 28px;
}

.login-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}

.login-desc {
  font-size: 14px;
  color: var(--text-light);
  line-height: 1.6;
  margin-bottom: 28px;
}

/* Microsoft branded sign-in button */
.btn-microsoft {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px 20px;
  background: #fff;
  border: 1.5px solid #8c8c8c;
  border-radius: 4px;
  font-size: 15px;
  font-weight: 600;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: #1a1a1a;
  cursor: pointer;
  transition: background 0.18s, box-shadow 0.18s;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.btn-microsoft:hover:not(:disabled) {
  background: #f3f3f3;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.btn-microsoft:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.login-error {
  margin-top: 18px;
  padding: 12px 16px;
  background: var(--red-pale);
  border-left: 4px solid var(--red);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--red);
  line-height: 1.55;
}

.login-card-footer {
  text-align: center;
  padding: 16px;
  font-size: 11px;
  color: var(--text-light);
  border-top: 1px solid var(--border);
  background: #fafbfc;
}

/* Topbar user with logout button */
.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.user-avatar {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--green) 0%, var(--blue) 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── Add Flow Card ───────────────────────────────────────────────────────── */
.flow-card-add {
  border: 2px dashed var(--border);
  background: var(--bg);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
}

.flow-card-add:hover {
  border-color: var(--blue);
  background: var(--blue-pale);
  transform: translateY(-2px);
}

.flow-add-inner {
  text-align: center;
  padding: 20px;
}

.flow-add-icon {
  font-size: 36px;
  color: var(--blue);
  margin-bottom: 8px;
  line-height: 1;
}

.flow-add-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-light);
}

.flow-card-add:hover .flow-add-text {
  color: var(--blue);
}

/* ── Flow Admin Actions (Edit + Delete) ───────────────────────────────────── */
.flow-admin-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
  flex-shrink: 0;
}

.flow-edit-btn {
  color: var(--blue);
  border-color: var(--blue);
}
.flow-edit-btn:hover {
  background: var(--blue);
  color: #fff;
}

.flow-delete-btn {
  flex-shrink: 0;
}

.flow-icon-name {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

/* ── Form Rows (Add Flow Modal) ──────────────────────────────────────────── */
.form-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.form-group-half {
  flex: 1;
}

.form-group-third {
  flex: 1;
}

.form-section-divider {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-light);
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: 8px;
  margin-bottom: 8px;
}

.form-help {
  font-size: 12px;
  color: var(--text-light);
  margin-bottom: 14px;
  line-height: 1.5;
}

/* ── Flow Input Row (dynamic inputs in add-flow modal) ───────────────────── */
.flow-input-row {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 10px;
}

.flow-input-remove {
  margin-bottom: 18px;
  align-self: flex-end;
}

/* ── Auth Gate Centering ─────────────────────────────────────────────────── */
.login-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Material Symbols – Panel Title Icon ─────────────────────────────────── */
.panel-title-icon {
  font-size: 18px;
  vertical-align: middle;
  margin-right: 4px;
}

/* ── Material Symbols – Badge Icon ───────────────────────────────────────── */
.badge-icon {
  font-size: 14px;
  vertical-align: middle;
  margin-right: 2px;
}

/* ── Material Symbols – Spin Animation ───────────────────────────────────── */
.spin-icon {
  animation: spin 0.7s linear infinite;
}

/* ── Material Symbols – Toast Icon ───────────────────────────────────────── */
.toast-icon {
  font-size: 20px;
  flex-shrink: 0;
}
.toast.success .toast-icon { color: var(--green-dark); }
.toast.error   .toast-icon { color: var(--red); }
.toast.warning .toast-icon { color: var(--orange); }
.toast.info    .toast-icon { color: var(--blue); }

/* ── Material Symbols – Activity Icon ────────────────────────────────────── */
.activity-icon-wrap .material-symbols-outlined {
  font-size: 20px;
  color: var(--text-light);
}

/* ── Material Symbols – Alert Icon ───────────────────────────────────────── */
.alert-icon .material-symbols-outlined {
  font-size: 20px;
}

/* ── Icon Picker (Add Flow Modal) ────────────────────────────────────────── */
.icon-picker-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-picker-preview {
  width: 40px;
  height: 40px;
  background: var(--blue);
  color: #fff;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.icon-picker-select {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
  background: var(--white);
}
.icon-picker-select:focus { border-color: var(--blue); }

/* ── Boolean Toggle (Yes/No input) ───────────────────────────────────────── */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding: 8px 0;
}

.toggle-input {
  display: none;
}

.toggle-slider {
  position: relative;
  width: 44px;
  height: 24px;
  background: #ccc;
  border-radius: 24px;
  transition: background 0.25s;
  flex-shrink: 0;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.25s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-input:checked + .toggle-slider {
  background: var(--green);
}

.toggle-input:checked + .toggle-slider::after {
  transform: translateX(20px);
}

.toggle-label-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-mid);
}

/* ── Topbar Bell Material Icon ───────────────────────────────────────────── */
.topbar-bell .material-symbols-outlined {
  font-size: 22px;
  color: var(--text-light);
}

/* ── Add Flow Card Icon ──────────────────────────────────────────────────── */
.flow-add-icon .material-symbols-outlined {
  font-size: 40px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Inspection (Ollama AI) Styles
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Status Bar ──────────────────────────────────────────────────────────── */
.inspection-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 14px 22px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.inspection-status-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.inspection-status-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.inspection-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: #ccc;
  transition: background 0.3s;
}

.inspection-status-dot.connected {
  background: var(--green);
  box-shadow: 0 0 6px rgba(141, 198, 63, 0.5);
}

.inspection-status-dot.disconnected {
  background: var(--red);
  box-shadow: 0 0 6px rgba(224, 85, 85, 0.4);
}

.inspection-status-dot.checking {
  background: var(--orange);
  animation: pulse-dot 1s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.inspection-status-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-mid);
}

/* ── Tab Switcher ────────────────────────────────────────────────────────── */
.inspection-input-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--border);
}

.inspection-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  color: var(--text-light);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: all 0.2s;
}

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

.inspection-tab.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

.inspection-tab-content {
  display: none;
}

.inspection-tab-content.active {
  display: block;
}

/* ── Textarea ────────────────────────────────────────────────────────────── */
.inspection-textarea {
  resize: vertical;
  min-height: 160px;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.6;
}

/* ── Drop Zone ───────────────────────────────────────────────────────────── */
.inspection-drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.inspection-drop-zone:hover,
.inspection-drop-zone.drag-over {
  border-color: var(--blue);
  background: var(--blue-pale);
}

.inspection-drop-zone p {
  font-size: 14px;
  color: var(--text-mid);
  margin: 0;
}

/* ── File Info ────────────────────────────────────────────────────────────── */
.inspection-file-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--green-pale);
  border: 1px solid var(--green);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

/* ── Result Display ──────────────────────────────────────────────────────── */
.inspection-result-content {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
}

.inspection-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 20px;
}

.inspection-field {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--blue);
}

.inspection-field-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
  min-width: 100px;
  flex-shrink: 0;
  padding-top: 2px;
}

.inspection-field-value {
  font-size: 14px;
  color: var(--text);
  font-weight: 600;
}

.inspection-raw {
  margin-top: 12px;
}

.inspection-raw summary {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
  cursor: pointer;
  padding: 8px 0;
}

.inspection-raw-text {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-size: 13px;
  font-family: 'Consolas', 'Courier New', monospace;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
  color: var(--text-mid);
  max-height: 400px;
  overflow-y: auto;
}

.inspection-meta {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-light);
}

/* ── JSON Result Display ─────────────────────────────────────────────────── */
.inspection-json-result {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.inspection-doctype-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 22px;
  background: linear-gradient(135deg, var(--blue-pale) 0%, var(--white) 100%);
  border: 1.5px solid var(--blue-light);
  border-radius: var(--radius);
  box-shadow: 0 2px 8px rgba(74, 144, 196, 0.08);
}

.inspection-doctype-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
}

.inspection-doctype-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

/* ── SharePoint Actions ──────────────────────────────────────────────────── */
.inspection-sp-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 4px;
}

.inspection-sp-status {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-mid);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ── Parse Warning ───────────────────────────────────────────────────────── */
.inspection-parse-warning {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: #8d6e00;
  margin-bottom: 12px;
}

/* ── Large Modal Variant ─────────────────────────────────────────────────── */
.modal.modal-lg {
  max-width: 720px;
  width: 90%;
}

.modal.modal-lg .inspection-raw-text {
  max-height: 500px;
}

/* ── Pipeline Status Steps ───────────────────────────────────────────────── */
.inspection-pipeline {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pipeline-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-light);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: all 0.3s;
}

.pipeline-step.active {
  color: var(--blue);
  background: var(--blue-pale);
}

.pipeline-step.active .material-symbols-outlined {
  animation: spin 0.7s linear infinite;
}

.pipeline-step.done {
  color: var(--green-dark);
}

.pipeline-step.done .material-symbols-outlined {
  color: var(--green);
}

.pipeline-step.warning {
  color: #8d6e00;
  background: #fff8e1;
}

.pipeline-step.warning .material-symbols-outlined {
  color: var(--orange);
}

.pipeline-step.error {
  color: var(--red);
  background: #fff0f0;
}

.pipeline-step.error .material-symbols-outlined {
  color: var(--red);
}

/* ── Low Confidence DocType Card ─────────────────────────────────────────── */
.inspection-doctype-card.low-confidence {
  background: linear-gradient(135deg, #fff8e1 0%, var(--white) 100%);
  border-color: var(--orange);
}

/* ── Review Queue ────────────────────────────────────────────────────────── */
.review-queue-item {
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--orange);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}

.review-queue-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.review-queue-time {
  font-size: 11px;
  color: var(--text-light);
}

.review-queue-preview {
  font-size: 13px;
  color: var(--text-mid);
  line-height: 1.5;
  max-height: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 8px;
  font-family: 'Consolas', 'Courier New', monospace;
  white-space: pre-wrap;
}

.review-queue-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: var(--text-light);
  margin-bottom: 10px;
}

.review-queue-meta strong {
  color: var(--text);
}

.review-queue-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.review-doctype-select {
  min-width: 200px;
  font-size: 13px;
}


/* ═══════════════════════════════════════════════════════════════════════
   FORMS MANAGEMENT
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Forms Tabs ──────────────────────────────────────────────────────── */
.forms-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: var(--white);
  padding: 6px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.forms-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.18s;
}

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

.forms-tab.active {
  background: var(--blue-pale);
  color: var(--blue);
  font-weight: 600;
}

.forms-tab-content { display: none; }
.forms-tab-content.active { display: block; }

/* ── Forms Grid (template cards) ─────────────────────────────────────── */
.forms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.form-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: box-shadow 0.2s;
}

.form-card:hover {
  box-shadow: var(--shadow);
}

.form-card-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.form-card-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
}

.form-card-icon .material-symbols-outlined { font-size: 22px; }

.form-card-info { flex: 1; min-width: 0; }

.form-card-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.form-card-desc {
  font-size: 13px;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.form-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.form-card-meta {
  font-size: 12px;
  color: var(--text-light);
}

.form-card-perms {
  margin-top: 4px;
}

.form-admin-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.form-card-add {
  border: 2px dashed var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 140px;
}

.form-card-add:hover {
  border-color: var(--blue);
  background: var(--blue-pale);
}

.form-add-inner { text-align: center; }

.form-add-icon .material-symbols-outlined {
  font-size: 36px;
  color: var(--blue);
}

.form-add-text {
  font-size: 14px;
  color: var(--text-light);
  margin-top: 4px;
}

/* ── Active Forms List ───────────────────────────────────────────────── */
.active-form-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.active-form-card:last-child { border-bottom: none; }

.active-form-left { flex: 1; min-width: 0; }

.active-form-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.active-form-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: 12px;
  color: var(--text-light);
}

.active-form-right {
  flex-shrink: 0;
  margin-left: 16px;
}

/* ── Submissions List ────────────────────────────────────────────────── */
.submission-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

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

.submission-icon {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
}

.submission-icon .material-symbols-outlined { font-size: 20px; }

.submission-body { flex: 1; min-width: 0; }

.submission-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.submission-meta {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 2px;
}

.submission-data {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.sub-data-item {
  font-size: 12px;
  color: var(--text-mid);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 4px;
}

.submission-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 24px;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.submission-detail-row {
  display: flex;
  padding: 8px 0;
  border-bottom: 1px solid var(--bg);
}

.submission-detail-label {
  width: 180px;
  flex-shrink: 0;
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}

.submission-detail-value {
  flex: 1;
  font-size: 13px;
  color: var(--text-mid);
}

/* ── Users List ──────────────────────────────────────────────────────── */
.forms-user-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.forms-user-card:last-child { border-bottom: none; }

.forms-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  flex-shrink: 0;
}

.forms-user-info { flex: 1; min-width: 0; }

.forms-user-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.forms-user-email {
  font-size: 12px;
  color: var(--text-light);
}

/* ── Form Editor (inside Admin) ──────────────────────────────────────── */
.editor-panel {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.editor-panel-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}

.editor-panel-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.editor-panel-body {
  padding: 22px;
}

.editor-panel-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 22px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.form-row {
  display: flex;
  gap: 14px;
  margin-bottom: 14px;
}

.form-row > .form-group { flex: 1; }
.form-group-third { flex: 1 !important; }

.form-section-divider {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 20px 0 8px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
}

.form-help {
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 14px;
}

/* ── Field Editor Rows ───────────────────────────────────────────────── */
.field-editor-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 14px;
  margin-bottom: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  position: relative;
}

.field-editor-row.dragging { opacity: 0.5; }
.field-editor-row.drag-over { border-color: var(--blue); background: var(--blue-pale); }

.field-editor-grip {
  cursor: grab;
  color: var(--text-light);
  padding: 4px 0;
  flex-shrink: 0;
}

.field-editor-grip:active { cursor: grabbing; }

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

.field-editor-remove {
  flex-shrink: 0;
  margin-top: 4px;
}

/* ── Permission Badges (small) ───────────────────────────────────────── */
.badge-xs {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 600;
}

.badge-blue { background: var(--blue-pale); color: #2B6CB0; }
.badge-purple { background: var(--purple-pale); color: #553C9A; }

/* ── Icon Picker ─────────────────────────────────────────────────────── */
.icon-picker-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-picker-preview {
  font-size: 22px;
  color: var(--text);
}

.icon-picker-select {
  flex: 1;
}

/* ── Import Sources ──────────────────────────────────────────────────── */
.import-source-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}

.import-source-item:hover { background: var(--bg); }
.import-source-item:last-child { border-bottom: none; }

.import-source-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--blue-pale);
  color: var(--blue);
}

.import-source-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}

.import-source-desc {
  font-size: 12px;
  color: var(--text-light);
}

/* ── Toggle (for required, checkbox fields) ──────────────────────────── */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.toggle-input { display: none; }

.toggle-slider {
  position: relative;
  width: 36px;
  height: 20px;
  background: var(--border);
  border-radius: 10px;
  transition: background 0.2s;
  flex-shrink: 0;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle-input:checked + .toggle-slider {
  background: var(--green);
}

.toggle-input:checked + .toggle-slider::after {
  transform: translateX(16px);
}

.toggle-label-text {
  font-size: 14px;
  color: var(--text);
}

/* ── Form Section Heading (in fill mode) ─────────────────────────────── */
.form-section-heading {
  margin: 20px 0 10px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
}

.form-section-heading h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.form-section-heading p {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 4px;
}

.form-help-inline {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 4px;
  display: block;
}

/* ── Responsive Forms ────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .forms-tabs {
    flex-wrap: wrap;
  }
  .forms-grid {
    grid-template-columns: 1fr;
  }
  .form-row {
    flex-direction: column;
    gap: 10px;
  }
  .submission-detail-row {
    flex-direction: column;
  }
  .submission-detail-label {
    width: 100%;
    margin-bottom: 2px;
  }
}


/* ═══════════════════════════════════════════════════════════════════════════
   SECTION EDITOR (Admin – Forms Management)
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Section Blocks ──────────────────────────────────────────────────── */
.section-editor-block {
  background: var(--bg-secondary, #f6f8fa);
  border: 1px solid var(--border, #e0e0e0);
  border-radius: 10px;
  margin-bottom: 16px;
  overflow: hidden;
  transition: box-shadow .2s;
}
.section-editor-block:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.section-editor-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-tertiary, #eef0f4);
  border-bottom: 1px solid var(--border, #e0e0e0);
  cursor: pointer;
  user-select: none;
}
.section-editor-header:hover { background: var(--bg-hover, #e8eaee); }
.section-editor-grip {
  font-size: 18px;
  opacity: .35;
  cursor: grab;
}
.section-editor-grip:active { cursor: grabbing; }
.section-editor-meta {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.section-editor-meta input,
.section-editor-meta select {
  padding: 6px 10px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}
.section-editor-meta input[type="text"] { flex: 1; min-width: 140px; }
.section-editor-meta select { min-width: 160px; }
.section-field-count {
  white-space: nowrap;
  flex-shrink: 0;
}
.section-toggle-icon {
  flex-shrink: 0;
  opacity: .5;
  transition: transform .2s, opacity .2s;
}
.section-editor-block.section-expanded .section-toggle-icon { opacity: .8; }
.section-editor-body {
  overflow: hidden;
  transition: max-height .25s ease;
}
.section-editor-fields {
  padding: 12px 16px 16px;
}

/* ─── Repeating Group ────────────────────────────────────────────────── */
.repeating-group-block {
  margin: 8px 0;
  border: 2px dashed var(--blue, #5B9BD5);
  border-radius: var(--radius-sm, 8px);
  background: rgba(91, 155, 213, 0.03);
  padding: 10px;
}
.repeating-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.repeating-group-fields {
  padding: 4px 8px;
}
.repeating-group-block .field-editor-row {
  margin-left: 4px;
  border-left: 3px solid var(--blue, #5B9BD5);
}

/* ─── Section Color Row ──────────────────────────────────────────────── */
.section-color-row {
  border-bottom: 1px solid var(--border, #e0e0e0);
  padding-bottom: 8px;
  margin-bottom: 4px;
}

/* ─── Preview Modal Fields ────────────────────────────────────────────── */
.pv-field { margin-bottom: 10px; }
.pv-field label { display: block; font-size: .88rem; font-weight: 600; margin-bottom: 3px; }
.pv-field input, .pv-field textarea, .pv-field select {
  border: 1px solid #d0d5dd;
  border-radius: 6px;
  padding: 7px 10px;
  font-size: .88rem;
  background: #fafafa;
  color: #888;
}

/* ─── Field Validation & Conditions (collapsible) ─────────────────────── */
.field-advanced-section {
  margin-top: 8px;
  border: 1px solid var(--border, #e0e0e0);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.field-advanced-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bg-secondary, #f6f8fa);
  border: none;
  width: 100%;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light, #555);
  cursor: pointer;
  text-align: left;
}
.field-advanced-toggle:hover { background: var(--bg-tertiary, #eef0f4); }
.field-advanced-toggle .material-symbols-outlined { font-size: 16px; transition: transform .2s; }
.field-advanced-section[open] > .field-advanced-toggle .material-symbols-outlined {
  transform: rotate(90deg);
}
.field-validation-body,
.field-conditions-body {
  padding: 12px;
}
.field-validation-body .form-row,
.field-conditions-body .form-row {
  margin-bottom: 8px;
}
.field-validation-body label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-light);
  margin-bottom: 2px;
  display: block;
}
.field-validation-body input,
.field-validation-body select {
  padding: 5px 8px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 5px;
  width: 100%;
  box-sizing: border-box;
}

/* ─── Condition Rows ──────────────────────────────────────────────────── */
.condition-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 8px;
  margin-bottom: 6px;
  background: var(--bg-secondary, #f6f8fa);
  border-radius: 6px;
  border: 1px solid var(--border);
}
.condition-row select,
.condition-row input {
  padding: 5px 8px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 5px;
  min-width: 100px;
  flex: 1;
}
.condition-row .btn-remove-condition {
  background: none;
  border: none;
  color: var(--red, #e74c3c);
  cursor: pointer;
  padding: 2px 6px;
  font-size: 16px;
  border-radius: 4px;
}
.condition-row .btn-remove-condition:hover {
  background: rgba(231,76,60,.1);
}

/* ─── Color Pickers Row ──────────────────────────────────────────────── */
.color-pickers-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.color-picker-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.color-picker-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
}
.color-picker-group input[type="color"] {
  width: 36px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0;
  cursor: pointer;
}

/* ─── JSON Import ──────────────────────────────────────────────────────── */
.json-import-schema {
  background: #1e1e2e;
  color: #cdd6f4;
  padding: 16px;
  border-radius: 8px;
  font-family: 'Cascadia Code', 'Fira Code', monospace;
  font-size: 11px;
  line-height: 1.5;
  max-height: 300px;
  overflow: auto;
  white-space: pre;
  margin-bottom: 12px;
}
.json-import-area {
  width: 100%;
  min-height: 200px;
  font-family: 'Cascadia Code', 'Fira Code', monospace;
  font-size: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  resize: vertical;
}
.json-import-error {
  color: var(--red, #e74c3c);
  font-size: 12px;
  padding: 8px 12px;
  margin-top: 8px;
  background: rgba(231,76,60,.08);
  border-radius: 6px;
  display: none;
}

/* ─── Section editor mobile ───────────────────────────────────────────── */
@media (max-width: 640px) {
  .section-editor-header { flex-direction: column; align-items: stretch; }
  .section-editor-meta { flex-direction: column; }
  .condition-row { flex-direction: column; }
  .color-pickers-row { flex-direction: column; gap: 10px; }
}