/* ============ TOPBAR ============ */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 30;
  height: 56px;
}
.topbar-left { display: flex; align-items: center; gap: 20px; height: 100%; }
.topbar-logo { height: 32px; object-fit: contain; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

/* View Switcher inside dropdown */
.dropdown-section {
  padding: 10px 14px 12px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
}
.dropdown-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.view-switcher-dropdown {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 2px;
  border-radius: 7px;
  gap: 2px;
  width: 100%;
}
.view-switcher-dropdown .view-btn {
  flex: 1;
  background: transparent;
  border: none;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  border-radius: 5px;
  transition: all 0.15s;
}
.view-switcher-dropdown .view-btn:hover { color: var(--text); }
.view-switcher-dropdown .view-btn.active {
  background: var(--primary);
  color: white;
}

/* Attribution — "by X · date" */
.attribution {
  font-size: 11px;
  color: var(--text-light);
  font-style: italic;
  margin-top: 4px;
}
.attribution strong { color: var(--text-muted); font-style: normal; font-weight: 600; }

/* ============ SECTION BAR (Parent Tabs) ============ */
.section-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.parent-tabs {
  display: inline-flex;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  padding: 4px;
  border-radius: 10px;
  gap: 2px;
}
.parent-tab {
  background: transparent;
  border: none;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.18s;
  white-space: nowrap;
}
.parent-tab .ptab-icon { opacity: 0.7; }
.parent-tab:hover {
  color: var(--text);
  background: rgba(255,255,255,0.5);
}
.parent-tab.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(15,23,42,0.10), 0 1px 2px rgba(15,23,42,0.05);
}
.parent-tab.active .ptab-icon { opacity: 1; }

/* ============ USER MENU ============ */
.user-menu { position: relative; }
.btn-user {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 5px 10px 5px 5px;
  border-radius: 20px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
}
.btn-user:hover { background: var(--surface-alt); }
.user-avatar {
  width: 26px;
  height: 26px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}
.user-name { font-weight: 500; }

.dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 220px;
  overflow: hidden;
  z-index: 40;
}
.dropdown-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
  font-size: 12px;
}
.dropdown-header strong { display: block; font-size: 13px; color: var(--text); margin-bottom: 2px; }
.dropdown-header span { color: var(--text-muted); }
.dropdown-item {
  display: block;
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  padding: 10px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
}
.dropdown-item:hover { background: var(--surface-alt); }
.dropdown-danger { color: var(--danger); }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ============ SUB TABS ============ */
.sub-tabs {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: thin;
  align-items: center;
}
.sub-tab {
  background: none;
  border: none;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  border-bottom: 2px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: all 0.15s;
  font-weight: 500;
}
.sub-tab:hover { color: var(--text); }
.sub-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}
.badge {
  background: var(--surface-alt);
  color: var(--text-muted);
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  min-width: 22px;
  text-align: center;
}
.sub-tab.active .badge { background: var(--primary); color: white; }
.orders-stage-tabs { display: contents; }

/* ============ TOOLBAR ============ */
.toolbar {
  background: var(--surface);
  padding: 10px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 400px;
  padding: 6px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.search-box svg { color: var(--text-muted); flex-shrink: 0; }
.search-box input {
  border: none;
  outline: none;
  flex: 1;
  font-size: 13px;
  font-family: inherit;
  background: transparent;
  color: var(--text);
}
.search-box:focus-within { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(59,130,246,0.12); }

.toolbar-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Filter group (date filter) */
.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.date-filter-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.date-filter-wrap .filter-icon {
  position: absolute;
  left: 10px;
  color: var(--text-muted);
  pointer-events: none;
}
.date-filter-wrap select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 6px 28px 6px 30px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  font-weight: 500;
}
.date-filter-wrap select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

.custom-range {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
}
.custom-range input[type="date"] {
  border: none;
  padding: 2px 4px;
  font-size: 12px;
  font-family: inherit;
  color: var(--text);
  background: transparent;
  width: 120px;
  outline: none;
}
.custom-range input[type="date"]:focus { color: var(--primary); }
.range-sep {
  font-size: 11px;
  color: var(--text-muted);
}
#custom-clear {
  padding: 2px 6px;
  font-size: 14px;
  line-height: 1;
  color: var(--text-muted);
  border: none;
  background: transparent;
}
#custom-clear:hover { color: var(--danger); background: var(--surface-alt); }

/* Stale dot indicator */
.stale-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  margin-right: 8px;
  vertical-align: middle;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(220,38,38,0.15);
}
.result-count {
  color: var(--text-muted);
  font-size: 12px;
}
.sync-pill {
  background: var(--success-bg);
  color: var(--success);
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}
.sync-pill.error { background: var(--danger-bg); color: var(--danger); }
.sync-pill.loading { background: var(--info-bg); color: var(--info); }

