/* ─────────────────────────────────────────────────────────────
   Logic Electric topbar V2 — Search-first
   Tokens scoped to .tb so existing app tokens aren't disturbed.
   ───────────────────────────────────────────────────────────── */

/* Token definitions — declared on every element that needs them,
   since the command palette + scrim live outside the .tb subtree. */
.tb,
.tb-cmd,
.tb-scrim,
.tb-pop {
  /* Surfaces */
  --bg:           #0B1020;
  --surface:      #161E33;
  --surface-2:    #1E2740;
  --surface-3:    #2A344E;
  --border:       #2A344E;
  --border-soft:  #1E2740;
  --border-hover: #3C4866;

  /* Text */
  --tb-text:      #E8ECF5;
  --tb-text-muted:#8A93A6;
  --tb-text-dim:  #5F6A82;

  /* Brand cyan */
  --cyan:         #3FB6E8;
  --cyan-hi:      #5BC4ED;
  --cyan-low:     #2A8FBE;
  --cyan-glow:    rgba(63, 182, 232, 0.18);
  --cyan-tint:    rgba(63, 182, 232, 0.08);

  /* Semantic */
  --danger:       #F87171;
  --warn:         #FBBF24;
  --success:      #34D399;
  --violet:       #A78BFA;

  /* Type */
  --tb-font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --tb-font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

.tb {
  width: 100%;
  background: var(--bg);
  color: var(--tb-text);
  font-family: var(--tb-font-sans);
  font-size: 14px;
  position: relative;
  overflow: visible;
  font-feature-settings: 'ss01', 'cv11';
  border-bottom: 1px solid var(--border);
}

.tb * { box-sizing: border-box; }
.tb button { font-family: inherit; cursor: pointer; }
.tb input { font-family: inherit; }

.tb-row {
  display: flex;
  align-items: center;
  height: 64px;
  padding: 0 24px;
  gap: 18px;
}
.tb-row > * { flex-shrink: 0; }

/* Brand */
.tb-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  height: 100%;
  background: none;
  border: 0;
  padding: 0;
}
.tb-logo img {
  height: 28px;
  width: auto;
  display: block;
}
.tb-logo .title {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--tb-text);
  white-space: nowrap;
}

.tb-sep {
  color: var(--tb-text-dim);
  font-size: 18px;
  font-weight: 300;
  user-select: none;
}

/* Workspace + module chips */
.tb-ws {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--tb-text);
  font-weight: 500;
  font-size: 13px;
  white-space: nowrap;
  transition: background .12s, border-color .12s;
  cursor: pointer;
  outline: none;
}
.tb-ws:hover { background: var(--surface-2); border-color: var(--border-hover); }
.tb-ws:focus { border-color: var(--border-hover); }
.tb-ws .ws-icon {
  width: 22px; height: 22px;
  border-radius: 6px;
  background: var(--cyan-tint);
  color: var(--cyan);
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid rgba(63,182,232,0.3);
}

/* Search bar (centre) */
.tb-search-wrap {
  flex: 1;
  display: flex;
  justify-content: center;
  min-width: 0;
}
.tb-search {
  -webkit-appearance: none;
  appearance: none;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 560px;
  height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--tb-text-muted);
  font-size: 13px;
  cursor: pointer;
  transition: border-color .12s;
  min-width: 0;
  text-align: left;
  outline: none;
}
.tb-search:hover { border-color: var(--border-hover); }
.tb-search:focus { border-color: var(--cyan); }
.tb-search > span.placeholder {
  flex: 1;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--tb-text-dim);
}

.tb-kbd {
  font-family: var(--tb-font-mono);
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--tb-text-dim);
  border: 1px solid var(--border);
  line-height: 1;
  white-space: nowrap;
}

/* Icon buttons */
.tb-icobtn {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--tb-text-muted);
  transition: background .12s, color .12s, border-color .12s;
  position: relative;
  flex-shrink: 0;
  padding: 0;
  cursor: pointer;
  outline: none;
}
.tb-icobtn:hover { background: var(--surface-2); color: var(--tb-text); border-color: var(--border); }
.tb-icobtn .dot {
  position: absolute;
  top: 7px; right: 7px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 0 2px var(--bg);
}

/* Avatar */
.tb-avatar-btn { background: transparent; border: 0; padding: 0; cursor: pointer; }
.tb-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  color: #0B1020;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.02em;
  border: 1.5px solid var(--bg);
  box-shadow: 0 0 0 1px var(--border);
}

.tb-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
}

/* Popovers (workspace / modules / quick-create / notif / user) */
.tb-pop {
  position: absolute;
  z-index: 5000;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.5), 0 2px 0 rgba(255,255,255,0.02) inset;
  overflow: hidden;
  font-size: 13px;
  color: var(--tb-text);
  animation: tb-pop-in .12s ease-out;
}
@keyframes tb-pop-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.tb-pop-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--tb-text-dim);
}
.tb-pop-header a {
  color: var(--cyan);
  text-decoration: none;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.tb-pop-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border: 0;
  background: transparent;
  width: 100%;
  color: var(--tb-text);
  font-size: 13px;
  text-align: left;
  transition: background .08s;
  cursor: pointer;
}
.tb-pop-row:hover, .tb-pop-row.is-active { background: var(--surface-2); }
.tb-pop-row .right {
  margin-left: auto;
  color: var(--tb-text-dim);
  font-size: 11px;
  font-family: var(--tb-font-mono);
}
.tb-pop-row.danger { color: var(--danger); }
.tb-pop-row.danger svg { color: var(--danger); }
.tb-pop-sep { height: 1px; background: var(--border-soft); margin: 4px 0; }

/* User menu header */
.tb-user-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--border-soft);
}
.tb-user-header .who { font-weight: 600; font-size: 14px; color: var(--tb-text); }
.tb-user-header .meta { font-size: 11.5px; color: var(--tb-text-dim); }

/* Quick-create tiles */
.tb-qc-tile {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  cursor: pointer;
  border: 0;
  background: transparent;
  width: 100%;
  text-align: left;
}
.tb-qc-tile:hover { background: var(--surface-2); }
.tb-qc-tile .ic {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--cyan-tint); color: var(--cyan);
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid rgba(63,182,232,0.25);
}
.tb-qc-tile .name { font-weight: 500; color: var(--tb-text); }
.tb-qc-tile .desc { font-size: 12px; color: var(--tb-text-dim); }
.tb-qc-tile .kbd { font-family: var(--tb-font-mono); font-size: 11px; color: var(--tb-text-dim); }

/* Notifications */
.tb-notif-list { max-height: 480px; overflow-y: auto; }
.tb-notif-item {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  position: relative;
}
.tb-notif-item:last-child { border-bottom: 0; }
.tb-notif-item:hover { background: var(--surface-2); }
.tb-notif-item.unread::before {
  content: '';
  position: absolute;
  left: 6px; top: 18px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--cyan);
}
.tb-notif-icon {
  width: 28px; height: 28px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2);
  color: var(--tb-text-muted);
  border: 1px solid var(--border);
}
.tb-notif-icon.quote  { color: var(--cyan);    background: var(--cyan-tint);              border-color: rgba(63,182,232,0.3); }
.tb-notif-icon.alert  { color: var(--warn);    background: rgba(251,191,36,0.10);          border-color: rgba(251,191,36,0.3); }
.tb-notif-icon.job    { color: var(--success); background: rgba(52,211,153,0.10);          border-color: rgba(52,211,153,0.3); }
.tb-notif-body { min-width: 0; }
.tb-notif-body .who { font-weight: 600; color: var(--tb-text); font-size: 13px; }
.tb-notif-body .text { color: var(--tb-text-muted); font-size: 12.5px; line-height: 1.4; }
.tb-notif-time { font-size: 11px; color: var(--tb-text-dim); font-family: var(--tb-font-mono); white-space: nowrap; align-self: center; }
.tb-notif-footer {
  padding: 12px 14px;
  text-align: center;
  border-top: 1px solid var(--border-soft);
  background: var(--surface-2);
}
.tb-notif-footer a {
  color: var(--cyan);
  text-decoration: none;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Command palette scrim + modal */
.tb-scrim {
  position: fixed;
  inset: 0;
  background: rgba(5,8,17,0.55);
  z-index: 9000;
  animation: tb-pop-in .12s ease-out;
}
.tb-cmd {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  width: 560px;
  max-width: calc(100vw - 32px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.5), 0 2px 0 rgba(255,255,255,0.02) inset;
  z-index: 9100;
  animation: tb-pop-in .12s ease-out;
  font-family: var(--tb-font-sans);
  color: var(--tb-text);
  overflow: hidden;
}
.tb-cmd-input {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--tb-text-muted);
}
.tb-cmd-input input {
  flex: 1; background: transparent; border: 0; outline: none; color: var(--tb-text);
  font-size: 15px;
}
.tb-cmd-list { max-height: 360px; overflow: auto; padding: 6px 0; }
.tb-cmd-group {
  padding: 8px 16px 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--tb-text-dim);
}
.tb-cmd-row {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 16px;
  cursor: pointer;
  border: 0;
  background: transparent;
  width: 100%;
  text-align: left;
}
.tb-cmd-row:hover, .tb-cmd-row.is-active { background: var(--surface-2); }
.tb-cmd-row .kind {
  font-family: var(--tb-font-mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  width: 56px;
  color: var(--tb-text-dim);
}
.tb-cmd-row .id {
  font-family: var(--tb-font-mono);
  font-size: 11px;
  color: var(--tb-text-dim);
}
.tb-cmd-row .title { color: var(--tb-text); font-weight: 500; }
.tb-cmd-row .meta  { color: var(--tb-text-dim); font-size: 12px; margin-left: auto; }
.tb-cmd-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--tb-text-dim);
  font-size: 13px;
}
.tb-cmd-footer {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px;
  border-top: 1px solid var(--border-soft);
  font-size: 11px; color: var(--tb-text-dim);
  background: var(--surface-2);
}
.tb-cmd-footer .tb-kbd { background: var(--bg); }

/* SVG icon defaults inside topbar */
.tb svg { display: inline-block; vertical-align: middle; }

/* Responsive: ≥1280 as designed; 1024–1279 drop wordmark; <1024 hide help */
@media (max-width: 1279px) {
  .tb-logo .title { display: none; }
  .tb-search { max-width: 420px; }
  .tb-help { display: none; }
}
@media (max-width: 1023px) {
  .tb-row { padding: 0 12px; gap: 10px; }
  .tb-ws { padding: 0 8px; }
  .tb-icobtn { width: 32px; height: 32px; }
}

/* Hide old finance topbar/nav-bar (V2 replaces both) */
.topbar { display: none !important; }
.nav-bar { display: none !important; }
