/* ============================================
   FINORA BASE — Sidebar, Topbar, App Shell
   ============================================ */

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

:root {
  --finora-blue: #3D63F5;
  --finora-blue-dark: #2B4CD8;
  --finora-blue-soft: #EEF2FF;
  --finora-bg: #F6F7FB;
  --finora-card: #FFFFFF;
  --finora-text: #0F172A;
  --finora-text-soft: #64748B;
  --finora-border: #E5E8F0;
  --finora-border-soft: #EFF1F6;
  --finora-success: #10B981;
  --finora-warning: #F59E0B;
  --finora-danger:  #EF4444;
  --finora-purple:  #8B5CF6;
  --finora-pink:    #EC4899;
  --finora-cyan:    #06B6D4;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.04);
  --shadow:    0 4px 16px rgba(15,23,42,.06);
  --shadow-lg: 0 12px 40px rgba(15,23,42,.10);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--finora-text);
  background: var(--finora-bg);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select { font: inherit; color: inherit; }

/* ============================================ APP SHELL */
.app {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

/* ============================================ SIDEBAR */
.sidebar {
  background: #FFFFFF;
  border-right: 1px solid var(--finora-border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 22px 8px;
}
.brand-logo {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: #101510;
  display: grid; place-items: center;
  color: white;
  box-shadow: 0 8px 20px rgba(16,21,16,.22);
}
.brand-logo svg { width: 18px; height: 18px; }
.brand-logo img { width: 27px; height: 27px; object-fit: contain; display: block; }
.brand-name { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--finora-text-soft);
  font-weight: 500;
  position: relative;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--finora-border-soft); color: var(--finora-text); }
.nav-item.active {
  background: var(--finora-blue-soft);
  color: var(--finora-blue);
  font-weight: 600;
}
.nav-item svg { width: 18px; height: 18px; flex: 0 0 18px; }
.nav-badge {
  margin-left: auto;
  min-width: 22px; height: 22px;
  padding: 0 7px;
  background: var(--finora-blue);
  color: white;
  border-radius: 11px;
  font-size: 12px;
  font-weight: 600;
  display: grid; place-items: center;
}
.nav-dot {
  margin-left: auto;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #22C55E;
  box-shadow: 0 0 0 3px rgba(34,197,94,.18);
}

.sidebar-spacer { flex: 1; }

.sidebar-org {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 10px;
  border-top: 1px solid var(--finora-border-soft);
  margin-top: 8px;
}
.org-logo {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: #101510;
  display: grid; place-items: center;
  color: white; font-weight: 700; font-size: 13px;
}
.org-logo img { width: 24px; height: 24px; object-fit: contain; display: block; }
.org-name { font-weight: 600; }

/* ============================================ TOPBAR */
.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  background: #FFFFFF;
  border-bottom: 1px solid var(--finora-border);
  padding: 0 28px;
  height: 68px;
  display: flex;
  align-items: center;
  gap: 28px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.tabs { display: flex; align-items: center; gap: 4px; }
.tab {
  padding: 22px 12px;
  font-weight: 500;
  color: var(--finora-text-soft);
  position: relative;
  cursor: pointer;
  transition: color .12s;
}
.tab:hover { color: var(--finora-text); }
.tab.active { color: var(--finora-blue); font-weight: 600; }
.tab.active::after {
  content: "";
  position: absolute;
  left: 12px; right: 12px; bottom: -1px;
  height: 2px;
  background: var(--finora-blue);
  border-radius: 2px 2px 0 0;
}

.search {
  flex: 1; max-width: 520px;
  margin-left: auto;
  background: var(--finora-bg);
  border: 1px solid var(--finora-border);
  border-radius: 12px;
  padding: 9px 14px;
  display: flex; align-items: center; gap: 10px;
  color: var(--finora-text-soft);
}
.search svg { width: 16px; height: 16px; }
.search input {
  flex: 1; border: none; background: none; outline: none;
  color: var(--finora-text);
}
.search-shortcut {
  padding: 2px 7px;
  background: #fff;
  border: 1px solid var(--finora-border);
  border-radius: 6px;
  font-size: 12px;
  color: var(--finora-text-soft);
}

.topbar-actions { display: flex; align-items: center; gap: 12px; }
.icon-btn {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: grid; place-items: center;
  color: var(--finora-text-soft);
  position: relative;
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--finora-border-soft); color: var(--finora-text); }
.icon-btn .badge {
  position: absolute;
  top: 5px; right: 5px;
  min-width: 16px; height: 16px;
  padding: 0 4px;
  background: var(--finora-danger);
  color: white;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 700;
  display: grid; place-items: center;
  border: 2px solid #fff;
}

.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 12px 6px 6px;
  border: 1px solid var(--finora-border);
  border-radius: 12px;
  cursor: pointer;
  transition: background .12s;
}
.user-chip:hover { background: var(--finora-border-soft); }
.avatar {
  width: 32px; height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, #0F172A, #334155);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 12px;
}
.user-name { font-weight: 600; line-height: 1.2; }
.user-role { font-size: 12px; color: var(--finora-text-soft); }
.user-chip svg { width: 14px; height: 14px; color: var(--finora-text-soft); }
.workflow-settings-shortcut svg { width: 18px; height: 18px; }

.user-chip:focus-visible {
  outline: 3px solid rgba(44, 108, 246, .22);
  outline-offset: 3px;
}

.workflow-shell-popover {
  position: fixed;
  z-index: 1000;
  width: min(430px, calc(100vw - 32px));
  padding: 14px;
  border: 1px solid rgba(226, 232, 240, .92);
  border-radius: 22px;
  background:
    radial-gradient(circle at 0 0, rgba(34, 197, 94, .12), transparent 190px),
    rgba(255, 255, 255, .98);
  box-shadow: 0 28px 80px rgba(15, 23, 42, .18);
  color: var(--finora-text);
}
.workflow-shell-popover[hidden] { display: none !important; }
.workflow-shell-popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  padding: 2px 2px 10px;
  border-bottom: 1px solid #EEF2F7;
}
.workflow-shell-popover-head strong {
  font-size: 15px;
  font-weight: 950;
}
.workflow-shell-popover-head span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid #BBF7D0;
  border-radius: 999px;
  background: #ECFDF5;
  color: #0F766E;
  font-size: 12px;
  font-weight: 900;
}
.workflow-shell-popover-list {
  display: grid;
  gap: 8px;
}
.workflow-shell-row {
  width: 100%;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  padding: 12px;
  border: 1px solid #E8EDF3;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 14px 34px rgba(15, 23, 42, .06);
  color: #334155;
  text-align: left;
  position: relative;
  transition: background .12s, border-color .12s, box-shadow .12s, transform .12s;
}
.workflow-shell-row:hover {
  background: #FBFDFF;
  border-color: #DBEAFE;
  box-shadow: 0 18px 42px rgba(37, 99, 235, .12);
  transform: translateY(-1px);
}
.workflow-shell-row.is-unread {
  background: linear-gradient(135deg, #fff 0%, #F0FDF4 100%);
  border-color: #BBF7D0;
  box-shadow: 0 18px 42px rgba(34, 197, 94, .13);
}
.workflow-shell-row-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  border: 1px solid #BFDBFE;
  border-radius: 14px;
  background: #EFF6FF;
  color: #2563EB;
  font-size: 11px;
  font-weight: 950;
  letter-spacing: 0;
}
.workflow-shell-row--green .workflow-shell-row-icon { background: #ECFDF5; border-color: #BBF7D0; color: #15803D; }
.workflow-shell-row--amber .workflow-shell-row-icon,
.workflow-shell-row--warning .workflow-shell-row-icon { background: #FFFBEB; border-color: #FDE68A; color: #B45309; }
.workflow-shell-row--danger .workflow-shell-row-icon { background: #FEF2F2; border-color: #FECACA; color: #DC2626; }
.workflow-shell-row--sky .workflow-shell-row-icon { background: #F0F9FF; border-color: #BAE6FD; color: #0284C7; }
.workflow-shell-row--violet .workflow-shell-row-icon { background: #F5F3FF; border-color: #DDD6FE; color: #7C3AED; }
.workflow-shell-row--slate .workflow-shell-row-icon { background: #F8FAFC; border-color: #CBD5E1; color: #475569; }
.workflow-shell-row-copy {
  display: grid;
  gap: 5px;
  min-width: 0;
}
.workflow-shell-row-meta,
.workflow-shell-row-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}
.workflow-shell-row-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid #E2E8F0;
  border-radius: 999px;
  background: #F8FAFC;
  color: #475569;
  font-size: 10.5px;
  font-weight: 950;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.workflow-shell-row strong {
  color: var(--finora-text);
  font-size: 13.5px;
  font-weight: 950;
  line-height: 1.25;
}
.workflow-shell-row span {
  color: var(--finora-text-soft);
  font-size: 12px;
  line-height: 1.4;
}
.workflow-shell-row .workflow-shell-row-icon {
  color: #2563EB;
  font-size: 11px;
}
.workflow-shell-row--green .workflow-shell-row-icon { color: #15803D; }
.workflow-shell-row--amber .workflow-shell-row-icon,
.workflow-shell-row--warning .workflow-shell-row-icon { color: #B45309; }
.workflow-shell-row--danger .workflow-shell-row-icon { color: #DC2626; }
.workflow-shell-row--sky .workflow-shell-row-icon { color: #0284C7; }
.workflow-shell-row--violet .workflow-shell-row-icon { color: #7C3AED; }
.workflow-shell-row--slate .workflow-shell-row-icon { color: #475569; }
.workflow-shell-row .workflow-shell-row-chip {
  color: #475569;
  font-size: 10.5px;
}
.workflow-shell-row small {
  color: #94A3B8;
  font-size: 11px;
  font-weight: 800;
}
.workflow-shell-row-footer {
  margin-top: 3px;
  padding-top: 7px;
  border-top: 1px solid #EEF2F7;
}
.workflow-shell-row-footer span {
  color: #64748B;
  font-size: 11px;
  font-weight: 850;
}
.workflow-shell-row-footer span:last-child {
  color: #0F766E;
}
.workflow-shell-popover-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  margin-top: 10px;
  border-radius: 999px;
  background: var(--finora-text);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}
.workflow-shell-empty {
  padding: 16px 12px;
  border-radius: 13px;
  background: #F8FAFC;
  color: var(--finora-text-soft);
  font-size: 12px;
  text-align: center;
}
.workflow-shell-empty--actions {
  display: grid;
  gap: 6px;
  justify-items: center;
  padding: 22px 16px;
  border: 1px dashed #CBD5E1;
  border-radius: 18px;
  background: linear-gradient(135deg, #F8FAFC 0%, #F0FDF4 100%);
}
.workflow-shell-empty--actions strong {
  color: var(--finora-text);
  font-size: 13px;
  font-weight: 950;
}
.workflow-shell-empty--actions small {
  color: var(--finora-text-soft);
  font-size: 12px;
  line-height: 1.35;
}
.workflow-shell-empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid #BBF7D0;
  border-radius: 14px;
  background: #ECFDF5;
  color: #15803D;
  font-size: 11px;
  font-weight: 950;
}
.workflow-shell-manager-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.workflow-shell-manager-grid span {
  display: grid;
  gap: 2px;
  place-items: center;
  padding: 12px 8px;
  border: 1px solid var(--finora-border);
  border-radius: 14px;
  background: #F8FAFC;
}
.workflow-shell-manager-grid strong {
  color: var(--finora-text);
  font-size: 18px;
  font-weight: 950;
}
.workflow-shell-manager-grid small {
  color: var(--finora-text-soft);
  font-size: 11px;
  font-weight: 800;
}

.workflow-shell-user-menu {
  width: min(292px, calc(100vw - 28px));
  padding: 8px;
  border-radius: 16px;
  background: #fff;
}
.workflow-shell-user-head {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 8px 8px 10px;
  border-bottom: 1px solid var(--finora-border);
  background: #fff;
}
.workflow-shell-user-avatar {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: #111827;
  color: #fff;
  font-weight: 900;
  font-size: 12px;
}
.workflow-shell-user-head strong {
  display: block;
  color: var(--finora-text);
  font-size: 13.5px;
  font-weight: 950;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.workflow-shell-user-head small {
  display: block;
  color: var(--finora-text-soft);
  font-size: 12px;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.workflow-shell-user-links {
  display: grid;
  gap: 3px;
  padding: 7px 0 0;
}
.workflow-shell-user-links a,
.workflow-shell-user-links button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 0 9px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--finora-text);
  font: inherit;
  font-size: 13px;
  font-weight: 850;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.workflow-shell-user-links a:hover,
.workflow-shell-user-links button:hover {
  background: var(--finora-border-soft);
}
.workflow-shell-user-links svg {
  width: 17px;
  height: 17px;
  color: var(--finora-text-soft);
  flex: 0 0 auto;
}
.workflow-shell-user-links span {
  margin-left: auto;
  min-height: 22px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #ECFDF5;
  color: #0F766E;
  font-size: 10px;
  font-weight: 950;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.workflow-shell-user-links [hidden] {
  display: none !important;
}
.workflow-shell-user-danger {
  color: #B91C1C !important;
}

/* ============================================ PAGE BODY */
.page {
  padding: 28px 32px;
  flex: 1;
  min-width: 0;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}
.page-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -.01em;
}
.page-sub {
  color: var(--finora-text-soft);
  margin-top: 4px;
}

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  border-radius: 11px;
  font-weight: 600;
  border: 1px solid var(--finora-border);
  background: #fff;
  color: var(--finora-text);
  transition: background .12s, border-color .12s, transform .08s;
}
.btn:hover { background: var(--finora-border-soft); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn.primary {
  background: linear-gradient(135deg, #3D63F5, #5B7CFF);
  color: white;
  border-color: transparent;
  box-shadow: 0 8px 22px rgba(61,99,245,.30);
}
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--finora-danger); }

/* utility */
.row { display: flex; align-items: center; gap: 10px; }
.spacer { flex: 1; }

/* ============================================ CUSTOM SCROLLBARS */
/* Light theme (default everywhere) */
*::-webkit-scrollbar { width: 12px; height: 12px; }
*::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 8px;
}
*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #CBD5E1, #94A3B8);
  border-radius: 8px;
  border: 3px solid transparent;
  background-clip: padding-box;
  transition: background .15s;
}
*::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #94A3B8, #64748B);
  background-clip: padding-box;
}
*::-webkit-scrollbar-corner { background: transparent; }
* { scrollbar-width: thin; scrollbar-color: #94A3B8 transparent; }

/* Slim variant for compact panels (sidebars, library) */
.scroll-slim::-webkit-scrollbar { width: 8px; height: 8px; }
.scroll-slim::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.scroll-slim::-webkit-scrollbar-thumb:hover { background: #94A3B8; background-clip: padding-box; }

/* Dark scrollbar for neon expert builder */
body.builder.expert-mode *::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #2A2A3F, #14141F);
  border-color: transparent;
  background-clip: padding-box;
  box-shadow: 0 0 6px rgba(0,229,255,.30);
}
body.builder.expert-mode *::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #00E5FF, #B14CFF);
  background-clip: padding-box;
  box-shadow: 0 0 10px rgba(0,229,255,.50);
}
body.builder.expert-mode { scrollbar-color: #2A2A3F transparent; }
